Skip to content

PMM-7 Fix PMM-T2227 tarball upgrade version check - #1137

Closed
travagliad wants to merge 3 commits into
mainfrom
cursor/pmm-fb-test-repair-d63c
Closed

PMM-7 Fix PMM-T2227 tarball upgrade version check#1137
travagliad wants to merge 3 commits into
mainfrom
cursor/pmm-fb-test-repair-d63c

Conversation

@travagliad

@travagliad travagliad commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Why

FB CLI / Integration / Generic failed on PMM-T2227 because the test compared the post-upgrade pmm-admin version against pmm-submodules/v3/VERSION (e.g. 3.9.0/3.9.1) instead of the tarball/client image actually under test. FB and dev tarballs report feature-branch versions (e.g. 3.9.0-v3-* or 3.9.0-PMM-*), so the assertion failed even when upgrade succeeded. The same VERSION-file mismatch also broke pmm-admin --version and summary --version in the Generic suite.

How

  • Resolve expected client version from CLIENT_IMAGE via docker run --entrypoint pmm-admin ... --version --json.
  • Quote tarball URLs passed to pmm3_client_install_tarball.sh.
  • Fix docker network connect argument order and harden pmm-agent restart/PID checks after upgrade.
  • Wait for tarball_client to be running before install steps; remove the container on completion.

Triggered by FB failure on Percona-Lab/pmm-submodules#4505 (CLI tests Generic).

CI: FB integration run 30909007760 — PMM-T2227 passed; follow-up commit fixes two related version-string tests.

Summary by CodeRabbit

  • Bug Fixes

    • Improved upgrade validation by confirming containers start successfully and agents shut down and restart as expected.
    • Added verification that upgraded installations report the correct client version.
    • Added cleanup of temporary test containers after upgrade checks.
  • Tests

    • Added support for configurable upgrade URLs and client image versions.
    • Enhanced checks to confirm the agent process is replaced during upgrades.

cursoragent and others added 3 commits August 4, 2026 12:21
Use CLIENT_IMAGE version instead of pmm-submodules VERSION file,
quote tarball URLs, and harden agent restart after upgrade.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: davi.travaglia <davi.travaglia@percona.com>
Fix docker run invocation on pmm-client images and wait for
tarball_client container to be running before setup.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: davi.travaglia <davi.travaglia@percona.com>
Use the client docker image version for --version checks when
CLIENT_VERSION is a tarball URL, matching PMM-T2227 expectations.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: davi.travaglia <davi.travaglia@percona.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The CLI tests now read expected versions from the configured client image when available. The tarball upgrade test validates startup, agent replacement, connectivity, version, and container cleanup.

Changes

CLI version and upgrade validation

Layer / File(s) Summary
Client image version resolution
cli/tests/generic.spec.ts
The tests retrieve pmm-admin version data from the configured Docker image. Expected versions use CLIENT_IMAGE when it is set and otherwise use the repository VERSION file.
Tarball upgrade lifecycle validation
cli/tests/generic.spec.ts
The upgrade test configures the tarball URL, validates container startup, checks agent shutdown and restart with a new PID, verifies connectivity and version, and removes the test container.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: petersirotnak, yurkovychv

Poem

A rabbit checks the image bright,
Then tests the agent through the night.
Old PIDs hop away,
New ones start the day.
The upgraded version lands just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the PMM-T2227 tarball upgrade version-check fix, which matches the main change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/pmm-fb-test-repair-d63c

Comment @coderabbitai help to get the list of available commands.

