Skip to content

Add API test for MongoDB SSL remote instance registration - #1292

Open
peterSirotnak wants to merge 1 commit into
PMM-7-migration-of-upgrade-testsfrom
claude/mongodb-ssl-remote-api-test-g61lya
Open

Add API test for MongoDB SSL remote instance registration#1292
peterSirotnak wants to merge 1 commit into
PMM-7-migration-of-upgrade-testsfrom
claude/mongodb-ssl-remote-api-test-g61lya

Conversation

@peterSirotnak

Copy link
Copy Markdown
Contributor

Add end-to-end API test to verify MongoDB SSL services can be added remotely via the PMM API before upgrade.

Changes:

  • New test file e2e_tests/tests/api/remoteInstances/mongoDb.test.ts that validates remote MongoDB instance registration with SSL/TLS configuration
  • Test extracts CA certificate and client certificate from a Docker container and uses them to add a remote MongoDB service via the API
  • Verifies that all agents for the registered service are running within a 2-minute timeout

Test Details:

  • Test ID: PMM-T948
  • Tagged as @pre-upgrade to run before upgrade scenarios
  • Uses X.509 authentication mechanism with TLS enabled
  • Validates agent health via inventory API polling

https://claude.ai/code/session_0179HcG7YKEKi78Ztmta5EbN

Recreate tests/api/remoteInstances/mongoDb.test.ts with a valid
AddMongoDBServiceParams body. The previous version returned HTTP 400
because pmm_agent_id (a required field, validate min_len=1) was omitted,
and it used schema='https' (not a MongoDB param) instead of tls=true,
with a wrong client-cert path.

Mirror the proven working configuration: set pmm_agent_id, tls=true,
tls_skip_verify, authentication_mechanism MONGODB-X509, and read certs
from /mongodb_certs inside the psmdb-server container. Poll that the
service agents are running after adding the instance.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0179HcG7YKEKi78Ztmta5EbN
Signed-off-by: Claude <peter.sirotnak@percona.com>
Comment on lines +10 to +47
pmmTest(
'PMM-T948 Verify adding MongoDB SSL services remotely via API before upgrade @pre-upgrade',
async ({ api, cliHelper }) => {
const ca = cliHelper
.execSilent(`docker exec ${container} cat /mongodb_certs/ca-certs.pem`)
.assertSuccess().stdout;
const clientCert = cliHelper
.execSilent(`docker exec ${container} cat /mongodb_certs/client.pem`)
.assertSuccess().stdout;

const data: AddRemoteInstance = {
mongodb: {
add_node: { node_name: 'psmdb_ssl_remote_upgrade_node', node_type: 'NODE_TYPE_REMOTE_NODE' },
address: container,
authentication_mechanism: 'MONGODB-X509',
cluster: 'mongodb_ssl_remote_cluster',
pmm_agent_id: 'pmm-server',
port: '27017',
qan_mongodb_profiler: true,
service_name: remoteServiceName,
tls: true,
tls_ca: ca,
tls_certificate_file_password: '',
tls_certificate_key: clientCert,
tls_skip_verify: true,
},
};

await api.remoteInstanceApi.addRemoteInstance(data);

await expect
.poll(() => api.inventoryApi.verifyAgentsAreRunning(remoteServiceName), {
message: `One or more agents are not running for ${remoteServiceName}`,
timeout: Timeouts.TWO_MINUTES,
})
.toBe(true);
},
);

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.

🔴 This is a second copy of a test that already exists on the base branch: e2e_tests/tests/upgrade/ssl.test.ts:11 is PMM-T948 + PMM-T947 - Verify Adding MongoDB SSL service remotely via API before upgrade @pre-upgrade, with the same psmdb-server container, the same MONGODB-X509 payload, the same cluster name and the same verifyAgentsAreRunning poll — only the CA lookup and the service name differ.

Both are tagged @pre-upgrade, so upgrade-pmm-runner.yml:205 (--grep "@pre-upgrade") now registers two remote MongoDB SSL services and runs PMM-T948 twice, and the Zephyr case reports against two results. The new service psmdb_ssl_remote_upgrade_service also has no post-upgrade counterpart — ssl.test.ts:50 only verifies metrics for remote_api_psmdb-server — so it adds pre-upgrade work that nothing checks afterwards.

The head commit message says "Fix MongoDB SSL remote API test (PMM-T948)", and reading the CA from docker exec … cat /mongodb_certs/ca-certs.pem instead of find / -name "ca.crt" (ssl.test.ts:16-21) is that fix. Apply it in place in ssl.test.ts and drop this file.

.execSilent(`docker exec ${container} cat /mongodb_certs/client.pem`)
.assertSuccess().stdout;

const data: AddRemoteInstance = {

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.

🔴 Lint is red on this head SHA because of this line — Lint run 33617968709:

/home/runner/work/pmm-qa/pmm-qa/e2e_tests/tests/api/remoteInstances/mongoDb.test.ts
  20:7  error  Unexpected blank line before this statement  @stylistic/padding-line-between-statements

The other six errors in that job are pre-existing on the base branch; this one is the PR's. npm run lint -- --fix in e2e_tests clears it.

const remoteServiceName = 'psmdb_ssl_remote_upgrade_service';

pmmTest(
'PMM-T948 Verify adding MongoDB SSL services remotely via API before upgrade @pre-upgrade',

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.

🔵 Title is missing the separator: the convention is PMM-Txxxx - description (e2e_tests/CONTRIBUTING.md:70), which every other upgrade test follows, including the existing PMM-T948 one. If this test survives the thread above, make it PMM-T948 - Verify adding ….

@claude

claude Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🟡 This PR targets PMM-7-migration-of-upgrade-tests, the head of the still-unmerged draft #1283, so it should be a draft with Depends on https://github.com/percona/pmm-qa/pull/1283 in the body. The body also links a Claude session instead of a CI run showing the new @pre-upgrade test passing against a real upgrade environment — upgrade-pmm-runner.yml is the run that would prove it.

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.

1 participant