summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWenbin Zhu <wenbin.zhu@mongodb.com>2021-05-12 19:25:22 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-13 17:54:32 +0000
commit713f6d9ad8cd9d1e01388d978f8fb3268ea79252 (patch)
treebaafb300fc8a9e0413f4a1866bf08897968ea359
parent8b528ab65eaaead1b5f8fb97d5f23092fee48f78 (diff)
downloadmongo-713f6d9ad8cd9d1e01388d978f8fb3268ea79252.tar.gz
SERVER-55202 Add assertion if migration committed or aborted in TenantMigrationTest fixture.
(cherry picked from commit 1cb18cbb349e71cbd869c48c1e288527b48d6d73)
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch.js5
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch_after_failover.js5
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js4
-rw-r--r--jstests/replsets/libs/tenant_migration_test.js23
-rw-r--r--jstests/replsets/tenant_migration_abort_forget_retry.js12
-rw-r--r--jstests/replsets/tenant_migration_aborted_buildindex.js2
-rw-r--r--jstests/replsets/tenant_migration_blocking_state_timeout.js4
-rw-r--r--jstests/replsets/tenant_migration_buildindex.js2
-rw-r--r--jstests/replsets/tenant_migration_cloner_stats.js2
-rw-r--r--jstests/replsets/tenant_migration_cloner_stats_with_failover.js2
-rw-r--r--jstests/replsets/tenant_migration_clones_system_views.js3
-rw-r--r--jstests/replsets/tenant_migration_cloning_uses_read_concern_majority.js2
-rw-r--r--jstests/replsets/tenant_migration_cluster_time_keys_cloning.js12
-rw-r--r--jstests/replsets/tenant_migration_collection_ttl.js10
-rw-r--r--jstests/replsets/tenant_migration_commit_transaction_retry.js2
-rw-r--r--jstests/replsets/tenant_migration_concurrent_bulk_writes.js19
-rw-r--r--jstests/replsets/tenant_migration_concurrent_migrations.js36
-rw-r--r--jstests/replsets/tenant_migration_concurrent_migrations_recipient.js5
-rw-r--r--jstests/replsets/tenant_migration_concurrent_reads_on_donor.js21
-rw-r--r--jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js12
-rw-r--r--jstests/replsets/tenant_migration_concurrent_state_doc_removal_and_stepdown.js2
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_donor.js15
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js9
-rw-r--r--jstests/replsets/tenant_migration_conflicting_donor_start_migration_cmds.js20
-rw-r--r--jstests/replsets/tenant_migration_donor_abort_state_transition.js2
-rw-r--r--jstests/replsets/tenant_migration_donor_current_op.js11
-rw-r--r--jstests/replsets/tenant_migration_donor_initial_sync_recovery.js2
-rw-r--r--jstests/replsets/tenant_migration_donor_interrupt_on_stepdown_and_shutdown.js2
-rw-r--r--jstests/replsets/tenant_migration_donor_kill_op_retry.js12
-rw-r--r--jstests/replsets/tenant_migration_donor_resume_on_stepup_and_restart.js8
-rw-r--r--jstests/replsets/tenant_migration_donor_retry.js10
-rw-r--r--jstests/replsets/tenant_migration_donor_rollback_recovery.js9
-rw-r--r--jstests/replsets/tenant_migration_donor_state_machine.js14
-rw-r--r--jstests/replsets/tenant_migration_donor_try_abort.js59
-rw-r--r--jstests/replsets/tenant_migration_drop_collection.js2
-rw-r--r--jstests/replsets/tenant_migration_drop_state_doc_collection.js2
-rw-r--r--jstests/replsets/tenant_migration_ensure_migration_outcome_visibility_for_blocked_writes.js6
-rw-r--r--jstests/replsets/tenant_migration_external_cluster_validation.js2
-rw-r--r--jstests/replsets/tenant_migration_external_keys_ttl.js30
-rw-r--r--jstests/replsets/tenant_migration_fetch_committed_transactions.js2
-rw-r--r--jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js9
-rw-r--r--jstests/replsets/tenant_migration_filters_tenant_id.js2
-rw-r--r--jstests/replsets/tenant_migration_find_and_modify_retry.js4
-rw-r--r--jstests/replsets/tenant_migration_ignore_create_index_on_nonempty_collection.js4
-rw-r--r--jstests/replsets/tenant_migration_large_txn.js2
-rw-r--r--jstests/replsets/tenant_migration_logs.js3
-rw-r--r--jstests/replsets/tenant_migration_metrics_output.js3
-rw-r--r--jstests/replsets/tenant_migration_multi_writes.js3
-rw-r--r--jstests/replsets/tenant_migration_multikey_index.js4
-rw-r--r--jstests/replsets/tenant_migration_no_failover.js3
-rw-r--r--jstests/replsets/tenant_migration_read_your_own_writes.js3
-rw-r--r--jstests/replsets/tenant_migration_recipient_current_op.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_does_not_change_sync_source_after_step_down.js4
-rw-r--r--jstests/replsets/tenant_migration_recipient_failover_before_creating_oplog_buffer.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_has_tenant_data.js8
-rw-r--r--jstests/replsets/tenant_migration_recipient_invalidates_in_memory_txns.js7
-rw-r--r--jstests/replsets/tenant_migration_recipient_resume_on_stepup_and_restart.js6
-rw-r--r--jstests/replsets/tenant_migration_recipient_resumes_on_donor_failover.js3
-rw-r--r--jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_rollback_recovery.js9
-rw-r--r--jstests/replsets/tenant_migration_recipient_stepdown_after_forget.js4
-rw-r--r--jstests/replsets/tenant_migration_recipient_sync_data_timeout.js3
-rw-r--r--jstests/replsets/tenant_migration_recipient_sync_donor_timestamp.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_sync_source_reconnect_delayed_secondary.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_sync_source_restart_donor_secondary.js2
-rw-r--r--jstests/replsets/tenant_migration_recipient_ttl.js5
-rw-r--r--jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js5
-rw-r--r--jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js2
-rw-r--r--jstests/replsets/tenant_migration_resume_oplog_application.js2
-rw-r--r--jstests/replsets/tenant_migration_retry_session_migration.js6
-rw-r--r--jstests/replsets/tenant_migration_retryable_write_retry.js2
-rw-r--r--jstests/replsets/tenant_migration_retryable_write_retry_on_recipient.js4
-rw-r--r--jstests/replsets/tenant_migration_stepup_recovery_after_abort.js16
-rw-r--r--jstests/replsets/tenant_migration_sync_source_too_stale.js4
-rw-r--r--jstests/replsets/tenant_migration_test_max_bson_limit.js3
-rw-r--r--jstests/replsets/tenant_migration_timeseries_collections.js3
-rw-r--r--jstests/replsets/tenant_migration_x509.js23
-rw-r--r--jstests/replsets/tenant_migrations_back_to_back.js5
-rw-r--r--jstests/replsets/tenant_migrations_transaction_with_create_collection.js4
80 files changed, 250 insertions, 334 deletions
diff --git a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch.js b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch.js
index cd4e88179ef..cad0c7bb913 100644
--- a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch.js
+++ b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch.js
@@ -54,9 +54,8 @@ function runTest(downgradeFCV) {
// Upgrade again to check on the status of the migration from the donor's point of view.
assert.commandWorked(donorPrimary.adminCommand({setFeatureCompatibilityVersion: latestFCV}));
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
+ TenantMigrationTest.assertAborted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
}
diff --git a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch_after_failover.js b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch_after_failover.js
index 47ead9f449f..6006118edc2 100644
--- a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch_after_failover.js
+++ b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch_after_failover.js
@@ -63,9 +63,8 @@ function runTest(downgradeFCV) {
// Upgrade again to check on the status of the migration from the donor's point of view.
assert.commandWorked(donorPrimary.adminCommand({setFeatureCompatibilityVersion: latestFCV}));
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
+ TenantMigrationTest.assertAborted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
}
diff --git a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js
index 04a0d732655..a79b9e99ee8 100644
--- a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js
+++ b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js
@@ -70,9 +70,7 @@ function runTest(downgradeFCV) {
recipientRst.getPrimary();
// The migration will not be able to continue in the downgraded version.
- const data = migrationThread.returnData();
- assert.commandWorked(data);
- assert.eq(data.state, TenantMigrationTest.DonorState.kAborted);
+ TenantMigrationTest.assertAborted(migrationThread.returnData());
checkLog.containsJson(newRecipientPrimary, 5356200); // Change-of-FCV detection message.
tenantMigrationTest.stop();
diff --git a/jstests/replsets/libs/tenant_migration_test.js b/jstests/replsets/libs/tenant_migration_test.js
index a77c866e828..51984dc8643 100644
--- a/jstests/replsets/libs/tenant_migration_test.js
+++ b/jstests/replsets/libs/tenant_migration_test.js
@@ -576,6 +576,29 @@ function TenantMigrationTest({
};
}
+/**
+ * Takes in the response to the donarStartMigration command and asserts the command
+ * works and the state is 'committed'.
+ */
+TenantMigrationTest.assertCommitted = function(stateRes) {
+ assert.commandWorked(stateRes);
+ assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted, tojson(stateRes));
+ return stateRes;
+};
+
+/**
+ * Takes in the response to the donarStartMigration command and asserts the command
+ * works and the state is 'aborted', with optional errorCode.
+ */
+TenantMigrationTest.assertAborted = function(stateRes, errorCode) {
+ assert.commandWorked(stateRes);
+ assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted, tojson(stateRes));
+ if (errorCode !== undefined) {
+ assert.eq(stateRes.abortReason.code, errorCode, tojson(stateRes));
+ }
+ return stateRes;
+};
+
TenantMigrationTest.DonorState = {
kCommitted: "committed",
kAborted: "aborted",
diff --git a/jstests/replsets/tenant_migration_abort_forget_retry.js b/jstests/replsets/tenant_migration_abort_forget_retry.js
index 96d0459f263..2aa2f21385f 100644
--- a/jstests/replsets/tenant_migration_abort_forget_retry.js
+++ b/jstests/replsets/tenant_migration_abort_forget_retry.js
@@ -43,11 +43,10 @@ if (!tenantMigrationTest.isFeatureFlagEnabled()) {
const donorPrimary = tenantMigrationTest.getDonorPrimary();
const abortFp =
configureFailPoint(donorPrimary, "abortTenantMigrationBeforeLeavingBlockingState");
- const abortRes = assert.commandWorked(
+ TenantMigrationTest.assertAborted(
tenantMigrationTest.runMigration({migrationIdString: migrationId1, tenantId: tenantId},
false /* retryOnRetryableErrors */,
false /* automaticForgetMigration */));
- assert.eq(abortRes.state, TenantMigrationTest.DonorState.kAborted);
abortFp.off();
// Forget the aborted migration.
@@ -58,9 +57,8 @@ if (!tenantMigrationTest.isFeatureFlagEnabled()) {
// migration with the same tenantId was aborted.
jsTestLog("Attempting to run a new migration with the same tenantId. New migrationId: " +
migrationId2 + ", tenantId: " + tenantId);
- const commitRes = assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tenantMigrationTest.runMigration({migrationIdString: migrationId2, tenantId: tenantId}));
- assert.eq(commitRes.state, TenantMigrationTest.DonorState.kCommitted);
})();
(() => {
@@ -98,9 +96,8 @@ if (!tenantMigrationTest.isFeatureFlagEnabled()) {
tryAbortThread.join();
assert.commandWorked(tryAbortThread.returnData());
- const stateRes = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(
{migrationIdString: migrationId1, tenantId: tenantId}));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
// Forget the aborted migration.
jsTestLog("Forgetting aborted migration with migrationId: " + migrationId1);
@@ -110,9 +107,8 @@ if (!tenantMigrationTest.isFeatureFlagEnabled()) {
// migration with the same tenantId was aborted.
jsTestLog("Attempting to run a new migration with the same tenantId. New migrationId: " +
migrationId2 + ", tenantId: " + tenantId);
- const commitRes = assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tenantMigrationTest.runMigration({migrationIdString: migrationId2, tenantId: tenantId}));
- assert.eq(commitRes.state, TenantMigrationTest.DonorState.kCommitted);
})();
tenantMigrationTest.stop();
diff --git a/jstests/replsets/tenant_migration_aborted_buildindex.js b/jstests/replsets/tenant_migration_aborted_buildindex.js
index 62cc3776092..39822f868aa 100644
--- a/jstests/replsets/tenant_migration_aborted_buildindex.js
+++ b/jstests/replsets/tenant_migration_aborted_buildindex.js
@@ -117,7 +117,7 @@ assert.soon(() => checkLog.checkContainsWithCountJson(donorPrimary, 4886202, und
const abortFp = configureFailPoint(donorPrimary, "abortTenantMigrationBeforeLeavingBlockingState");
blockingFp.off();
-assert.commandWorked(migrationThread.returnData());
+TenantMigrationTest.assertAborted(migrationThread.returnData());
abortFp.off();
// The index creation threads should be done.
diff --git a/jstests/replsets/tenant_migration_blocking_state_timeout.js b/jstests/replsets/tenant_migration_blocking_state_timeout.js
index df51dd47a73..628a3dca42f 100644
--- a/jstests/replsets/tenant_migration_blocking_state_timeout.js
+++ b/jstests/replsets/tenant_migration_blocking_state_timeout.js
@@ -63,9 +63,7 @@ function testTimeoutBlockingState() {
tenantMigrationTest.waitForDonorNodesToReachState(
donorRst.nodes, migrationId, tenantId, TenantMigrationTest.DonorState.kAborted);
- const stateRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.ExceededTimeLimit);
+ TenantMigrationTest.assertAborted(migrationThread.returnData(), ErrorCodes.ExceededTimeLimit);
// This fail point is pausing all calls to recipient, so it has to be disabled to make
// the 'forget migration' command to work.
diff --git a/jstests/replsets/tenant_migration_buildindex.js b/jstests/replsets/tenant_migration_buildindex.js
index 3190d878cd1..d627bdff49b 100644
--- a/jstests/replsets/tenant_migration_buildindex.js
+++ b/jstests/replsets/tenant_migration_buildindex.js
@@ -131,7 +131,7 @@ assert.soon(() => {
return state === TenantMigrationTest.DonorAccessState.kBlockWritesAndReads ||
state === TenantMigrationTest.DonorAccessState.kReject;
});
-assert.commandWorked(migrationThread.returnData());
+TenantMigrationTest.assertCommitted(migrationThread.returnData());
// The index creation threads should be done.
racyIndexThread.join();
diff --git a/jstests/replsets/tenant_migration_cloner_stats.js b/jstests/replsets/tenant_migration_cloner_stats.js
index 54a6dbf28a8..f6408b27d8f 100644
--- a/jstests/replsets/tenant_migration_cloner_stats.js
+++ b/jstests/replsets/tenant_migration_cloner_stats.js
@@ -180,7 +180,7 @@ fpBeforeCopyingSecondDB.off();
// After the migration completes, the total bytes copied should be equal to the total data size.
jsTestLog("Waiting for migration to complete.");
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
res = recipientPrimary.adminCommand({currentOp: true, desc: "tenant recipient migration"});
currOp = res.inprog[0];
assert.eq(currOp.approxTotalDataSize, db1Size + db2Size, res);
diff --git a/jstests/replsets/tenant_migration_cloner_stats_with_failover.js b/jstests/replsets/tenant_migration_cloner_stats_with_failover.js
index 393a0d8e887..467af8a798e 100644
--- a/jstests/replsets/tenant_migration_cloner_stats_with_failover.js
+++ b/jstests/replsets/tenant_migration_cloner_stats_with_failover.js
@@ -137,7 +137,7 @@ fpAfterCreatingCollectionOfSecondDB.off();
// After the migration completes, the total bytes copied should be equal to the total data size.
jsTestLog("Waiting for migration to complete.");
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
res = newRecipientPrimary.adminCommand({currentOp: true, desc: "tenant recipient migration"});
currOp = res.inprog[0];
assert.eq(currOp.approxTotalDataSize, db1Size + db2Size, res);
diff --git a/jstests/replsets/tenant_migration_clones_system_views.js b/jstests/replsets/tenant_migration_clones_system_views.js
index dd6d5e9e5d5..f969d6d4d2b 100644
--- a/jstests/replsets/tenant_migration_clones_system_views.js
+++ b/jstests/replsets/tenant_migration_clones_system_views.js
@@ -49,8 +49,7 @@ const migrationOpts = {
tenantId,
};
-const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
-assert.eq(TenantMigrationTest.DonorState.kCommitted, stateRes.state);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
// Verify that the view was cloned correctly.
const recipientView = recipientPrimary.getDB(tenantDBName)[viewName];
diff --git a/jstests/replsets/tenant_migration_cloning_uses_read_concern_majority.js b/jstests/replsets/tenant_migration_cloning_uses_read_concern_majority.js
index bbdece41e3a..3f0a03bf189 100644
--- a/jstests/replsets/tenant_migration_cloning_uses_read_concern_majority.js
+++ b/jstests/replsets/tenant_migration_cloning_uses_read_concern_majority.js
@@ -87,6 +87,6 @@ notRejectReadsFp.off();
// Restart secondary replication in the donor replica set and complete the migration.
restartReplicationOnSecondaries(donorRst);
waitAfterCloning.off();
-assert.commandWorked(migrationThread.returnData());
+TenantMigrationTest.assertCommitted(migrationThread.returnData());
tenantMigrationTest.stop();
})(); \ No newline at end of file
diff --git a/jstests/replsets/tenant_migration_cluster_time_keys_cloning.js b/jstests/replsets/tenant_migration_cluster_time_keys_cloning.js
index 14b04a39658..3a3d73e3cb5 100644
--- a/jstests/replsets/tenant_migration_cluster_time_keys_cloning.js
+++ b/jstests/replsets/tenant_migration_cluster_time_keys_cloning.js
@@ -50,7 +50,7 @@ function runMigrationAndAssertExternalKeysCopied(tenantMigrationTest, tenantId)
migrationIdString: extractUUIDFromObject(migrationId),
tenantId: tenantId,
};
- assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
assertCopiedExternalKeys(tenantMigrationTest, migrationId);
}
@@ -78,7 +78,7 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
migrationIdString: extractUUIDFromObject(migrationId),
tenantId: kTenantId1,
};
- assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
assertCopiedExternalKeys(tenantMigrationTest, migrationId);
// After another migration, the first's keys should still exist.
@@ -117,7 +117,7 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
tenantId: kTenantId1,
readPreference: {mode: "secondary"}
};
- assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
assertCopiedExternalKeys(tenantMigrationTest, migrationId);
// After another migration, the first's keys should still exist.
@@ -161,9 +161,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
assert.commandWorked(donorPrimary.adminCommand({replSetFreeze: 0}));
fp.off();
- const stateRes = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(
migrationOpts, true /* retryOnRetryableErrors */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
assertCopiedExternalKeys(tenantMigrationTest, migrationId);
@@ -209,9 +208,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
assert.commandWorked(recipientPrimary.adminCommand({replSetFreeze: 0}));
fp.off();
- const stateRes = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(
migrationOpts, true /* retryOnRetryableErrors */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
assertCopiedExternalKeys(tenantMigrationTest, migrationId);
diff --git a/jstests/replsets/tenant_migration_collection_ttl.js b/jstests/replsets/tenant_migration_collection_ttl.js
index cfffa252eef..caf086ed1f1 100644
--- a/jstests/replsets/tenant_migration_collection_ttl.js
+++ b/jstests/replsets/tenant_migration_collection_ttl.js
@@ -133,9 +133,8 @@ function assertTTLDeleteExpiredDocs(dbName, node) {
hangDuringCollectionClone.off();
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.State.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
// Data should be consistent after the migration commits.
assertTTLDeleteExpiredDocs(dbName, recipientPrimary);
@@ -192,9 +191,8 @@ function assertTTLDeleteExpiredDocs(dbName, node) {
blockFp.off();
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.State.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
// Tests that the TTL cleanup was suspended during the tenant migration.
waitForOneTTLPassAtNode(donorPrimary);
diff --git a/jstests/replsets/tenant_migration_commit_transaction_retry.js b/jstests/replsets/tenant_migration_commit_transaction_retry.js
index 91ace828403..d219327ee2c 100644
--- a/jstests/replsets/tenant_migration_commit_transaction_retry.js
+++ b/jstests/replsets/tenant_migration_commit_transaction_retry.js
@@ -113,7 +113,7 @@ for (let i = 0; i < 10; i++) {
waitAfterStartingOplogApplier.off();
waitInOplogApplier.off();
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString);
tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, kTenantId);
diff --git a/jstests/replsets/tenant_migration_concurrent_bulk_writes.js b/jstests/replsets/tenant_migration_concurrent_bulk_writes.js
index dc39487da6a..8c809c8c7c0 100644
--- a/jstests/replsets/tenant_migration_concurrent_bulk_writes.js
+++ b/jstests/replsets/tenant_migration_concurrent_bulk_writes.js
@@ -128,8 +128,7 @@ function bulkWriteDocsUnordered(primaryHost, dbName, collName, numDocs) {
bulkWriteThread.start();
writeFp.wait();
- const migrationRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
writeFp.off();
bulkWriteThread.join();
@@ -210,8 +209,7 @@ function bulkWriteDocsUnordered(primaryHost, dbName, collName, numDocs) {
bulkWriteThread.join();
migrationThread.join();
- const migrationRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(migrationThread.returnData());
let bulkWriteRes = bulkWriteThread.returnData();
let writeErrors = bulkWriteRes.res.writeErrors;
@@ -296,8 +294,7 @@ function bulkWriteDocsUnordered(primaryHost, dbName, collName, numDocs) {
abortFp.off();
- const migrationRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kAborted);
+ TenantMigrationTest.assertAborted(migrationThread.returnData());
const bulkWriteRes = bulkWriteThread.returnData();
const writeErrors = bulkWriteRes.res.writeErrors;
@@ -358,8 +355,7 @@ function bulkWriteDocsUnordered(primaryHost, dbName, collName, numDocs) {
bulkWriteThread.start();
writeFp.wait();
- const migrationRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
writeFp.off();
bulkWriteThread.join();
@@ -436,9 +432,7 @@ function bulkWriteDocsUnordered(primaryHost, dbName, collName, numDocs) {
bulkWriteThread.join();
migrationThread.join();
- const migrationRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kCommitted);
-
+ TenantMigrationTest.assertCommitted(migrationThread.returnData());
const bulkWriteRes = bulkWriteThread.returnData();
const writeErrors = bulkWriteRes.res.writeErrors;
@@ -517,8 +511,7 @@ function bulkWriteDocsUnordered(primaryHost, dbName, collName, numDocs) {
abortFp.off();
- const migrationRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kAborted);
+ TenantMigrationTest.assertAborted(migrationThread.returnData());
const bulkWriteRes = bulkWriteThread.returnData();
const writeErrors = bulkWriteRes.res.writeErrors;
diff --git a/jstests/replsets/tenant_migration_concurrent_migrations.js b/jstests/replsets/tenant_migration_concurrent_migrations.js
index 37c0baa0574..a4849dea452 100644
--- a/jstests/replsets/tenant_migration_concurrent_migrations.js
+++ b/jstests/replsets/tenant_migration_concurrent_migrations.js
@@ -63,14 +63,11 @@ const kTenantIdPrefix = "testTenantId";
assert.commandWorked(tenantMigrationTest0.startMigration(migrationOpts0));
assert.commandWorked(tenantMigrationTest1.startMigration(migrationOpts1));
- const stateRes0 =
- assert.commandWorked(tenantMigrationTest0.waitForMigrationToComplete(migrationOpts0));
- const stateRes1 =
- assert.commandWorked(tenantMigrationTest1.waitForMigrationToComplete(migrationOpts1));
-
- // Verify that both migrations succeeded.
- assert.eq(stateRes0.state, TenantMigrationTest.DonorState.kCommitted);
- assert.eq(stateRes1.state, TenantMigrationTest.DonorState.kCommitted);
+ // Wait for both migration to finish and verify they succeeded.
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest0.waitForMigrationToComplete(migrationOpts0));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest1.waitForMigrationToComplete(migrationOpts1));
const connPoolStatsAfter0 = assert.commandWorked(donorPrimary.adminCommand({connPoolStats: 1}));
// Donor targeted two different replica sets.
@@ -115,14 +112,11 @@ const kTenantIdPrefix = "testTenantId";
assert.commandWorked(tenantMigrationTest0.startMigration(migrationOpts0));
assert.commandWorked(tenantMigrationTest1.startMigration(migrationOpts1));
- const stateRes0 =
- assert.commandWorked(tenantMigrationTest0.waitForMigrationToComplete(migrationOpts0));
- const stateRes1 =
- assert.commandWorked(tenantMigrationTest1.waitForMigrationToComplete(migrationOpts1));
-
- // Verify that both migrations succeeded.
- assert.eq(stateRes0.state, TenantMigrationTest.DonorState.kCommitted);
- assert.eq(stateRes1.state, TenantMigrationTest.DonorState.kCommitted);
+ // Wait for both migration to finish and verify they succeeded.
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest0.waitForMigrationToComplete(migrationOpts0));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest1.waitForMigrationToComplete(migrationOpts1));
// Cleanup.
assert.commandWorked(tenantMigrationTest0.forgetMigration(migrationOpts0.migrationIdString));
@@ -174,9 +168,8 @@ const kTenantIdPrefix = "testTenantId";
// Wait migration1 to pause in the blocking state and for migration0 to commit.
blockFp.wait();
- const stateRes0 =
- assert.commandWorked(tenantMigrationTest0.waitForMigrationToComplete(migrationOpts0));
- assert(stateRes0.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest0.waitForMigrationToComplete(migrationOpts0));
// Verify that exactly one RSM was created.
const connPoolStatsDuringMigration =
@@ -194,9 +187,8 @@ const kTenantIdPrefix = "testTenantId";
// Let the migration1 to finish.
blockFp.off();
- const stateRes1 =
- assert.commandWorked(tenantMigrationTest1.waitForMigrationToComplete(migrationOpts1));
- assert(stateRes1.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest1.waitForMigrationToComplete(migrationOpts1));
// Verify that now the RSM is garbage collected after the migration1 is cleaned.
assert.commandWorked(tenantMigrationTest1.forgetMigration(migrationOpts1.migrationIdString));
diff --git a/jstests/replsets/tenant_migration_concurrent_migrations_recipient.js b/jstests/replsets/tenant_migration_concurrent_migrations_recipient.js
index 93cd9ef89ce..d7b1ec85477 100644
--- a/jstests/replsets/tenant_migration_concurrent_migrations_recipient.js
+++ b/jstests/replsets/tenant_migration_concurrent_migrations_recipient.js
@@ -59,9 +59,8 @@ hangDuringCollectionClone.off();
migrationOptsArray.forEach((migrationOpts) => {
jsTestLog("Waiting for migration for tenant: " + migrationOpts.tenantId + " to complete");
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
});
tenantMigrationTest.stop();
diff --git a/jstests/replsets/tenant_migration_concurrent_reads_on_donor.js b/jstests/replsets/tenant_migration_concurrent_reads_on_donor.js
index 8968ffc17e6..70e97620ad5 100644
--- a/jstests/replsets/tenant_migration_concurrent_reads_on_donor.js
+++ b/jstests/replsets/tenant_migration_concurrent_reads_on_donor.js
@@ -110,9 +110,8 @@ function testRejectReadsAfterMigrationCommitted(testCase, dbName, collName) {
const donorRst = tenantMigrationTest.getDonorRst();
const donorPrimary = donorRst.getPrimary();
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
// Wait for the last oplog entry on the primary to be visible in the committed snapshot view of
// the oplog on all the secondaries. This is to ensure that snapshot reads on secondaries with
@@ -164,9 +163,8 @@ function testDoNotRejectReadsAfterMigrationAborted(testCase, dbName, collName) {
let abortFp =
configureFailPoint(donorPrimary, "abortTenantMigrationBeforeLeavingBlockingState");
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
abortFp.off();
// Wait for the last oplog entry on the primary to be visible in the committed snapshot view of
@@ -244,9 +242,8 @@ function testBlockReadsAfterMigrationEnteredBlocking(testCase, dbName, collName)
});
blockingFp.off();
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
}
@@ -308,9 +305,8 @@ function testRejectBlockedReadsAfterMigrationCommitted(testCase, dbName, collNam
// Verify that the migration succeeded.
resumeMigrationThread.join();
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
}
@@ -376,9 +372,8 @@ function testUnblockBlockedReadsAfterMigrationAborted(testCase, dbName, collName
// Verify that the migration failed due to the simulated error.
resumeMigrationThread.join();
abortFp.off();
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
+ TenantMigrationTest.assertAborted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
}
diff --git a/jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js b/jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js
index 8bd4fb12619..5ac946ae1de 100644
--- a/jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js
+++ b/jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js
@@ -92,8 +92,7 @@ function testRejectAllReadsAfterCloningDone(testCase, dbName, collName) {
});
clonerDoneFp.off();
- const stateRes = assert.commandWorked(runMigrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(runMigrationThread.returnData());
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
}
@@ -152,8 +151,7 @@ function testRejectOnlyReadsWithAtClusterTimeLessThanBlockTimestamp(testCase, db
});
waitForRejectReadsBeforeTsFp.off();
- const stateRes = assert.commandWorked(runMigrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(runMigrationThread.returnData());
nodes.forEach(node => {
const db = node.getDB(dbName);
@@ -194,9 +192,8 @@ function testDoNotRejectReadsAfterMigrationAbortedBeforeReachingBlockTimestamp(
let abortFp = configureFailPoint(recipientPrimary,
"fpBeforeFulfillingDataConsistentPromise",
{action: "stop", stopErrorCode: ErrorCodes.InternalError});
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
abortFp.off();
const nodes = testCase.isSupportedOnSecondaries ? recipientRst.nodes : [recipientPrimary];
@@ -265,9 +262,8 @@ function testDoNotRejectReadsAfterMigrationAbortedAfterReachingBlockTimestamp(
// recipientSyncData (i.e. after it has reached the returnAfterReachingTimestamp).
let abortFp =
configureFailPoint(donorPrimary, "abortTenantMigrationBeforeLeavingBlockingState");
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
abortFp.off();
// Wait for the last oplog entry on the primary to be visible in the committed snapshot view of
diff --git a/jstests/replsets/tenant_migration_concurrent_state_doc_removal_and_stepdown.js b/jstests/replsets/tenant_migration_concurrent_state_doc_removal_and_stepdown.js
index 7f431576382..859c4c9bef4 100644
--- a/jstests/replsets/tenant_migration_concurrent_state_doc_removal_and_stepdown.js
+++ b/jstests/replsets/tenant_migration_concurrent_state_doc_removal_and_stepdown.js
@@ -42,7 +42,7 @@ const migrationOpts = {
tenantId: kTenantId,
};
-assert.commandWorked(tenantMigrationTest.runMigration(
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
let fp = configureFailPoint(donorPrimary,
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_donor.js b/jstests/replsets/tenant_migration_concurrent_writes_on_donor.js
index 513e9ebde23..419783b0b8d 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_donor.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_donor.js
@@ -280,9 +280,8 @@ function testRejectWritesAfterMigrationCommitted(testCase, testOpts) {
tenantId,
};
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
runCommand(testOpts, ErrorCodes.TenantMigrationCommitted);
testCase.assertCommandFailed(testOpts.primaryDB, testOpts.dbName, testOpts.collName);
@@ -304,9 +303,8 @@ function testDoNotRejectWritesAfterMigrationAborted(testCase, testOpts) {
let abortFp =
configureFailPoint(testOpts.primaryDB, "abortTenantMigrationBeforeLeavingBlockingState");
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
abortFp.off();
// Wait until the in-memory migration state is updated after the migration has majority
@@ -348,9 +346,8 @@ function testBlockWritesAfterMigrationEnteredBlocking(testCase, testOpts) {
// Allow the migration to complete.
blockingFp.off();
- const stateRes = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(
migrationOpts, false /* retryOnRetryableErrors */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
testCase.assertCommandFailed(testOpts.primaryDB, testOpts.dbName, testOpts.collName);
checkTenantMigrationAccessBlocker(testOpts.primaryDB, tenantId, {numBlockedWrites: 1});
@@ -386,9 +383,8 @@ function testRejectBlockedWritesAfterMigrationCommitted(testCase, testOpts) {
// Verify that the migration succeeded.
resumeMigrationThread.join();
- const stateRes = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(
migrationOpts, false /* retryOnRetryableErrors */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
testCase.assertCommandFailed(testOpts.primaryDB, testOpts.dbName, testOpts.collName);
checkTenantMigrationAccessBlocker(
@@ -427,10 +423,9 @@ function testRejectBlockedWritesAfterMigrationAborted(testCase, testOpts) {
// Verify that the migration aborted due to the simulated error.
resumeMigrationThread.join();
- const stateRes = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(
migrationOpts, false /* retryOnRetryableErrors */));
abortFp.off();
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
testCase.assertCommandFailed(testOpts.primaryDB, testOpts.dbName, testOpts.collName);
checkTenantMigrationAccessBlocker(
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js b/jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js
index 868314d8ea1..36d52454626 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js
@@ -73,8 +73,7 @@ const kTenantId = "testTenantId";
assert.commandWorked(tenantCollOnRecipient.remove({_id: 1}));
waitForRejectReadsBeforeTsFp.off();
- const stateRes = assert.commandWorked(runMigrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(runMigrationThread.returnData());
// Write after the migration committed.
assert.commandWorked(tenantCollOnRecipient.remove({_id: 1}));
@@ -105,9 +104,8 @@ const kTenantId = "testTenantId";
let abortFp = configureFailPoint(recipientPrimary,
"fpBeforeFulfillingDataConsistentPromise",
{action: "stop", stopErrorCode: ErrorCodes.InternalError});
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
abortFp.off();
// Write after the migration aborted.
@@ -137,9 +135,8 @@ const kTenantId = "testTenantId";
// recipientSyncData (i.e. after it has reached the returnAfterReachingTimestamp).
let abortFp =
configureFailPoint(donorPrimary, "abortTenantMigrationBeforeLeavingBlockingState");
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
abortFp.off();
// Write after the migration aborted.
diff --git a/jstests/replsets/tenant_migration_conflicting_donor_start_migration_cmds.js b/jstests/replsets/tenant_migration_conflicting_donor_start_migration_cmds.js
index 704049fad4a..bc76c446e8c 100644
--- a/jstests/replsets/tenant_migration_conflicting_donor_start_migration_cmds.js
+++ b/jstests/replsets/tenant_migration_conflicting_donor_start_migration_cmds.js
@@ -76,8 +76,8 @@ let numRecipientSyncDataCmdSent = 0;
tenantId,
};
- assert.commandWorked(tenantMigrationTest0.runMigration(migrationOpts));
- assert.commandWorked(tenantMigrationTest0.runMigration(migrationOpts));
+ TenantMigrationTest.assertCommitted(tenantMigrationTest0.runMigration(migrationOpts));
+ TenantMigrationTest.assertCommitted(tenantMigrationTest0.runMigration(migrationOpts));
// If the second donorStartMigration had started a duplicate migration, the recipient would have
// received four recipientSyncData commands instead of two.
@@ -96,8 +96,10 @@ let numRecipientSyncDataCmdSent = 0;
assert.commandWorked(tenantMigrationTest0.startMigration(migrationOpts));
assert.commandWorked(tenantMigrationTest0.startMigration(migrationOpts));
- assert.commandWorked(tenantMigrationTest0.waitForMigrationToComplete(migrationOpts));
- assert.commandWorked(tenantMigrationTest0.waitForMigrationToComplete(migrationOpts));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest0.waitForMigrationToComplete(migrationOpts));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest0.waitForMigrationToComplete(migrationOpts));
// If the second donorStartMigration had started a duplicate migration, the recipient would have
// received four recipientSyncData commands instead of two.
@@ -114,8 +116,8 @@ let numRecipientSyncDataCmdSent = 0;
*/
function testStartingConflictingMigrationAfterInitialMigrationCommitted(
tenantMigrationTest0, migrationOpts0, tenantMigrationTest1, migrationOpts1) {
- tenantMigrationTest0.runMigration(
- migrationOpts0, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */);
+ TenantMigrationTest.assertCommitted(tenantMigrationTest0.runMigration(
+ migrationOpts0, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
const res1 = assert.commandFailedWithCode(tenantMigrationTest1.runMigration(migrationOpts1),
ErrorCodes.ConflictingOperationInProgress);
assertNoCertificateOrPrivateKey(res1.errmsg);
@@ -174,7 +176,8 @@ function testConcurrentConflictingMigrations(
tenantId: migrationOpts1.tenantId
}).length);
}
- assert.commandWorked(tenantMigrationTest0.waitForMigrationToComplete(migrationOpts0));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest0.waitForMigrationToComplete(migrationOpts0));
assert.commandWorked(
tenantMigrationTest0.forgetMigration(migrationOpts0.migrationIdString));
} else {
@@ -195,7 +198,8 @@ function testConcurrentConflictingMigrations(
tenantId: migrationOpts0.tenantId
}).length);
}
- assert.commandWorked(tenantMigrationTest1.waitForMigrationToComplete(migrationOpts1));
+ TenantMigrationTest.assertAborted(
+ tenantMigrationTest1.waitForMigrationToComplete(migrationOpts1));
assert.commandWorked(
tenantMigrationTest1.forgetMigration(migrationOpts1.migrationIdString));
}
diff --git a/jstests/replsets/tenant_migration_donor_abort_state_transition.js b/jstests/replsets/tenant_migration_donor_abort_state_transition.js
index 1dd476a5196..363b224e97f 100644
--- a/jstests/replsets/tenant_migration_donor_abort_state_transition.js
+++ b/jstests/replsets/tenant_migration_donor_abort_state_transition.js
@@ -57,7 +57,7 @@ function testAbortInitialState(donorRst) {
opObserverFp.off();
// Verify that the migration completes successfully.
- assert.commandWorked(migrationThread.returnData());
+ TenantMigrationTest.assertCommitted(migrationThread.returnData());
tenantMigrationTest.waitForDonorNodesToReachState(
donorRst.nodes, migrationId, tenantId, TenantMigrationTest.DonorState.kCommitted);
diff --git a/jstests/replsets/tenant_migration_donor_current_op.js b/jstests/replsets/tenant_migration_donor_current_op.js
index 1dadd951b48..8de38eba46e 100644
--- a/jstests/replsets/tenant_migration_donor_current_op.js
+++ b/jstests/replsets/tenant_migration_donor_current_op.js
@@ -64,7 +64,8 @@ const kReadPreference = {
assert(res.inprog[0].migrationStart instanceof Date);
fp.off();
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
})();
@@ -103,7 +104,8 @@ const kReadPreference = {
assert(res.inprog[0].migrationStart instanceof Date);
fp.off();
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
})();
@@ -142,7 +144,8 @@ const kReadPreference = {
assert(res.inprog[0].migrationStart instanceof Date);
fp.off();
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
})();
@@ -162,7 +165,7 @@ const kReadPreference = {
readPreference: kReadPreference
};
configureFailPoint(donorPrimary, "abortTenantMigrationBeforeLeavingBlockingState");
- assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
const res = assert.commandWorked(
diff --git a/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js b/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js
index 10290fbc5af..a3b29f62246 100644
--- a/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js
+++ b/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js
@@ -143,7 +143,7 @@ if (fp) {
restartServerReplication(initialSyncNode);
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
})();
diff --git a/jstests/replsets/tenant_migration_donor_interrupt_on_stepdown_and_shutdown.js b/jstests/replsets/tenant_migration_donor_interrupt_on_stepdown_and_shutdown.js
index 42d733d3b5c..638f65301af 100644
--- a/jstests/replsets/tenant_migration_donor_interrupt_on_stepdown_and_shutdown.js
+++ b/jstests/replsets/tenant_migration_donor_interrupt_on_stepdown_and_shutdown.js
@@ -86,7 +86,7 @@ function testDonorForgetMigrationInterrupt(interruptFunc, verifyCmdResponseFunc)
const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
- assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
const forgetMigrationThread = new Thread(
TenantMigrationUtil.forgetMigrationAsync, migrationOpts.migrationIdString, donorRstArgs);
diff --git a/jstests/replsets/tenant_migration_donor_kill_op_retry.js b/jstests/replsets/tenant_migration_donor_kill_op_retry.js
index 06b8a853ec7..111f753b616 100644
--- a/jstests/replsets/tenant_migration_donor_kill_op_retry.js
+++ b/jstests/replsets/tenant_migration_donor_kill_op_retry.js
@@ -78,8 +78,7 @@ if (!tenantMigrationTest.isFeatureFlagEnabled()) {
fp.off();
runMigrationThread.join();
- const stateRes = assert.commandWorked(runMigrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(runMigrationThread.returnData());
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
}
}
@@ -138,8 +137,7 @@ if (!tenantMigrationTest.isFeatureFlagEnabled()) {
fp.off();
runMigrationThread.join();
- const stateRes = assert.commandWorked(runMigrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(runMigrationThread.returnData());
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
}
@@ -188,8 +186,7 @@ if (!tenantMigrationTest.isFeatureFlagEnabled()) {
runMigrationThread.join();
- const stateRes = assert.commandWorked(runMigrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(runMigrationThread.returnData());
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
}
}
@@ -229,11 +226,10 @@ if (!tenantMigrationTest.isFeatureFlagEnabled()) {
let fp = configureFailPoint(tenantMigrationTest.getDonorPrimary(), fpName);
- const stateRes = assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tenantMigrationTest.runMigration(migrationOpts,
false /* retry on retriable errors */,
false /* Automatically forget migration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
const donorPrimary = tenantMigrationTest.getDonorPrimary();
const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
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 4be931f314d..0142a1f89ce 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
@@ -73,8 +73,7 @@ function testDonorStartMigrationInterrupt(interruptFunc, donorRestarted) {
sleep(Math.random() * kMaxSleepTimeMS);
interruptFunc(donorRst);
- const stateRes = assert.commandWorked(runMigrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(runMigrationThread.returnData());
tenantMigrationTest.waitForDonorNodesToReachState(donorRst.nodes,
migrationId,
migrationOpts.tenantId,
@@ -153,9 +152,8 @@ function testDonorForgetMigrationInterrupt(interruptFunc) {
};
const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
migrationOpts.migrationIdString,
donorRstArgs,
@@ -316,7 +314,7 @@ function testStateDocPersistenceOnFailover(interruptFunc, fpName, isShutdown = f
assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
fp.wait();
} else {
- assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
}
let configDonorsColl = donorPrimary.getCollection(TenantMigrationTest.kConfigDonorsNS);
diff --git a/jstests/replsets/tenant_migration_donor_retry.js b/jstests/replsets/tenant_migration_donor_retry.js
index 1f6b5288276..9db52a3c621 100644
--- a/jstests/replsets/tenant_migration_donor_retry.js
+++ b/jstests/replsets/tenant_migration_donor_retry.js
@@ -84,9 +84,8 @@ function testDonorRetryRecipientSyncDataCmdOnError(errorCode, failMode) {
}
fp.off();
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
return migrationId;
@@ -115,8 +114,7 @@ function testDonorRetryRecipientForgetMigrationCmdOnError(errorCode) {
},
{times: 1});
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
// Verify that the initial recipientForgetMigration command failed.
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
@@ -222,7 +220,7 @@ const kWriteErrorTimeMS = 50;
fp.off();
migrationThread.join();
- assert.commandWorked(migrationThread.returnData());
+ TenantMigrationTest.assertCommitted(migrationThread.returnData());
const configDonorsColl = donorPrimary.getCollection(TenantMigrationTest.kConfigDonorsNS);
const donorStateDoc = configDonorsColl.findOne({_id: migrationId});
diff --git a/jstests/replsets/tenant_migration_donor_rollback_recovery.js b/jstests/replsets/tenant_migration_donor_rollback_recovery.js
index 39864e4e05a..a34c53a92f1 100644
--- a/jstests/replsets/tenant_migration_donor_rollback_recovery.js
+++ b/jstests/replsets/tenant_migration_donor_rollback_recovery.js
@@ -135,8 +135,7 @@ function testRollbackInitialState() {
let steadyStateFunc = (tenantMigrationTest) => {
// Verify that the migration restarted successfully on the new primary despite rollback.
- const stateRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(assert.commandWorked(migrationThread.returnData()));
tenantMigrationTest.waitForDonorNodesToReachState(
tenantMigrationTest.getDonorRst().nodes,
migrationId,
@@ -190,8 +189,7 @@ function testRollBackStateTransition(pauseFailPoint, setUpFailPoints, nextState)
let steadyStateFunc = (tenantMigrationTest) => {
// Verify that the migration resumed successfully on the new primary despite the rollback.
- const stateRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(migrationThread.returnData());
tenantMigrationTest.waitForDonorNodesToReachState(
tenantMigrationTest.getDonorRst().nodes,
migrationId,
@@ -215,11 +213,10 @@ function testRollBackMarkingStateGarbageCollectable() {
let forgetMigrationThread;
let setUpFunc = (tenantMigrationTest, donorRstArgs) => {
- const stateRes = assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tenantMigrationTest.runMigration(migrationOpts,
true /* retryOnRetryableErrors */,
false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
};
let rollbackOpsFunc = (tenantMigrationTest, donorRstArgs) => {
diff --git a/jstests/replsets/tenant_migration_donor_state_machine.js b/jstests/replsets/tenant_migration_donor_state_machine.js
index 062c404928a..47cd092703b 100644
--- a/jstests/replsets/tenant_migration_donor_state_machine.js
+++ b/jstests/replsets/tenant_migration_donor_state_machine.js
@@ -177,9 +177,8 @@ function testStats(node, {
// Allow the migration to complete.
blockingFp.off();
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
donorDoc = configDonorsColl.findOne({tenantId: kTenantId});
let commitOplogEntry = donorPrimary.getDB("local").oplog.rs.findOne(
@@ -219,9 +218,8 @@ function testStats(node, {
configureFailPoint(recipientPrimary,
"fpBeforeFulfillingDataConsistentPromise",
{action: "stop", stopErrorCode: ErrorCodes.InternalError});
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
abortRecipientFp.off();
const donorDoc = configDonorsColl.findOne({tenantId: kTenantId});
@@ -262,9 +260,8 @@ function testStats(node, {
let abortDonorFp =
configureFailPoint(donorPrimary, "abortTenantMigrationBeforeLeavingBlockingState");
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
abortDonorFp.off();
const donorDoc = configDonorsColl.findOne({tenantId: kTenantId});
@@ -312,9 +309,8 @@ configDonorsColl.dropIndex({expireAt: 1});
donorPrimary.adminCommand({donorForgetMigration: 1, migrationId: migrationId}),
ErrorCodes.NoSuchTenantMigration);
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
assert.commandWorked(
donorPrimary.adminCommand({donorForgetMigration: 1, migrationId: migrationId}));
diff --git a/jstests/replsets/tenant_migration_donor_try_abort.js b/jstests/replsets/tenant_migration_donor_try_abort.js
index f003429e935..9600debd8f3 100644
--- a/jstests/replsets/tenant_migration_donor_try_abort.js
+++ b/jstests/replsets/tenant_migration_donor_try_abort.js
@@ -67,9 +67,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
tryAbortThread.join();
let r = assert.commandWorked(tryAbortThread.returnData());
- const stateRes = assert.commandWorked(tmt.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted, tojson(stateRes));
+ TenantMigrationTest.assertAborted(tmt.waitForMigrationToComplete(migrationOpts),
+ ErrorCodes.TenantMigrationAborted);
tmt.stop();
})();
@@ -107,10 +106,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
assert.commandWorked(tenantMigrationTest.tryAbortMigration(
{migrationIdString: migrationOpts.migrationIdString}));
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted, tojson(stateRes));
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts),
+ ErrorCodes.TenantMigrationAborted);
fp.off();
tenantMigrationTest.stop();
@@ -149,10 +146,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
assert.commandWorked(tenantMigrationTest.tryAbortMigration(
{migrationIdString: migrationOpts.migrationIdString}));
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted, tojson(stateRes));
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts),
+ ErrorCodes.TenantMigrationAborted);
fp.off();
tenantMigrationTest.stop();
@@ -211,10 +206,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
assert.commandWorked(tenantMigrationTest.tryAbortMigration(
{migrationIdString: migrationOpts.migrationIdString}));
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted, tojson(stateRes));
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts),
+ ErrorCodes.TenantMigrationAborted);
tenantMigrationTest.stop();
})();
@@ -251,10 +244,9 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
});
assert.commandWorked(tenantMigrationTest.tryAbortMigration(
{migrationIdString: migrationOpts.migrationIdString}));
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted, tojson(stateRes));
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts),
+ ErrorCodes.TenantMigrationAborted);
+
tenantMigrationTest.stop();
})();
@@ -305,9 +297,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
tryAbortThread.join();
assert.commandWorked(tryAbortThread.returnData());
- const stateRes = assert.commandWorked(tmt.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted, tojson(stateRes));
+ TenantMigrationTest.assertAborted(tmt.waitForMigrationToComplete(migrationOpts),
+ ErrorCodes.TenantMigrationAborted);
tmt.stop();
})();
@@ -365,9 +356,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
// concern still not being satisfied.
assert.commandWorked(tenantMigrationTest.tryAbortMigration(migrationOpts));
- res = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(
migrationOpts, false /* retryOnRetryableErrors */));
- assert.eq(res.state, "aborted", tojson(res));
restartServerReplication(delayedSecondary);
@@ -416,10 +406,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
tryAbortThread.join();
assert.commandWorked(tryAbortThread.returnData());
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted, tojson(stateRes));
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts),
+ ErrorCodes.TenantMigrationAborted);
tenantMigrationTest.stop();
})();
@@ -465,10 +453,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
tryAbortThread.join();
assert.commandWorked(tryAbortThread.returnData());
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted, tojson(stateRes));
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts),
+ ErrorCodes.TenantMigrationAborted);
tenantMigrationTest.stop();
})();
@@ -493,9 +479,8 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.InternalError, tojson(stateRes));
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(migrationOpts),
+ ErrorCodes.InternalError);
fp.off();
@@ -522,9 +507,7 @@ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
recipientConnString: tenantMigrationTest.getRecipientConnString()
};
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
- assert.isnull(stateRes.abortReason, tojson(stateRes));
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
assert.commandFailedWithCode(
tenantMigrationTest.tryAbortMigration({migrationIdString: migrationOpts.migrationIdString}),
diff --git a/jstests/replsets/tenant_migration_drop_collection.js b/jstests/replsets/tenant_migration_drop_collection.js
index 00053d310c9..409dfc19e0e 100644
--- a/jstests/replsets/tenant_migration_drop_collection.js
+++ b/jstests/replsets/tenant_migration_drop_collection.js
@@ -95,7 +95,7 @@ function runDropTest({failPointName, failPointData, expectedLog, createNew}) {
}
jsTestLog("Waiting for migration to complete");
- assert.commandWorked(migrationThread.returnData());
+ TenantMigrationTest.assertCommitted(migrationThread.returnData());
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
const recipientColl = recipientPrimary.getDB(dbName).getCollection(collName);
diff --git a/jstests/replsets/tenant_migration_drop_state_doc_collection.js b/jstests/replsets/tenant_migration_drop_state_doc_collection.js
index d52fe64bff4..b52dbdedab5 100644
--- a/jstests/replsets/tenant_migration_drop_state_doc_collection.js
+++ b/jstests/replsets/tenant_migration_drop_state_doc_collection.js
@@ -71,7 +71,7 @@ function testDroppingStateDocCollections(tenantMigrationTest, fpName, {
false /* automaticForgetMigration */));
fp.wait();
} else {
- assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tenantMigrationTest.runMigration(migrationOptsBeforeDrop,
false /* retryOnRetryableErrors */,
false /* automaticForgetMigration */));
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 86919415b58..8593e6dbaf0 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
@@ -91,8 +91,7 @@ function insertDocument(primaryHost, dbName, collName) {
migrationThread.join();
- const migrationRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(migrationThread.returnData());
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, tenantId);
@@ -155,8 +154,7 @@ function insertDocument(primaryHost, dbName, collName) {
migrationThread.join();
- const migrationRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kAborted);
+ TenantMigrationTest.assertAborted(migrationThread.returnData());
abortFp.off();
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
diff --git a/jstests/replsets/tenant_migration_external_cluster_validation.js b/jstests/replsets/tenant_migration_external_cluster_validation.js
index 6034360588d..6ef99afca33 100644
--- a/jstests/replsets/tenant_migration_external_cluster_validation.js
+++ b/jstests/replsets/tenant_migration_external_cluster_validation.js
@@ -142,7 +142,7 @@ const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationId),
tenantId: kTenantId,
};
-assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
donorAdminDB.logout();
recipientAdminDB.logout();
diff --git a/jstests/replsets/tenant_migration_external_keys_ttl.js b/jstests/replsets/tenant_migration_external_keys_ttl.js
index d844afe8e76..60a9f982f38 100644
--- a/jstests/replsets/tenant_migration_external_keys_ttl.js
+++ b/jstests/replsets/tenant_migration_external_keys_ttl.js
@@ -109,9 +109,9 @@ function makeTestParams() {
{
const [tenantId, migrationId, migrationOpts] = makeTestParams();
- assert.commandWorked(tmt.runMigration(migrationOpts,
- false /* retryOnRetryableErrors */,
- false /* automaticForgetMigration */));
+ TenantMigrationTest.assertCommitted(tmt.runMigration(migrationOpts,
+ false /* retryOnRetryableErrors */,
+ false /* automaticForgetMigration */));
// The keys should have been created without a TTL deadline.
verifyExternalKeys(tmt.getDonorPrimary(), {migrationId, expectTTLValue: false});
@@ -125,9 +125,9 @@ function makeTestParams() {
tenantId: makeTenantId(),
};
- assert.commandWorked(tmt.runMigration(otherMigrationOpts,
- false /* retryOnRetryableErrors */,
- false /* automaticForgetMigration */));
+ TenantMigrationTest.assertCommitted(tmt.runMigration(otherMigrationOpts,
+ false /* retryOnRetryableErrors */,
+ false /* automaticForgetMigration */));
// The keys should have been created without a TTL deadline.
verifyExternalKeys(tmt.getDonorPrimary(),
@@ -166,9 +166,9 @@ function makeTestParams() {
assert.eq(origDonorKeysExpirationParam, 60 * 60 * 24); // 1 day.
assert.eq(origRecipientKeysExpirationParam, 60 * 60 * 24); // 1 day.
- assert.commandWorked(tmt.runMigration(migrationOpts,
- false /* retryOnRetryableErrors */,
- false /* automaticForgetMigration */));
+ TenantMigrationTest.assertCommitted(tmt.runMigration(migrationOpts,
+ false /* retryOnRetryableErrors */,
+ false /* automaticForgetMigration */));
// The keys should have been created without a TTL deadline.
verifyExternalKeys(tmt.getDonorPrimary(), {migrationId, expectTTLValue: false});
@@ -240,7 +240,7 @@ function makeTestParams() {
assert.commandWorked(donorPrimary.adminCommand({replSetFreeze: 0}));
fp.off();
- assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tmt.waitForMigrationToComplete(migrationOpts, true /* retryOnRetryableErrors */));
// The keys should have been created without a TTL deadline.
@@ -271,7 +271,7 @@ function makeTestParams() {
assert.commandWorked(recipientPrimary.adminCommand({replSetFreeze: 0}));
fp.off();
- assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tmt.waitForMigrationToComplete(migrationOpts, true /* retryOnRetryableErrors */));
// The keys should have been created without a TTL deadline.
@@ -293,7 +293,7 @@ function makeTestParams() {
const donorPrimary = tmt.getDonorPrimary();
assert.commandWorked(tmt.startMigration(migrationOpts));
- assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tmt.waitForMigrationToComplete(migrationOpts, true /* retryOnRetryableErrors */));
// The keys should have been created without a TTL deadline.
@@ -329,7 +329,7 @@ function makeTestParams() {
const recipientPrimary = tmt.getRecipientPrimary();
assert.commandWorked(tmt.startMigration(migrationOpts));
- assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tmt.waitForMigrationToComplete(migrationOpts, true /* retryOnRetryableErrors */));
// The keys should have been created without a TTL deadline.
@@ -370,7 +370,7 @@ function makeTestParams() {
const donorPrimary = tmt.getDonorPrimary();
assert.commandWorked(tmt.startMigration(migrationOpts));
- assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tmt.waitForMigrationToComplete(migrationOpts, true /* retryOnRetryableErrors */));
// The keys should have been created without a TTL deadline.
@@ -407,7 +407,7 @@ function makeTestParams() {
const recipientPrimary = tmt.getRecipientPrimary();
assert.commandWorked(tmt.startMigration(migrationOpts));
- assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tmt.waitForMigrationToComplete(migrationOpts, true /* retryOnRetryableErrors */));
// The keys should have been created without a TTL deadline.
diff --git a/jstests/replsets/tenant_migration_fetch_committed_transactions.js b/jstests/replsets/tenant_migration_fetch_committed_transactions.js
index fca54a61db7..63850f4b5ba 100644
--- a/jstests/replsets/tenant_migration_fetch_committed_transactions.js
+++ b/jstests/replsets/tenant_migration_fetch_committed_transactions.js
@@ -95,7 +95,7 @@ const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationId),
tenantId,
};
-assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
// Verify that the recipient has fetched and written only the first committed transaction entry from
// the donor.
diff --git a/jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js b/jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js
index 1606d0a4ec6..bc20a96f090 100644
--- a/jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js
+++ b/jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js
@@ -115,7 +115,8 @@ const assertTransactionEntries = (donorTxnEntries, recipientTxnEntries) => {
fpAfterCollectionClonerDone.off();
// Verify that the migration completes successfully.
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
recipientTxnEntries = recipientPrimary.getCollection(transactionsNS).find().toArray();
assertTransactionEntries(donorTxnEntries, recipientTxnEntries);
@@ -180,7 +181,8 @@ const assertTransactionEntries = (donorTxnEntries, recipientTxnEntries) => {
fpAfterCollectionClonerDone.off();
// Verify that the migration completes successfully.
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
recipientTxnEntries = recipientPrimary.getCollection(transactionsNS).find().toArray();
assertTransactionEntries(donorTxnEntries, recipientTxnEntries);
@@ -256,7 +258,8 @@ const assertTransactionEntries = (donorTxnEntries, recipientTxnEntries) => {
fpAfterCollectionClonerDone.off();
// Verify that the migration completes successfully.
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
recipientTxnEntries = recipientPrimary.getCollection(transactionsNS).find().toArray();
assertTransactionEntries(updatedDonorTxnEntries, recipientTxnEntries);
diff --git a/jstests/replsets/tenant_migration_filters_tenant_id.js b/jstests/replsets/tenant_migration_filters_tenant_id.js
index 1b64d407684..0183e8be16f 100644
--- a/jstests/replsets/tenant_migration_filters_tenant_id.js
+++ b/jstests/replsets/tenant_migration_filters_tenant_id.js
@@ -38,7 +38,7 @@ const runTest = (baseTenantId, dbName, shouldMatch) => {
migrationIdString: extractUUIDFromObject(UUID()),
tenantId: baseTenantId,
};
- tenantMigrationTest.runMigration(migrationOpts);
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
// verifyRecipientDB calls isNamespaceForTenant() to determine if the data should have been
// migrated, so we can directly call it here.
diff --git a/jstests/replsets/tenant_migration_find_and_modify_retry.js b/jstests/replsets/tenant_migration_find_and_modify_retry.js
index 1a77e92fc2c..ad296f6f234 100644
--- a/jstests/replsets/tenant_migration_find_and_modify_retry.js
+++ b/jstests/replsets/tenant_migration_find_and_modify_retry.js
@@ -83,9 +83,7 @@ jsTestLog("Second findAndModify: " + tojson(res));
// Resume the tenant migration.
hangAfterRetrievingStartOpTime.off();
-const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
-assert.eq(stateRes.state, TenantMigrationTest.State.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
res = assert.commandWorked(recipientPrimary.getDB(kDbName).runCommand({
findAndModify: kCollName,
diff --git a/jstests/replsets/tenant_migration_ignore_create_index_on_nonempty_collection.js b/jstests/replsets/tenant_migration_ignore_create_index_on_nonempty_collection.js
index 07a1fc1883c..765109c0828 100644
--- a/jstests/replsets/tenant_migration_ignore_create_index_on_nonempty_collection.js
+++ b/jstests/replsets/tenant_migration_ignore_create_index_on_nonempty_collection.js
@@ -54,9 +54,7 @@ assert.commandWorked(donorColl.insert({x: 1}, {writeConcern: {w: "majority"}}));
hangAfterRetrievingStartOpTime.off();
// Test that the recipient ignores the createIndex and the migration should succeed.
-const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
-assert.eq(stateRes.state, TenantMigrationTest.State.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
})();
diff --git a/jstests/replsets/tenant_migration_large_txn.js b/jstests/replsets/tenant_migration_large_txn.js
index 8893efe6087..ecc4d59449d 100644
--- a/jstests/replsets/tenant_migration_large_txn.js
+++ b/jstests/replsets/tenant_migration_large_txn.js
@@ -85,7 +85,7 @@ assert.soon(
() => tenantMigrationTest.getTenantMigrationAccessBlocker(donorPrimary, kTenantId).state ===
TenantMigrationTest.DonorAccessState.kBlockWritesAndReads);
logApplyOpsForTxnFp.off();
-assert.commandWorked(migrationThread.returnData());
+TenantMigrationTest.assertCommitted(migrationThread.returnData());
// Verify that the transaction commits successfully since both applyOps have oplog timestamp <
// blockingTimestamp .
diff --git a/jstests/replsets/tenant_migration_logs.js b/jstests/replsets/tenant_migration_logs.js
index c5fec2d5bc6..e4fdeb16af7 100644
--- a/jstests/replsets/tenant_migration_logs.js
+++ b/jstests/replsets/tenant_migration_logs.js
@@ -41,8 +41,7 @@ const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
tenantId: "slowCommands",
};
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
assertNoCertificateOrPrivateKeyLogsForCmd(donorPrimary, "donorStartMigration");
assertNoCertificateOrPrivateKeyLogsForCmd(recipientPrimary, "recipientSyncData");
diff --git a/jstests/replsets/tenant_migration_metrics_output.js b/jstests/replsets/tenant_migration_metrics_output.js
index 1680a775468..ac108be13e5 100644
--- a/jstests/replsets/tenant_migration_metrics_output.js
+++ b/jstests/replsets/tenant_migration_metrics_output.js
@@ -56,8 +56,7 @@ const migrationOpts = {
recipientConnString: tenantMigrationTest.getRecipientConnString()
};
-const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
-assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
verifyServerStatus(tenantMigrationTest.getDonorPrimary());
verifyFTDCOutput(tenantMigrationTest.getDonorPrimary());
diff --git a/jstests/replsets/tenant_migration_multi_writes.js b/jstests/replsets/tenant_migration_multi_writes.js
index d34de831ed9..67e18319226 100644
--- a/jstests/replsets/tenant_migration_multi_writes.js
+++ b/jstests/replsets/tenant_migration_multi_writes.js
@@ -142,9 +142,8 @@ function testMultiWritesWhileInBlockingState(readConcern, writeConcern) {
});
assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
- const stateRes = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(
+ TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(
migrationOpts, false /* retryOnRetryableErrors */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
abortFp.wait();
abortFp.off();
diff --git a/jstests/replsets/tenant_migration_multikey_index.js b/jstests/replsets/tenant_migration_multikey_index.js
index a79e8281e25..d2140f855f4 100644
--- a/jstests/replsets/tenant_migration_multikey_index.js
+++ b/jstests/replsets/tenant_migration_multikey_index.js
@@ -121,9 +121,7 @@ verifyMultiKeyIndex(donorColl2, true, {"a.b": ["a", "a.b"], "a.c": ["a"]});
fpBeforeFulfillingDataConsistentPromise.off();
// Wait for tenant migration to finish.
-const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
-assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
// Recipient now should have fetched the newly updated data, and changed the multi-key path
// on "a.c" in collection 1.
diff --git a/jstests/replsets/tenant_migration_no_failover.js b/jstests/replsets/tenant_migration_no_failover.js
index e84beff55fe..a0e52c18839 100644
--- a/jstests/replsets/tenant_migration_no_failover.js
+++ b/jstests/replsets/tenant_migration_no_failover.js
@@ -36,8 +36,7 @@ const migrationOpts = {
tenantId,
};
-const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
-assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
for (const db of [...tenantDBs, ...nonTenantDBs]) {
for (const coll of collNames) {
diff --git a/jstests/replsets/tenant_migration_read_your_own_writes.js b/jstests/replsets/tenant_migration_read_your_own_writes.js
index 6eeac579037..52adb15df6e 100644
--- a/jstests/replsets/tenant_migration_read_your_own_writes.js
+++ b/jstests/replsets/tenant_migration_read_your_own_writes.js
@@ -46,8 +46,7 @@ const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationId),
tenantId: kTenantId,
};
-const migrationRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
-assert.eq(migrationRes.state, TenantMigrationTest.State.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
// Test that getMore works after the migration has committed.
jsTestLog(`Testing getMore on cursor id ${cursor.id} on the donor after the migration`);
diff --git a/jstests/replsets/tenant_migration_recipient_current_op.js b/jstests/replsets/tenant_migration_recipient_current_op.js
index a8585289d4b..bcd58ce8efd 100644
--- a/jstests/replsets/tenant_migration_recipient_current_op.js
+++ b/jstests/replsets/tenant_migration_recipient_current_op.js
@@ -185,7 +185,7 @@ assert.gte(currOp.numOpsApplied, 1, tojson(res));
fpAfterDataConsistent.off();
jsTestLog("Waiting for migration to complete.");
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
jsTestLog("Issuing a forget migration command.");
const forgetMigrationThread =
diff --git a/jstests/replsets/tenant_migration_recipient_does_not_change_sync_source_after_step_down.js b/jstests/replsets/tenant_migration_recipient_does_not_change_sync_source_after_step_down.js
index 32f508ded2c..208a6b9e17a 100644
--- a/jstests/replsets/tenant_migration_recipient_does_not_change_sync_source_after_step_down.js
+++ b/jstests/replsets/tenant_migration_recipient_does_not_change_sync_source_after_step_down.js
@@ -115,9 +115,7 @@ hangDuringCollectionClone.off();
// After recipient syncs new documents, becomes consistent, and finishes migration,
// verify the sync source is still the donor's old primary.
-const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
-assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.eq(recipientColl.find().itcount(), docs1.length + docs2.length);
assert.docEq(recipientColl.find().sort({_id: 1}).toArray(), docs1.concat(docs2));
verifySyncSource(recipientPrimary, migrationId, donorPrimary.host);
diff --git a/jstests/replsets/tenant_migration_recipient_failover_before_creating_oplog_buffer.js b/jstests/replsets/tenant_migration_recipient_failover_before_creating_oplog_buffer.js
index 124afd17479..d4b9eaadbad 100644
--- a/jstests/replsets/tenant_migration_recipient_failover_before_creating_oplog_buffer.js
+++ b/jstests/replsets/tenant_migration_recipient_failover_before_creating_oplog_buffer.js
@@ -52,7 +52,7 @@ assert.commandWorked(tenantMigrationTest.getRecipientRst().getSecondaries()[0].a
fpBeforeCreatingOplogBuffer.off();
jsTestLog("Waiting for migration to complete.");
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
})(); \ No newline at end of file
diff --git a/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js b/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js
index 98ac4e63c62..c82613b8ea1 100644
--- a/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js
+++ b/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js
@@ -180,7 +180,7 @@ assert.eq(0, recipientOplogBuffer.find({"entry.o._id": "bulkRetryableWrite1"}).i
fpAfterRetrievingRetryableWrites.off();
jsTestLog("Wait for migration to complete");
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, kTenantId);
diff --git a/jstests/replsets/tenant_migration_recipient_has_tenant_data.js b/jstests/replsets/tenant_migration_recipient_has_tenant_data.js
index e9671e69839..5bdaf254895 100644
--- a/jstests/replsets/tenant_migration_recipient_has_tenant_data.js
+++ b/jstests/replsets/tenant_migration_recipient_has_tenant_data.js
@@ -54,8 +54,7 @@ jsTest.log("Start a tenant migration and verify that it commits successfully");
tenantId: kTenantId,
};
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, kTenantId);
})();
@@ -71,9 +70,8 @@ jsTest.log(
tenantId: kTenantId,
};
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.NamespaceExists);
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(migrationOpts),
+ ErrorCodes.NamespaceExists);
})();
donorRst.stopSet();
diff --git a/jstests/replsets/tenant_migration_recipient_invalidates_in_memory_txns.js b/jstests/replsets/tenant_migration_recipient_invalidates_in_memory_txns.js
index e916e36b7d3..d5b22b9ec26 100644
--- a/jstests/replsets/tenant_migration_recipient_invalidates_in_memory_txns.js
+++ b/jstests/replsets/tenant_migration_recipient_invalidates_in_memory_txns.js
@@ -77,8 +77,7 @@ const migrationOpts1 = {
migrationIdString: extractUUIDFromObject(migrationId1),
tenantId,
};
-let migrationRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts1));
-assert.eq(migrationRes.state, TenantMigrationTest.State.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts1));
tenantMigrationTest.waitForMigrationGarbageCollection(migrationId1, tenantId);
// Verify that the config.transaction entry was migrated successfully.
@@ -107,10 +106,10 @@ const migrationOpts2 = {
migrationIdString: extractUUIDFromObject(migrationId2),
tenantId,
};
-migrationRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts2));
+
// The migration should have committed successfully even though the in-memory transaction number was
// higher, since the higher number should have been invalidated.
-assert.eq(migrationRes.state, TenantMigrationTest.State.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts2));
tenantMigrationTest.stop();
})();
diff --git a/jstests/replsets/tenant_migration_recipient_resume_on_stepup_and_restart.js b/jstests/replsets/tenant_migration_recipient_resume_on_stepup_and_restart.js
index 7f8424b5dcd..c70cca50eaf 100644
--- a/jstests/replsets/tenant_migration_recipient_resume_on_stepup_and_restart.js
+++ b/jstests/replsets/tenant_migration_recipient_resume_on_stepup_and_restart.js
@@ -70,8 +70,7 @@ function testRecipientSyncDataInterrupt(interruptFunc, recipientRestarted) {
sleep(Math.random() * kMaxSleepTimeMS);
interruptFunc(recipientRst);
- const stateRes = assert.commandWorked(runMigrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(runMigrationThread.returnData());
tenantMigrationTest.waitForDonorNodesToReachState(donorRst.nodes,
migrationId,
migrationOpts.tenantId,
@@ -146,9 +145,8 @@ function testRecipientForgetMigrationInterrupt(interruptFunc) {
};
const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
migrationOpts.migrationIdString,
donorRstArgs,
diff --git a/jstests/replsets/tenant_migration_recipient_resumes_on_donor_failover.js b/jstests/replsets/tenant_migration_recipient_resumes_on_donor_failover.js
index c84129d98ec..b5af732a935 100644
--- a/jstests/replsets/tenant_migration_recipient_resumes_on_donor_failover.js
+++ b/jstests/replsets/tenant_migration_recipient_resumes_on_donor_failover.js
@@ -115,7 +115,8 @@ function runTest(failPoint) {
assert.eq(donorSecondary.host, currOp.donorSyncSource, currOp);
hangOnRetry.off();
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
// Remove 'donorPrimary' so that the test can complete properly.
donorRst.remove(donorPrimary);
recipientRst.stopSet();
diff --git a/jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js b/jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js
index ceaf0bd68eb..fff4a8d62ef 100644
--- a/jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js
+++ b/jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js
@@ -120,7 +120,7 @@ fpAfterFetchingRetryableWritesEntries.off();
fpSetSmallAggregationBatchSize.off();
jsTestLog("Waiting for migration to complete.");
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
})();
diff --git a/jstests/replsets/tenant_migration_recipient_rollback_recovery.js b/jstests/replsets/tenant_migration_recipient_rollback_recovery.js
index 5f518bf84c9..b84286dae2c 100644
--- a/jstests/replsets/tenant_migration_recipient_rollback_recovery.js
+++ b/jstests/replsets/tenant_migration_recipient_rollback_recovery.js
@@ -138,8 +138,7 @@ function testRollbackInitialState() {
let steadyStateFunc = (tenantMigrationTest) => {
// Verify that the migration restarted successfully on the new primary despite rollback.
- const stateRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(migrationThread.returnData());
tenantMigrationTest.assertRecipientNodesInExpectedState(
tenantMigrationTest.getRecipientRst().nodes,
migrationId,
@@ -196,8 +195,7 @@ function testRollBackStateTransition(pauseFailPoint, setUpFailPoints, nextState,
let steadyStateFunc = (tenantMigrationTest) => {
// Verify that the migration resumed successfully on the new primary despite the rollback.
- const stateRes = assert.commandWorked(migrationThread.returnData());
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(migrationThread.returnData());
tenantMigrationTest.waitForRecipientNodesToReachState(
tenantMigrationTest.getRecipientRst().nodes,
migrationId,
@@ -224,11 +222,10 @@ function testRollBackMarkingStateGarbageCollectable() {
let setUpFunc = (tenantMigrationTest, donorRstArgs) => {
migrationOpts = makeMigrationOpts(
tenantMigrationTest, migrationId, kTenantId + "-markGarbageCollectable");
- const stateRes = assert.commandWorked(
+ TenantMigrationTest.assertCommitted(
tenantMigrationTest.runMigration(migrationOpts,
false /* retryOnRetryableErrors */,
false /* automaticForgetMigration */));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
};
let rollbackOpsFunc = (tenantMigrationTest, donorRstArgs) => {
diff --git a/jstests/replsets/tenant_migration_recipient_stepdown_after_forget.js b/jstests/replsets/tenant_migration_recipient_stepdown_after_forget.js
index 42601d0b108..ab1fc85118a 100644
--- a/jstests/replsets/tenant_migration_recipient_stepdown_after_forget.js
+++ b/jstests/replsets/tenant_migration_recipient_stepdown_after_forget.js
@@ -36,8 +36,8 @@ const migrationOpts = {
readPreference: kReadPreference
};
-tenantMigrationTest.runMigration(
- migrationOpts, true /* retryOnRetryableErrors */, false /* automaticForgetMigration */);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(
+ migrationOpts, true /* retryOnRetryableErrors */, false /* automaticForgetMigration */));
const fpBeforeDroppingOplogBufferCollection =
configureFailPoint(tenantMigrationTest.getRecipientPrimary(),
diff --git a/jstests/replsets/tenant_migration_recipient_sync_data_timeout.js b/jstests/replsets/tenant_migration_recipient_sync_data_timeout.js
index 5c689095b5d..040bee9374b 100644
--- a/jstests/replsets/tenant_migration_recipient_sync_data_timeout.js
+++ b/jstests/replsets/tenant_migration_recipient_sync_data_timeout.js
@@ -34,8 +34,7 @@ const migrationOpts = {
tenantId: kTenantId,
};
-const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
-assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
diff --git a/jstests/replsets/tenant_migration_recipient_sync_donor_timestamp.js b/jstests/replsets/tenant_migration_recipient_sync_donor_timestamp.js
index 3069c919d33..e7db16bd505 100644
--- a/jstests/replsets/tenant_migration_recipient_sync_donor_timestamp.js
+++ b/jstests/replsets/tenant_migration_recipient_sync_donor_timestamp.js
@@ -92,7 +92,7 @@ jsTestLog("Release the tenant oplog applier failpoint.");
fpPauseOplogApplier.off();
jsTestLog("Waiting for migration to complete.");
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
})();
diff --git a/jstests/replsets/tenant_migration_recipient_sync_source_reconnect_delayed_secondary.js b/jstests/replsets/tenant_migration_recipient_sync_source_reconnect_delayed_secondary.js
index e5b6ebe4570..ad0d852d443 100644
--- a/jstests/replsets/tenant_migration_recipient_sync_source_reconnect_delayed_secondary.js
+++ b/jstests/replsets/tenant_migration_recipient_sync_source_reconnect_delayed_secondary.js
@@ -48,7 +48,7 @@ assert.eq(delayedSecondary.host,
hangAfterCreatingConnections.off();
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
// Remove 'donorSecondary' so that the test can complete properly.
diff --git a/jstests/replsets/tenant_migration_recipient_sync_source_restart_donor_secondary.js b/jstests/replsets/tenant_migration_recipient_sync_source_restart_donor_secondary.js
index c4edbec28aa..6ab5d6bbf46 100644
--- a/jstests/replsets/tenant_migration_recipient_sync_source_restart_donor_secondary.js
+++ b/jstests/replsets/tenant_migration_recipient_sync_source_restart_donor_secondary.js
@@ -52,7 +52,7 @@ assert.eq(donorSecondary.host,
hangAfterCreatingConnections.off();
restartServerReplication(delayedSecondary);
-assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
donorRst.stopSet();
diff --git a/jstests/replsets/tenant_migration_recipient_ttl.js b/jstests/replsets/tenant_migration_recipient_ttl.js
index 5f484c22d30..4ca0abedb8c 100644
--- a/jstests/replsets/tenant_migration_recipient_ttl.js
+++ b/jstests/replsets/tenant_migration_recipient_ttl.js
@@ -2,7 +2,8 @@
* Tests to check whether the TTL index is being created and is functioning correctly on the tenant
* migration recipient.
*
- * @tags: [requires_fcv_49, incompatible_with_eft, incompatible_with_macos, requires_persistence]
+ * @tags: [requires_fcv_49, incompatible_with_eft, incompatible_with_macos, requires_persistence,
+ * incompatible_with_windows_tls]
*/
(function() {
@@ -59,7 +60,7 @@ 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));
+TenantMigrationTest.assertCommitted(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.
diff --git a/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js b/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js
index a10fe38dba4..44777ba142a 100644
--- a/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js
+++ b/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js
@@ -109,9 +109,8 @@ const tenantMigrationFailoverTest = function(isTimeSeries, createCollFn, docs) {
recipientRst.getPrimary();
// The migration should go through after recipient failover.
- const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(
+ tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
// Check that recipient has cloned all documents in the collection.
recipientColl = newRecipientPrimary.getDB(dbName).getCollection(collName);
diff --git a/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js b/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js
index b1fb3d12078..1e74998859c 100644
--- a/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js
+++ b/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js
@@ -98,7 +98,7 @@ const collNameRenamed = collName + "_renamed";
assert.commandWorked(donorColl.renameCollection(collNameRenamed));
// The migration should go through after recipient failover.
-assert.commandWorked(migrationThread.returnData());
+TenantMigrationTest.assertCommitted(migrationThread.returnData());
// Check that recipient has cloned all documents in the renamed collection.
recipientColl = newRecipientPrimary.getDB(dbName).getCollection(collNameRenamed);
diff --git a/jstests/replsets/tenant_migration_resume_oplog_application.js b/jstests/replsets/tenant_migration_resume_oplog_application.js
index ae131b8fd50..1fbbeb5e028 100644
--- a/jstests/replsets/tenant_migration_resume_oplog_application.js
+++ b/jstests/replsets/tenant_migration_resume_oplog_application.js
@@ -95,7 +95,7 @@ waitInOplogApplier.off();
recipientRst.getPrimary();
// The migration should go through after recipient failover.
-assert.commandWorked(migrationThread.returnData());
+TenantMigrationTest.assertCommitted(migrationThread.returnData());
// Validate that the last no-op entry is applied.
local = newRecipientPrimary.getDB("local");
appliedNoOps = local.oplog.rs.find({fromTenantMigration: migrationId, op: "n"});
diff --git a/jstests/replsets/tenant_migration_retry_session_migration.js b/jstests/replsets/tenant_migration_retry_session_migration.js
index 425c1593732..5fdae0f83c5 100644
--- a/jstests/replsets/tenant_migration_retry_session_migration.js
+++ b/jstests/replsets/tenant_migration_retry_session_migration.js
@@ -86,8 +86,7 @@ for (const lsid of [lsid1, lsid2]) {
const abortFp = configureFailPoint(donorPrimary, "abortTenantMigrationBeforeLeavingBlockingState");
waitAfterCloning.off();
-let res = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
-assert.eq(res.state, TenantMigrationTest.State.kAborted);
+TenantMigrationTest.assertAborted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString);
tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, kTenantId);
@@ -123,8 +122,7 @@ assert.commandWorked(donorPrimary.getDB(kDbName).runCommand({
waitAfterCloning.off();
-res = assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
-assert.eq(res.state, TenantMigrationTest.State.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
// Retrying commitTransaction against the recipient.
assert.commandWorked(recipientPrimary.adminCommand({
diff --git a/jstests/replsets/tenant_migration_retryable_write_retry.js b/jstests/replsets/tenant_migration_retryable_write_retry.js
index 0bd659a2d6c..3ad8e8e78b7 100644
--- a/jstests/replsets/tenant_migration_retryable_write_retry.js
+++ b/jstests/replsets/tenant_migration_retryable_write_retry.js
@@ -197,7 +197,7 @@ const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationId),
tenantId: kTenantId,
};
-assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
const donorDoc =
donorPrimary.getCollection(TenantMigrationTest.kConfigDonorsNS).findOne({tenantId: kTenantId});
diff --git a/jstests/replsets/tenant_migration_retryable_write_retry_on_recipient.js b/jstests/replsets/tenant_migration_retryable_write_retry_on_recipient.js
index f96d3175d8d..52c2471242f 100644
--- a/jstests/replsets/tenant_migration_retryable_write_retry_on_recipient.js
+++ b/jstests/replsets/tenant_migration_retryable_write_retry_on_recipient.js
@@ -173,7 +173,7 @@ assert.commandWorked(
// Wait for the migration to complete.
jsTest.log("Waiting for migration to complete");
waitAfterCloning.off();
-migrationThread.join();
+TenantMigrationTest.assertCommitted(migrationThread.returnData());
// Print the no-op oplog entries for debugging purposes.
jsTestLog("Recipient oplog migration entries.");
@@ -270,7 +270,7 @@ const migrationOpts2 = {
tenantId: kTenantId,
};
-assert.commandWorked(tenantMigrationTest2.runMigration(migrationOpts2));
+TenantMigrationTest.assertCommitted(tenantMigrationTest2.runMigration(migrationOpts2));
// Print the no-op oplog entries for debugging purposes.
jsTestLog("Second recipient oplog migration entries.");
diff --git a/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js b/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js
index fedb598c042..b45200396bd 100644
--- a/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js
+++ b/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js
@@ -49,20 +49,20 @@ assert.commandWorked(donorPrimary.getCollection(tenantId + "_testDb.testColl").i
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);
+TenantMigrationTest.assertAborted(
+ tenantMigrationTest.runMigration(
+ migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */),
+ 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);
+TenantMigrationTest.assertAborted(
+ tenantMigrationTest.runMigration(
+ migrationOpts, false /* retryOnRetryableErrors */, false /* automaticForgetMigration */),
+ ErrorCodes.InternalError);
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, tenantId);
diff --git a/jstests/replsets/tenant_migration_sync_source_too_stale.js b/jstests/replsets/tenant_migration_sync_source_too_stale.js
index cf315683e5f..4304f84c238 100644
--- a/jstests/replsets/tenant_migration_sync_source_too_stale.js
+++ b/jstests/replsets/tenant_migration_sync_source_too_stale.js
@@ -160,9 +160,7 @@ donorRst.awaitReplication();
hangAfterPersistingTenantMigrationRecipientInstanceStateDoc.off();
// Verify that the migration eventually commits successfully.
-const migrationRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
-assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
donorRst.stopSet();
tenantMigrationTest.stop();
diff --git a/jstests/replsets/tenant_migration_test_max_bson_limit.js b/jstests/replsets/tenant_migration_test_max_bson_limit.js
index 04f1b661748..d12e4049725 100644
--- a/jstests/replsets/tenant_migration_test_max_bson_limit.js
+++ b/jstests/replsets/tenant_migration_test_max_bson_limit.js
@@ -65,8 +65,7 @@ const bulkWriteThread =
bulkWriteThread.start();
writeFp.wait();
-const migrationRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
-assert.eq(migrationRes.state, TenantMigrationTest.DonorState.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
writeFp.off();
bulkWriteThread.join();
diff --git a/jstests/replsets/tenant_migration_timeseries_collections.js b/jstests/replsets/tenant_migration_timeseries_collections.js
index 452b2a1aeec..81477fba1cd 100644
--- a/jstests/replsets/tenant_migration_timeseries_collections.js
+++ b/jstests/replsets/tenant_migration_timeseries_collections.js
@@ -38,8 +38,7 @@ const migrationOpts = {
tenantId,
};
-const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
-assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
tenantMigrationTest.stop();
})();
diff --git a/jstests/replsets/tenant_migration_x509.js b/jstests/replsets/tenant_migration_x509.js
index 544821a0607..89072d9091a 100644
--- a/jstests/replsets/tenant_migration_x509.js
+++ b/jstests/replsets/tenant_migration_x509.js
@@ -41,8 +41,7 @@ const kRecipientCertificateAndPrivateKey =
const {dbName, collName} = makeTestNs(tenantId);
tenantMigrationTest.insertDonorDB(dbName, collName);
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOpts));
tenantMigrationTest.verifyRecipientDB(
tenantId, dbName, collName, true /* migrationCommitted */);
})();
@@ -279,9 +278,8 @@ const kRecipientCertificateAndPrivateKey =
const {dbName, collName} = makeTestNs(tenantId);
tenantMigrationTest.insertDonorDB(dbName, collName);
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.InvalidSSLConfiguration);
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(migrationOpts),
+ ErrorCodes.InvalidSSLConfiguration);
tenantMigrationTest.verifyRecipientDB(
tenantId, dbName, collName, false /* migrationCommitted */);
})();
@@ -302,9 +300,8 @@ const kRecipientCertificateAndPrivateKey =
const {dbName, collName} = makeTestNs(tenantId);
tenantMigrationTest.insertDonorDB(dbName, collName);
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.InvalidSSLConfiguration);
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(migrationOpts),
+ ErrorCodes.InvalidSSLConfiguration);
tenantMigrationTest.verifyRecipientDB(
tenantId, dbName, collName, false /* migrationCommitted */);
})();
@@ -329,9 +326,8 @@ if (!TestData.auth) {
const {dbName, collName} = makeTestNs(tenantId);
tenantMigrationTest.insertDonorDB(dbName, collName);
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.Unauthorized);
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(migrationOpts),
+ ErrorCodes.Unauthorized);
tenantMigrationTest.verifyRecipientDB(
tenantId, dbName, collName, false /* migrationCommitted */);
})();
@@ -350,9 +346,8 @@ if (!TestData.auth) {
const {dbName, collName} = makeTestNs(tenantId);
tenantMigrationTest.insertDonorDB(dbName, collName);
- const stateRes = assert.commandWorked(tenantMigrationTest.runMigration(migrationOpts));
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
- assert.eq(stateRes.abortReason.code, ErrorCodes.Unauthorized);
+ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(migrationOpts),
+ ErrorCodes.Unauthorized);
tenantMigrationTest.verifyRecipientDB(
tenantId, dbName, collName, false /* migrationCommitted */);
})();
diff --git a/jstests/replsets/tenant_migrations_back_to_back.js b/jstests/replsets/tenant_migrations_back_to_back.js
index 08ffa58d85e..dc742319ac2 100644
--- a/jstests/replsets/tenant_migrations_back_to_back.js
+++ b/jstests/replsets/tenant_migrations_back_to_back.js
@@ -56,8 +56,7 @@ assert.lt(preMigrationTimestamp, donorDoc.blockTimestamp);
waitForRejectReadsBeforeTsFp.off();
// Wait for the migration to complete.
jsTest.log("Waiting for migration to complete");
-const stateRes = assert.commandWorked(migrationThread.returnData());
-assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
+TenantMigrationTest.assertCommitted(migrationThread.returnData());
tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString);
@@ -146,7 +145,7 @@ newDonorRst.nodes.forEach(node => {
});
waitAfterCreatingMtab.off();
-migration2Thread.join();
+TenantMigrationTest.assertCommitted(migration2Thread.returnData());
tenantMigrationTest2.stop();
tenantMigrationTest.stop();
diff --git a/jstests/replsets/tenant_migrations_transaction_with_create_collection.js b/jstests/replsets/tenant_migrations_transaction_with_create_collection.js
index 3fa3d84120e..9be3ef5e95a 100644
--- a/jstests/replsets/tenant_migrations_transaction_with_create_collection.js
+++ b/jstests/replsets/tenant_migrations_transaction_with_create_collection.js
@@ -61,9 +61,7 @@ session.endSession();
hangAfterStartingOplogApplier.off();
jsTestLog("Waiting for migration to complete");
-const stateRes =
- assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
-assert.eq(TenantMigrationTest.State.kCommitted, stateRes.state);
+TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
// Verify that all docs were successfully migrated onto the recipient.
assert.eq(1, recipientPrimary.getCollection(transactionsNS).find().itcount());