diff options
Diffstat (limited to 'jstests/replsets/tenant_migration_external_keys_ttl.js')
-rw-r--r-- | jstests/replsets/tenant_migration_external_keys_ttl.js | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/jstests/replsets/tenant_migration_external_keys_ttl.js b/jstests/replsets/tenant_migration_external_keys_ttl.js index 246c3af0197..0006d9e63f5 100644 --- a/jstests/replsets/tenant_migration_external_keys_ttl.js +++ b/jstests/replsets/tenant_migration_external_keys_ttl.js @@ -14,19 +14,13 @@ * ] */ -import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js"; -import { - forgetMigrationAsync, - getExternalKeys, - isShardMergeEnabled, - kExternalKeysNs, - makeX509OptionsForTest -} from "jstests/replsets/libs/tenant_migration_util.js"; +(function() { +"use strict"; load("jstests/libs/fail_point_util.js"); load("jstests/libs/uuid_util.js"); +load("jstests/replsets/libs/tenant_migration_test.js"); load("jstests/libs/parallelTester.js"); -load("jstests/replsets/rslib.js"); // `createRstArgs` const kExternalKeysTTLIndexName = "ExternalKeysTTLIndex"; const kTenantIdPrefix = "testTenantId"; @@ -41,7 +35,7 @@ let makeTenantId = function() { function waitForExternalKeysTTLIndex(conn) { assert.soon(() => { - const indexSpecs = conn.getCollection(kExternalKeysNs).getIndexSpecs(); + const indexSpecs = conn.getCollection(TenantMigrationUtil.kExternalKeysNs).getIndexSpecs(); const hasIndex = indexSpecs.some(indexSpec => { return indexSpec.name === kExternalKeysTTLIndexName && indexSpec.key.ttlExpiresAt === 1 && indexSpec.expireAfterSeconds === 0; @@ -57,14 +51,15 @@ function waitForExternalKeysTTLIndex(conn) { function waitForExternalKeysToBeDeleted(conn, migrationId) { assert.soonNoExcept(() => { - const externalKeys = getExternalKeys(conn, migrationId); + const externalKeys = TenantMigrationUtil.getExternalKeys(conn, migrationId); assert.eq(0, externalKeys.length, tojson(externalKeys)); return true; }); } function verifyExternalKeys(conn, {migrationId, expectTTLValue}) { - const externalKeys = conn.getCollection(kExternalKeysNs).find({migrationId}).toArray(); + const externalKeys = + conn.getCollection(TenantMigrationUtil.kExternalKeysNs).find({migrationId}).toArray(); assert.gt(externalKeys.length, 0); externalKeys.forEach(key => { @@ -123,7 +118,7 @@ function makeTestParams() { (() => { jsTestLog("Basic case with multiple migrations"); const {tmt, teardown} = setup(); - if (isShardMergeEnabled(tmt.getDonorPrimary().getDB("admin"))) { + if (TenantMigrationUtil.isShardMergeEnabled(tmt.getDonorPrimary().getDB("admin"))) { // This test runs multiple concurrent migrations, which shard merge can't handle. jsTestLog( "Skip: featureFlagShardMerge is enabled and this test runs multiple concurrent migrations, which shard merge can't handle."); @@ -221,7 +216,7 @@ function makeTestParams() { (() => { function setup() { - const migrationX509Options = makeX509OptionsForTest(); + const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest(); const donorRst = new ReplSetTest({ nodes: 3, name: "donorRst", @@ -336,8 +331,10 @@ function makeTestParams() { const fp = configureFailPoint( donorPrimary, "pauseTenantMigrationBeforeMarkingExternalKeysGarbageCollectable"); - const forgetMigrationThread = new Thread( - forgetMigrationAsync, migrationOpts.migrationIdString, createRstArgs(donorRst), true); + const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync, + migrationOpts.migrationIdString, + TenantMigrationUtil.createRstArgs(donorRst), + true); forgetMigrationThread.start(); fp.wait(); @@ -372,8 +369,10 @@ function makeTestParams() { const fp = configureFailPoint( recipientPrimary, "pauseTenantMigrationBeforeMarkingExternalKeysGarbageCollectable"); - const forgetMigrationThread = new Thread( - forgetMigrationAsync, migrationOpts.migrationIdString, createRstArgs(donorRst), true); + const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync, + migrationOpts.migrationIdString, + TenantMigrationUtil.createRstArgs(donorRst), + true); forgetMigrationThread.start(); fp.wait(); @@ -412,8 +411,10 @@ function makeTestParams() { const fp = configureFailPoint( donorPrimary, "pauseTenantMigrationDonorBeforeMarkingStateGarbageCollectable"); - const forgetMigrationThread = new Thread( - forgetMigrationAsync, migrationOpts.migrationIdString, createRstArgs(donorRst), true); + const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync, + migrationOpts.migrationIdString, + TenantMigrationUtil.createRstArgs(donorRst), + true); forgetMigrationThread.start(); fp.wait(); @@ -456,8 +457,10 @@ function makeTestParams() { const fp = configureFailPoint( recipientPrimary, "fpAfterReceivingRecipientForgetMigration", {action: "hang"}); - const forgetMigrationThread = new Thread( - forgetMigrationAsync, migrationOpts.migrationIdString, createRstArgs(donorRst), true); + const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync, + migrationOpts.migrationIdString, + TenantMigrationUtil.createRstArgs(donorRst), + true); forgetMigrationThread.start(); fp.wait(); @@ -479,3 +482,4 @@ function makeTestParams() { teardown(); } })(); +})(); |