summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorVishnu Kaushik <vishnu.kaushik@mongodb.com>2021-02-04 03:20:30 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-04 20:39:55 +0000
commitfde81f2dfd4f55ccabb041927aaf2a48807dce6a (patch)
tree32659451bc339cbe24216d2aba95ca347d04899c /jstests
parent6ee5a25cfc951f6e914dcc9f7d1a63d2e7aeaa67 (diff)
downloadmongo-fde81f2dfd4f55ccabb041927aaf2a48807dce6a.tar.gz
SERVER-53023 Create TTL index on config.tenantMigrationRecipient
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/libs/tenant_migration_test.js37
-rw-r--r--jstests/replsets/tenant_migration_commit_transaction_retry.js25
-rw-r--r--jstests/replsets/tenant_migration_donor_resume_on_stepup_and_restart.js11
-rw-r--r--jstests/replsets/tenant_migration_donor_retry.js23
-rw-r--r--jstests/replsets/tenant_migration_donor_rollback_recovery.js17
-rw-r--r--jstests/replsets/tenant_migration_ensure_migration_outcome_visibility_for_blocked_writes.js33
-rw-r--r--jstests/replsets/tenant_migration_recipient_has_tenant_data.js27
-rw-r--r--jstests/replsets/tenant_migration_recipient_ttl.js87
-rw-r--r--jstests/replsets/tenant_migration_retryable_write_retry.js30
9 files changed, 196 insertions, 94 deletions
diff --git a/jstests/replsets/libs/tenant_migration_test.js b/jstests/replsets/libs/tenant_migration_test.js
index a810a8c889a..6062f40afe4 100644
--- a/jstests/replsets/libs/tenant_migration_test.js
+++ b/jstests/replsets/libs/tenant_migration_test.js
@@ -17,15 +17,25 @@ load("jstests/replsets/libs/tenant_migration_util.js");
* @param {string} [name] the name of the replica sets
* @param {Object} [donorRst] the ReplSetTest instance to adopt for the donor
* @param {Object} [recipientRst] the ReplSetTest instance to adopt for the recipient
+ * @param {Object} [sharedOptions] an object that can contain 'nodes' <number>, the number of nodes
+ * each RST will contain, and 'setParameter' <object>, an object with various server parameters.
*/
-function TenantMigrationTest(
- {name = "TenantMigrationTest", enableRecipientTesting = true, donorRst, recipientRst}) {
+function TenantMigrationTest({
+ name = "TenantMigrationTest",
+ enableRecipientTesting = true,
+ donorRst,
+ recipientRst,
+ sharedOptions = {}
+}) {
const donorPassedIn = (donorRst !== undefined);
const recipientPassedIn = (recipientRst !== undefined);
const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const migrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest();
+ const nodes = sharedOptions.nodes || 2;
+ let setParameterOpts = sharedOptions.setParameter || {};
+
donorRst = donorPassedIn ? donorRst : performSetUp(true /* isDonor */);
recipientRst = recipientPassedIn ? recipientRst : performSetUp(false /* isDonor */);
@@ -39,10 +49,9 @@ function TenantMigrationTest(
createFindInternalClusterTimeKeysRoleIfNotExist(recipientRst);
/**
- * Creates a ReplSetTest instance. The repl set will have 2 nodes.
+ * Creates a ReplSetTest instance. The repl set will have 2 nodes if not otherwise specified.
*/
function performSetUp(isDonor) {
- let setParameterOpts = {};
if (TestData.logComponentVerbosity) {
setParameterOpts["logComponentVerbosity"] =
tojsononeline(TestData.logComponentVerbosity);
@@ -57,7 +66,7 @@ function TenantMigrationTest(
nodeOptions["setParameter"] = setParameterOpts;
const rstName = `${name}_${(isDonor ? "donor" : "recipient")}`;
- const rst = new ReplSetTest({name: rstName, nodes: 2, nodeOptions});
+ const rst = new ReplSetTest({name: rstName, nodes, nodeOptions});
rst.startSet();
rst.initiateWithHighElectionTimeout();
@@ -328,10 +337,14 @@ function TenantMigrationTest(
* Asserts that durable and in-memory state for the migration 'migrationId' and 'tenantId' is
* eventually deleted from the given nodes.
*/
- this.waitForMigrationGarbageCollection = function(nodes, migrationId, tenantId) {
- nodes.forEach(node => {
- const configDonorsColl = node.getCollection("config.tenantMigrationDonors");
- assert.soon(() => 0 === configDonorsColl.count({_id: migrationId}));
+ this.waitForMigrationGarbageCollection = function(
+ migrationId, tenantId, donorNodes, recipientNodes) {
+ donorNodes = donorNodes || donorRst.nodes;
+ recipientNodes = recipientNodes || recipientRst.nodes;
+
+ donorNodes.forEach(node => {
+ const configDonorsColl = node.getCollection(TenantMigrationTest.kConfigDonorsNS);
+ assert.soon(() => 0 === configDonorsColl.count({_id: migrationId}), tojson(node));
let mtabs;
assert.soon(() => {
@@ -340,6 +353,12 @@ function TenantMigrationTest(
return !mtabs || !mtabs[tenantId];
}, tojson(mtabs));
});
+
+ recipientNodes.forEach(node => {
+ const configRecipientsColl =
+ node.getCollection(TenantMigrationTest.kConfigRecipientsNS);
+ assert.soon(() => 0 === configRecipientsColl.count({_id: migrationId}));
+ });
};
/**
diff --git a/jstests/replsets/tenant_migration_commit_transaction_retry.js b/jstests/replsets/tenant_migration_commit_transaction_retry.js
index 5b548cd7249..113324fa5f3 100644
--- a/jstests/replsets/tenant_migration_commit_transaction_retry.js
+++ b/jstests/replsets/tenant_migration_commit_transaction_retry.js
@@ -17,24 +17,25 @@ load("jstests/replsets/rslib.js");
load("jstests/libs/uuid_util.js");
const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
+const kGarbageCollectionParams = {
+ // Set the delay before a donor state doc is garbage collected to be short to speed up
+ // the test.
+ tenantMigrationGarbageCollectionDelayMS: 3 * 1000,
+
+ // Set the TTL monitor to run at a smaller interval to speed up the test.
+ ttlMonitorSleepSecs: 1,
+};
+
const donorRst = new ReplSetTest({
nodes: 1,
name: "donor",
- nodeOptions: Object.assign(migrationX509Options.donor, {
- setParameter: {
- // Set the delay before a donor state doc is garbage collected to be short to speed up
- // the test.
- tenantMigrationGarbageCollectionDelayMS: 3 * 1000,
-
- // Set the TTL monitor to run at a smaller interval to speed up the test.
- ttlMonitorSleepSecs: 1,
- }
- })
+ nodeOptions: Object.assign(migrationX509Options.donor, {setParameter: kGarbageCollectionParams})
});
const recipientRst = new ReplSetTest({
nodes: [{}, {rsConfig: {priority: 0}}, {rsConfig: {priority: 0}}],
name: "recipient",
- nodeOptions: migrationX509Options.recipient
+ nodeOptions:
+ Object.assign(migrationX509Options.recipient, {setParameter: kGarbageCollectionParams})
});
donorRst.startSet();
@@ -89,7 +90,7 @@ assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
const donorDoc =
donorPrimary.getCollection(TenantMigrationTest.kConfigDonorsNS).findOne({tenantId: kTenantId});
-tenantMigrationTest.waitForMigrationGarbageCollection(donorRst.nodes, migrationId, kTenantId);
+tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, kTenantId);
{
jsTest.log("Run another transaction after the migration");
diff --git a/jstests/replsets/tenant_migration_donor_resume_on_stepup_and_restart.js b/jstests/replsets/tenant_migration_donor_resume_on_stepup_and_restart.js
index d1c12b2adda..54ed5292e10 100644
--- a/jstests/replsets/tenant_migration_donor_resume_on_stepup_and_restart.js
+++ b/jstests/replsets/tenant_migration_donor_resume_on_stepup_and_restart.js
@@ -177,16 +177,7 @@ function testDonorForgetMigrationInterrupt(interruptFunc) {
ErrorCodes.NoSuchTenantMigration);
assert.commandWorked(forgetMigrationThread.returnData());
- // After forgetMigrationThread returns, check that the recipient state doc is correctly marked
- // as garbage collectable.
- const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
- const recipientStateDoc =
- recipientPrimary.getCollection(TenantMigrationTest.kConfigRecipientsNS).findOne({
- _id: migrationId
- });
- assert(recipientStateDoc.expireAt);
- tenantMigrationTest.waitForMigrationGarbageCollection(
- donorRst.nodes, migrationId, migrationOpts.tenantId);
+ tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, migrationOpts.tenantId);
tenantMigrationTest.stop();
donorRst.stopSet();
diff --git a/jstests/replsets/tenant_migration_donor_retry.js b/jstests/replsets/tenant_migration_donor_retry.js
index e1df3b78ed4..6d82ae988a2 100644
--- a/jstests/replsets/tenant_migration_donor_retry.js
+++ b/jstests/replsets/tenant_migration_donor_retry.js
@@ -19,23 +19,25 @@ const kGarbageCollectionDelayMS = 5 * 1000;
const kTenantIdPrefix = "testTenantId";
let testNum = 0;
+const garbageCollectionOpts = {
+ // Set the delay before a donor state doc is garbage collected to be short to speed
+ // up the test.
+ tenantMigrationGarbageCollectionDelayMS: kGarbageCollectionDelayMS,
+ ttlMonitorSleepSecs: 1
+};
+
const donorRst = new ReplSetTest({
name: "donorRst",
nodes: 1,
- nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
- setParameter: {
- // Set the delay before a donor state doc is garbage collected to be short to speed
- // up the test.
- tenantMigrationGarbageCollectionDelayMS: kGarbageCollectionDelayMS,
- ttlMonitorSleepSecs: 1,
- }
- })
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor,
+ {setParameter: garbageCollectionOpts})
});
donorRst.startSet();
donorRst.initiate();
-const tenantMigrationTest = new TenantMigrationTest({name: jsTestName(), donorRst: donorRst});
+const tenantMigrationTest = new TenantMigrationTest(
+ {name: jsTestName(), donorRst: donorRst, sharedOptions: {setParameter: garbageCollectionOpts}});
const donorPrimary = tenantMigrationTest.getDonorPrimary();
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
@@ -122,8 +124,7 @@ function testDonorRetryRecipientForgetMigrationCmdOnError(errorCode) {
fp.off();
// Check that forgetMigration properly deletes the stateDoc and mtab from the donor primary.
- tenantMigrationTest.waitForMigrationGarbageCollection(
- tenantMigrationTest.getDonorRst().nodes, migrationId, tenantId);
+ tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, tenantId);
}
(() => {
diff --git a/jstests/replsets/tenant_migration_donor_rollback_recovery.js b/jstests/replsets/tenant_migration_donor_rollback_recovery.js
index bafea4fc040..c11e838161d 100644
--- a/jstests/replsets/tenant_migration_donor_rollback_recovery.js
+++ b/jstests/replsets/tenant_migration_donor_rollback_recovery.js
@@ -17,6 +17,8 @@ load("jstests/replsets/libs/tenant_migration_util.js");
const kTenantId = "testTenantId";
const kMaxSleepTimeMS = 250;
+
+// Set the delay before a donor state doc is garbage collected to be short to speed up the test.
const kGarbageCollectionDelayMS = 5 * 1000;
const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
@@ -27,7 +29,9 @@ const recipientRst = new ReplSetTest({
nodeOptions: Object.assign(migrationX509Options.recipient, {
setParameter: {
// TODO SERVER-52719: Remove the failpoint 'returnResponseOkForRecipientSyncDataCmd'.
- 'failpoint.returnResponseOkForRecipientSyncDataCmd': tojson({mode: 'alwaysOn'})
+ 'failpoint.returnResponseOkForRecipientSyncDataCmd': tojson({mode: 'alwaysOn'}),
+ tenantMigrationGarbageCollectionDelayMS: kGarbageCollectionDelayMS,
+ ttlMonitorSleepSecs: 1,
}
})
});
@@ -64,8 +68,6 @@ function testRollBack(setUpFunc, rollbackOpsFunc, steadyStateFunc) {
settings: {chainingAllowed: false},
nodeOptions: Object.assign(migrationX509Options.donor, {
setParameter: {
- // Set the delay before a donor state doc is garbage collected to be short to speed
- // up the test.
tenantMigrationGarbageCollectionDelayMS: kGarbageCollectionDelayMS,
ttlMonitorSleepSecs: 1,
}
@@ -237,15 +239,8 @@ function testRollBackMarkingStateGarbageCollectable() {
let steadyStateFunc = (tenantMigrationTest, donorPrimary, donorSecondary) => {
// Verify that the migration state got garbage collected successfully despite the rollback.
assert.commandWorked(forgetMigrationThread.returnData());
- // Check that the recipient state doc is correctly marked as garbage collectable.
- const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
- const recipientStateDoc =
- recipientPrimary.getCollection(TenantMigrationTest.kConfigRecipientsNS).findOne({
- _id: migrationId
- });
- assert(recipientStateDoc.expireAt);
tenantMigrationTest.waitForMigrationGarbageCollection(
- [donorPrimary, donorSecondary], migrationId, migrationOpts.tenantId);
+ migrationId, migrationOpts.tenantId, [donorPrimary, donorSecondary]);
};
testRollBack(setUpFunc, rollbackOpsFunc, steadyStateFunc);
diff --git a/jstests/replsets/tenant_migration_ensure_migration_outcome_visibility_for_blocked_writes.js b/jstests/replsets/tenant_migration_ensure_migration_outcome_visibility_for_blocked_writes.js
index 8fa95d4df07..b2dc0cb1e58 100644
--- a/jstests/replsets/tenant_migration_ensure_migration_outcome_visibility_for_blocked_writes.js
+++ b/jstests/replsets/tenant_migration_ensure_migration_outcome_visibility_for_blocked_writes.js
@@ -16,23 +16,21 @@ load("jstests/libs/uuid_util.js");
load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/replsets/libs/tenant_migration_util.js");
-// Set the delay before a donor state doc is garbage collected to be short to speed up the test.
-const kGarbageCollectionDelayMS = 30 * 1000;
+const kGarbageCollectionParams = {
+ // Set the delay before a donor state doc is garbage collected to be short to speed up the test.
+ tenantMigrationGarbageCollectionDelayMS: 30 * 1000,
+ // Set the TTL monitor to run at a smaller interval to speed up the test.
+ ttlMonitorSleepSecs: 1,
+};
-// Set the TTL monitor to run at a smaller interval to speed up the test.
-const kTTLMonitorSleepSecs = 1;
const kCollName = "testColl";
const kTenantDefinedDbName = "0";
const donorRst = new ReplSetTest({
nodes: 1,
name: 'donor',
- nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
- setParameter: {
- tenantMigrationGarbageCollectionDelayMS: kGarbageCollectionDelayMS,
- ttlMonitorSleepSecs: kTTLMonitorSleepSecs,
- }
- })
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor,
+ {setParameter: kGarbageCollectionParams})
});
function insertDocument(primaryHost, dbName, collName) {
@@ -49,8 +47,12 @@ function insertDocument(primaryHost, dbName, collName) {
donorRst.startSet();
donorRst.initiate();
- const tenantMigrationTest =
- new TenantMigrationTest({name: jsTestName(), donorRst, enableRecipientTesting: false});
+ const tenantMigrationTest = new TenantMigrationTest({
+ name: jsTestName(),
+ donorRst,
+ enableRecipientTesting: false,
+ sharedOptions: {setParameter: kGarbageCollectionParams}
+ });
if (!tenantMigrationTest.isFeatureFlagEnabled()) {
jsTestLog("Skipping test because the tenant migrations feature flag is disabled");
donorRst.stopSet();
@@ -93,7 +95,7 @@ function insertDocument(primaryHost, dbName, collName) {
assert.eq(migrationRes.state, TenantMigrationTest.State.kCommitted);
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
- tenantMigrationTest.waitForMigrationGarbageCollection(donorRst.nodes, migrationId, tenantId);
+ tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, tenantId);
writeFp.off();
writeThread.join();
@@ -112,7 +114,8 @@ function insertDocument(primaryHost, dbName, collName) {
donorRst.startSet();
donorRst.initiate();
- const tenantMigrationTest = new TenantMigrationTest({name: jsTestName(), donorRst});
+ const tenantMigrationTest = new TenantMigrationTest(
+ {name: jsTestName(), donorRst, sharedOptions: {setParameter: kGarbageCollectionParams}});
if (!tenantMigrationTest.isFeatureFlagEnabled()) {
jsTestLog("Skipping test because the tenant migrations feature flag is disabled");
donorRst.stopSet();
@@ -157,7 +160,7 @@ function insertDocument(primaryHost, dbName, collName) {
abortFp.off();
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
- tenantMigrationTest.waitForMigrationGarbageCollection(donorRst.nodes, migrationId, tenantId);
+ tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, tenantId);
writeFp.off();
writeThread.join();
diff --git a/jstests/replsets/tenant_migration_recipient_has_tenant_data.js b/jstests/replsets/tenant_migration_recipient_has_tenant_data.js
index 5044b2f306d..ace3cc38b55 100644
--- a/jstests/replsets/tenant_migration_recipient_has_tenant_data.js
+++ b/jstests/replsets/tenant_migration_recipient_has_tenant_data.js
@@ -13,25 +13,27 @@ load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/replsets/libs/tenant_migration_test.js");
+const kGarbageCollectionParams = {
+ // Set the delay before a donor state doc is garbage collected to be short to speed up
+ // the test.
+ tenantMigrationGarbageCollectionDelayMS: 3 * 1000,
+
+ // Set the TTL monitor to run at a smaller interval to speed up the test.
+ ttlMonitorSleepSecs: 1,
+};
+
const donorRst = new ReplSetTest({
nodes: 1,
name: "donor",
- nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
- setParameter: {
- // Set the delay before a donor state doc is garbage collected to be short to speed up
- // the test.
- tenantMigrationGarbageCollectionDelayMS: 3 * 1000,
-
- // Set the TTL monitor to run at a smaller interval to speed up the test.
- ttlMonitorSleepSecs: 1,
- }
- })
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor,
+ {setParameter: kGarbageCollectionParams})
});
donorRst.startSet();
donorRst.initiate();
-const tenantMigrationTest = new TenantMigrationTest({name: jsTestName(), donorRst});
+const tenantMigrationTest = new TenantMigrationTest(
+ {name: jsTestName(), donorRst, sharedOptions: {setParameter: kGarbageCollectionParams}});
if (!tenantMigrationTest.isFeatureFlagEnabled()) {
jsTestLog("Skipping test because the tenant migrations feature flag is disabled");
donorRst.stopSet();
@@ -55,8 +57,7 @@ jsTest.log("Start a tenant migration and verify that it commits successfully");
const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
assert.eq(stateRes.state, TenantMigrationTest.State.kCommitted);
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
- tenantMigrationTest.waitForMigrationGarbageCollection(
- tenantMigrationTest.getDonorRst().nodes, migrationId, kTenantId);
+ tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, kTenantId);
})();
jsTest.log(
diff --git a/jstests/replsets/tenant_migration_recipient_ttl.js b/jstests/replsets/tenant_migration_recipient_ttl.js
new file mode 100644
index 00000000000..e08d01bfcb3
--- /dev/null
+++ b/jstests/replsets/tenant_migration_recipient_ttl.js
@@ -0,0 +1,87 @@
+/**
+ * Tests to check whether the TTL index is being created and is functioning correctly on the tenant
+ * migration recipient.
+ *
+ * @tags: [requires_fcv_49]
+ */
+
+(function() {
+
+"use strict";
+load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+
+const kGarbageCollectionParams = {
+ // Set the delay to 30s so that we can see the document vanish.
+ tenantMigrationGarbageCollectionDelayMS: 30 * 1000,
+
+ // Set the TTL monitor to run at a smaller interval to speed up the test.
+ ttlMonitorSleepSecs: 1
+};
+
+const tenantMigrationTest = new TenantMigrationTest(
+ {name: jsTestName(), sharedOptions: {setParameter: kGarbageCollectionParams}});
+
+if (!tenantMigrationTest.isFeatureFlagEnabled()) {
+ jsTestLog("Skipping test because the tenant migrations feature flag is disabled");
+ tenantMigrationTest.stop();
+ return;
+}
+
+const kRecipientTTLIndexName = "TenantMigrationRecipientTTLIndex";
+
+const kMigrationId = UUID();
+const kTenantId = 'testTenantId';
+const migrationOpts = {
+ migrationIdString: extractUUIDFromObject(kMigrationId),
+ tenantId: kTenantId,
+ readPreference: {mode: "primary"}
+};
+
+const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
+const configDB = recipientPrimary.getDB("config");
+const tenantMigrationRecipientStateColl = configDB["tenantMigrationRecipients"];
+
+jsTestLog("Ensure the TTL index was created.");
+const indexes = tenantMigrationRecipientStateColl.getIndexes();
+let i = 0;
+for (; i < indexes.length; i++) {
+ if (indexes[i].name == kRecipientTTLIndexName) {
+ assert.eq(indexes[i].key.expireAt, 1, tojson(indexes));
+ assert.eq(indexes[i].expireAfterSeconds, 0, tojson(indexes));
+ break;
+ }
+}
+// A TTL index must be found on the primary.
+assert.neq(i, indexes.length, tojson(indexes));
+
+jsTestLog("Starting and completing a tenant migration with migrationId: " + kMigrationId +
+ ", tenantId: " + kTenantId);
+assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
+assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+
+// The migration's document will not be marked as garbage collectable until forgetMigration. The
+// document should exist in the collection now, without an expireAt field.
+jsTestLog("Making sure migration state document exists.");
+let stateDocQuery = tenantMigrationRecipientStateColl.find({_id: kMigrationId}).toArray();
+assert.eq(stateDocQuery.length, 1, tojson(stateDocQuery));
+assert(!stateDocQuery[0].hasOwnProperty("expireAt"), tojson(stateDocQuery));
+
+jsTestLog("Forgetting the migration.");
+assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
+
+// The state document should now have the expireAt field.
+jsTestLog("Expect to find expireAt field.");
+stateDocQuery = tenantMigrationRecipientStateColl.find({_id: kMigrationId}).toArray();
+assert.eq(stateDocQuery.length, 1, tojson(stateDocQuery));
+assert(stateDocQuery[0].hasOwnProperty("expireAt"), tojson(stateDocQuery));
+
+// Sleep past the garbage collection delay time, and then make sure the state document for our
+// migration does not exist.
+jsTestLog("Sleeping and then expecting the state document to have been deleted.");
+sleep(30000); // The garbage collection delay is 30s.
+tenantMigrationTest.waitForMigrationGarbageCollection(kMigrationId, kTenantId);
+
+tenantMigrationTest.stop();
+})(); \ No newline at end of file
diff --git a/jstests/replsets/tenant_migration_retryable_write_retry.js b/jstests/replsets/tenant_migration_retryable_write_retry.js
index 9222668b50b..2e1aae90924 100644
--- a/jstests/replsets/tenant_migration_retryable_write_retry.js
+++ b/jstests/replsets/tenant_migration_retryable_write_retry.js
@@ -14,22 +14,26 @@ load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
+const kGarbageCollectionParams = {
+ // Set the delay before a donor state doc is garbage collected to be short to speed up
+ // the test.
+ tenantMigrationGarbageCollectionDelayMS: 3 * 1000,
+
+ // Set the TTL monitor to run at a smaller interval to speed up the test.
+ ttlMonitorSleepSecs: 1,
+};
+
const donorRst = new ReplSetTest({
nodes: 1,
name: "donor",
- nodeOptions: Object.assign(migrationX509Options.donor, {
- setParameter: {
- // Set the delay before a donor state doc is garbage collected to be short to speed up
- // the test.
- tenantMigrationGarbageCollectionDelayMS: 3 * 1000,
-
- // Set the TTL monitor to run at a smaller interval to speed up the test.
- ttlMonitorSleepSecs: 1,
- }
- })
+ nodeOptions: Object.assign(migrationX509Options.donor, {setParameter: kGarbageCollectionParams})
+});
+const recipientRst = new ReplSetTest({
+ nodes: 1,
+ name: "recipient",
+ nodeOptions:
+ Object.assign(migrationX509Options.recipient, {setParameter: kGarbageCollectionParams})
});
-const recipientRst =
- new ReplSetTest({nodes: 1, name: "recipient", nodeOptions: migrationX509Options.recipient});
donorRst.startSet();
donorRst.initiate();
@@ -198,7 +202,7 @@ assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
const donorDoc =
donorPrimary.getCollection(TenantMigrationTest.kConfigDonorsNS).findOne({tenantId: kTenantId});
-tenantMigrationTest.waitForMigrationGarbageCollection(donorRst.nodes, migrationId, kTenantId);
+tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, kTenantId);
// Test the aggregation pipeline the recipient would use for getting the config.transactions entries
// and oplog chains for the retryable writes that committed before startFetchingTimestamp. The