Skip to content

Replace partial name lookup with regex-based service queries - #1294

Merged
peterSirotnak merged 1 commit into
PMM-7-migration-of-upgrade-testsfrom
claude/pmm-t2159-rta-agent-test-ry5hms
Sep 2, 2026
Merged

Replace partial name lookup with regex-based service queries#1294
peterSirotnak merged 1 commit into
PMM-7-migration-of-upgrade-testsfrom
claude/pmm-t2159-rta-agent-test-ry5hms

Conversation

@peterSirotnak

Copy link
Copy Markdown
Contributor

Update e2e tests to use regex-based service lookup instead of partial name matching for improved precision when retrieving MongoDB RTA services.

Changes:

  • Replace getServiceDetailsByPartialName() calls with getServiceDetailsByRegex() using anchored patterns (^rs101_, ^rs102_) across all RTA and inventory test files
  • Add PMM_SERVER_LATEST environment variable to post-upgrade UI test step in CI workflow

Rationale:
The regex-based approach provides more precise service matching by anchoring patterns to the service name prefix, reducing the risk of matching unintended services when multiple services with similar names exist in the test environment.

https://claude.ai/code/session_01Jfa9TRv3eUmizp4AyqNHDr

The upgrade playbook provisions psmdb with SETUP_TYPE=sharding plus a
separate ssl_psmdb (diffauth) deployment. The diffauth deployment
registers plainly named rs101/rs102 services (no _<random> suffix, and
duplicated across auth methods), so getServiceDetailsByPartialName('rs101')
picked those up instead of the pbm replica-set member on 127.0.0.1:27027
that mongoDbHelper actually drives. That broke the exact-title inventory
locator (strict-mode: 2 rows titled "rs101") and the host-name split('_')
assertions, and left the CSV export monitoring the wrong mongod.

Anchor the RTA service lookups to '^rs101_' / '^rs102_' so they select the
pbm member service in every RTA environment (pss, sharded, and gssapi
'rs101_gssapi_<random>' naming) while excluding the bare diffauth service.

Also pass PMM_SERVER_LATEST to the Post-client-upgrade UI tests step; it
runs @post-upgrade (upgradePMM.test.ts) which requires that env var, the
same way the Post-server-upgrade step already sets it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jfa9TRv3eUmizp4AyqNHDr
@peterSirotnak
peterSirotnak merged commit 4887e4b into PMM-7-migration-of-upgrade-tests Sep 2, 2026
1 of 2 checks passed
@peterSirotnak
peterSirotnak deleted the claude/pmm-t2159-rta-agent-test-ry5hms branch September 2, 2026 16:43
'PMM-T2159 - Verify MongoDB RTA Agent displayed in Inventory UI @rta',
async ({ agentsPage, api, servicesPage }) => {
const service = await api.inventoryApi.getServiceDetailsByPartialName('rs101');
const service = await api.inventoryApi.getServiceDetailsByRegex('^rs101_');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Switching to getServiceDetailsByRegex drops the "service is not present" error, because that path's guard is broken: getAllServiceDetailsByRegex (e2e_tests/api/inventory.api.ts:14) checks if (!service) on the result of .filter(), and an empty array is truthy — so it never throws and getServiceDetailsByRegex returns undefined.

getServiceDetailsByPartialName used .find() and did throw Service with name rs101 is not present. After this change, an environment where the mongo services never registered fails with TypeError: Cannot read properties of undefined (reading 'service_id') on the next line instead — exactly the failure mode this PR is trying to diagnose in the post-client-upgrade step, now with a worse message. Same for the other seven call sites in this PR.

Fix the guard in inventory.api.ts (if (!service.length) throw ...) as part of this PR, since the diff is what makes the RTA tests depend on it.

Comment on lines +11 to +12
const service1 = await api.inventoryApi.getServiceDetailsByRegex('^rs101_');
const service2 = await api.inventoryApi.getServiceDetailsByRegex('^rs102_');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 ^rs101_ and includes('rs101') select the same service in every runner that greps @rta, so this rename cannot be what fixes the post-client-upgrade RTA failure the commit message claims.

The service name is always ${node}_${random_number}rs101_31226 from configure-agents.sh:61 (fb-e2e-suite.yml --database psmdb), rs101_gssapi_31226 when GSSAPI=true (gssapi-psmdb-tests-matrix.yml), rs101_31226 from start-sharded.sh:329 (upgrade-pmm-runner.yml SETUP_TYPE=sharding). Nothing else in any of those inventories contains the substring rs101, and .find() and .filter()[0] both take the first match of the same array, so the eight changed call sites resolve identically before and after.

The env var added to the post-client-upgrade step is the change that does something — upgradePMM.test.ts:7 throws without PMM_SERVER_LATEST. Drop the lookup rename (or land it separately with its own reason) so the fix is reviewable on its own.

@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

This targets PMM-7-migration-of-upgrade-tests, the branch of the still-open draft #1283, so it should be a draft with Depends on https://github.com/percona/pmm-qa/pull/1283 in the body.

No gate on this PR exercises the diff: Lint is red on 889b597, but every violation it reports comes from the base branch and not from lines this PR touches (FAIL: eslint/tsc in e2e_testsapi/grafana.api.ts:50, helpers/grafana.helper.ts:321, pages/advisors/advisors.page.ts:6, pages/dashboards/mongo/mongodbShardedClusterSummary.ts:51, tests/upgrade/upgradePMM.test.ts:1; FAIL: yamllint/FAIL: actionlintupgrade-pmm-runner.yml lines 44, 91-224, 250, 255), and upgrade-pmm-runner.yml only triggers on pull requests to main, so the workflow change it edits never ran here.

The body links a Claude session rather than a run of the @post-upgrade|@rta step it claims to fix.

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