summaryrefslogtreecommitdiff
path: root/jstests/replsets/tenant_migration_metrics_output.js
blob: 6a117ac64a37f3a4612194b9842e739b2d64f191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * Verifies the serverStatus output and FTDC output for tenant migrations.
 *
 * @tags: [
 *   incompatible_with_macos,
 *   incompatible_with_windows_tls,
 *   requires_majority_read_concern,
 *   requires_persistence,
 *   serverless,
 * ]
 */

(function() {
"use strict";

load("jstests/libs/ftdc.js");
load("jstests/libs/uuid_util.js");
load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/replsets/libs/tenant_migration_util.js");

// Verify that the server status response has the fields that we expect.
function verifyServerStatus(conn) {
    const res = assert.commandWorked(conn.adminCommand({serverStatus: 1}));
    assert.hasFields(res, ["tenantMigrationAccessBlocker"]);
}
// Verify the periodic samples used for FTDC do not have the 'tenantMigrationAccessBlocker' section.
function verifyFTDCOutput(conn) {
    const latestPeriodicFTDC = verifyGetDiagnosticData(conn.getDB("admin"));
    assert.hasFields(latestPeriodicFTDC, ["serverStatus"]);
    assert.eq(undefined, latestPeriodicFTDC.serverStatus.tenantMigrationAccessBlocker);
}

jsTestLog("Verify serverStatus and FTDC output after a migration has committed.");

const testPath = MongoRunner.toRealPath("ftdc_dir_repl_node");
const donorRst = new ReplSetTest({
    nodes: 1,
    name: "donorRst",
    nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor,
                               {setParameter: {diagnosticDataCollectionDirectoryPath: testPath}})
});

donorRst.startSet();
donorRst.initiate();

const tenantMigrationTest =
    new TenantMigrationTest({name: jsTestName(), donorRst, enableRecipientTesting: false});

const tenantId = ObjectId().str;
const migrationId = extractUUIDFromObject(UUID());
const migrationOpts = {
    migrationIdString: migrationId,
    tenantId: tenantId,
    recipientConnString: tenantMigrationTest.getRecipientConnString()
};

TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));

verifyServerStatus(tenantMigrationTest.getDonorPrimary());
verifyFTDCOutput(tenantMigrationTest.getDonorPrimary());

tenantMigrationTest.stop();
donorRst.stopSet();
})();