Replace partial name lookup with regex-based service queries - #1294
Conversation
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
4887e4b
into
PMM-7-migration-of-upgrade-tests
| '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_'); |
There was a problem hiding this comment.
🟡 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.
| const service1 = await api.inventoryApi.getServiceDetailsByRegex('^rs101_'); | ||
| const service2 = await api.inventoryApi.getServiceDetailsByRegex('^rs102_'); |
There was a problem hiding this comment.
🟡 ^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.
|
This targets No gate on this PR exercises the diff: The body links a Claude session rather than a run of the |
Update e2e tests to use regex-based service lookup instead of partial name matching for improved precision when retrieving MongoDB RTA services.
Changes:
getServiceDetailsByPartialName()calls withgetServiceDetailsByRegex()using anchored patterns (^rs101_,^rs102_) across all RTA and inventory test filesPMM_SERVER_LATESTenvironment variable to post-upgrade UI test step in CI workflowRationale:
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