@travagliad travagliad closed this Aug 4, 2026
@travagliad
travagliad deleted the cursor/pmm-fb-test-repair-d63c branch August 4, 2026 13:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cli/tests/generic.spec.ts`:
- Line 600: Validate the result from the oldPid docker exec call before
comparing restart PIDs: assert the command succeeded and that oldPid.stdout
contains exactly one PID. Update the restart comparison assertions around oldPid
and the corresponding new PID checks so an empty or malformed initial PID fails
the test instead of allowing any new PID to pass.
- Around line 612-623: The newAdminStatus command is executed once before
polling starts, so the subsequent assertion checking for 'Connected' uses stale
output captured before the agent had time to fully reconnect. Move the pmm-admin
status command execution and the outContains('Connected') assertion inside the
toPass() callback alongside the PID validation. This ensures the connectivity
status is checked on each poll interval rather than using the initial stale
capture, allowing the test to wait for the agent to actually reconnect after
restart.
- Line 625: The docker rm cleanup command at line 625 does not execute if an
earlier installation or assertion fails, leaving the container running and
affecting subsequent tests. Wrap the code section from container creation
through all assertions and test logic in a try block, and move the cli.exec
docker rm command into a finally block that ensures cleanup runs regardless of
test success or failure.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 83948907-6de1-4fac-8397-233fa8e249e4

📥 Commits

Reviewing files that changed from the base of the PR and between e0d20d3 and 387dc46.

📒 Files selected for processing (1)
  • cli/tests/generic.spec.ts

Comment thread cli/tests/generic.spec.ts
const adminStatus = await cli.exec(`docker exec ${containerName} pmm-admin status`);
const oldVersion = await cli.exec(`docker exec ${containerName} pmm-admin version | grep "Version:"`);
const oldVersion = await cli.exec(`docker exec ${containerName} pmm-admin version | grep "^Version:"`);
const oldPid = await cli.exec(`docker exec ${containerName} ps -C pmm-agent -o pid=`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Validate the old PID before you compare restart PIDs.

The test does not assert that oldPid succeeded or contained exactly one PID. If oldPid.stdout is empty, any new PID passes the restart comparison without proving that the original agent was replaced.

Proposed validation
 const oldPid = await cli.exec(`docker exec ${containerName} ps -C pmm-agent -o pid=`);
+await oldPid.assertSuccess();
+const oldPids = oldPid.getStdOutLines().map((pid) => pid.trim()).filter(Boolean);
+expect(oldPids, 'Exactly one PMM Agent must run before upgrade').toHaveLength(1);
...
-const oldPidValue = oldPid.stdout.trim();
+const oldPidValue = oldPids[0];

Also applies to: 614-620

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/tests/generic.spec.ts` at line 600, Validate the result from the oldPid
docker exec call before comparing restart PIDs: assert the command succeeded and
that oldPid.stdout contains exactly one PID. Update the restart comparison
assertions around oldPid and the corresponding new PID checks so an empty or
malformed initial PID fails the test instead of allowing any new PID to pass.

Comment thread cli/tests/generic.spec.ts
Comment on lines 612 to +623
const newAdminStatus = await cli.exec(`docker exec ${containerName} pmm-admin status`);
const newVersion = await cli.exec(`docker exec ${containerName} pmm-admin version | grep "Version:"`);
const newVersion = await cli.exec(`docker exec ${containerName} pmm-admin version | grep "^Version:"`);
const oldPidValue = oldPid.stdout.trim();

await newPid.outNotContains(oldPid.stdout);
await expect(async () => {
const newPid = await cli.exec(`docker exec ${containerName} ps -C pmm-agent -o pid=`);
const pids = newPid.getStdOutLines().map((pid) => pid.trim());
expect(pids, 'PMM Agent should be running after upgrade').toHaveLength(1);
expect(pids[0], `PMM Agent was not restarted. Old PID: ${oldPidValue}, New PID: ${pids[0]}`).not.toBe(oldPidValue);
}).toPass({ intervals: [1_000], timeout: 30_000 });
await newAdminStatus.outContains('Connected');
await newVersion.outContains(latestVersion);
await newVersion.outContains(expectedUpgradeVersion);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Poll live connectivity after the agent restart.

newAdminStatus is captured immediately after the detached start command. The PID poll does not refresh this result or prove that the agent is connected. A normal startup delay can therefore fail the test with stale status output.

Run pmm-admin status inside toPass(). Assert Connected on each current result.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/tests/generic.spec.ts` around lines 612 - 623, The newAdminStatus command
is executed once before polling starts, so the subsequent assertion checking for
'Connected' uses stale output captured before the agent had time to fully
reconnect. Move the pmm-admin status command execution and the
outContains('Connected') assertion inside the toPass() callback alongside the
PID validation. This ensures the connectivity status is checked on each poll
interval rather than using the initial stale capture, allowing the test to wait
for the agent to actually reconnect after restart.

Comment thread cli/tests/generic.spec.ts
await newVersion.outContains(latestVersion);
await newVersion.outContains(expectedUpgradeVersion);

await cli.exec(`docker rm -f ${containerName}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Move container cleanup into a finally block.

If installation or an assertion fails, line 625 does not execute. The detached container remains active and can affect later tests. Wrap the flow after container creation in try/finally, and remove the container in finally.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/tests/generic.spec.ts` at line 625, The docker rm cleanup command at line
625 does not execute if an earlier installation or assertion fails, leaving the
container running and affecting subsequent tests. Wrap the code section from
container creation through all assertions and test logic in a try block, and
move the cli.exec docker rm command into a finally block that ensures cleanup
runs regardless of test success or failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants