summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorChristopher Caplinger <christopher.caplinger@mongodb.com>2022-11-23 23:10:16 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-11-23 23:59:46 +0000
commitda704aa92e02f244e713a035c1ef3e53f20e314a (patch)
tree6a34170d57226a67859eb2940c7f7a69a0a08eaa /jstests
parent5e35b4a34496933257ced0cb8e3b6d99439985f0 (diff)
downloadmongo-da704aa92e02f244e713a035c1ef3e53f20e314a.tar.gz
SERVER-69229: Drop donated files collection when marking as garbage
Diffstat (limited to 'jstests')
-rw-r--r--jstests/replsets/tenant_migration_recipient_forget_migration.js145
-rw-r--r--jstests/replsets/tenant_migration_recipient_stepdown_after_forget.js71
2 files changed, 145 insertions, 71 deletions
diff --git a/jstests/replsets/tenant_migration_recipient_forget_migration.js b/jstests/replsets/tenant_migration_recipient_forget_migration.js
new file mode 100644
index 00000000000..e3d5cd36a8a
--- /dev/null
+++ b/jstests/replsets/tenant_migration_recipient_forget_migration.js
@@ -0,0 +1,145 @@
+/**
+ * Tests forgetMigration cleanup behavior.
+ *
+ * @tags: [
+ * incompatible_with_macos,
+ * incompatible_with_windows_tls,
+ * requires_persistence,
+ * requires_replication,
+ * serverless,
+ * ]
+ */
+
+(function() {
+
+"use strict";
+load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
+load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
+load("jstests/libs/parallelTester.js"); // For Thread(), used for async forgetMigration.
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+
+const tenantMigrationTest = new TenantMigrationTest({
+ name: jsTestName(),
+ sharedOptions: {nodes: 2},
+ quickGarbageCollection: true,
+});
+
+const kTenantId = "testTenantId";
+const kReadPreference = {
+ mode: "primary"
+};
+
+const isShardMergeEnabled =
+ TenantMigrationUtil.isShardMergeEnabled(tenantMigrationTest.getDonorPrimary().getDB("admin"));
+
+const oplogBufferCollectionName = (migrationIdString) =>
+ `repl.migration.oplog_${migrationIdString}`;
+const donatedFilesCollectionName = (migrationIdString) => `donatedFiles.${migrationIdString}`;
+
+const assertTempCollectionsExist = (conn, migrationIdString) => {
+ const collections = conn.getDB("config").getCollectionNames();
+ assert(collections.includes(oplogBufferCollectionName(migrationIdString)), collections);
+ if (isShardMergeEnabled) {
+ assert(collections.includes(donatedFilesCollectionName(migrationIdString)), collections);
+ }
+};
+
+const assertTempCollectionsDoNotExist = (conn, migrationIdString) => {
+ const collections = conn.getDB("config").getCollectionNames();
+ assert(!collections.includes(oplogBufferCollectionName(migrationIdString)), collections);
+ if (isShardMergeEnabled) {
+ assert(!collections.includes(donatedFilesCollectionName(migrationIdString)), collections);
+ }
+};
+
+(() => {
+ jsTestLog("Test that expected collections are cleaned up when forgetting a migration.");
+ const kMigrationId = UUID();
+ const migrationOpts = {
+ migrationIdString: extractUUIDFromObject(kMigrationId),
+ tenantId: kTenantId,
+ readPreference: kReadPreference
+ };
+
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
+ migrationOpts, {retryOnRetryableErrors: true, automaticForgetMigration: false}));
+
+ const fpBeforeDroppingTempCollections =
+ configureFailPoint(tenantMigrationTest.getRecipientPrimary(),
+ "fpBeforeDroppingTempCollections",
+ {action: "hang"});
+
+ jsTestLog("Issuing a forget migration command.");
+ const forgetMigrationThread =
+ new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst()),
+ true /* retryOnRetryableErrors */);
+ forgetMigrationThread.start();
+
+ fpBeforeDroppingTempCollections.wait();
+
+ const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
+
+ assertTempCollectionsExist(recipientPrimary, migrationOpts.migrationIdString);
+
+ fpBeforeDroppingTempCollections.off();
+
+ jsTestLog("Waiting for forget migration to complete.");
+ assert.commandWorked(forgetMigrationThread.returnData());
+
+ assertTempCollectionsDoNotExist(recipientPrimary, migrationOpts.migrationIdString);
+
+ tenantMigrationTest.waitForMigrationGarbageCollection(migrationOpts.migrationIdString);
+})();
+
+(() => {
+ jsTestLog(
+ "Tests whether the new recipient primary properly processes a forgetMigration when " +
+ "the original primary steps down after the migration is marked as garbage collectable.");
+ const kMigrationId = UUID();
+ const migrationOpts = {
+ migrationIdString: extractUUIDFromObject(kMigrationId),
+ tenantId: kTenantId,
+ readPreference: kReadPreference
+ };
+
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
+ migrationOpts, {retryOnRetryableErrors: true, automaticForgetMigration: false}));
+
+ const fpBeforeDroppingTempCollections =
+ configureFailPoint(tenantMigrationTest.getRecipientPrimary(),
+ "fpBeforeDroppingTempCollections",
+ {action: "hang"});
+
+ jsTestLog("Issuing a forget migration command.");
+ const forgetMigrationThread =
+ new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst()),
+ true /* retryOnRetryableErrors */);
+ forgetMigrationThread.start();
+
+ fpBeforeDroppingTempCollections.wait();
+
+ assertTempCollectionsExist(tenantMigrationTest.getRecipientPrimary(),
+ migrationOpts.migrationIdString);
+
+ jsTestLog("Stepping up a new recipient primary.");
+ tenantMigrationTest.getRecipientRst().stepUp(
+ tenantMigrationTest.getRecipientRst().getSecondaries()[0]);
+
+ fpBeforeDroppingTempCollections.off();
+
+ jsTestLog("Waiting for forget migration to complete.");
+ assert.commandWorked(forgetMigrationThread.returnData());
+
+ assertTempCollectionsDoNotExist(tenantMigrationTest.getRecipientPrimary(),
+ migrationOpts.migrationIdString);
+
+ tenantMigrationTest.waitForMigrationGarbageCollection(migrationOpts.migrationIdString);
+})();
+
+tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_stepdown_after_forget.js b/jstests/replsets/tenant_migration_recipient_stepdown_after_forget.js
deleted file mode 100644
index 3e542cabaec..00000000000
--- a/jstests/replsets/tenant_migration_recipient_stepdown_after_forget.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Tests whether the new recipient primary properly processes a forgetMigration when the original
- * primary is made to step down after marking as garbage collectable. The oplog buffer collection
- * must be dropped.
- *
- * @tags: [
- * incompatible_with_macos,
- * incompatible_with_windows_tls,
- * requires_persistence,
- * requires_replication,
- * serverless,
- * ]
- */
-
-(function() {
-
-"use strict";
-load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
-load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
-load("jstests/libs/parallelTester.js"); // For Thread(), used for async forgetMigration.
-load("jstests/replsets/libs/tenant_migration_test.js");
-load("jstests/replsets/libs/tenant_migration_util.js");
-
-const tenantMigrationTest =
- new TenantMigrationTest({name: jsTestName(), sharedOptions: {nodes: 2}});
-
-const kMigrationId = UUID();
-const kTenantId = 'testTenantId';
-const kReadPreference = {
- mode: "primary"
-};
-const migrationOpts = {
- migrationIdString: extractUUIDFromObject(kMigrationId),
- tenantId: kTenantId,
- readPreference: kReadPreference
-};
-
-TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
- migrationOpts, {retryOnRetryableErrors: true, automaticForgetMigration: false}));
-
-const fpBeforeDroppingOplogBufferCollection =
- configureFailPoint(tenantMigrationTest.getRecipientPrimary(),
- "fpBeforeDroppingOplogBufferCollection",
- {action: "hang"});
-
-jsTestLog("Issuing a forget migration command.");
-const forgetMigrationThread =
- new Thread(TenantMigrationUtil.forgetMigrationAsync,
- migrationOpts.migrationIdString,
- TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst()),
- true /* retryOnRetryableErrors */);
-forgetMigrationThread.start();
-
-fpBeforeDroppingOplogBufferCollection.wait();
-
-jsTestLog("Step up a new recipient primary.");
-tenantMigrationTest.getRecipientRst().stepUp(
- tenantMigrationTest.getRecipientRst().getSecondaries()[0]);
-
-fpBeforeDroppingOplogBufferCollection.off();
-
-jsTestLog("Waiting for forget migration to complete.");
-assert.commandWorked(forgetMigrationThread.returnData());
-
-const configDBCollections =
- tenantMigrationTest.getRecipientPrimary().getDB('config').getCollectionNames();
-assert(!configDBCollections.includes('repl.migration.oplog_' + migrationOpts.migrationIdString),
- configDBCollections);
-
-tenantMigrationTest.stop();
-})();