summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@10gen.com>2021-04-05 17:19:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-01 03:30:15 +0000
commitda663d32d6f62d0ca48e1944fda8b3abe362b0cd (patch)
treea10ca1e544e4ca1f4b527f694e747d0c7208c82b /jstests
parentc1213e2bbfb379d3defdc08a48067a350e84027c (diff)
downloadmongo-da663d32d6f62d0ca48e1944fda8b3abe362b0cd.tar.gz
SERVER-53563 Cancel tenant migrations on FCV change (donor side)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js
new file mode 100644
index 00000000000..0e958568cc9
--- /dev/null
+++ b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js
@@ -0,0 +1,70 @@
+/**
+ * Tests that the donor cancels all migrations when its FCV changes.
+ * @tags: [requires_majority_read_concern, incompatible_with_windows_tls]
+ */
+
+(function() {
+"use strict";
+
+load("jstests/libs/fail_point_util.js");
+load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+load("jstests/libs/parallelTester.js"); // for 'Thread'
+load("jstests/replsets/rslib.js"); // for 'setLogVerbosity'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+
+const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
+if (!tenantMigrationTest.isFeatureFlagEnabled()) {
+ jsTestLog("Skipping test because the tenant migrations feature flag is disabled");
+ return;
+}
+
+const tenantId = "testTenantId";
+const dbName = tenantMigrationTest.tenantDB(tenantId, "testDB");
+const collName = "testColl";
+
+const donorRst = tenantMigrationTest.getDonorRst();
+const donorPrimary = tenantMigrationTest.getDonorPrimary();
+const donorDB = donorPrimary.getDB(dbName);
+
+setLogVerbosity([donorPrimary], {"tenantMigration": {"verbosity": 3}});
+
+tenantMigrationTest.insertDonorDB(dbName, collName);
+
+const migrationId = UUID();
+const migrationIdString = extractUUIDFromObject(migrationId);
+const migrationOpts = {
+ migrationIdString: migrationIdString,
+ recipientConnString: tenantMigrationTest.getRecipientConnString(),
+ tenantId: tenantId,
+};
+
+const hangWhileMigratingFP =
+ configureFailPoint(donorDB, "pauseTenantMigrationBeforeLeavingAbortingIndexBuildsState");
+
+// Start a migration and wait for donor to hang at the failpoint.
+assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
+
+hangWhileMigratingFP.wait();
+
+// Initiate a downgrade and let it complete.
+assert.commandWorked(
+ donorPrimary.adminCommand({setFeatureCompatibilityVersion: lastContinuousFCV}));
+
+// Upgrade again and finish the test.
+assert.commandWorked(donorPrimary.adminCommand({setFeatureCompatibilityVersion: latestFCV}));
+
+hangWhileMigratingFP.off();
+
+const stateRes =
+ assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
+assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted);
+
+tenantMigrationTest.waitForDonorNodesToReachState(
+ donorRst.nodes, migrationId, tenantId, TenantMigrationTest.DonorState.kAborted);
+
+assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
+
+tenantMigrationTest.stop();
+})(); \ No newline at end of file