summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorCheahuychou Mao <mao.cheahuychou@gmail.com>2021-03-16 18:36:09 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-17 19:22:01 +0000
commit2a7d4e1159ee9484ffd1954b220957b1679b74c2 (patch)
treef5d439bc119e8e4bc9a5cb94b37061c1fff90809 /jstests
parente3b9f422e0977417f97821e53e436b3692d6037f (diff)
downloadmongo-2a7d4e1159ee9484ffd1954b220957b1679b74c2.tar.gz
SERVER-55234 Ensure that tenant migration abortReason is recovered correctly on stepup recovery
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/tenant_migration_stepup_recovery_after_abort.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js b/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js
new file mode 100644
index 00000000000..a3e0f39b1ee
--- /dev/null
+++ b/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js
@@ -0,0 +1,72 @@
+/**
+ * Tests the the donor correctly recovers the abort reason and the migration after stepup.
+ *
+ * @tags: [requires_fcv_47, requires_majority_read_concern, incompatible_with_eft,
+ * incompatible_with_windows_tls]
+ */
+
+(function() {
+"use strict";
+
+load("jstests/libs/fail_point_util.js");
+load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+
+// Set the delay before a state doc is garbage collected to be short to speed up the test.
+const kGarbageCollectionParams = {
+ tenantMigrationGarbageCollectionDelayMS: 3 * 1000,
+ ttlMonitorSleepSecs: 1,
+};
+
+const donorRst = new ReplSetTest({
+ nodes: 3,
+ name: "donor",
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor,
+ {setParameter: kGarbageCollectionParams})
+});
+
+donorRst.startSet();
+donorRst.initiate();
+
+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();
+ return;
+}
+
+const tenantId = "testTenantId";
+const migrationId = UUID();
+const migrationOpts = {
+ migrationIdString: extractUUIDFromObject(migrationId),
+ tenantId: tenantId,
+};
+
+const donorPrimary = tenantMigrationTest.getDonorPrimary();
+
+assert.commandWorked(donorPrimary.getCollection(tenantId + "_testDb.testColl").insert({_id: 0}));
+
+const donorFp = configureFailPoint(donorPrimary, "abortTenantMigrationBeforeLeavingBlockingState");
+
+let stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
+assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
+assert.eq(stateRes.abortReason.code, ErrorCodes.InternalError);
+donorFp.off();
+
+assert.commandWorked(
+ donorPrimary.adminCommand({replSetStepDown: ReplSetTest.kForeverSecs, force: true}));
+assert.commandWorked(donorPrimary.adminCommand({replSetFreeze: 0}));
+
+stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
+assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
+assert.eq(stateRes.abortReason.code, ErrorCodes.InternalError);
+
+assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
+tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, tenantId);
+
+donorRst.stopSet();
+tenantMigrationTest.stop();
+})();