-
Notifications
You must be signed in to change notification settings - Fork 14
PMM-7 Fix PMM-T2227 tarball upgrade version check #1137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,13 @@ const PGSQL_USER = 'postgres'; | |
| const PGSQL_PASSWORD = 'pass+this'; | ||
| const ipPort = async () => ((await cli.exec('docker ps')).stdout.includes('pdpgsql_pmm_') ? '127.0.0.1:5432' : '127.0.0.1:5447'); | ||
|
|
||
| const getClientImageVersion = (): string => { | ||
| const clientImage = process.env.CLIENT_IMAGE ?? 'perconalab/pmm-client:3-dev-latest'; | ||
| return JSON.parse( | ||
| cli.execute(`docker run --rm --entrypoint pmm-admin ${clientImage} --version --json`).stdout, | ||
| ).Version; | ||
| }; | ||
|
|
||
| test.describe('PMM Client "Generic" CLI tests', { tag: '@generic' }, async () => { | ||
| test.beforeAll(async ({}) => { | ||
| const result = await cli.exec('docker ps | grep pdpgsql_pmm | awk \'{print $NF}\''); | ||
|
|
@@ -17,10 +24,9 @@ test.describe('PMM Client "Generic" CLI tests', { tag: '@generic' }, async () => | |
|
|
||
| let PMM_VERSION = `${process.env.CLIENT_VERSION}`; | ||
| if (/latest-tarball|3-dev-latest|pmm3-rc|https:/.test(PMM_VERSION)) { | ||
| // TODO: refactor to use docker hub API to remove file-update dependency | ||
| // See: https://github.com/Percona-QA/package-testing/blob/master/playbooks/pmm2-client_integration_upgrade_custom_path.yml#L41 | ||
| PMM_VERSION = cli.execute('curl -s https://raw.githubusercontent.com/Percona-Lab/pmm-submodules/v3/VERSION') | ||
| .stdout.trim(); | ||
| PMM_VERSION = process.env.CLIENT_IMAGE | ||
| ? getClientImageVersion() | ||
| : cli.execute('curl -s https://raw.githubusercontent.com/Percona-Lab/pmm-submodules/v3/VERSION').stdout.trim(); | ||
| } | ||
|
|
||
| test('Verify pt summary for mysql mongodb and pgsql', async ({}) => { | ||
|
|
@@ -570,34 +576,52 @@ test.describe('PMM Client "Generic" CLI tests', { tag: '@generic' }, async () => | |
|
|
||
| test('PMM-T2227 - Verify tarball upgrade @generic', async ({}) => { | ||
| const containerName = 'tarball_client'; | ||
| const tarballURL = process.env.PMM_CLIENT_VERSION?.includes('http') | ||
| ? process.env.PMM_CLIENT_VERSION | ||
| : 'https://pmm-build-cache.s3.us-east-2.amazonaws.com/PR-BUILDS/pmm-client/pmm-client-latest.tar.gz'; | ||
| const expectedUpgradeVersion = getClientImageVersion(); | ||
|
|
||
| await cli.exec('docker network create pmm-qa || true'); | ||
| await cli.exec('docker network connect pmm-server pmm-qa'); | ||
| await cli.exec('docker network connect pmm-qa pmm-server || true'); | ||
| await cli.exec(`docker rm -f ${containerName} 2>/dev/null || true`); | ||
| await cli.exec(`docker run --rm -d --name="${containerName}" --network="pmm-qa" --privileged --cgroupns=host -v /sys/fs/cgroup:/sys/fs/cgroup:rw -v /var/lib/containerd antmelekhin/docker-systemd:almalinux-10`); | ||
| const latestReleasedVersion = (await cli.exec('wget -q https://registry.hub.docker.com/v2/repositories/percona/pmm-client/tags -O - | jq -r .results[].name | grep -v latest | sort -V | tail -n1')).stdout; | ||
| await expect(async () => { | ||
| const status = await cli.exec(`docker inspect -f '{{.State.Running}}' ${containerName}`); | ||
| expect(status.stdout.trim()).toBe('true'); | ||
| }).toPass({ intervals: [1_000], timeout: 60_000 }); | ||
| const latestReleasedVersion = (await cli.exec('wget -q https://registry.hub.docker.com/v2/repositories/percona/pmm-client/tags -O - | jq -r .results[].name | grep -v latest | sort -V | tail -n1')).stdout.trim(); | ||
| await cli.exec(`docker cp ../package_tests/scripts/pmm3_client_install_tarball.sh ${containerName}:/`); | ||
| await cli.exec(`docker exec ${containerName} dnf install -y wget`); | ||
| await cli.exec(`docker exec ${containerName} /pmm3_client_install_tarball.sh -v ${latestReleasedVersion}`); | ||
| await (await cli.exec(`docker exec ${containerName} /pmm3_client_install_tarball.sh -v '${latestReleasedVersion}'`)).assertSuccess(); | ||
| await cli.exec(`docker exec ${containerName} pmm-agent setup --config-file=/usr/local/percona/pmm/config/pmm-agent.yaml --force --server-insecure-tls --server-address=pmm-server:8443 --server-username=admin --server-password=admin 127.0.0.1 generic tarball_node`); | ||
| await cli.exec(`docker exec -d ${containerName} pmm-agent --debug --config-file=/usr/local/percona/pmm/config/pmm-agent.yaml`); | ||
| 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=`); | ||
|
|
||
| await adminStatus.outContains('Connected'); | ||
| await oldVersion.outContains(latestReleasedVersion); | ||
| const tarballURL = process.env.PMM_CLIENT_VERSION!.includes('http') ? process.env.PMM_CLIENT_VERSION : 'https://pmm-build-cache.s3.us-east-2.amazonaws.com/PR-BUILDS/pmm-client/pmm-client-latest.tar.gz'; | ||
|
|
||
| await cli.exec(`docker exec ${containerName} /pmm3_client_install_tarball.sh -v ${tarballURL} -u`); | ||
| await cli.exec(`docker exec ${containerName} pkill -f pmm-agent`); | ||
| await (await cli.exec(`docker exec ${containerName} /pmm3_client_install_tarball.sh -v '${tarballURL}' -u`)).assertSuccess(); | ||
| await cli.exec(`docker exec ${containerName} pkill -9 -f pmm-agent || true`); | ||
| await expect(async () => { | ||
| const ps = await cli.exec(`docker exec ${containerName} pgrep -c pmm-agent || true`); | ||
| expect(parseInt(ps.stdout.trim(), 10) || 0).toBe(0); | ||
| }).toPass({ intervals: [500], timeout: 10_000 }); | ||
| await cli.exec(`docker exec -d ${containerName} pmm-agent --debug --config-file=/usr/local/percona/pmm/config/pmm-agent.yaml`); | ||
|
|
||
| const newPid = await cli.exec(`docker exec ${containerName} ps -C pmm-agent -o pid=`); | ||
| const latestVersion = (await cli.exec('curl -s https://raw.githubusercontent.com/Percona-Lab/pmm-submodules/v3/VERSION')).stdout.trim(); | ||
| 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); | ||
|
Comment on lines
612
to
+623
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Poll live connectivity after the agent restart.
Run 🤖 Prompt for AI Agents |
||
|
|
||
| await cli.exec(`docker rm -f ${containerName}`); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Move container cleanup into a 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 🤖 Prompt for AI Agents |
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
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
oldPidsucceeded or contained exactly one PID. IfoldPid.stdoutis 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