summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorauto-revert-processor <dev-prod-dag@mongodb.com>2023-01-10 04:53:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-10 05:28:35 +0000
commit1d37ab71d4d1aa7baa6cea50cda7be099e53ce60 (patch)
tree7bb70ee6f50efb26719549b6f5fb220818194117 /jstests
parent23acbaa87ef1cbf9e2136c0ad63c32efd0c39bd4 (diff)
downloadmongo-1d37ab71d4d1aa7baa6cea50cda7be099e53ce60.tar.gz
Revert "SERVER-72577 Convert tenant migrations tests to use es modules"
This reverts commit 9c2d2f716db7924c7fe12af379437f637efba744.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/auth/commands_builtin_roles_nonexistent.js7
-rw-r--r--jstests/auth/commands_builtin_roles_sharded.js6
-rw-r--r--jstests/auth/commands_builtin_roles_standalone.js6
-rw-r--r--jstests/auth/commands_user_defined_roles.js12
-rw-r--r--jstests/auth/lib/commands_builtin_roles.js19
-rw-r--r--jstests/auth/lib/commands_lib.js53
-rw-r--r--jstests/hooks/run_check_tenant_migration_dbhash.js16
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js7
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch.js13
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch_after_failover.js13
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/tenant_migration_recipient_abort_on_fcv_change.js7
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js29
-rw-r--r--jstests/noPassthrough/comment_field_passthrough.js17
-rw-r--r--jstests/replsets/libs/tenant_migration_recipient_sync_source.js11
-rw-r--r--jstests/replsets/libs/tenant_migration_test.js454
-rw-r--r--jstests/replsets/libs/tenant_migration_util.js1028
-rw-r--r--jstests/replsets/shard_merge_enabled.js15
-rw-r--r--jstests/replsets/shard_merge_invalid_options.js15
-rw-r--r--jstests/replsets/tenant_migration_abort_forget_retry.js17
-rw-r--r--jstests/replsets/tenant_migration_aborted_buildindex.js15
-rw-r--r--jstests/replsets/tenant_migration_advance_stable_ts_after_clone.js10
-rw-r--r--jstests/replsets/tenant_migration_blocking_state_timeout.js15
-rw-r--r--jstests/replsets/tenant_migration_buildindex.js21
-rw-r--r--jstests/replsets/tenant_migration_buildindex_shard_merge.js20
-rw-r--r--jstests/replsets/tenant_migration_causal_consistency_commit_optime_before_last_cloning_optime.js8
-rw-r--r--jstests/replsets/tenant_migration_cloner_stats.js6
-rw-r--r--jstests/replsets/tenant_migration_cloner_stats_with_failover.js6
-rw-r--r--jstests/replsets/tenant_migration_clones_system_views.js6
-rw-r--r--jstests/replsets/tenant_migration_cloning_uses_read_concern_majority.js13
-rw-r--r--jstests/replsets/tenant_migration_cluster_time_keys_cloning.js18
-rw-r--r--jstests/replsets/tenant_migration_collection_rename.js13
-rw-r--r--jstests/replsets/tenant_migration_collection_ttl.js9
-rw-r--r--jstests/replsets/tenant_migration_commit_transaction_retry.js7
-rw-r--r--jstests/replsets/tenant_migration_concurrent_bulk_writes.js49
-rw-r--r--jstests/replsets/tenant_migration_concurrent_migrations.js13
-rw-r--r--jstests/replsets/tenant_migration_concurrent_migrations_recipient.js7
-rw-r--r--jstests/replsets/tenant_migration_concurrent_migrations_stress_test.js7
-rw-r--r--jstests/replsets/tenant_migration_concurrent_reads_on_donor.js20
-rw-r--r--jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js19
-rw-r--r--jstests/replsets/tenant_migration_concurrent_reconfig.js7
-rw-r--r--jstests/replsets/tenant_migration_concurrent_state_doc_removal_and_stepdown.js12
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_donor.js13
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_donor_aborted.js19
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking.js15
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_aborted.js24
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_committed.js24
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_donor_committed.js15
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js996
-rw-r--r--jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js18
-rw-r--r--jstests/replsets/tenant_migration_conflicting_donor_start_migration_cmds.js29
-rw-r--r--jstests/replsets/tenant_migration_conflicting_recipient_sync_data_cmds.js19
-rw-r--r--jstests/replsets/tenant_migration_donor_abort_state_transition.js14
-rw-r--r--jstests/replsets/tenant_migration_donor_current_op.js10
-rw-r--r--jstests/replsets/tenant_migration_donor_directly_deletes_its_state_doc.js6
-rw-r--r--jstests/replsets/tenant_migration_donor_initial_sync_cloning.js6
-rw-r--r--jstests/replsets/tenant_migration_donor_initial_sync_recovery.js10
-rw-r--r--jstests/replsets/tenant_migration_donor_interrupt_on_stepdown_and_shutdown.js37
-rw-r--r--jstests/replsets/tenant_migration_donor_kill_op_retry.js44
-rw-r--r--jstests/replsets/tenant_migration_donor_resume_on_stepup_and_restart.js35
-rw-r--r--jstests/replsets/tenant_migration_donor_retry.js31
-rw-r--r--jstests/replsets/tenant_migration_donor_rollback_during_cloning.js9
-rw-r--r--jstests/replsets/tenant_migration_donor_rollback_recovery.js40
-rw-r--r--jstests/replsets/tenant_migration_donor_shutdown_while_blocking_reads.js9
-rw-r--r--jstests/replsets/tenant_migration_donor_startup_recovery.js13
-rw-r--r--jstests/replsets/tenant_migration_donor_state_machine.js32
-rw-r--r--jstests/replsets/tenant_migration_donor_try_abort.js44
-rw-r--r--jstests/replsets/tenant_migration_donor_unblock_reads_and_writes_on_completion.js21
-rw-r--r--jstests/replsets/tenant_migration_donor_wont_retry_recipientsyncdata_on_non_retriable_interruption_errors.js18
-rw-r--r--jstests/replsets/tenant_migration_drop_collection.js18
-rw-r--r--jstests/replsets/tenant_migration_drop_state_doc_collection.js7
-rw-r--r--jstests/replsets/tenant_migration_ensure_migration_outcome_visibility_for_blocked_writes.js26
-rw-r--r--jstests/replsets/tenant_migration_external_cluster_validation.js8
-rw-r--r--jstests/replsets/tenant_migration_external_keys_ttl.js48
-rw-r--r--jstests/replsets/tenant_migration_fetch_committed_transactions.js7
-rw-r--r--jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js6
-rw-r--r--jstests/replsets/tenant_migration_fetch_committed_transactions_shard_merge.js13
-rw-r--r--jstests/replsets/tenant_migration_filters_tenant_id.js11
-rw-r--r--jstests/replsets/tenant_migration_find_and_modify_retry.js7
-rw-r--r--jstests/replsets/tenant_migration_ignore_create_index_on_nonempty_collection.js6
-rw-r--r--jstests/replsets/tenant_migration_index_oplog_entries.js1
-rw-r--r--jstests/replsets/tenant_migration_invalid_inputs.js141
-rw-r--r--jstests/replsets/tenant_migration_large_txn.js15
-rw-r--r--jstests/replsets/tenant_migration_logs.js6
-rw-r--r--jstests/replsets/tenant_migration_metrics_output.js11
-rw-r--r--jstests/replsets/tenant_migration_multi_writes.js11
-rw-r--r--jstests/replsets/tenant_migration_multikey_index.js11
-rw-r--r--jstests/replsets/tenant_migration_network_error_via_rollback.js11
-rw-r--r--jstests/replsets/tenant_migration_no_failover.js6
-rw-r--r--jstests/replsets/tenant_migration_on_clustered_collection.js15
-rw-r--r--jstests/replsets/tenant_migration_oplog_view.js5
-rw-r--r--jstests/replsets/tenant_migration_read_your_own_writes.js7
-rw-r--r--jstests/replsets/tenant_migration_recipient_aborts_merge_on_donor_failure.js9
-rw-r--r--jstests/replsets/tenant_migration_recipient_access_blocker_rollback.js18
-rw-r--r--jstests/replsets/tenant_migration_recipient_current_op.js17
-rw-r--r--jstests/replsets/tenant_migration_recipient_directly_deletes_its_state_doc.js6
-rw-r--r--jstests/replsets/tenant_migration_recipient_does_not_change_sync_source_after_step_down.js9
-rw-r--r--jstests/replsets/tenant_migration_recipient_failover_before_creating_oplog_buffer.js7
-rw-r--r--jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_entry_after_committed_snapshot.js16
-rw-r--r--jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_oplog_entries.js12
-rw-r--r--jstests/replsets/tenant_migration_recipient_fetches_synthetic_find_and_modify_oplog_entries.js5
-rw-r--r--jstests/replsets/tenant_migration_recipient_forget_migration.js37
-rw-r--r--jstests/replsets/tenant_migration_recipient_has_tenant_data.js10
-rw-r--r--jstests/replsets/tenant_migration_recipient_initial_sync_cloning.js8
-rw-r--r--jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js10
-rw-r--r--jstests/replsets/tenant_migration_recipient_invalidates_in_memory_txns.js6
-rw-r--r--jstests/replsets/tenant_migration_recipient_resume_on_stepup_and_restart.js23
-rw-r--r--jstests/replsets/tenant_migration_recipient_resumes_on_donor_failover.js9
-rw-r--r--jstests/replsets/tenant_migration_recipient_retry_forget_migration.js9
-rw-r--r--jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js6
-rw-r--r--jstests/replsets/tenant_migration_recipient_rollback_recovery.js35
-rw-r--r--jstests/replsets/tenant_migration_recipient_shard_merge_learn_files.js11
-rw-r--r--jstests/replsets/tenant_migration_recipient_shard_merge_oplog_catchup.js11
-rw-r--r--jstests/replsets/tenant_migration_recipient_shard_merge_ttl.js13
-rw-r--r--jstests/replsets/tenant_migration_recipient_startup_recovery.js8
-rw-r--r--jstests/replsets/tenant_migration_recipient_sync_data_timeout.js6
-rw-r--r--jstests/replsets/tenant_migration_recipient_sync_donor_timestamp.js7
-rw-r--r--jstests/replsets/tenant_migration_recipient_ttl.js7
-rw-r--r--jstests/replsets/tenant_migration_recipient_vote_imported_files.js20
-rw-r--r--jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js20
-rw-r--r--jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover_with_dropped_views.js15
-rw-r--r--jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js21
-rw-r--r--jstests/replsets/tenant_migration_resume_oplog_application.js21
-rw-r--r--jstests/replsets/tenant_migration_retry_session_migration.js9
-rw-r--r--jstests/replsets/tenant_migration_retryable_write_retry.js11
-rw-r--r--jstests/replsets/tenant_migration_retryable_write_retry_on_recipient.js20
-rw-r--r--jstests/replsets/tenant_migration_shard_merge_import_write_conflict_retry.js11
-rw-r--r--jstests/replsets/tenant_migration_shard_merge_invalid_inputs.js17
-rw-r--r--jstests/replsets/tenant_migration_shard_merge_read_preference.js14
-rw-r--r--jstests/replsets/tenant_migration_shard_merge_recipient_current_op.js25
-rw-r--r--jstests/replsets/tenant_migration_shard_merge_recipient_fetches_synthetic_find_and_modify_entries.js11
-rw-r--r--jstests/replsets/tenant_migration_ssl_configuration.js108
-rw-r--r--jstests/replsets/tenant_migration_stepup_recovery_after_abort.js10
-rw-r--r--jstests/replsets/tenant_migration_sync_source_too_stale.js8
-rw-r--r--jstests/replsets/tenant_migration_test_max_bson_limit.js6
-rw-r--r--jstests/replsets/tenant_migration_timeseries_collections.js6
-rw-r--r--jstests/replsets/tenant_migration_timeseries_retryable_write_oplog_cloning.js9
-rw-r--r--jstests/replsets/tenant_migration_timeseries_retryable_write_retry_on_recipient.js13
-rw-r--r--jstests/replsets/tenant_migration_transaction_boundary.js7
-rw-r--r--jstests/replsets/tenant_migration_v1_id_index.js6
-rw-r--r--jstests/replsets/tenant_migration_x509.js25
-rw-r--r--jstests/replsets/tenant_migrations_back_to_back.js19
-rw-r--r--jstests/replsets/tenant_migrations_noop_writes.js14
-rw-r--r--jstests/replsets/tenant_migrations_transaction_with_create_collection.js6
-rw-r--r--jstests/serverless/libs/shard_split_test.js6
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_access_blocker.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_migration_after_garbage_collection.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_migration_different_tenant.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_migration_donor.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_migration_donor_retry.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_migration_fail.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_migration_fail_on_recipient.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_migration_recipient_retry.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_split.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_split_retry.js4
-rw-r--r--jstests/serverless/serverless_reject_multiple_ops_split_success.js4
-rw-r--r--jstests/serverless/shard_split_buildindex.js2
-rw-r--r--jstests/serverless/shard_split_concurrent_writes_on_donor_aborted.js9
-rw-r--r--jstests/serverless/shard_split_concurrent_writes_on_donor_blocking.js18
-rw-r--r--jstests/serverless/shard_split_concurrent_writes_on_donor_committed.js7
-rw-r--r--jstests/serverless/shard_split_recipient_removes_serverless_lock.js6
-rw-r--r--jstests/serverless/shard_split_startup_recovery_aborted.js2
-rw-r--r--jstests/serverless/shard_split_startup_recovery_blocking.js2
-rw-r--r--jstests/serverless/shard_split_startup_recovery_committed.js2
-rw-r--r--jstests/serverless/shard_split_startup_recovery_initially_aborted.js8
-rw-r--r--jstests/sharding/tenant_migration_disallowed_on_config_server.js11
165 files changed, 2592 insertions, 2286 deletions
diff --git a/jstests/auth/commands_builtin_roles_nonexistent.js b/jstests/auth/commands_builtin_roles_nonexistent.js
index 13de0a2fc65..c817e064091 100644
--- a/jstests/auth/commands_builtin_roles_nonexistent.js
+++ b/jstests/auth/commands_builtin_roles_nonexistent.js
@@ -5,8 +5,10 @@
* that aren't part of the global "roles" array.
*/
-import {roles} from "jstests/auth/lib/commands_builtin_roles.js";
-import {authCommandsLib} from "jstests/auth/lib/commands_lib.js";
+(function() {
+'use strict';
+
+load('jstests/auth/lib/commands_builtin_roles.js');
function checkForNonExistentRoles() {
const tests = authCommandsLib.tests;
@@ -31,3 +33,4 @@ function checkForNonExistentRoles() {
}
checkForNonExistentRoles();
+})();
diff --git a/jstests/auth/commands_builtin_roles_sharded.js b/jstests/auth/commands_builtin_roles_sharded.js
index c9a746f0b70..ab3e1505100 100644
--- a/jstests/auth/commands_builtin_roles_sharded.js
+++ b/jstests/auth/commands_builtin_roles_sharded.js
@@ -9,7 +9,10 @@
* @tags: [requires_sharding]
*/
-import {runAllCommandsBuiltinRoles} from "jstests/auth/lib/commands_builtin_roles.js";
+(function() {
+'use strict';
+
+load('jstests/auth/lib/commands_builtin_roles.js');
const dbPath = MongoRunner.toRealDir("$dataDir/commands_built_in_roles_sharded/");
mkdir(dbPath);
@@ -29,3 +32,4 @@ const conn = new ShardingTest({
});
runAllCommandsBuiltinRoles(conn);
conn.stop();
+})();
diff --git a/jstests/auth/commands_builtin_roles_standalone.js b/jstests/auth/commands_builtin_roles_standalone.js
index f42cdb14c8d..630ed098429 100644
--- a/jstests/auth/commands_builtin_roles_standalone.js
+++ b/jstests/auth/commands_builtin_roles_standalone.js
@@ -7,7 +7,10 @@
* in jstests/auth/lib/commands_lib.js
*/
-import {runAllCommandsBuiltinRoles} from "jstests/auth/lib/commands_builtin_roles.js";
+(function() {
+'use strict';
+
+load('jstests/auth/lib/commands_builtin_roles.js');
const dbPath = MongoRunner.toRealDir("$dataDir/commands_built_in_roles_standalone/");
mkdir(dbPath);
@@ -21,3 +24,4 @@ const opts = {
const conn = MongoRunner.runMongod(opts);
runAllCommandsBuiltinRoles(conn);
MongoRunner.stopMongod(conn);
+})();
diff --git a/jstests/auth/commands_user_defined_roles.js b/jstests/auth/commands_user_defined_roles.js
index e8c2b77e1fc..3c9b33cd54a 100644
--- a/jstests/auth/commands_user_defined_roles.js
+++ b/jstests/auth/commands_user_defined_roles.js
@@ -9,15 +9,6 @@ in jstests/auth/lib/commands_lib.js.
*/
-import {
- adminDbName,
- authCommandsLib,
- authErrCode,
- commandNotSupportedCode
-} from "jstests/auth/lib/commands_lib.js";
-
-load("jstests/libs/fail_point_util.js");
-
// This test involves killing all sessions, which will not work as expected if the kill command is
// sent with an implicit session.
TestData.disableImplicitSessions = true;
@@ -26,6 +17,9 @@ TestData.disableImplicitSessions = true;
var testUser = "userDefinedRolesTestUser";
var testRole = "userDefinedRolesTestRole";
+load("jstests/auth/lib/commands_lib.js");
+load("jstests/libs/fail_point_util.js");
+
function doTestSetup(conn, t, testcase, privileges) {
const admin = conn.getDB('admin');
const runOnDb = conn.getDB(testcase.runOnDb);
diff --git a/jstests/auth/lib/commands_builtin_roles.js b/jstests/auth/lib/commands_builtin_roles.js
index f81a8b2efaa..e478598ce2b 100644
--- a/jstests/auth/lib/commands_builtin_roles.js
+++ b/jstests/auth/lib/commands_builtin_roles.js
@@ -5,21 +5,14 @@
* in jstests/auth/lib/commands_lib.js
*/
-import {
- adminDbName,
- authCommandsLib,
- authErrCode,
- commandNotSupportedCode,
- firstDbName
-} from "jstests/auth/lib/commands_lib.js";
-
-load("jstests/libs/fail_point_util.js");
-
// This test involves killing all sessions, which will not work as expected if the kill command is
// sent with an implicit session.
TestData.disableImplicitSessions = true;
-export const roles = [
+load("jstests/auth/lib/commands_lib.js");
+load("jstests/libs/fail_point_util.js");
+
+var roles = [
{key: "read", role: "read", dbname: firstDbName},
{key: "readLocal", role: {role: "read", db: "local"}, dbname: adminDbName},
{key: "readAnyDatabase", role: "readAnyDatabase", dbname: adminDbName},
@@ -139,7 +132,7 @@ function createUsers(conn) {
assert(adminDb.auth("admin", "password"));
for (var i = 0; i < roles.length; i++) {
- const r = roles[i];
+ r = roles[i];
r.db = conn.getDB(r.dbname);
r.db.createUser({user: "user|" + r.key, pwd: "password", roles: [r.role]});
}
@@ -150,7 +143,7 @@ function createUsers(conn) {
* This tests the authorization of commands with builtin roles for a given server configuration
* represented in 'conn'.
*/
-export function runAllCommandsBuiltinRoles(conn) {
+function runAllCommandsBuiltinRoles(conn) {
const testFunctionImpls = {createUsers: createUsers, runOneTest: runOneTest};
authCommandsLib.runTests(conn, testFunctionImpls);
}
diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js
index d3f69ed3dc6..70d669e968b 100644
--- a/jstests/auth/lib/commands_lib.js
+++ b/jstests/auth/lib/commands_lib.js
@@ -91,10 +91,7 @@ one argument, the connection object.
*/
-import {
- isShardMergeEnabled,
- makeMigrationCertificatesForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
+load("jstests/replsets/libs/tenant_migration_util.js");
// constants
@@ -102,13 +99,13 @@ import {
// when using the roles in 'roles_read', the 'read' role will only be granted on 'firstDbName'. In
// particular, this means that when 'runOnDb' is 'secondDbName', the test user with the 'read' role
// should not be able to perform read operations.
-export const firstDbName = "roles_commands_1";
-export const secondDbName = "roles_commands_2";
-export const adminDbName = "admin";
-export const authErrCode = 13;
-export const commandNotSupportedCode = 115;
-let shard0name = "shard0000";
-const migrationCertificates = makeMigrationCertificatesForTest();
+var firstDbName = "roles_commands_1";
+var secondDbName = "roles_commands_2";
+var adminDbName = "admin";
+var authErrCode = 13;
+var commandNotSupportedCode = 115;
+var shard0name = "shard0000";
+const migrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest();
function buildTenantMigrationCmd(cmd, state) {
const {isShardMergeEnabled} = state;
@@ -206,7 +203,7 @@ load("jstests/libs/uuid_util.js");
// For isReplSet
load("jstests/libs/fixture_helpers.js");
-export const authCommandsLib = {
+var authCommandsLib = {
/************* TEST CASES ****************/
@@ -2227,7 +2224,7 @@ export const authCommandsLib = {
command: {
bulkWrite: 1,
ops: [
- {insert: 0, document: {skey: "MongoDB"}},
+ {insert: 0, document: {skey: "MongoDB"}},
{insert: 1, document: {skey: "MongoDB"}}],
nsInfo: [{ns: firstDbName + ".coll"}, {ns: secondDbName + ".coll1"}]
},
@@ -2243,7 +2240,7 @@ export const authCommandsLib = {
command: {
bulkWrite: 1,
ops: [
- {insert: 0, document: {skey: "MongoDB"}},
+ {insert: 0, document: {skey: "MongoDB"}},
{insert: 1, document: {skey: "MongoDB"}}],
nsInfo: [{ns: firstDbName + ".coll"}, {ns: secondDbName + ".coll1"}],
bypassDocumentValidation: true,
@@ -2253,11 +2250,11 @@ export const authCommandsLib = {
runOnDb: adminDbName,
privileges: [
{
- resource: {db: firstDbName, collection: "coll"},
+ resource: {db: firstDbName, collection: "coll"},
actions: ['insert', 'bypassDocumentValidation']
},
{
- resource: {db: secondDbName, collection: "coll1"},
+ resource: {db: secondDbName, collection: "coll1"},
actions: ['insert', 'bypassDocumentValidation']
}
]
@@ -3820,7 +3817,7 @@ export const authCommandsLib = {
{
testname: "donorStartMigration",
setup: (db) => {
- return {isShardMergeEnabled: isShardMergeEnabled(db)};
+ return {isShardMergeEnabled: TenantMigrationUtil.isShardMergeEnabled(db)};
},
command: (state) => {
return buildTenantMigrationCmd({
@@ -3848,7 +3845,7 @@ export const authCommandsLib = {
{
testname: "recipientSyncData",
setup: (db) => {
- return {isShardMergeEnabled: isShardMergeEnabled(db)};
+ return {isShardMergeEnabled: TenantMigrationUtil.isShardMergeEnabled(db)};
},
command: (state) => {
return buildTenantMigrationCmd({
@@ -3876,7 +3873,7 @@ export const authCommandsLib = {
{
testname: "recipientForgetMigration",
setup: (db) => {
- return {isShardMergeEnabled: isShardMergeEnabled(db)};
+ return {isShardMergeEnabled: TenantMigrationUtil.isShardMergeEnabled(db)};
},
command: (state) => {
return buildTenantMigrationCmd({
@@ -6704,14 +6701,7 @@ export const authCommandsLib = {
* An array of strings. Each string in the array reports
* a particular test error.
*/
- runOneTest: function(conn, t, impls, options) {
- options = options || {};
-
- const isMongos = !!options.isMongos || this.isMongos(conn);
- if (options.shard0Name) {
- shard0name = options.shard0Name;
- }
-
+ runOneTest: function(conn, t, impls, isMongos) {
jsTest.log("Running test: " + t.testname);
if (t.skipTest && t.skipTest(conn)) {
@@ -6763,9 +6753,7 @@ export const authCommandsLib = {
/**
* Top-level test runner
*/
- runTests: function(conn, impls, options) {
- options = options || {};
- options.isMongos = options.isMongos || this.isMongos(conn);
+ runTests: function(conn, impls) {
// impls must provide implementations of a few functions
assert("createUsers" in impls);
@@ -6775,9 +6763,9 @@ export const authCommandsLib = {
var failures = [];
-
+ const isMongos = this.isMongos(conn);
for (var i = 0; i < this.tests.length; i++) {
- const res = this.runOneTest(conn, this.tests[i], impls, options);
+ res = this.runOneTest(conn, this.tests[i], impls, isMongos);
failures = failures.concat(res);
}
@@ -6786,4 +6774,5 @@ export const authCommandsLib = {
});
assert.eq(0, failures.length);
}
+
};
diff --git a/jstests/hooks/run_check_tenant_migration_dbhash.js b/jstests/hooks/run_check_tenant_migration_dbhash.js
index ad50999240a..933c9e6679f 100644
--- a/jstests/hooks/run_check_tenant_migration_dbhash.js
+++ b/jstests/hooks/run_check_tenant_migration_dbhash.js
@@ -1,9 +1,9 @@
// Does a dbhash check between the donor and recipient primaries during a tenant migration.
+'use strict';
-import {
- checkIfRetryableErrorForTenantDbHashCheck,
- checkTenantDBHashes
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+
+load("jstests/replsets/libs/tenant_migration_util.js");
const excludedDBs = ["testTenantMigration"];
const testDBName = "testTenantMigration";
@@ -32,7 +32,7 @@ while (true) {
break;
} catch (e) {
- if (!checkIfRetryableErrorForTenantDbHashCheck(e)) {
+ if (!TenantMigrationUtil.checkIfRetryableErrorForTenantDbHashCheck(e)) {
throw e;
}
print(`Got error: ${tojson(e)}. Retrying ReplSetTest setup on retryable error.`);
@@ -44,10 +44,11 @@ const skipTempCollections = TestData.skipTempCollections ? true : false;
// We assume every db is under the tenant being migrated.
if (TestData.tenantIds) {
TestData.tenantIds.forEach(
- tenantId => checkTenantDBHashes(
+ tenantId => TenantMigrationUtil.checkTenantDBHashes(
{donorRst, recipientRst, tenantId, excludedDBs, skipTempCollections}));
} else {
- checkTenantDBHashes({donorRst, recipientRst, tenantId, excludedDBs, skipTempCollections});
+ TenantMigrationUtil.checkTenantDBHashes(
+ {donorRst, recipientRst, tenantId, excludedDBs, skipTempCollections});
}
// Mark that we have completed the dbhash check.
@@ -59,3 +60,4 @@ if (TestData.useLocalDBForDBCheck) {
assert.commandWorked(donorDB.runCommand(
{insert: dbhashCollName, documents: [{_id: migrationId}], writeConcern: {w: "majority"}}));
}
+})();
diff --git a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js
index 73326dd39ef..c749ba29b5c 100644
--- a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js
+++ b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_abort_on_fcv_change.js
@@ -7,11 +7,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
load("jstests/libs/parallelTester.js"); // for 'Thread'
load("jstests/replsets/rslib.js"); // for 'setLogVerbosity'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -61,3 +65,4 @@ tenantMigrationTest.waitForDonorNodesToReachState(
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
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 8c924efe732..35ed7fd811e 100644
--- a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch.js
+++ b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_donor_recipient_fcv_mismatch.js
@@ -7,12 +7,16 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-load("jstests/libs/fail_point_util.js");
-load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
-load("jstests/libs/parallelTester.js"); // for 'Thread'
+(function() {
+"use strict";
function runTest(downgradeFCV) {
+ load("jstests/libs/fail_point_util.js");
+ load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+ load("jstests/libs/parallelTester.js"); // for 'Thread'
+ load("jstests/replsets/libs/tenant_migration_test.js");
+ load("jstests/replsets/libs/tenant_migration_util.js");
+
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
const tenantId = ObjectId().str;
@@ -60,3 +64,4 @@ runTest(lastContinuousFCV);
if (lastContinuousFCV != lastLTSFCV) {
runTest(lastLTSFCV);
}
+})();
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 4e40d7e5c3f..661b2b6e62d 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
@@ -8,12 +8,16 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-load("jstests/libs/fail_point_util.js");
-load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
-load("jstests/libs/parallelTester.js"); // for 'Thread'
+(function() {
+"use strict";
function runTest(downgradeFCV) {
+ load("jstests/libs/fail_point_util.js");
+ load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+ load("jstests/libs/parallelTester.js"); // for 'Thread'
+ load("jstests/replsets/libs/tenant_migration_test.js");
+ load("jstests/replsets/libs/tenant_migration_util.js");
+
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
const tenantId = ObjectId().str;
@@ -69,3 +73,4 @@ runTest(lastContinuousFCV);
if (lastContinuousFCV != lastLTSFCV) {
runTest(lastLTSFCV);
}
+})();
diff --git a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_recipient_abort_on_fcv_change.js b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_recipient_abort_on_fcv_change.js
index 717cf2e5287..76110d70267 100644
--- a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_recipient_abort_on_fcv_change.js
+++ b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_recipient_abort_on_fcv_change.js
@@ -7,11 +7,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
load("jstests/libs/parallelTester.js"); // for 'Thread'
load("jstests/replsets/rslib.js"); // for 'setLogVerbosity'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -70,3 +74,4 @@ tenantMigrationTest.waitForDonorNodesToReachState(
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js
index 2a88f62439b..9533f8c01d4 100644
--- a/jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js
+++ b/jstests/multiVersion/genericSetFCVUsage/tenant_migration_save_fcv.js
@@ -8,23 +8,20 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- makeX509OptionsForTest,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
-
-load("jstests/libs/fail_point_util.js");
-load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
-load("jstests/libs/parallelTester.js"); // for 'Thread'
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+(function() {
+"use strict";
function runTest(downgradeFCV) {
+ load("jstests/libs/fail_point_util.js");
+ load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+ load("jstests/libs/parallelTester.js"); // for 'Thread'
+ load("jstests/replsets/libs/tenant_migration_test.js");
+ load("jstests/replsets/libs/tenant_migration_util.js");
+
const recipientRst = new ReplSetTest({
nodes: 2,
name: jsTestName() + "_recipient",
- nodeOptions: makeX509OptionsForTest().recipient
+ nodeOptions: TenantMigrationUtil.makeX509OptionsForTest().recipient
});
recipientRst.startSet();
@@ -53,12 +50,13 @@ function runTest(downgradeFCV) {
recipientDb, "fpAfterRecordingRecipientPrimaryStartingFCV", {action: "hang"});
// Start a migration and wait for recipient to hang at the failpoint.
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
hangAfterSavingFCV.wait();
- const isRunningMergeProtocol = isShardMergeEnabled(recipientDb);
+ const isRunningMergeProtocol = TenantMigrationUtil.isShardMergeEnabled(recipientDb);
// Downgrade the FCV for the recipient set.
assert.commandWorked(
@@ -91,3 +89,4 @@ runTest(lastContinuousFCV);
if (lastContinuousFCV != lastLTSFCV) {
runTest(lastLTSFCV);
}
+})();
diff --git a/jstests/noPassthrough/comment_field_passthrough.js b/jstests/noPassthrough/comment_field_passthrough.js
index 7af96170f23..41a1994ba45 100644
--- a/jstests/noPassthrough/comment_field_passthrough.js
+++ b/jstests/noPassthrough/comment_field_passthrough.js
@@ -7,10 +7,12 @@
* requires_sharding,
* ]
*/
+(function() {
-import {authCommandsLib, firstDbName, secondDbName} from "jstests/auth/lib/commands_lib.js";
+"use strict";
-load("jstests/libs/fail_point_util.js"); // Helper to enable/disable failpoints easily.
+load("jstests/auth/lib/commands_lib.js"); // Provides an exhaustive list of commands.
+load("jstests/libs/fail_point_util.js"); // Helper to enable/disable failpoints easily.
const tests = authCommandsLib.tests;
@@ -18,10 +20,13 @@ const tests = authCommandsLib.tests;
const denylistedTests =
["startRecordingTraffic", "stopRecordingTraffic", "addShardToZone", "removeShardFromZone"];
-function runTests(tests, conn, impls, options) {
+function runTests(tests, conn, impls) {
+ const firstDb = conn.getDB(firstDbName);
+ const secondDb = conn.getDB(secondDbName);
+ const isMongos = authCommandsLib.isMongos(conn);
for (const test of tests) {
if (!denylistedTests.includes(test.testname)) {
- authCommandsLib.runOneTest(conn, test, impls, options);
+ authCommandsLib.runOneTest(conn, test, impls, isMongos);
}
}
}
@@ -68,6 +73,8 @@ MongoRunner.stopMongod(conn);
// Test with a sharded cluster. Some tests require the first shard's name acquired from the
// auth commands library to be up-to-date in order to set up correctly.
conn = new ShardingTest({shards: 1, mongos: 2});
-runTests(tests, conn, impls, {shard0name: conn.shard0.shardName});
+shard0name = conn.shard0.shardName;
+runTests(tests, conn, impls);
conn.stop();
+})();
diff --git a/jstests/replsets/libs/tenant_migration_recipient_sync_source.js b/jstests/replsets/libs/tenant_migration_recipient_sync_source.js
index 92e80d462b8..a052b0f5268 100644
--- a/jstests/replsets/libs/tenant_migration_recipient_sync_source.js
+++ b/jstests/replsets/libs/tenant_migration_recipient_sync_source.js
@@ -2,12 +2,11 @@
* Helper functions for running tests related to sync source selection during a tenant migration.
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
-
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load('jstests/replsets/rslib.js');
/**
@@ -19,12 +18,12 @@ load('jstests/replsets/rslib.js');
* 'startApplyingDonorOpTime' stored in the recipient state document. As a result, neither nodes are
* eligible sync sources for the migration.
*/
-export function setUpMigrationSyncSourceTest() {
+const setUpMigrationSyncSourceTest = function() {
const donorRst = new ReplSetTest({
name: `${jsTestName()}_donor`,
nodes: 3,
settings: {chainingAllowed: false},
- nodeOptions: Object.assign(makeX509OptionsForTest().donor, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
setParameter: {
tenantMigrationExcludeDonorHostTimeoutMS: 30 * 1000,
// Allow non-timestamped reads on donor after migration completes for testing.
@@ -154,4 +153,4 @@ export function setUpMigrationSyncSourceTest() {
delayedSecondary,
hangAfterCreatingConnections: hangNewRecipientPrimaryAfterCreatingConnections
};
-}
+};
diff --git a/jstests/replsets/libs/tenant_migration_test.js b/jstests/replsets/libs/tenant_migration_test.js
index 799a27d01ab..c158be4da82 100644
--- a/jstests/replsets/libs/tenant_migration_test.js
+++ b/jstests/replsets/libs/tenant_migration_test.js
@@ -4,33 +4,8 @@
"use strict";
-import {
- makeX509OptionsForTest,
- makeMigrationCertificatesForTest,
- createTenantMigrationRecipientRoleIfNotExist,
- createTenantMigrationDonorRoleIfNotExist,
- runTenantMigrationCommand,
- isMigrationCompleted,
- checkTenantDBHashes,
- getExternalKeys,
- isShardMergeEnabled,
- isNamespaceForTenant,
- getTenantMigrationAccessBlocker,
-} from "jstests/replsets/libs/tenant_migration_util.js";
load("jstests/aggregation/extras/utils.js");
-
-function loadDummyData() {
- const numDocs = 20;
- const testData = [];
- for (let i = 0; i < numDocs; ++i) {
- testData.push({_id: i, x: i});
- }
- return testData;
-}
-
-function buildErrorMsg(migrationId, expectedState, expectedAccessState, configDoc, recipientMtab) {
- return tojson({migrationId, expectedState, expectedAccessState, configDoc, recipientMtab});
-}
+load("jstests/replsets/libs/tenant_migration_util.js");
/**
* This fixture allows the user to optionally pass in a custom ReplSetTest for the donor and
@@ -38,160 +13,138 @@ function buildErrorMsg(migrationId, expectedState, expectedAccessState, configDo
*
* If the caller does not provide their own replica set, a two node replset will be initialized
* instead, with all nodes running the latest version.
+ *
+ * @param {string} [name] the name of the replica sets
+ * @param {boolean} [enableRecipientTesting] whether recipient would actually migrate tenant data
+ * @param {Object} [donorRst] the ReplSetTest instance to adopt for the donor
+ * @param {Object} [recipientRst] the ReplSetTest instance to adopt for the recipient
+ * @param {Object} [sharedOptions] an object that can contain 'nodes' <number>, the number of nodes
+ * each RST will contain, and 'setParameter' <object>, an object with various server parameters.
+ * @param {boolean} [allowDonorReadAfterMigration] whether donor would allow reads after a committed
+ * migration.
+ * @param {boolean} [initiateRstWithHighElectionTimeout] whether donor and recipient replica sets
+ * should be initiated with high election timeout.
+ * @param {boolean} [quickGarbageCollection] whether to set a low garbageCollectionDelayMS.
+ * @param {string} [insertDataForTenant] create dummy data in <tenantId>_test database.
*/
-export class TenantMigrationTest {
- /**
- * Takes in the response to the donarStartMigration command and asserts the command
- * works and the state is 'committed'.
- */
- static assertCommitted(stateRes) {
- assert.commandWorked(stateRes);
- assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted, tojson(stateRes));
- return stateRes;
+function TenantMigrationTest({
+ name = "TenantMigrationTest",
+ enableRecipientTesting = true,
+ donorRst,
+ recipientRst,
+ sharedOptions = {},
+ // Default this to true so it is easier for data consistency checks.
+ allowStaleReadsOnDonor = true,
+ initiateRstWithHighElectionTimeout = true,
+ quickGarbageCollection = false,
+ insertDataForTenant,
+ optimizeMigrations = true,
+}) {
+ const donorPassedIn = (donorRst !== undefined);
+ const recipientPassedIn = (recipientRst !== undefined);
+
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
+ const migrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest();
+
+ const nodes = sharedOptions.nodes || 2;
+ const setParameterOpts = sharedOptions.setParameter || {};
+ if (optimizeMigrations) {
+ // A tenant migration recipient's `OplogFetcher` uses aggregation which does not support
+ // tailable awaitdata cursors. For aggregation commands `OplogFetcher` will default to half
+ // the election timeout (e.g: 5 seconds) between getMores. That wait is largely unnecessary.
+ setParameterOpts["failpoint.setSmallOplogGetMoreMaxTimeMS"] = tojson({"mode": "alwaysOn"});
}
-
- /**
- * Takes in the response to the donarStartMigration command and asserts the command
- * works and the state is 'aborted', with optional errorCode.
- */
- static assertAborted(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;
+ if (quickGarbageCollection) {
+ setParameterOpts.tenantMigrationGarbageCollectionDelayMS = 0;
+ setParameterOpts.ttlMonitorSleepSecs = 1;
}
- /**
- * Make a new TenantMigrationTest
- *
- * @param {string} [name] the name of the replica sets
- * @param {boolean} [enableRecipientTesting] whether recipient would actually migrate tenant
- * data
- * @param {Object} [donorRst] the ReplSetTest instance to adopt for the donor
- * @param {Object} [recipientRst] the ReplSetTest instance to adopt for the recipient
- * @param {Object} [sharedOptions] an object that can contain 'nodes' <number>, the number of
- * nodes each RST will contain, and 'setParameter' <object>, an object with various server
- * parameters.
- * @param {boolean} [allowDonorReadAfterMigration] whether donor would allow reads after a
- * committed migration.
- * @param {boolean} [initiateRstWithHighElectionTimeout] whether donor and recipient replica
- * sets should be initiated with high election timeout.
- * @param {boolean} [quickGarbageCollection] whether to set a low garbageCollectionDelayMS.
- * @param {string} [insertDataForTenant] create dummy data in <tenantId>_test database.
- */
- constructor({
- name = "TenantMigrationTest",
- enableRecipientTesting = true,
- donorRst,
- recipientRst,
- sharedOptions = {},
- // Default this to true so it is easier for data consistency checks.
- allowStaleReadsOnDonor = true,
- initiateRstWithHighElectionTimeout = true,
- quickGarbageCollection = false,
- insertDataForTenant,
- optimizeMigrations = true,
- }) {
- this._donorPassedIn = (donorRst !== undefined);
- this._recipientPassedIn = (recipientRst !== undefined);
- const migrationX509Options = makeX509OptionsForTest();
- const nodes = sharedOptions.nodes || 2;
- const setParameterOpts = sharedOptions.setParameter || {};
- if (optimizeMigrations) {
- // A tenant migration recipient's `OplogFetcher` uses aggregation which does not support
- // tailable awaitdata cursors. For aggregation commands `OplogFetcher` will default to
- // half the election timeout (e.g: 5 seconds) between getMores. That wait is largely
- // unnecessary.
- setParameterOpts["failpoint.setSmallOplogGetMoreMaxTimeMS"] =
- tojson({"mode": "alwaysOn"});
- }
- if (quickGarbageCollection) {
- setParameterOpts.tenantMigrationGarbageCollectionDelayMS = 0;
- setParameterOpts.ttlMonitorSleepSecs = 1;
- }
-
- /**
- * Creates a ReplSetTest instance. The repl set will have 2 nodes if not otherwise
- * specified.
- */
- function performSetUp(isDonor) {
- if (TestData.logComponentVerbosity) {
- setParameterOpts["logComponentVerbosity"] =
- tojsononeline(TestData.logComponentVerbosity);
- }
-
- if (!(isDonor || enableRecipientTesting)) {
- setParameterOpts["failpoint.returnResponseOkForRecipientSyncDataCmd"] =
- tojson({mode: 'alwaysOn'});
- }
-
- if (allowStaleReadsOnDonor) {
- setParameterOpts["failpoint.tenantMigrationDonorAllowsNonTimestampedReads"] =
- tojson({mode: 'alwaysOn'});
- }
-
- let nodeOptions = isDonor ? migrationX509Options.donor : migrationX509Options.recipient;
- nodeOptions["setParameter"] = setParameterOpts;
-
- const rstName = `${name}_${(isDonor ? "donor" : "recipient")}`;
- const rst = new ReplSetTest({name: rstName, nodes, serverless: true, nodeOptions});
- rst.startSet();
- if (initiateRstWithHighElectionTimeout) {
- rst.initiateWithHighElectionTimeout();
- } else {
- rst.initiate();
- }
-
- return rst;
- }
-
- this._donorRst = this._donorPassedIn ? donorRst : performSetUp(true /* isDonor */);
- this._recipientRst =
- this._recipientPassedIn ? recipientRst : performSetUp(false /* isDonor */);
-
- this._donorRst.asCluster(this._donorRst.nodes, () => {
- this._donorRst.getPrimary();
- this._donorRst.awaitReplication();
- createTenantMigrationRecipientRoleIfNotExist(this._donorRst);
- });
-
- this._recipientRst.asCluster(this._recipientRst.nodes, () => {
- this._recipientRst.getPrimary();
- this._recipientRst.awaitReplication();
- createTenantMigrationDonorRoleIfNotExist(this._recipientRst);
- });
-
- // Shard Merge installs TenantRecipientAccessBlockers only for tenants with data, so most
- // tests require some data.
- if (insertDataForTenant !== undefined) {
- this.insertDonorDB(`${insertDataForTenant}_test`, "test");
+ donorRst = donorPassedIn ? donorRst : performSetUp(true /* isDonor */);
+ recipientRst = recipientPassedIn ? recipientRst : performSetUp(false /* isDonor */);
+
+ donorRst.asCluster(donorRst.nodes, () => {
+ donorRst.getPrimary();
+ donorRst.awaitReplication();
+ TenantMigrationUtil.createTenantMigrationRecipientRoleIfNotExist(donorRst);
+ });
+
+ recipientRst.asCluster(recipientRst.nodes, () => {
+ recipientRst.getPrimary();
+ recipientRst.awaitReplication();
+ TenantMigrationUtil.createTenantMigrationDonorRoleIfNotExist(recipientRst);
+ });
+
+ function loadDummyData() {
+ const numDocs = 20;
+ const testData = [];
+ for (let i = 0; i < numDocs; ++i) {
+ testData.push({_id: i, x: i});
}
+ return testData;
}
/**
* Inserts documents into the specified collection on the donor primary.
*/
- insertDonorDB(dbName, collName, data = loadDummyData()) {
+ this.insertDonorDB = function(dbName, collName, data = loadDummyData()) {
jsTestLog(`Inserting data into collection ${collName} of DB ${dbName} on the donor`);
- const primary = this._donorRst.getPrimary();
+ const primary = donorRst.getPrimary();
const db = primary.getDB(dbName);
const res = assert.commandWorked(
db.runCommand({insert: collName, documents: data, writeConcern: {w: 'majority'}}));
jsTestLog(`Inserted with w: majority, opTime ${tojson(res.operationTime)}`);
- }
+ };
/**
* Inserts documents into the specified collection on the recipient primary.
*/
- insertRecipientDB(dbName, collName, data = loadDummyData()) {
+ this.insertRecipientDB = function(dbName, collName, data = loadDummyData()) {
jsTestLog(`Inserting data into collection ${collName} of DB ${dbName} on the recipient`);
- const primary = this._recipientRst.getPrimary();
+ const primary = recipientRst.getPrimary();
const db = primary.getDB(dbName);
const res = assert.commandWorked(
db.runCommand({insert: collName, documents: data, writeConcern: {w: 'majority'}}));
jsTestLog(`Inserted with w: majority, opTime ${tojson(res.operationTime)}`);
+ };
+
+ // Shard Merge installs TenantRecipientAccessBlockers only for tenants with data, so most tests
+ // require some data.
+ if (insertDataForTenant !== undefined) {
+ this.insertDonorDB(`${insertDataForTenant}_test`, "test");
+ }
+
+ /**
+ * Creates a ReplSetTest instance. The repl set will have 2 nodes if not otherwise specified.
+ */
+ function performSetUp(isDonor) {
+ if (TestData.logComponentVerbosity) {
+ setParameterOpts["logComponentVerbosity"] =
+ tojsononeline(TestData.logComponentVerbosity);
+ }
+
+ if (!(isDonor || enableRecipientTesting)) {
+ setParameterOpts["failpoint.returnResponseOkForRecipientSyncDataCmd"] =
+ tojson({mode: 'alwaysOn'});
+ }
+
+ if (allowStaleReadsOnDonor) {
+ setParameterOpts["failpoint.tenantMigrationDonorAllowsNonTimestampedReads"] =
+ tojson({mode: 'alwaysOn'});
+ }
+
+ let nodeOptions = isDonor ? migrationX509Options.donor : migrationX509Options.recipient;
+ nodeOptions["setParameter"] = setParameterOpts;
+
+ const rstName = `${name}_${(isDonor ? "donor" : "recipient")}`;
+ const rst = new ReplSetTest({name: rstName, nodes, serverless: true, nodeOptions});
+ rst.startSet();
+ if (initiateRstWithHighElectionTimeout) {
+ rst.initiateWithHighElectionTimeout();
+ } else {
+ rst.initiate();
+ }
+
+ return rst;
}
/**
@@ -202,8 +155,12 @@ export class TenantMigrationTest {
* returns the command response containing the migration state on the donor after the
* migration has completed.
*/
- runMigration(migrationOpts, opts = {}) {
- const {retryOnRetryableErrors = false, automaticForgetMigration = true} = opts;
+ this.runMigration = function(migrationOpts, opts = {}) {
+ const {
+ retryOnRetryableErrors = false,
+ automaticForgetMigration = true,
+ enableDonorStartMigrationFsync = false
+ } = opts;
const startRes = this.startMigration(migrationOpts, opts);
if (!startRes.ok) {
@@ -221,20 +178,21 @@ export class TenantMigrationTest {
}
return completeRes;
- }
+ };
/**
* Starts a tenant migration by running the 'donorStartMigration' command once.
*
* Returns the result of the 'donorStartMigration' command.
*/
- startMigration(migrationOpts,
- {retryOnRetryableErrors = false, enableDonorStartMigrationFsync = false} = {}) {
+ this.startMigration = function(
+ migrationOpts,
+ {retryOnRetryableErrors = false, enableDonorStartMigrationFsync = false} = {}) {
return this.runDonorStartMigration(migrationOpts, {
retryOnRetryableErrors,
enableDonorStartMigrationFsync,
});
- }
+ };
/**
* Waits for a migration to complete by continuously polling the donor primary with
@@ -243,9 +201,8 @@ export class TenantMigrationTest {
*
* Returns the result of the last 'donorStartMigration' command executed.
*/
- waitForMigrationToComplete(migrationOpts,
- retryOnRetryableErrors = false,
- forgetMigration = false) {
+ this.waitForMigrationToComplete = function(
+ migrationOpts, retryOnRetryableErrors = false, forgetMigration = false) {
// Assert that the migration has already been started.
assert(this.getDonorPrimary().getCollection(TenantMigrationTest.kConfigDonorsNS).findOne({
_id: UUID(migrationOpts.migrationIdString)
@@ -259,7 +216,7 @@ export class TenantMigrationTest {
this.forgetMigration(migrationOpts.migrationIdString, retryOnRetryableErrors);
return donorStartReply;
- }
+ };
/**
* Executes the 'donorStartMigration' command on the donor primary.
@@ -271,23 +228,17 @@ export class TenantMigrationTest {
* If 'retryOnRetryableErrors' is set, this function will retry if the command fails
* with a NotPrimary or network error.
*/
- runDonorStartMigration({
+ this.runDonorStartMigration = function({
migrationIdString,
tenantId,
protocol,
tenantIds,
- recipientConnectionString = this._recipientRst.getURL(),
+ recipientConnectionString = recipientRst.getURL(),
readPreference = {mode: "primary"},
- donorCertificateForRecipient,
- recipientCertificateForDonor,
+ donorCertificateForRecipient = migrationCertificates.donorCertificateForRecipient,
+ recipientCertificateForDonor = migrationCertificates.recipientCertificateForDonor,
},
- opts = {}) {
- const migrationCertificates = makeMigrationCertificatesForTest();
- donorCertificateForRecipient =
- donorCertificateForRecipient || migrationCertificates.donorCertificateForRecipient;
- recipientCertificateForDonor =
- recipientCertificateForDonor || migrationCertificates.recipientCertificateForDonor;
-
+ opts = {}) {
const {
waitForMigrationToComplete = false,
retryOnRetryableErrors = false,
@@ -306,22 +257,22 @@ export class TenantMigrationTest {
protocol
};
- const stateRes = runTenantMigrationCommand(cmdObj, this.getDonorRst(), {
+ const stateRes = TenantMigrationUtil.runTenantMigrationCommand(cmdObj, this.getDonorRst(), {
enableDonorStartMigrationFsync,
retryOnRetryableErrors,
shouldStopFunc: stateRes =>
- (!waitForMigrationToComplete || isMigrationCompleted(stateRes))
+ (!waitForMigrationToComplete || TenantMigrationUtil.isMigrationCompleted(stateRes))
});
// If the migration has been successfully committed, check the db hashes for the tenantId
// between the donor and recipient.
if (stateRes.state === TenantMigrationTest.State.kCommitted) {
- checkTenantDBHashes(
+ TenantMigrationUtil.checkTenantDBHashes(
{donorRst: this.getDonorRst(), recipientRst: this.getRecipientRst(), tenantId});
}
return stateRes;
- }
+ };
/**
* Runs the donorForgetMigration command with the given migrationId and returns the response.
@@ -329,9 +280,10 @@ export class TenantMigrationTest {
* If 'retryOnRetryableErrors' is set, this function will retry if the command fails with a
* NotPrimary or network error.
*/
- forgetMigration(migrationIdString, retryOnRetryableErrors = false) {
+ this.forgetMigration = function(migrationIdString, retryOnRetryableErrors = false) {
const cmdObj = {donorForgetMigration: 1, migrationId: UUID(migrationIdString)};
- const res = runTenantMigrationCommand(cmdObj, this.getDonorRst(), {retryOnRetryableErrors});
+ const res = TenantMigrationUtil.runTenantMigrationCommand(
+ cmdObj, this.getDonorRst(), {retryOnRetryableErrors});
// If the command succeeded, we expect that the migration is marked garbage collectable on
// the donor and the recipient. Check the state docs for expireAt, check that the oplog
@@ -361,7 +313,8 @@ export class TenantMigrationTest {
configDBCollections);
this.getDonorRst().asCluster(donorPrimary, () => {
- const donorKeys = getExternalKeys(donorPrimary, UUID(migrationIdString));
+ const donorKeys =
+ TenantMigrationUtil.getExternalKeys(donorPrimary, UUID(migrationIdString));
if (donorKeys.length) {
donorKeys.forEach(key => {
assert(key.hasOwnProperty("ttlExpiresAt"), tojson(key));
@@ -370,7 +323,8 @@ export class TenantMigrationTest {
});
this.getRecipientRst().asCluster(recipientPrimary, () => {
- const recipientKeys = getExternalKeys(recipientPrimary, UUID(migrationIdString));
+ const recipientKeys =
+ TenantMigrationUtil.getExternalKeys(recipientPrimary, UUID(migrationIdString));
if (recipientKeys.length) {
recipientKeys.forEach(key => {
assert(key.hasOwnProperty("ttlExpiresAt"), tojson(key));
@@ -380,27 +334,29 @@ export class TenantMigrationTest {
}
return res;
- }
+ };
/**
* Runs the donorAbortMigration command with the given migration options and returns the
* response.
*/
- tryAbortMigration(migrationOpts, retryOnRetryableErrors = false) {
+ this.tryAbortMigration = function(migrationOpts, retryOnRetryableErrors = false) {
const cmdObj = {
donorAbortMigration: 1,
migrationId: UUID(migrationOpts.migrationIdString),
};
- return runTenantMigrationCommand(cmdObj, this.getDonorRst(), {retryOnRetryableErrors});
- }
+ return TenantMigrationUtil.runTenantMigrationCommand(
+ cmdObj, this.getDonorRst(), {retryOnRetryableErrors});
+ };
/**
* Asserts that durable and in-memory state for the migration 'migrationId' and 'tenantId' is
* eventually deleted from the given nodes.
*/
- waitForMigrationGarbageCollection(migrationId, tenantId, donorNodes, recipientNodes) {
- donorNodes = donorNodes || this._donorRst.nodes;
- recipientNodes = recipientNodes || this._recipientRst.nodes;
+ this.waitForMigrationGarbageCollection = function(
+ migrationId, tenantId, donorNodes, recipientNodes) {
+ donorNodes = donorNodes || donorRst.nodes;
+ recipientNodes = recipientNodes || recipientRst.nodes;
if (typeof migrationId === "string") {
migrationId = UUID(migrationId);
@@ -429,34 +385,34 @@ export class TenantMigrationTest {
return !mtab;
}, tojson(mtab));
});
- }
+ };
/**
* Asserts that the migration 'migrationId' and 'tenantId' eventually goes to the
* expected state on all the given donor nodes.
*/
- waitForDonorNodesToReachState(nodes, migrationId, tenantId, expectedState) {
+ this.waitForDonorNodesToReachState = function(nodes, migrationId, tenantId, expectedState) {
nodes.forEach(node => {
assert.soon(
() => this.isDonorNodeInExpectedState(node, migrationId, tenantId, expectedState));
});
- }
+ };
/**
* Asserts that the migration 'migrationId' and 'tenantId' is in the expected state on all the
* given donor nodes.
*/
- assertDonorNodesInExpectedState(nodes, migrationId, tenantId, expectedState) {
+ this.assertDonorNodesInExpectedState = function(nodes, migrationId, tenantId, expectedState) {
nodes.forEach(node => {
assert(this.isDonorNodeInExpectedState(node, migrationId, tenantId, expectedState));
});
- }
+ };
/**
* Returns true if the durable and in-memory state for the migration 'migrationId' and
* 'tenantId' is in the expected state, and false otherwise.
*/
- isDonorNodeInExpectedState(node, migrationId, tenantId, expectedState) {
+ this.isDonorNodeInExpectedState = function(node, migrationId, tenantId, expectedState) {
const configDonorsColl =
this.getDonorPrimary().getCollection(TenantMigrationTest.kConfigDonorsNS);
const configDoc = configDonorsColl.findOne({_id: migrationId});
@@ -469,13 +425,18 @@ export class TenantMigrationTest {
: TenantMigrationTest.DonorAccessState.kAborted;
const mtab = this.getTenantMigrationAccessBlocker({donorNode: node, tenantId});
return (mtab.donor.state === expectedAccessState);
+ };
+
+ function buildErrorMsg(
+ migrationId, expectedState, expectedAccessState, configDoc, recipientMtab) {
+ return tojson({migrationId, expectedState, expectedAccessState, configDoc, recipientMtab});
}
/**
* Asserts that the migration 'migrationId' and 'tenantId' eventually goes to the expected state
* on all the given recipient nodes.
*/
- waitForRecipientNodesToReachState(
+ this.waitForRecipientNodesToReachState = function(
nodes, migrationId, tenantId, expectedState, expectedAccessState) {
nodes.forEach(node => {
let result = {};
@@ -494,13 +455,13 @@ export class TenantMigrationTest {
result.recipientMtab);
});
});
- }
+ };
/**
* Asserts that the migration 'migrationId' and 'tenantId' is in the expected state on all the
* given recipient nodes.
*/
- assertRecipientNodesInExpectedState({
+ this.assertRecipientNodesInExpectedState = function({
nodes,
migrationId,
tenantId,
@@ -519,13 +480,13 @@ export class TenantMigrationTest {
result.recipientMtab);
});
});
- }
+ };
/**
* Returns true if the durable and in-memory state for the migration 'migrationId' and
* 'tenantId' is in the expected state, and false otherwise.
*/
- isRecipientNodeInExpectedState({
+ this.isRecipientNodeInExpectedState = function({
node,
migrationId,
tenantId,
@@ -545,17 +506,17 @@ export class TenantMigrationTest {
};
return {value: checkStates(), configDoc: configDoc, recipientMtab: mtab.recipient};
- }
+ };
/**
* Verifies that the documents on the recipient primary are correct.
*/
- verifyRecipientDB(
+ this.verifyRecipientDB = function(
tenantId, dbName, collName, migrationCommitted = true, data = loadDummyData()) {
// We should migrate all data regardless of tenant id for shard merge.
const shouldMigrate = migrationCommitted &&
- (isShardMergeEnabled(this.getRecipientPrimary().getDB("admin")) ||
- isNamespaceForTenant(tenantId, dbName));
+ (TenantMigrationUtil.isShardMergeEnabled(this.getRecipientPrimary().getDB("admin")) ||
+ TenantMigrationUtil.isNamespaceForTenant(tenantId, dbName));
jsTestLog(`Verifying that data in collection ${collName} of DB ${dbName} was ${
(shouldMigrate ? "" : "not")} migrated to the recipient`);
@@ -583,85 +544,108 @@ export class TenantMigrationTest {
const docsReturned = findRes.sort({_id: 1}).toArray();
assert(arrayEq(docsReturned, data),
() => (`${tojson(docsReturned)} is not equal to ${tojson(data)}`));
- }
+ };
/**
* Crafts a tenant database name.
*/
- tenantDB(tenantId, dbName) {
+ this.tenantDB = function(tenantId, dbName) {
return `${tenantId}_${dbName}`;
- }
+ };
/**
* Crafts a database name that does not belong to the tenant.
*/
- nonTenantDB(tenantId, dbName) {
+ this.nonTenantDB = function(tenantId, dbName) {
return `non_${tenantId}_${dbName}`;
- }
+ };
/**
* Returns the TenantMigrationAccessBlocker serverStatus output for the migration or shard merge
* for the given node.
*/
- getTenantMigrationAccessBlocker(obj) {
- return getTenantMigrationAccessBlocker(obj);
- }
+ this.getTenantMigrationAccessBlocker = function(obj) {
+ return TenantMigrationUtil.getTenantMigrationAccessBlocker(obj);
+ };
/**
* Returns the TenantMigrationStats on the node.
*/
- getTenantMigrationStats(node) {
+ this.getTenantMigrationStats = function(node) {
return assert.commandWorked(node.adminCommand({serverStatus: 1})).tenantMigrations;
- }
+ };
/**
* Returns the donor ReplSetTest.
*/
- getDonorRst() {
- return this._donorRst;
- }
+ this.getDonorRst = function() {
+ return donorRst;
+ };
/**
* Returns the recipient ReplSetTest.
*/
- getRecipientRst() {
- return this._recipientRst;
- }
+ this.getRecipientRst = function() {
+ return recipientRst;
+ };
/**
* Returns the donor's primary.
*/
- getDonorPrimary() {
+ this.getDonorPrimary = function() {
return this.getDonorRst().getPrimary();
- }
+ };
/**
* Returns the recipient's primary.
*/
- getRecipientPrimary() {
+ this.getRecipientPrimary = function() {
return this.getRecipientRst().getPrimary();
- }
+ };
/**
* Returns the recipient's connection string.
*/
- getRecipientConnString() {
+ this.getRecipientConnString = function() {
return this.getRecipientRst().getURL();
- }
+ };
/**
* Shuts down the donor and recipient sets, only if they were not passed in as parameters.
* If they were passed in, the test that initialized them should be responsible for shutting
* them down.
*/
- stop() {
- if (!this._donorPassedIn)
- this._donorRst.stopSet();
- if (!this._recipientPassedIn)
- this._recipientRst.stopSet();
- }
+ this.stop = function() {
+ if (!donorPassedIn)
+ donorRst.stopSet();
+ if (!recipientPassedIn)
+ recipientRst.stopSet();
+ };
}
+/**
+ * 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/libs/tenant_migration_util.js b/jstests/replsets/libs/tenant_migration_util.js
index 93926f527ce..9ac12f63737 100644
--- a/jstests/replsets/libs/tenant_migration_util.js
+++ b/jstests/replsets/libs/tenant_migration_util.js
@@ -1,562 +1,586 @@
/**
* Utilities for testing tenant migrations.
*/
-export const kExternalKeysNs = "config.external_validation_keys";
+var TenantMigrationUtil = (function() {
+ load("jstests/replsets/rslib.js");
+
+ const kExternalKeysNs = "config.external_validation_keys";
+
+ /**
+ * Returns true if feature flag 'featureFlagShardMerge' is enabled, false otherwise.
+ */
+ function isShardMergeEnabled(db) {
+ const adminDB = db.getSiblingDB("admin");
+ const flagDoc =
+ assert.commandWorked(adminDB.adminCommand({getParameter: 1, featureFlagShardMerge: 1}));
+ const fcvDoc = assert.commandWorked(
+ adminDB.adminCommand({getParameter: 1, featureCompatibilityVersion: 1}));
+ return flagDoc.hasOwnProperty("featureFlagShardMerge") &&
+ flagDoc.featureFlagShardMerge.value &&
+ MongoRunner.compareBinVersions(fcvDoc.featureCompatibilityVersion.version,
+ flagDoc.featureFlagShardMerge.version) >= 0;
+ }
-/**
- * Returns true if feature flag 'featureFlagShardMerge' is enabled, false otherwise.
- */
-export function isShardMergeEnabled(db) {
- const adminDB = db.getSiblingDB("admin");
- const flagDoc =
- assert.commandWorked(adminDB.adminCommand({getParameter: 1, featureFlagShardMerge: 1}));
- const fcvDoc = assert.commandWorked(
- adminDB.adminCommand({getParameter: 1, featureCompatibilityVersion: 1}));
- return flagDoc.hasOwnProperty("featureFlagShardMerge") && flagDoc.featureFlagShardMerge.value &&
- MongoRunner.compareBinVersions(fcvDoc.featureCompatibilityVersion.version,
- flagDoc.featureFlagShardMerge.version) >= 0;
-}
+ /**
+ * Checks the FCV and the command object passed to see if tenantIds should be set for shard
+ * merge.
+ */
+ function shouldUseMergeTenantIds(db) {
+ const fcvDoc = assert.commandWorked(
+ db.adminCommand({getParameter: 1, featureCompatibilityVersion: 1}));
-/**
- * Checks the FCV and the command object passed to see if tenantIds should be set for shard
- * merge.
- */
-function shouldUseMergeTenantIds(db) {
- const fcvDoc =
- assert.commandWorked(db.adminCommand({getParameter: 1, featureCompatibilityVersion: 1}));
+ return MongoRunner.compareBinVersions(fcvDoc.featureCompatibilityVersion.version, "6.3") >=
+ 0;
+ }
- return MongoRunner.compareBinVersions(fcvDoc.featureCompatibilityVersion.version, "6.3") >= 0;
-}
+ /**
+ * Construct a donorStartMigration command object with protocol: "shard merge" if the feature
+ * flag is enabled.
+ */
+ function donorStartMigrationWithProtocol(cmd, db) {
+ // If we don't pass "protocol" and shard merge is enabled, we set the protocol to
+ // "shard merge". Otherwise, the provided protocol is used, which defaults to
+ // "multitenant migrations" if not provided.
+ if (cmd["protocol"] === undefined && isShardMergeEnabled(db)) {
+ const cmdCopy = Object.assign({}, cmd);
+
+ if (shouldUseMergeTenantIds(db)) {
+ cmdCopy.tenantIds = cmdCopy.tenantIds || [ObjectId(cmdCopy.tenantId)];
+ }
-/**
- * Construct a donorStartMigration command object with protocol: "shard merge" if the feature
- * flag is enabled.
- */
-export function donorStartMigrationWithProtocol(cmd, db) {
- // If we don't pass "protocol" and shard merge is enabled, we set the protocol to
- // "shard merge". Otherwise, the provided protocol is used, which defaults to
- // "multitenant migrations" if not provided.
- if (cmd["protocol"] === undefined && isShardMergeEnabled(db)) {
- const cmdCopy = Object.assign({}, cmd);
-
- if (shouldUseMergeTenantIds(db)) {
- cmdCopy.tenantIds = cmdCopy.tenantIds || [ObjectId(cmdCopy.tenantId)];
+ delete cmdCopy.tenantId;
+ cmdCopy.protocol = "shard merge";
+ return cmdCopy;
+ } else if (cmd["protocol"] == "shard merge") {
+ const cmdCopy = Object.assign({}, cmd);
+ delete cmdCopy.tenantId;
+ return cmdCopy;
+ } else {
+ const cmdCopy = Object.assign({}, cmd);
+ delete cmdCopy.tenantIds;
+ return cmdCopy;
}
+ }
- delete cmdCopy.tenantId;
- cmdCopy.protocol = "shard merge";
- return cmdCopy;
- } else if (cmd["protocol"] == "shard merge") {
- const cmdCopy = Object.assign({}, cmd);
- delete cmdCopy.tenantId;
- return cmdCopy;
- } else {
- const cmdCopy = Object.assign({}, cmd);
- delete cmdCopy.tenantIds;
- return cmdCopy;
+ /**
+ * Returns the external keys for the given migration id.
+ */
+ function getExternalKeys(conn, migrationId) {
+ return conn.getCollection(kExternalKeysNs).find({migrationId}).toArray();
}
-}
-/**
- * Returns the external keys for the given migration id.
- */
-export function getExternalKeys(conn, migrationId) {
- return conn.getCollection(kExternalKeysNs).find({migrationId}).toArray();
-}
+ /**
+ * Returns X509 options for ReplSetTest with the given certificate-key file and CA pem file.
+ */
+ function makeX509Options(certPemFile, caPemFile = "jstests/libs/ca.pem") {
+ return {
+ // When the global sslMode is preferSSL or requireSSL, the transport layer would do the
+ // SSL handshake regardless of the specified sslMode for the connection. So we use a
+ // allowTLS to verify that the donor and recipient use SSL to authenticate to each other
+ // regardless of the global sslMode.
+ tlsMode: "allowTLS",
+ tlsCertificateKeyFile: certPemFile,
+ tlsCAFile: caPemFile,
+ tlsAllowInvalidHostnames: ''
+ };
+ }
-/**
- * Returns X509 options for ReplSetTest with the given certificate-key file and CA pem file.
- */
-export function makeX509Options(certPemFile, caPemFile = "jstests/libs/ca.pem") {
- return {
- // When the global sslMode is preferSSL or requireSSL, the transport layer would do the
- // SSL handshake regardless of the specified sslMode for the connection. So we use a
- // allowTLS to verify that the donor and recipient use SSL to authenticate to each other
- // regardless of the global sslMode.
- tlsMode: "allowTLS",
- tlsCertificateKeyFile: certPemFile,
- tlsCAFile: caPemFile,
- tlsAllowInvalidHostnames: ''
- };
-}
+ /**
+ * Returns an object containing the certificate and private key extracted from the given
+ * pem file.
+ */
+ function getCertificateAndPrivateKey(pemFile) {
+ const lines = cat(pemFile);
+ const certificate =
+ lines.match(new RegExp("-*BEGIN CERTIFICATE-*\\n(.*\\n)*-*END CERTIFICATE-*\\n"))[0];
+ const privateKey =
+ lines.match(new RegExp("-*BEGIN PRIVATE KEY-*\\n(.*\\n)*-*END PRIVATE KEY-*\\n"))[0];
+ return {certificate, privateKey};
+ }
-/**
- * Returns an object containing the certificate and private key extracted from the given
- * pem file.
- */
-export function getCertificateAndPrivateKey(pemFile) {
- const lines = cat(pemFile);
- const certificate =
- lines.match(new RegExp("-*BEGIN CERTIFICATE-*\\n(.*\\n)*-*END CERTIFICATE-*\\n"))[0];
- const privateKey =
- lines.match(new RegExp("-*BEGIN PRIVATE KEY-*\\n(.*\\n)*-*END PRIVATE KEY-*\\n"))[0];
- return {certificate, privateKey};
-}
+ /**
+ * Returns an object containing the donor and recipient ReplSetTest X509 options for tenant
+ * migration testing.
+ */
+ function makeX509OptionsForTest() {
+ return {
+ donor: makeX509Options("jstests/libs/rs0.pem"),
+ recipient: makeX509Options("jstests/libs/rs1.pem")
+ };
+ }
-/**
- * Returns an object containing the donor and recipient ReplSetTest X509 options for tenant
- * migration testing.
- */
-export function makeX509OptionsForTest() {
- return {
- donor: makeX509Options("jstests/libs/rs0.pem"),
- recipient: makeX509Options("jstests/libs/rs1.pem")
- };
-}
+ /**
+ * Returns an object containing the donor and recipient's certificate and private key for
+ * tenant migration testing.
+ */
+ function makeMigrationCertificatesForTest() {
+ return {
+ donorCertificateForRecipient:
+ getCertificateAndPrivateKey("jstests/libs/tenant_migration_donor.pem"),
+ recipientCertificateForDonor:
+ getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem")
+ };
+ }
-/**
- * Returns an object containing the donor and recipient's certificate and private key for
- * tenant migration testing.
- */
-export function makeMigrationCertificatesForTest() {
- return {
- donorCertificateForRecipient:
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_donor.pem"),
- recipientCertificateForDonor:
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem")
- };
-}
+ /**
+ * Takes in the response to the donorStartMigration command and returns true if the state is
+ * "committed" or "aborted".
+ */
+ function isMigrationCompleted(res) {
+ return res.state === "committed" || res.state === "aborted";
+ }
-/**
- * Takes in the response to the donorStartMigration command and returns true if the state is
- * "committed" or "aborted".
- */
-export function isMigrationCompleted(res) {
- return res.state === "committed" || res.state === "aborted";
-}
+ /**
+ * Runs the donorStartMigration command with the given migration options
+ * until the migration commits or aborts, or until the command fails. Returns the last command
+ * response.
+ *
+ * If 'retryOnRetryableErrors' is set, this function will retry if the command fails with a
+ * retryable error.
+ *
+ * Only use when it is necessary to run the donorStartMigration command in its own thread. For
+ * all other use cases, please consider the runMigration() function in the TenantMigrationTest
+ * fixture.
+ */
+ function runMigrationAsync(migrationOpts, donorRstArgs, opts = {}) {
+ const {
+ retryOnRetryableErrors = false,
+ enableDonorStartMigrationFsync = false,
+ } = opts;
+ load("jstests/replsets/libs/tenant_migration_util.js");
+ const donorRst = TenantMigrationUtil.createRst(donorRstArgs, retryOnRetryableErrors);
+
+ const migrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest();
+ const cmdObj = {
+ donorStartMigration: 1,
+ migrationId: UUID(migrationOpts.migrationIdString),
+ tenantId: migrationOpts.tenantId,
+ tenantIds: eval(migrationOpts.tenantIds),
+ recipientConnectionString: migrationOpts.recipientConnString,
+ readPreference: migrationOpts.readPreference || {mode: "primary"},
+ donorCertificateForRecipient: migrationOpts.donorCertificateForRecipient ||
+ migrationCertificates.donorCertificateForRecipient,
+ recipientCertificateForDonor: migrationOpts.recipientCertificateForDonor ||
+ migrationCertificates.recipientCertificateForDonor,
+ };
-/**
- * Runs the donorStartMigration command with the given migration options
- * until the migration commits or aborts, or until the command fails. Returns the last command
- * response.
- *
- * If 'retryOnRetryableErrors' is set, this function will retry if the command fails with a
- * retryable error.
- *
- * Only use when it is necessary to run the donorStartMigration command in its own thread. For
- * all other use cases, please consider the runMigration() function in the TenantMigrationTest
- * fixture.
- */
-export async function runMigrationAsync(migrationOpts, donorRstArgs, opts = {}) {
- const {isMigrationCompleted, makeMigrationCertificatesForTest, runTenantMigrationCommand} =
- await import("jstests/replsets/libs/tenant_migration_util.js");
- load("jstests/replsets/rslib.js"); // createRst
+ return TenantMigrationUtil.runTenantMigrationCommand(cmdObj, donorRst, {
+ retryOnRetryableErrors,
+ enableDonorStartMigrationFsync,
+ shouldStopFunc: TenantMigrationUtil.isMigrationCompleted
+ });
+ }
- const {
- retryOnRetryableErrors = false,
- enableDonorStartMigrationFsync = false,
- } = opts;
-
- const donorRst = createRst(donorRstArgs, retryOnRetryableErrors);
- const migrationCertificates = makeMigrationCertificatesForTest();
- const cmdObj = {
- donorStartMigration: 1,
- migrationId: UUID(migrationOpts.migrationIdString),
- tenantId: migrationOpts.tenantId,
- tenantIds: eval(migrationOpts.tenantIds),
- recipientConnectionString: migrationOpts.recipientConnString,
- readPreference: migrationOpts.readPreference || {mode: "primary"},
- donorCertificateForRecipient: migrationOpts.donorCertificateForRecipient ||
- migrationCertificates.donorCertificateForRecipient,
- recipientCertificateForDonor: migrationOpts.recipientCertificateForDonor ||
- migrationCertificates.recipientCertificateForDonor,
- };
+ /**
+ * Runs the donorForgetMigration command with the given migrationId and returns the response.
+ *
+ * If 'retryOnRetryableErrors' is set, this function will retry if the command fails with a
+ * retryable error.
+ *
+ * Only use when it is necessary to run the donorForgetMigration command in its own thread. For
+ * all other use cases, please consider the forgetMigration() function in the
+ * TenantMigrationTest fixture.
+ */
+ function forgetMigrationAsync(migrationIdString, donorRstArgs, retryOnRetryableErrors = false) {
+ load("jstests/replsets/libs/tenant_migration_util.js");
+ const donorRst = TenantMigrationUtil.createRst(donorRstArgs, retryOnRetryableErrors);
+ const cmdObj = {donorForgetMigration: 1, migrationId: UUID(migrationIdString)};
+ return TenantMigrationUtil.runTenantMigrationCommand(
+ cmdObj, donorRst, {retryOnRetryableErrors});
+ }
- return runTenantMigrationCommand(cmdObj, donorRst, {
- retryOnRetryableErrors,
- enableDonorStartMigrationFsync,
- shouldStopFunc: isMigrationCompleted
- });
-}
+ /**
+ * Runs the donorAbortMigration command with the given migration options and returns the
+ * response.
+ *
+ * If 'retryOnRetryableErrors' is set, this function will retry if the command fails with a
+ * retryable error.
+ *
+ * Only use when it is necessary to run the donorAbortMigration command in its own thread. For
+ * all other use cases, please consider the tryAbortMigration() function in the
+ * TenantMigrationTest fixture.
+ */
+ function tryAbortMigrationAsync(migrationOpts, donorRstArgs, retryOnRetryableErrors = false) {
+ load("jstests/replsets/libs/tenant_migration_util.js");
+ const donorRst = TenantMigrationUtil.createRst(donorRstArgs, retryOnRetryableErrors);
+ const cmdObj = {
+ donorAbortMigration: 1,
+ migrationId: UUID(migrationOpts.migrationIdString),
+ };
+ return TenantMigrationUtil.runTenantMigrationCommand(
+ cmdObj, donorRst, {retryOnRetryableErrors});
+ }
-/**
- * Runs the donorForgetMigration command with the given migrationId and returns the response.
- *
- * If 'retryOnRetryableErrors' is set, this function will retry if the command fails with a
- * retryable error.
- *
- * Only use when it is necessary to run the donorForgetMigration command in its own thread. For
- * all other use cases, please consider the forgetMigration() function in the
- * TenantMigrationTest fixture.
- */
-export async function forgetMigrationAsync(
- migrationIdString, donorRstArgs, retryOnRetryableErrors = false) {
- const {runTenantMigrationCommand} =
- await import("jstests/replsets/libs/tenant_migration_util.js");
- load("jstests/replsets/rslib.js"); // createRst
+ /**
+ * Runs the given tenant migration command against the primary of the given replica set until
+ * the command succeeds or fails with a non-retryable error (if 'retryOnRetryableErrors' is
+ * true) or until 'shouldStopFunc' returns true. Returns the last response.
+ */
+ function runTenantMigrationCommand(cmdObj, rst, {
+ retryOnRetryableErrors = false,
+ shouldStopFunc = () => true,
+ enableDonorStartMigrationFsync = false
+ } = {}) {
+ let primary = rst.getPrimary();
+ let localCmdObj = cmdObj;
+ let run = () => primary.adminCommand(localCmdObj);
+ if (Object.keys(cmdObj)[0] === "donorStartMigration") {
+ run = () => {
+ const adminDB = primary.getDB("admin");
+ localCmdObj = donorStartMigrationWithProtocol(cmdObj, adminDB);
+ if (enableDonorStartMigrationFsync) {
+ rst.awaitLastOpCommitted();
+ assert.commandWorked(primary.adminCommand({fsync: 1}));
+ }
+ return primary.adminCommand(localCmdObj);
+ };
+ }
- const donorRst = createRst(donorRstArgs, retryOnRetryableErrors);
- const cmdObj = {donorForgetMigration: 1, migrationId: UUID(migrationIdString)};
- return runTenantMigrationCommand(cmdObj, donorRst, {retryOnRetryableErrors});
-}
+ let res;
+ assert.soon(() => {
+ try {
+ // Note: assert.commandWorked() considers command responses with embedded
+ // writeErrors and WriteConcernErrors as a failure even if the command returned
+ // "ok: 1". And, admin commands(like, donorStartMigration)
+ // doesn't generate writeConcernErros or WriteErrors. So, it's safe to wrap up
+ // run() with assert.commandWorked() here. However, in few scenarios, like
+ // Mongo.prototype.recordRerouteDueToTenantMigration(), it's not safe to wrap up
+ // run() with commandWorked() as retrying on retryable writeConcernErrors can
+ // cause the retry attempt to fail with writeErrors.
+ res = undefined;
+ res = run();
+ assert.commandWorked(res);
+ return shouldStopFunc(res);
+ } catch (e) {
+ if (retryOnRetryableErrors && isRetryableError(e)) {
+ jsTestLog(`Retryable error runing runTenantMigrationCommand. Command: ${
+ tojson(localCmdObj)}, Error: ${tojson(e)}`);
+
+ primary = rst.getPrimary();
+ return false;
+ }
+ jsTestLog(`Error running runTenantMigrationCommand. Command: ${
+ tojson(localCmdObj)}, Error: ${tojson(e)}`);
-/**
- * Runs the donorAbortMigration command with the given migration options and returns the
- * response.
- *
- * If 'retryOnRetryableErrors' is set, this function will retry if the command fails with a
- * retryable error.
- *
- * Only use when it is necessary to run the donorAbortMigration command in its own thread. For
- * all other use cases, please consider the tryAbortMigration() function in the
- * TenantMigrationTest fixture.
- */
-export async function tryAbortMigrationAsync(
- migrationOpts, donorRstArgs, retryOnRetryableErrors = false) {
- const {runTenantMigrationCommand} =
- await import("jstests/replsets/libs/tenant_migration_util.js");
- load("jstests/replsets/rslib.js"); // createRst
-
- const donorRst = createRst(donorRstArgs, retryOnRetryableErrors);
- const cmdObj = {
- donorAbortMigration: 1,
- migrationId: UUID(migrationOpts.migrationIdString),
- };
- return runTenantMigrationCommand(cmdObj, donorRst, {retryOnRetryableErrors});
-}
+ // If res is defined, return true to exit assert.soon and return res to the caller.
+ // Otherwise rethrow e to propagate it to the caller.
+ if (res)
+ return true;
-/**
- * Runs the given tenant migration command against the primary of the given replica set until
- * the command succeeds or fails with a non-retryable error (if 'retryOnRetryableErrors' is
- * true) or until 'shouldStopFunc' returns true. Returns the last response.
- */
-export function runTenantMigrationCommand(cmdObj, rst, {
- retryOnRetryableErrors = false,
- shouldStopFunc = () => true,
- enableDonorStartMigrationFsync = false
-} = {}) {
- let primary = rst.getPrimary();
- let localCmdObj = cmdObj;
- let run = () => primary.adminCommand(localCmdObj);
- if (Object.keys(cmdObj)[0] === "donorStartMigration") {
- run = () => {
- const adminDB = primary.getDB("admin");
- localCmdObj = donorStartMigrationWithProtocol(cmdObj, adminDB);
- if (enableDonorStartMigrationFsync) {
- rst.awaitLastOpCommitted();
- assert.commandWorked(primary.adminCommand({fsync: 1}));
+ throw e;
}
- return primary.adminCommand(localCmdObj);
- };
+ });
+ return res;
}
- let res;
- assert.soon(() => {
- try {
- // Note: assert.commandWorked() considers command responses with embedded
- // writeErrors and WriteConcernErrors as a failure even if the command returned
- // "ok: 1". And, admin commands(like, donorStartMigration)
- // doesn't generate writeConcernErros or WriteErrors. So, it's safe to wrap up
- // run() with assert.commandWorked() here. However, in few scenarios, like
- // Mongo.prototype.recordRerouteDueToTenantMigration(), it's not safe to wrap up
- // run() with commandWorked() as retrying on retryable writeConcernErrors can
- // cause the retry attempt to fail with writeErrors.
- res = undefined;
- res = run();
- assert.commandWorked(res);
- return shouldStopFunc(res);
- } catch (e) {
- if (retryOnRetryableErrors && isRetryableError(e)) {
- jsTestLog(`Retryable error running runTenantMigrationCommand. Command: ${
- tojson(localCmdObj)}, Error: ${tojson(e)}`);
-
- primary = rst.getPrimary();
- return false;
- }
- jsTestLog(`Error running runTenantMigrationCommand. Command: ${
- tojson(localCmdObj)}, Error: ${tojson(e)}`);
+ const ServerlessLockType =
+ {None: 0, ShardSplitDonor: 1, TenantMigrationDonor: 2, TenantMigrationRecipient: 3};
- // If res is defined, return true to exit assert.soon and return res to the caller.
- // Otherwise rethrow e to propagate it to the caller.
- if (res)
- return true;
+ /**
+ * Return the active serverless operation lock, if one is acquired.
+ */
+ function getServerlessOperationLock(node) {
+ return assert.commandWorked(node.adminCommand({serverStatus: 1, serverless: 1}))
+ .serverless.operationLock;
+ }
- throw e;
+ /**
+ * Returns the TenantMigrationAccessBlocker serverStatus output for the multi-tenant migration
+ * or shard merge for the given node.
+ */
+ function getTenantMigrationAccessBlocker({donorNode, recipientNode, tenantId}) {
+ assert(donorNode || recipientNode, "missing required parameter donorNode or recipientNode");
+ if (donorNode && recipientNode) {
+ throw new Error("please specify either 'donorNode' or 'recipientNode' but not both");
}
- });
- return res;
-}
-export const ServerlessLockType = {
- None: 0,
- ShardSplitDonor: 1,
- TenantMigrationDonor: 2,
- TenantMigrationRecipient: 3
-};
+ const node = donorNode || recipientNode;
+ const {tenantMigrationAccessBlocker} =
+ assert.commandWorked(node.adminCommand({serverStatus: 1}));
-/**
- * Return the active serverless operation lock, if one is acquired.
- */
-export function getServerlessOperationLock(node) {
- return assert.commandWorked(node.adminCommand({serverStatus: 1, serverless: 1}))
- .serverless.operationLock;
-}
+ if (tenantMigrationAccessBlocker && tenantId &&
+ tenantMigrationAccessBlocker.hasOwnProperty(tenantId)) {
+ return tenantMigrationAccessBlocker[tenantId];
+ }
-/**
- * Returns the TenantMigrationAccessBlocker serverStatus output for the multi-tenant migration
- * or shard merge for the given node.
- */
-export function getTenantMigrationAccessBlocker({donorNode, recipientNode, tenantId}) {
- assert(donorNode || recipientNode, "missing required parameter donorNode or recipientNode");
- if (donorNode && recipientNode) {
- throw new Error("please specify either 'donorNode' or 'recipientNode' but not both");
+ return tenantMigrationAccessBlocker;
}
- const node = donorNode || recipientNode;
- const {tenantMigrationAccessBlocker} =
- assert.commandWorked(node.adminCommand({serverStatus: 1}));
-
- if (tenantMigrationAccessBlocker && tenantId &&
- tenantMigrationAccessBlocker.hasOwnProperty(tenantId)) {
- return tenantMigrationAccessBlocker[tenantId];
+ /**
+ * Returns all TenantMigrationAccessBlocker serverStatus output for the multi-tenant migration
+ * or shard merge associated with the provided tenantId for the given nodes, filtering out any
+ * empty entries.
+ */
+ function getTenantMigrationAccessBlockers({donorNodes = [], recipientNodes = [], tenantId}) {
+ const recipientAccessBlockers = recipientNodes.reduce((acc, node) => {
+ const accessBlocker = getTenantMigrationAccessBlocker({recipientNode: node, tenantId});
+ return accessBlocker && accessBlocker.recipient ? acc.concat(accessBlocker.recipient)
+ : acc;
+ }, []);
+
+ const donorAccessBlockers = donorNodes.reduce((acc, node) => {
+ const accessBlocker = getTenantMigrationAccessBlocker({donorNode: node, tenantId});
+ return accessBlocker && accessBlocker.donor ? acc.concat(accessBlocker.donor) : acc;
+ }, []);
+
+ return {recipientAccessBlockers, donorAccessBlockers};
}
- return tenantMigrationAccessBlocker;
-}
-
-/**
- * Returns all TenantMigrationAccessBlocker serverStatus output for the multi-tenant migration
- * or shard merge associated with the provided tenantId for the given nodes, filtering out any
- * empty entries.
- */
-export function getTenantMigrationAccessBlockers({donorNodes = [], recipientNodes = [], tenantId}) {
- const recipientAccessBlockers = recipientNodes.reduce((acc, node) => {
- const accessBlocker = getTenantMigrationAccessBlocker({recipientNode: node, tenantId});
- return accessBlocker && accessBlocker.recipient ? acc.concat(accessBlocker.recipient) : acc;
- }, []);
-
- const donorAccessBlockers = donorNodes.reduce((acc, node) => {
- const accessBlocker = getTenantMigrationAccessBlocker({donorNode: node, tenantId});
- return accessBlocker && accessBlocker.donor ? acc.concat(accessBlocker.donor) : acc;
- }, []);
-
- return {recipientAccessBlockers, donorAccessBlockers};
-}
-
-/**
- * Returns the number of reads on the given donor node that were blocked due to tenant migration
- * for the given tenant.
- */
-export function getNumBlockedReads(donorNode, tenantId) {
- const mtab = getTenantMigrationAccessBlocker({donorNode, tenantId});
- if (!mtab) {
- return 0;
+ /**
+ * Returns the number of reads on the given donor node that were blocked due to tenant migration
+ * for the given tenant.
+ */
+ function getNumBlockedReads(donorNode, tenantId) {
+ const mtab = getTenantMigrationAccessBlocker({donorNode, tenantId});
+ if (!mtab) {
+ return 0;
+ }
+ return mtab.donor.numBlockedReads;
}
- return mtab.donor.numBlockedReads;
-}
-/**
- * Returns the number of writes on the given donor node that were blocked due to tenant
- * migration for the given tenant.
- */
-export function getNumBlockedWrites(donorNode, tenantId) {
- const mtab = getTenantMigrationAccessBlocker({donorNode, tenantId});
- if (!mtab) {
- return 0;
+ /**
+ * Returns the number of writes on the given donor node that were blocked due to tenant
+ * migration for the given tenant.
+ */
+ function getNumBlockedWrites(donorNode, tenantId) {
+ const mtab = getTenantMigrationAccessBlocker({donorNode, tenantId});
+ if (!mtab) {
+ return 0;
+ }
+ return mtab.donor.numBlockedWrites;
}
- return mtab.donor.numBlockedWrites;
-}
-/**
- * Determines if a database name belongs to the given tenant.
- */
-export function isNamespaceForTenant(tenantId, dbName) {
- return dbName.startsWith(`${tenantId}_`);
-}
+ /**
+ * Determines if a database name belongs to the given tenant.
+ */
+ function isNamespaceForTenant(tenantId, dbName) {
+ return dbName.startsWith(`${tenantId}_`);
+ }
-/**
- * Compares the hashes for DBs that belong to the specified tenant between the donor and
- * recipient primaries.
- */
-export function checkTenantDBHashes({
- donorRst,
- recipientRst,
- tenantId,
- excludedDBs = [],
- msgPrefix = 'checkTenantDBHashes',
- ignoreUUIDs = false,
- skipTempCollections = false
-}) {
- // Always skip db hash checks for the config, admin, and local database.
- excludedDBs = [...excludedDBs, "config", "admin", "local"];
-
- while (true) {
- try {
- const donorPrimaryConn = donorRst.getPrimary();
- const recipientPrimaryConn = recipientRst.getPrimary();
-
- // Allows listCollections and listIndexes on donor after migration for consistency
- // checks.
- const donorAllowsReadsAfterMigration =
- assert
- .commandWorked(donorPrimaryConn.adminCommand({
- getParameter: 1,
- "failpoint.tenantMigrationDonorAllowsNonTimestampedReads": 1
- }))["failpoint.tenantMigrationDonorAllowsNonTimestampedReads"]
- .mode;
- // Only turn on the failpoint if it is not already.
- if (!donorAllowsReadsAfterMigration) {
- assert.commandWorked(donorPrimaryConn.adminCommand({
- configureFailPoint: "tenantMigrationDonorAllowsNonTimestampedReads",
- mode: "alwaysOn"
- }));
- }
+ /**
+ * Compares the hashes for DBs that belong to the specified tenant between the donor and
+ * recipient primaries.
+ */
+ function checkTenantDBHashes({
+ donorRst,
+ recipientRst,
+ tenantId,
+ excludedDBs = [],
+ msgPrefix = 'checkTenantDBHashes',
+ ignoreUUIDs = false,
+ skipTempCollections = false
+ }) {
+ // Always skip db hash checks for the config, admin, and local database.
+ excludedDBs = [...excludedDBs, "config", "admin", "local"];
+
+ while (true) {
+ try {
+ const donorPrimaryConn = donorRst.getPrimary();
+ const recipientPrimaryConn = recipientRst.getPrimary();
+
+ // Allows listCollections and listIndexes on donor after migration for consistency
+ // checks.
+ const donorAllowsReadsAfterMigration =
+ assert
+ .commandWorked(donorPrimaryConn.adminCommand({
+ getParameter: 1,
+ "failpoint.tenantMigrationDonorAllowsNonTimestampedReads": 1
+ }))["failpoint.tenantMigrationDonorAllowsNonTimestampedReads"]
+ .mode;
+ // Only turn on the failpoint if it is not already.
+ if (!donorAllowsReadsAfterMigration) {
+ assert.commandWorked(donorPrimaryConn.adminCommand({
+ configureFailPoint: "tenantMigrationDonorAllowsNonTimestampedReads",
+ mode: "alwaysOn"
+ }));
+ }
- // Filter out all dbs that don't belong to the tenant.
- let combinedDBNames =
- [...donorPrimaryConn.getDBNames(), ...recipientPrimaryConn.getDBNames()];
- combinedDBNames =
- combinedDBNames.filter(dbName => (isNamespaceForTenant(tenantId, dbName) &&
- !excludedDBs.includes(dbName)));
- combinedDBNames = new Set(combinedDBNames);
-
- for (const dbName of combinedDBNames) {
- // Pass in an empty array for the secondaries, since we only wish to compare
- // the DB hashes between the donor and recipient primary in this test.
- const donorDBHash = assert.commandWorked(
- donorRst.getHashes(dbName, [], skipTempCollections).primary);
- const recipientDBHash = assert.commandWorked(
- recipientRst.getHashes(dbName, [], skipTempCollections).primary);
-
- const donorCollections = Object.keys(donorDBHash.collections);
- const donorCollInfos = new CollInfos(donorPrimaryConn, 'donorPrimary', dbName);
- donorCollInfos.filter(donorCollections);
-
- const recipientCollections = Object.keys(recipientDBHash.collections);
- const recipientCollInfos =
- new CollInfos(recipientPrimaryConn, 'recipientPrimary', dbName);
- recipientCollInfos.filter(recipientCollections);
-
- print(`checking db hash for tenant '${tenantId}' between donor: ${
- donorPrimaryConn.host}, and recipient: ${recipientPrimaryConn.host}`);
-
- const collectionPrinted = new Set();
- const success = DataConsistencyChecker.checkDBHash(donorDBHash,
- donorCollInfos,
- recipientDBHash,
- recipientCollInfos,
- msgPrefix,
- ignoreUUIDs,
- true, /* syncingHasIndexes */
- collectionPrinted);
- if (!success) {
- print(`checkTenantDBHashes dumping donor and recipient primary oplogs`);
- donorRst.dumpOplog(donorPrimaryConn, {}, 100);
- recipientRst.dumpOplog(recipientPrimaryConn, {}, 100);
+ // Filter out all dbs that don't belong to the tenant.
+ let combinedDBNames =
+ [...donorPrimaryConn.getDBNames(), ...recipientPrimaryConn.getDBNames()];
+ combinedDBNames =
+ combinedDBNames.filter(dbName => (isNamespaceForTenant(tenantId, dbName) &&
+ !excludedDBs.includes(dbName)));
+ combinedDBNames = new Set(combinedDBNames);
+
+ for (const dbName of combinedDBNames) {
+ // Pass in an empty array for the secondaries, since we only wish to compare
+ // the DB hashes between the donor and recipient primary in this test.
+ const donorDBHash = assert.commandWorked(
+ donorRst.getHashes(dbName, [], skipTempCollections).primary);
+ const recipientDBHash = assert.commandWorked(
+ recipientRst.getHashes(dbName, [], skipTempCollections).primary);
+
+ const donorCollections = Object.keys(donorDBHash.collections);
+ const donorCollInfos = new CollInfos(donorPrimaryConn, 'donorPrimary', dbName);
+ donorCollInfos.filter(donorCollections);
+
+ const recipientCollections = Object.keys(recipientDBHash.collections);
+ const recipientCollInfos =
+ new CollInfos(recipientPrimaryConn, 'recipientPrimary', dbName);
+ recipientCollInfos.filter(recipientCollections);
+
+ print(`checking db hash for tenant '${tenantId}' between donor: ${
+ donorPrimaryConn.host}, and recipient: ${recipientPrimaryConn.host}`);
+
+ const collectionPrinted = new Set();
+ const success = DataConsistencyChecker.checkDBHash(donorDBHash,
+ donorCollInfos,
+ recipientDBHash,
+ recipientCollInfos,
+ msgPrefix,
+ ignoreUUIDs,
+ true, /* syncingHasIndexes */
+ collectionPrinted);
+ if (!success) {
+ print(`checkTenantDBHashes dumping donor and recipient primary oplogs`);
+ donorRst.dumpOplog(donorPrimaryConn, {}, 100);
+ recipientRst.dumpOplog(recipientPrimaryConn, {}, 100);
+ }
+ assert(success, 'dbhash mismatch between donor and recipient primaries');
}
- assert(success, 'dbhash mismatch between donor and recipient primaries');
- }
- // Reset failpoint on the donor after consistency checks if it wasn't enabled
- // before.
- if (!donorAllowsReadsAfterMigration) {
- // We unset the failpoint for every node in case there was a failover at some
- // point before this.
- donorRst.nodes.forEach(node => {
- assert.commandWorked(node.adminCommand({
- configureFailPoint: "tenantMigrationDonorAllowsNonTimestampedReads",
- mode: "off"
- }));
- });
- }
+ // Reset failpoint on the donor after consistency checks if it wasn't enabled
+ // before.
+ if (!donorAllowsReadsAfterMigration) {
+ // We unset the failpoint for every node in case there was a failover at some
+ // point before this.
+ donorRst.nodes.forEach(node => {
+ assert.commandWorked(node.adminCommand({
+ configureFailPoint: "tenantMigrationDonorAllowsNonTimestampedReads",
+ mode: "off"
+ }));
+ });
+ }
- break;
- } catch (e) {
- if (!checkIfRetryableErrorForTenantDbHashCheck(e)) {
- throw e;
- } else {
- print(`Got error: ${tojson(e)}. Failover occurred during tenant dbhash check,` +
- ` retrying tenant dbhash check.`);
+ break;
+ } catch (e) {
+ if (!checkIfRetryableErrorForTenantDbHashCheck(e)) {
+ throw e;
+ } else {
+ print(`Got error: ${tojson(e)}. Failover occurred during tenant dbhash check,` +
+ ` retrying tenant dbhash check.`);
+ }
}
}
}
-}
-/**
- * Creates a role for tenant migration donor if it doesn't exist.
- */
-export function createTenantMigrationDonorRoleIfNotExist(rst) {
- const adminDB = rst.getPrimary().getDB("admin");
+ /**
+ * Creates a role for tenant migration donor if it doesn't exist.
+ */
+ function createTenantMigrationDonorRoleIfNotExist(rst) {
+ const adminDB = rst.getPrimary().getDB("admin");
+
+ if (roleExists(adminDB, "tenantMigrationDonorRole")) {
+ return;
+ }
- if (roleExists(adminDB, "tenantMigrationDonorRole")) {
- return;
+ assert.commandWorked(adminDB.runCommand({
+ createRole: "tenantMigrationDonorRole",
+ privileges: [
+ {resource: {cluster: true}, actions: ["runTenantMigration"]},
+ {resource: {db: "admin", collection: "system.keys"}, actions: ["find"]}
+ ],
+ roles: []
+ }));
}
- assert.commandWorked(adminDB.runCommand({
- createRole: "tenantMigrationDonorRole",
- privileges: [
- {resource: {cluster: true}, actions: ["runTenantMigration"]},
- {resource: {db: "admin", collection: "system.keys"}, actions: ["find"]}
- ],
- roles: []
- }));
-}
+ /**
+ * Checks if an error gotten while doing a tenant dbhash check is retryable.
+ */
+ function checkIfRetryableErrorForTenantDbHashCheck(error) {
+ // Due to the shell not propagating error codes correctly, if we get any of the following
+ // error messages, we can retry the operation.
+ const retryableErrorMessages = [
+ "The server is in quiesce mode and will shut down",
+ "can't connect to new replica set primary"
+ ];
+
+ // The following shell helper methods check if the error message contains some
+ // notion of retryability. This is in case the error does not contain an error code.
+ return isRetryableError(error) || isNetworkError(error) ||
+ // If there's a failover while we're running a dbhash check, the elected secondary might
+ // not have set the tenantMigrationDonorAllowsNonTimestampedReads failpoint, which means
+ // that the listCollections command run when we call CollInfos would throw a
+ // TenantMigrationCommitted error.
+ ErrorCodes.isTenantMigrationError(error.code) ||
+ // If there's a failover as we're creating a ReplSetTest from either the donor or
+ // recipient URLs, it's possible to get back a NotYetInitialized error, so we want to
+ // retry creating the ReplSetTest.
+ error.code == ErrorCodes.NotYetInitialized ||
+ // TODO (SERVER-54026): Remove check for error message once the shell correctly
+ // propagates the error code.
+ retryableErrorMessages.some(msg => error.message.includes(msg));
+ }
-/**
- * Checks if an error gotten while doing a tenant dbhash check is retryable.
- */
-export function checkIfRetryableErrorForTenantDbHashCheck(error) {
- // Due to the shell not propagating error codes correctly, if we get any of the following
- // error messages, we can retry the operation.
- const retryableErrorMessages = [
- "The server is in quiesce mode and will shut down",
- "can't connect to new replica set primary"
- ];
-
- // The following shell helper methods check if the error message contains some
- // notion of retryability. This is in case the error does not contain an error code.
- return isRetryableError(error) || isNetworkError(error) ||
- // If there's a failover while we're running a dbhash check, the elected secondary might
- // not have set the tenantMigrationDonorAllowsNonTimestampedReads failpoint, which means
- // that the listCollections command run when we call CollInfos would throw a
- // TenantMigrationCommitted error.
- ErrorCodes.isTenantMigrationError(error.code) ||
- // If there's a failover as we're creating a ReplSetTest from either the donor or
- // recipient URLs, it's possible to get back a NotYetInitialized error, so we want to
- // retry creating the ReplSetTest.
- error.code == ErrorCodes.NotYetInitialized ||
- // TODO (SERVER-54026): Remove check for error message once the shell correctly
- // propagates the error code.
- retryableErrorMessages.some(msg => error.message.includes(msg));
-}
+ /**
+ * Creates a role for tenant migration recipient if it doesn't exist.
+ */
+ function createTenantMigrationRecipientRoleIfNotExist(rst) {
+ const adminDB = rst.getPrimary().getDB("admin");
-/**
- * Creates a role for tenant migration recipient if it doesn't exist.
- */
-export function createTenantMigrationRecipientRoleIfNotExist(rst) {
- const adminDB = rst.getPrimary().getDB("admin");
+ if (roleExists(adminDB, "tenantMigrationRecipientRole")) {
+ return;
+ }
- if (roleExists(adminDB, "tenantMigrationRecipientRole")) {
- return;
+ assert.commandWorked(adminDB.runCommand({
+ createRole: "tenantMigrationRecipientRole",
+ privileges: [
+ {
+ resource: {cluster: true},
+ actions: ["listDatabases", "useUUID", "advanceClusterTime"]
+ },
+ {resource: {db: "", collection: ""}, actions: ["listCollections"]},
+ {
+ resource: {anyResource: true},
+ actions: ["dbStats", "collStats", "find", "listIndexes"]
+ }
+ ],
+ roles: []
+ }));
}
- assert.commandWorked(adminDB.runCommand({
- createRole: "tenantMigrationRecipientRole",
- privileges: [
- {
- resource: {cluster: true},
- actions: ["listDatabases", "useUUID", "advanceClusterTime"]
- },
- {resource: {db: "", collection: ""}, actions: ["listCollections"]},
- {
- resource: {anyResource: true},
- actions: ["dbStats", "collStats", "find", "listIndexes"]
+ /**
+ * Returns true if the given database role already exists.
+ */
+ function roleExists(db, roleName) {
+ const roles = db.getRoles({rolesInfo: 1, showPrivileges: false, showBuiltinRoles: false});
+ const fullRoleName = `${db.getName()}.${roleName}`;
+ for (let role of roles) {
+ if (role._id == fullRoleName) {
+ return true;
}
- ],
- roles: []
- }));
-}
-
-/**
- * Returns true if the given database role already exists.
- */
-export function roleExists(db, roleName) {
- const roles = db.getRoles({rolesInfo: 1, showPrivileges: false, showBuiltinRoles: false});
- const fullRoleName = `${db.getName()}.${roleName}`;
- for (let role of roles) {
- if (role._id == fullRoleName) {
- return true;
}
+ return false;
}
- return false;
-}
+
+ return {
+ kExternalKeysNs,
+ isShardMergeEnabled,
+ donorStartMigrationWithProtocol,
+ getExternalKeys,
+ runMigrationAsync,
+ forgetMigrationAsync,
+ tryAbortMigrationAsync,
+ createRstArgs,
+ createRst,
+ runTenantMigrationCommand,
+ getCertificateAndPrivateKey,
+ makeX509Options,
+ makeMigrationCertificatesForTest,
+ makeX509OptionsForTest,
+ isMigrationCompleted,
+ ServerlessLockType,
+ getServerlessOperationLock,
+ getTenantMigrationAccessBlocker,
+ getTenantMigrationAccessBlockers,
+ getNumBlockedReads,
+ getNumBlockedWrites,
+ isNamespaceForTenant,
+ checkTenantDBHashes,
+ createTenantMigrationDonorRoleIfNotExist,
+ createTenantMigrationRecipientRoleIfNotExist,
+ roleExists,
+ checkIfRetryableErrorForTenantDbHashCheck
+ };
+})();
diff --git a/jstests/replsets/shard_merge_enabled.js b/jstests/replsets/shard_merge_enabled.js
index 4796e2646f7..dabb0ca7116 100644
--- a/jstests/replsets/shard_merge_enabled.js
+++ b/jstests/replsets/shard_merge_enabled.js
@@ -3,10 +3,10 @@
* @tags: [featureFlagShardMerge]
*/
-import {
- isShardMergeEnabled,
- makeMigrationCertificatesForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/fail_point_util.js");
function runTest(downgradeFCV) {
@@ -20,7 +20,7 @@ function runTest(downgradeFCV) {
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
- if (!isShardMergeEnabled(primary.getDB("admin"))) {
+ if (!TenantMigrationUtil.isShardMergeEnabled(primary.getDB("admin"))) {
rst.stopSet();
jsTestLog("Skipping Shard Merge-specific test");
return;
@@ -29,7 +29,7 @@ function runTest(downgradeFCV) {
const adminDB = primary.getDB("admin");
const kDummyConnStr = "mongodb://localhost/?replicaSet=foo";
const readPreference = {mode: 'primary'};
- const migrationCertificates = makeMigrationCertificatesForTest();
+ const migrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest();
// A function, not a constant, to ensure unique UUIDs.
function donorStartMigrationCmd() {
@@ -109,7 +109,7 @@ function runTest(downgradeFCV) {
configureFailPoint(primary, "returnResponseOkForRecipientForgetMigrationCmd");
// Preconditions: the shard merge feature is enabled and our fresh RS is on the latest FCV.
- assert(isShardMergeEnabled(adminDB));
+ assert(TenantMigrationUtil.isShardMergeEnabled(adminDB));
assert.eq(getFCVConstants().latest,
adminDB.system.version.findOne({_id: 'featureCompatibilityVersion'}).version);
@@ -135,3 +135,4 @@ function runTest(downgradeFCV) {
}
runFeatureFlagMultiversionTest('featureFlagShardMerge', runTest);
+})();
diff --git a/jstests/replsets/shard_merge_invalid_options.js b/jstests/replsets/shard_merge_invalid_options.js
index d461cbc16d1..78c3dece7f7 100644
--- a/jstests/replsets/shard_merge_invalid_options.js
+++ b/jstests/replsets/shard_merge_invalid_options.js
@@ -6,10 +6,10 @@
* ]
*/
-import {
- isShardMergeEnabled,
- makeMigrationCertificatesForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/fail_point_util.js");
function runTest(nodeOptions) {
@@ -21,7 +21,7 @@ function runTest(nodeOptions) {
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
- if (!isShardMergeEnabled(rst.getPrimary().getDB("admin"))) {
+ if (!TenantMigrationUtil.isShardMergeEnabled(rst.getPrimary().getDB("admin"))) {
rst.stopSet();
jsTestLog("Skipping Shard Merge-specific test");
return;
@@ -31,7 +31,7 @@ function runTest(nodeOptions) {
const adminDB = primary.getDB("admin");
const kDummyConnStr = "mongodb://localhost/?replicaSet=foo";
const readPreference = {mode: 'primary'};
- const migrationCertificates = makeMigrationCertificatesForTest();
+ const migrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest();
// Enable below fail points to prevent starting the donor/recipient POS instance.
configureFailPoint(primary, "returnResponseCommittedForDonorStartMigrationCmd");
@@ -39,7 +39,7 @@ function runTest(nodeOptions) {
configureFailPoint(primary, "returnResponseOkForRecipientForgetMigrationCmd");
// Ensure the feature flag is enabled and FCV is latest
- assert(isShardMergeEnabled(adminDB));
+ assert(TenantMigrationUtil.isShardMergeEnabled(adminDB));
assert.eq(getFCVConstants().latest,
adminDB.system.version.findOne({_id: 'featureCompatibilityVersion'}).version);
@@ -165,3 +165,4 @@ runTest({directoryperdb: ""});
// Shard merge is not allowed when directoryForIndexes is enabled
runTest({"wiredTigerDirectoryForIndexes": ""});
+})();
diff --git a/jstests/replsets/tenant_migration_abort_forget_retry.js b/jstests/replsets/tenant_migration_abort_forget_retry.js
index 53f8d16d097..4990b014730 100644
--- a/jstests/replsets/tenant_migration_abort_forget_retry.js
+++ b/jstests/replsets/tenant_migration_abort_forget_retry.js
@@ -13,16 +13,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- runTenantMigrationCommand,
- tryAbortMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
function makeTenantId() {
return ObjectId().str;
@@ -77,11 +75,11 @@ const tenantMigrationTest =
fp.wait();
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
- const tryAbortThread = new Thread(tryAbortMigrationAsync,
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+ const tryAbortThread = new Thread(TenantMigrationUtil.tryAbortMigrationAsync,
{migrationIdString: migrationId1, tenantId: tenantId},
donorRstArgs,
- runTenantMigrationCommand);
+ TenantMigrationUtil.runTenantMigrationCommand);
tryAbortThread.start();
// Wait for donorAbortMigration command to start.
@@ -114,3 +112,4 @@ const tenantMigrationTest =
})();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_aborted_buildindex.js b/jstests/replsets/tenant_migration_aborted_buildindex.js
index fd6c9baf57c..1b63967536b 100644
--- a/jstests/replsets/tenant_migration_aborted_buildindex.js
+++ b/jstests/replsets/tenant_migration_aborted_buildindex.js
@@ -10,15 +10,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- runMigrationAsync,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -45,7 +44,7 @@ const migrationOpts = {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId: kTenantId,
};
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
// Put some data in the non-empty collection, and create the empty one.
const db = donorPrimary.getDB(kDbName);
@@ -69,7 +68,8 @@ indexBuildFp.wait();
jsTestLog("Starting a migration and pausing after majority-committing the initial state doc.");
const dataSyncFp =
configureFailPoint(donorPrimary, "pauseTenantMigrationBeforeLeavingDataSyncState");
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
dataSyncFp.wait();
@@ -154,3 +154,4 @@ assert.commandWorked(db[kNonEmptyCollName].createIndex({a: 1, b: 1}));
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_advance_stable_ts_after_clone.js b/jstests/replsets/tenant_migration_advance_stable_ts_after_clone.js
index af4a9897c19..4959af76798 100644
--- a/jstests/replsets/tenant_migration_advance_stable_ts_after_clone.js
+++ b/jstests/replsets/tenant_migration_advance_stable_ts_after_clone.js
@@ -12,10 +12,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {isShardMergeEnabled} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/replsets/rslib.js");
@@ -39,10 +40,10 @@ const recipientPrimary = tmt.getRecipientPrimary();
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
tmt.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
// Insert a doc on the recipient with {writeConcern: majority} to advance the stable timestamp. We
@@ -120,3 +121,4 @@ assert(bsonWoCompare(majorityWriteTs, donorAdvancedStableTs) >= 0);
TenantMigrationTest.assertCommitted(tmt.waitForMigrationToComplete(migrationOpts));
tmt.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_blocking_state_timeout.js b/jstests/replsets/tenant_migration_blocking_state_timeout.js
index 57d9790e508..5129d38944f 100644
--- a/jstests/replsets/tenant_migration_blocking_state_timeout.js
+++ b/jstests/replsets/tenant_migration_blocking_state_timeout.js
@@ -10,15 +10,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- runMigrationAsync,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/parallelTester.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -41,7 +40,7 @@ function testTimeoutBlockingState() {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
// Fail point to pause right before entering the blocking mode.
let afterDataSyncFp =
@@ -49,7 +48,8 @@ function testTimeoutBlockingState() {
// Run the migration in its own thread, since the initial 'donorStartMigration' command will
// hang due to the fail point.
- let migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ let migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
afterDataSyncFp.wait();
@@ -76,3 +76,4 @@ jsTest.log("Test timeout of the blocking state");
testTimeoutBlockingState();
tenantMigrationTest.stop();
+}());
diff --git a/jstests/replsets/tenant_migration_buildindex.js b/jstests/replsets/tenant_migration_buildindex.js
index 9745ddfd049..b0efd5df416 100644
--- a/jstests/replsets/tenant_migration_buildindex.js
+++ b/jstests/replsets/tenant_migration_buildindex.js
@@ -10,24 +10,23 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
// TODO (SERVER-63517): This test assumes the donor blocks only some tenants. Replace this test with
// tenant_migration_buildindex_shard_merge.js.
-if (isShardMergeEnabled(tenantMigrationTest.getDonorPrimary().getDB("adminDB"))) {
+if (TenantMigrationUtil.isShardMergeEnabled(
+ tenantMigrationTest.getDonorPrimary().getDB("adminDB"))) {
jsTestLog("Skip: incompatible with featureFlagShardMerge");
tenantMigrationTest.stop();
- quit();
+ return;
}
const kTenantId = ObjectId().str;
@@ -63,7 +62,7 @@ const migrationOpts = {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId: kTenantId,
};
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
// Put some data in the non-empty collections, and create the empty one.
const db = donorPrimary.getDB(kDbName);
@@ -106,7 +105,8 @@ jsTestLog("Starting a migration and pausing after majority-committing the initia
// Start a migration, and pause it after the donor has majority-committed the initial state doc.
const dataSyncFp =
configureFailPoint(donorPrimary, "pauseTenantMigrationBeforeLeavingDataSyncState");
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
dataSyncFp.wait();
@@ -163,3 +163,4 @@ assert.commandFailedWithCode(db[kNewCollName2].createIndex({b: 1}),
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_buildindex_shard_merge.js b/jstests/replsets/tenant_migration_buildindex_shard_merge.js
index b7ec757f8b3..1a1a2655e5c 100644
--- a/jstests/replsets/tenant_migration_buildindex_shard_merge.js
+++ b/jstests/replsets/tenant_migration_buildindex_shard_merge.js
@@ -13,16 +13,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
// Index builds should be blocked by the tenant access blocker, not maxNumActiveUserIndexBuilds.
const tenantMigrationTest = new TenantMigrationTest(
@@ -34,10 +32,10 @@ const donorPrimary = tenantMigrationTest.getDonorPrimary();
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
const kTenant1Id = ObjectId().str;
@@ -66,7 +64,7 @@ const migrationOpts = {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantIds: tojson([ObjectId(kTenant1Id), ObjectId(kTenant2Id)])
};
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
// Put some data in the non-empty collections, and create the empty one.
const db1 = donorPrimary.getDB(kTenant1DbName);
@@ -109,7 +107,8 @@ jsTestLog("Starting a migration and pausing after majority-committing the initia
// Start a migration, and pause it after the donor has majority-committed the initial state doc.
const dataSyncFp =
configureFailPoint(donorPrimary, "pauseTenantMigrationBeforeLeavingDataSyncState");
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
dataSyncFp.wait();
@@ -180,3 +179,4 @@ assert.commandFailedWithCode(db2[kNewCollName2].createIndex({d: 1}),
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_causal_consistency_commit_optime_before_last_cloning_optime.js b/jstests/replsets/tenant_migration_causal_consistency_commit_optime_before_last_cloning_optime.js
index 2e4200c3829..e7da3a678d3 100644
--- a/jstests/replsets/tenant_migration_causal_consistency_commit_optime_before_last_cloning_optime.js
+++ b/jstests/replsets/tenant_migration_causal_consistency_commit_optime_before_last_cloning_optime.js
@@ -16,11 +16,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/replsets/rslib.js");
function assertCanFindWithReadConcern(conn, dbName, collName, expectedDoc, readConcern) {
@@ -37,7 +38,7 @@ let makeTenantId = function() {
// Local read concern case.
(() => {
- const migrationX509Options = makeX509OptionsForTest();
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
// Simulate a lagged node by setting secondaryDelaySecs on one recipient secondary. Verify this
// does not prevent reading all the tenant's data after the migration commits.
@@ -203,3 +204,4 @@ let makeTenantId = function() {
})();
// Snapshot read concern is tested in replsets/tenant_migration_concurrent_reads_on_recipient.js
+})();
diff --git a/jstests/replsets/tenant_migration_cloner_stats.js b/jstests/replsets/tenant_migration_cloner_stats.js
index ae793bcc00c..6b2a2f6e8a3 100644
--- a/jstests/replsets/tenant_migration_cloner_stats.js
+++ b/jstests/replsets/tenant_migration_cloner_stats.js
@@ -15,9 +15,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
// Limit the batch size to test the stat in between batches.
const tenantMigrationTest = new TenantMigrationTest(
@@ -192,3 +195,4 @@ assertNothingClonedBeforeFailover(res);
assert.eq(currOp.remainingReceiveEstimatedMillis, 0, res);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_cloner_stats_with_failover.js b/jstests/replsets/tenant_migration_cloner_stats_with_failover.js
index 5dca785ee39..6f963c4aa5c 100644
--- a/jstests/replsets/tenant_migration_cloner_stats_with_failover.js
+++ b/jstests/replsets/tenant_migration_cloner_stats_with_failover.js
@@ -21,9 +21,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
// Limit the batch size to test the stat in between batches.
const tenantMigrationTest = new TenantMigrationTest(
@@ -144,3 +147,4 @@ assert.eq(currOp.databases.databasesClonedBeforeFailover, 1, res);
assert.eq(currOp.databases[dbName2].clonedCollectionsBeforeFailover, 1, res);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_clones_system_views.js b/jstests/replsets/tenant_migration_clones_system_views.js
index b1a93f254f3..27721e53389 100644
--- a/jstests/replsets/tenant_migration_clones_system_views.js
+++ b/jstests/replsets/tenant_migration_clones_system_views.js
@@ -11,8 +11,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -56,3 +59,4 @@ assert.eq(1, findRes.length, `find result: ${tojson(findRes)}`);
assert.eq([doc1], findRes);
tenantMigrationTest.stop();
+})();
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 4c0713019c5..0fe36350ede 100644
--- a/jstests/replsets/tenant_migration_cloning_uses_read_concern_majority.js
+++ b/jstests/replsets/tenant_migration_cloning_uses_read_concern_majority.js
@@ -15,14 +15,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {runMigrationAsync} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
load("jstests/libs/parallelTester.js"); // for 'Thread'
load("jstests/libs/write_concern_util.js"); // for 'stopReplicationOnSecondaries'
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -64,8 +65,9 @@ const waitBeforeCloning = configureFailPoint(recipientDb, "hangBeforeClonerStage
// Start a migration and wait for recipient to hang before querying the donor in the cloning phase.
// At this point, we have waited for the listIndex results to be majority committed on the donor,
// so we can stop server replication.
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
waitBeforeCloning.wait();
stopReplicationOnSecondaries(donorRst);
@@ -98,3 +100,4 @@ restartReplicationOnSecondaries(donorRst);
waitBeforeFetchingTransactions.off();
TenantMigrationTest.assertCommitted(migrationThread.returnData());
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_cluster_time_keys_cloning.js b/jstests/replsets/tenant_migration_cluster_time_keys_cloning.js
index 5d80e412f9f..a165db82781 100644
--- a/jstests/replsets/tenant_migration_cluster_time_keys_cloning.js
+++ b/jstests/replsets/tenant_migration_cluster_time_keys_cloning.js
@@ -14,15 +14,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- makeX509OptionsForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const kInternalKeysNs = "admin.system.keys";
const kExternalKeysNs = "config.external_validation_keys";
@@ -72,7 +70,7 @@ function assertHasExternalKeys(conn, migrationId) {
const kTenantId1 = "testTenantId1";
const kTenantId2 = "testTenantId2";
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
(() => {
jsTest.log("Test that the donor and recipient correctly copy each other's cluster time keys " +
@@ -135,7 +133,7 @@ const migrationX509Options = makeX509OptionsForTest();
new ReplSetTest({nodes: 3, name: "donorRst", nodeOptions: migrationX509Options.donor});
donorRst.startSet();
donorRst.initiate();
- if (isShardMergeEnabled(donorRst.getPrimary().getDB("adminDB"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(donorRst.getPrimary().getDB("adminDB"))) {
jsTestLog("Skip: featureFlagShardMerge enabled, but shard merge does not survive failover");
donorRst.stopSet();
return;
@@ -180,7 +178,7 @@ const migrationX509Options = makeX509OptionsForTest();
{nodes: 3, name: "recipientRst", nodeOptions: migrationX509Options.recipient});
recipientRst.startSet();
recipientRst.initiate();
- if (isShardMergeEnabled(recipientRst.getPrimary().getDB("adminDB"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(recipientRst.getPrimary().getDB("adminDB"))) {
jsTestLog("Skip: featureFlagShardMerge enabled, but shard merge does not survive failover");
recipientRst.stopSet();
return;
@@ -233,7 +231,8 @@ const migrationX509Options = makeX509OptionsForTest();
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName(), donorRst});
function runTest(tenantId, withFailover) {
- if (withFailover && isShardMergeEnabled(donorRst.getPrimary().getDB("adminDB"))) {
+ if (withFailover &&
+ TenantMigrationUtil.isShardMergeEnabled(donorRst.getPrimary().getDB("adminDB"))) {
jsTestLog(
"Skip: featureFlagShardMerge enabled, but shard merge does not survive failover");
tenantMigrationTest.stop();
@@ -307,3 +306,4 @@ const migrationX509Options = makeX509OptionsForTest();
donorRst.stopSet();
tenantMigrationTest.stop();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_collection_rename.js b/jstests/replsets/tenant_migration_collection_rename.js
index b7cd2d0d2fb..1564a0c2de1 100644
--- a/jstests/replsets/tenant_migration_collection_rename.js
+++ b/jstests/replsets/tenant_migration_collection_rename.js
@@ -16,13 +16,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {runMigrationAsync} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
function insertData(collection) {
// Enough for several batches.
@@ -38,7 +39,7 @@ const kDbName = tenantMigrationTest.tenantDB(kTenantId, "testDB");
const kCollectionName = "toBeRenamed";
const donorPrimary = tenantMigrationTest.getDonorPrimary();
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
const db = donorPrimary.getDB(kDbName);
jsTestLog("Populate collection");
@@ -56,7 +57,8 @@ const fpAfterBatch = configureFailPoint(
recipientPrimary, "tenantMigrationHangCollectionClonerAfterHandlingBatchResponse");
jsTestLog("Start a migration and pause after first batch");
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
jsTestLog("Wait to reach failpoint");
@@ -73,3 +75,4 @@ fpAfterBatch.off();
TenantMigrationTest.assertAborted(migrationThread.returnData(), ErrorCodes.DuplicateKey);
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_collection_ttl.js b/jstests/replsets/tenant_migration_collection_ttl.js
index 105fa1d3108..77277579fc4 100644
--- a/jstests/replsets/tenant_migration_collection_ttl.js
+++ b/jstests/replsets/tenant_migration_collection_ttl.js
@@ -12,11 +12,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {isShardMergeEnabled} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const garbageCollectionOpts = {
// Set the delay before a donor state doc is garbage collected to be short to speed
@@ -106,7 +108,7 @@ function assertTTLDeleteExpiredDocs(dbName, node) {
// 1. At the recipient, the TTL deletions are suspended during the cloning phase.
// 2. At the donor, TTL deletions are not suspended before blocking state.
(() => {
- if (isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
jsTestLog(
"Skip: featureFlagShardMerge enabled, but shard merge does not use logical cloning");
return;
@@ -232,3 +234,4 @@ function assertTTLDeleteExpiredDocs(dbName, node) {
})();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_commit_transaction_retry.js b/jstests/replsets/tenant_migration_commit_transaction_retry.js
index f2f0d946584..c0b55b799b3 100644
--- a/jstests/replsets/tenant_migration_commit_transaction_retry.js
+++ b/jstests/replsets/tenant_migration_commit_transaction_retry.js
@@ -10,7 +10,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/replsets/rslib.js");
load("jstests/libs/uuid_util.js");
@@ -132,3 +136,4 @@ tenantMigrationTest2.waitForMigrationGarbageCollection(migrationId2, kTenantId);
tenantMigrationTest2.stop();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_bulk_writes.js b/jstests/replsets/tenant_migration_concurrent_bulk_writes.js
index d630988fea9..8b87bbdbfe4 100644
--- a/jstests/replsets/tenant_migration_concurrent_bulk_writes.js
+++ b/jstests/replsets/tenant_migration_concurrent_bulk_writes.js
@@ -10,17 +10,14 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- makeX509OptionsForTest,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kMaxBatchSize = 2;
const kCollName = "testColl";
@@ -30,9 +27,14 @@ const kNumWriteBatchesWithoutMigrationConflict =
2; // num of write batches we allow to complete before migration blocks writes.
const kNumUpdatesWithoutMigrationConflict = 2;
const kMaxSleepTimeMS = 1000;
+const kBatchTypes = {
+ insert: 1,
+ update: 2,
+ remove: 3
+};
function setup() {
- const migrationX509Options = makeX509OptionsForTest();
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const donorRst = new ReplSetTest({
nodes: 1,
name: 'donor',
@@ -226,7 +228,7 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
recipientConnString: recipientRst.getURL(),
tenantId,
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
const dbName = tenantMigrationTest.tenantDB(tenantId, kTenantDefinedDbName);
const primary = donorRst.getPrimary();
@@ -240,7 +242,8 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
new Thread(bulkInsertDocsUnordered, primary.host, dbName, kCollName, kNumWriteOps);
const blockFp = configureFailPoint(primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
bulkWriteThread.start();
writeFp.wait();
@@ -290,7 +293,7 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId,
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
const dbName = tenantMigrationTest.tenantDB(tenantId, kTenantDefinedDbName);
const primary = donorRst.getPrimary();
@@ -309,7 +312,8 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
// TenantMigrationConflict in the op observer. Without this failpoint, the migration
// could have already aborted by the time the write gets to the op observer.
const blockFp = configureFailPoint(primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
bulkWriteThread.start();
writeFp.wait();
@@ -405,7 +409,7 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId,
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
const dbName = tenantMigrationTest.tenantDB(tenantId, kTenantDefinedDbName);
const primary = donorRst.getPrimary();
@@ -419,7 +423,8 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
new Thread(bulkInsertDocsOrdered, primary.host, dbName, kCollName, kNumWriteOps);
const blockFp = configureFailPoint(primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
bulkWriteThread.start();
writeFp.wait();
@@ -461,7 +466,7 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId,
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
const dbName = tenantMigrationTest.tenantDB(tenantId, kTenantDefinedDbName);
const primary = donorRst.getPrimary();
@@ -480,7 +485,8 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
// TenantMigrationConflict in the op observer. Without this failpoint, the migration
// could have already aborted by the time the write gets to the op observer.
const blockFp = configureFailPoint(primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
bulkWriteThread.start();
writeFp.wait();
@@ -525,7 +531,7 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
recipientConnString: recipientRst.getURL(),
tenantId,
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
const dbName = tenantMigrationTest.tenantDB(tenantId, kTenantDefinedDbName);
const primary = donorRst.getPrimary();
@@ -539,7 +545,8 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
new Thread(bulkMultiUpdateDocsUnordered, primary.host, dbName, kCollName, kNumWriteOps);
const blockFp = configureFailPoint(primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
bulkWriteThread.start();
writeFp.wait();
@@ -577,7 +584,7 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
recipientConnString: recipientRst.getURL(),
tenantId,
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
const dbName = tenantMigrationTest.tenantDB(tenantId, kTenantDefinedDbName);
const primary = donorRst.getPrimary();
@@ -591,7 +598,8 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
new Thread(bulkMultiUpdateDocsOrdered, primary.host, dbName, kCollName, kNumWriteOps);
const blockFp = configureFailPoint(primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
bulkWriteThread.start();
writeFp.wait();
@@ -695,3 +703,4 @@ function bulkMultiUpdateDocsUnordered(primaryHost, dbName, collName, numDocs) {
tojson(bulkWriteRes));
teardown();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_migrations.js b/jstests/replsets/tenant_migration_concurrent_migrations.js
index efba49f9d16..ef8d7638f68 100644
--- a/jstests/replsets/tenant_migration_concurrent_migrations.js
+++ b/jstests/replsets/tenant_migration_concurrent_migrations.js
@@ -13,16 +13,18 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509Options} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
-const x509Options0 = makeX509Options("jstests/libs/rs0.pem");
-const x509Options1 = makeX509Options("jstests/libs/rs1.pem");
-const x509Options2 = makeX509Options("jstests/libs/rs2.pem");
+const x509Options0 = TenantMigrationUtil.makeX509Options("jstests/libs/rs0.pem");
+const x509Options1 = TenantMigrationUtil.makeX509Options("jstests/libs/rs1.pem");
+const x509Options2 = TenantMigrationUtil.makeX509Options("jstests/libs/rs2.pem");
const rst0 = new ReplSetTest({nodes: 1, name: 'rst0', nodeOptions: x509Options0});
const rst1 = new ReplSetTest({nodes: 1, name: 'rst1', nodeOptions: x509Options1});
@@ -191,3 +193,4 @@ const kTenantIdPrefix = "testTenantId";
rst0.stopSet();
rst1.stopSet();
rst2.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_migrations_recipient.js b/jstests/replsets/tenant_migration_concurrent_migrations_recipient.js
index d76e100cf3c..47642073e9e 100644
--- a/jstests/replsets/tenant_migration_concurrent_migrations_recipient.js
+++ b/jstests/replsets/tenant_migration_concurrent_migrations_recipient.js
@@ -14,9 +14,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
TestData.logComponentVerbosity = {
accessControl: {verbosity: 3}
@@ -74,3 +78,4 @@ migrationOptsArray.forEach((migrationOpts) => {
});
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_migrations_stress_test.js b/jstests/replsets/tenant_migration_concurrent_migrations_stress_test.js
index 7dbfaec2884..3f95d39fe99 100644
--- a/jstests/replsets/tenant_migration_concurrent_migrations_stress_test.js
+++ b/jstests/replsets/tenant_migration_concurrent_migrations_stress_test.js
@@ -14,9 +14,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/replsets/rslib.js"); // for 'setLogVerbosity'
const kMigrationsCount = 300;
@@ -217,3 +221,4 @@ for (let i = 0; i < kMigrationsCount; ++i) {
}
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 7a346f2ec09..086cb67e1a3 100644
--- a/jstests/replsets/tenant_migration_concurrent_reads_on_donor.js
+++ b/jstests/replsets/tenant_migration_concurrent_reads_on_donor.js
@@ -16,12 +16,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {getTenantMigrationAccessBlocker} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -42,7 +44,8 @@ function checkTenantMigrationAccessBlocker(node, tenantId, {
numTenantMigrationCommittedErrors = 0,
numTenantMigrationAbortedErrors = 0
}) {
- const mtab = getTenantMigrationAccessBlocker({donorNode: node, tenantId}).donor;
+ const mtab =
+ TenantMigrationUtil.getTenantMigrationAccessBlocker({donorNode: node, tenantId}).donor;
if (!mtab) {
assert.eq(0, numBlockedReads);
assert.eq(0, numTenantMigrationCommittedErrors);
@@ -61,10 +64,14 @@ function checkTenantMigrationAccessBlocker(node, tenantId, {
* To be used to resume a migration that is paused after entering the blocking state. Waits for the
* number of blocked reads to reach 'targetNumBlockedReads' and unpauses the migration.
*/
-async function resumeMigrationAfterBlockingRead(host, tenantId, targetNumBlockedReads) {
- const {getNumBlockedReads} = await import("jstests/replsets/libs/tenant_migration_util.js");
+function resumeMigrationAfterBlockingRead(host, tenantId, targetNumBlockedReads) {
+ load("jstests/libs/fail_point_util.js");
+ load("jstests/replsets/libs/tenant_migration_util.js");
const primary = new Mongo(host);
- assert.soon(() => getNumBlockedReads(primary, tenantId) == targetNumBlockedReads);
+
+ assert.soon(() => TenantMigrationUtil.getNumBlockedReads(primary, tenantId) ==
+ targetNumBlockedReads);
+
assert.commandWorked(primary.adminCommand(
{configureFailPoint: "pauseTenantMigrationBeforeLeavingBlockingState", mode: "off"}));
}
@@ -509,3 +516,4 @@ for (const [testName, testFunc] of Object.entries(testFuncs)) {
}
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js b/jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js
index 21bcb2c55f9..a15299b6171 100644
--- a/jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js
+++ b/jstests/replsets/tenant_migration_concurrent_reads_on_recipient.js
@@ -17,13 +17,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {runMigrationAsync} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+load("jstests/replsets/rslib.js");
const kCollName = "testColl";
const kTenantDefinedDbName = "0";
@@ -67,8 +69,9 @@ function testRejectAllReadsAfterCloningDone({testCase, dbName, collName, tenantM
let beforeFetchingTransactionsFp = configureFailPoint(
recipientPrimary, "fpBeforeFetchingCommittedTransactions", {action: "hang"});
- const donorRstArgs = createRstArgs(donorRst);
- const runMigrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
+ const runMigrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
runMigrationThread.start();
beforeFetchingTransactionsFp.wait();
@@ -115,8 +118,9 @@ function testRejectOnlyReadsWithAtClusterTimeLessThanRejectReadsBeforeTimestamp(
let waitForRejectReadsBeforeTsFp = configureFailPoint(
recipientPrimary, "fpAfterWaitForRejectReadsBeforeTimestamp", {action: "hang"});
- const donorRstArgs = createRstArgs(donorRst);
- const runMigrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
+ const runMigrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
runMigrationThread.start();
waitForRejectReadsBeforeTsFp.wait();
@@ -442,3 +446,4 @@ for (const [testName, testFunc] of Object.entries(testFuncs)) {
}
}
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_reconfig.js b/jstests/replsets/tenant_migration_concurrent_reconfig.js
index e766b7c5342..a33f2456675 100644
--- a/jstests/replsets/tenant_migration_concurrent_reconfig.js
+++ b/jstests/replsets/tenant_migration_concurrent_reconfig.js
@@ -10,9 +10,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
function runTest({failPoint, shouldFail = false}) {
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -79,3 +83,4 @@ runTest({failPoint: "pauseTenantMigrationAfterPersistingInitialDonorStateDoc", s
jsTestLog("[4] Testing reconfig before fetching keys.");
runTest({failPoint: "pauseTenantMigrationBeforeFetchingKeys", shouldFail: false});
+})();
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 242ebcbf03c..05823af3d59 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
@@ -11,13 +11,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {forgetMigrationAsync} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/parallelTester.js");
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest(
{name: jsTestName(), quickGarbageCollection: true, initiateRstWithHighElectionTimeout: false});
@@ -25,7 +26,7 @@ const tenantMigrationTest = new TenantMigrationTest(
const kTenantId = ObjectId().str;
const donorRst = tenantMigrationTest.getDonorRst();
-const donorRstArgs = createRstArgs(donorRst);
+const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
let donorPrimary = tenantMigrationTest.getDonorPrimary();
const migrationId = UUID();
@@ -39,7 +40,7 @@ TenantMigrationTest.assertCommitted(
let fp = configureFailPoint(donorPrimary,
"pauseTenantMigrationDonorAfterMarkingStateGarbageCollectable");
-const forgetMigrationThread = new Thread(forgetMigrationAsync,
+const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
migrationOpts.migrationIdString,
donorRstArgs,
false /* retryOnRetryableErrors */);
@@ -58,3 +59,4 @@ assert.commandFailedWithCode(forgetMigrationThread.returnData(),
donorRst.stopSet();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_donor.js b/jstests/replsets/tenant_migration_concurrent_writes_on_donor.js
index 78bf93d2c92..c1d5b02f969 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_donor.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_donor.js
@@ -9,17 +9,15 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- runCommandForConcurrentWritesTest,
- runTestForConcurrentWritesTest,
- TenantMigrationConcurrentWriteUtil
-} from "jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+load("jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -76,3 +74,4 @@ for (const [commandName, testCase] of Object.entries(testCases)) {
}
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_aborted.js b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_aborted.js
index 7cbe5af8db9..cbe12347a3c 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_aborted.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_aborted.js
@@ -9,20 +9,15 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {getTenantMigrationAccessBlocker} from "jstests/replsets/libs/tenant_migration_util.js";
-import {
- checkTenantMigrationAccessBlockerForConcurrentWritesTest,
- makeTestOptionsForConcurrentWritesTest,
- runCommandForConcurrentWritesTest,
- setupTestForConcurrentWritesTest,
- TenantMigrationConcurrentWriteUtil
-} from "jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+load("jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -52,7 +47,8 @@ function testDoNotRejectWritesAfterMigrationAborted(testCase, testOpts) {
// committed the abort decision. Otherwise, the command below is expected to block and then get
// rejected.
assert.soon(() => {
- const mtab = getTenantMigrationAccessBlocker({donorNode: testOpts.primaryDB, tenantId});
+ const mtab = TenantMigrationUtil.getTenantMigrationAccessBlocker(
+ {donorNode: testOpts.primaryDB, tenantId});
return mtab.donor.state === TenantMigrationTest.DonorAccessState.kAborted;
});
@@ -147,3 +143,4 @@ assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migration
tenantMigrationTest.waitForMigrationGarbageCollection(migrationOpts.migrationIdString);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking.js b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking.js
index dd2b09321bc..6dd6f1846bd 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking.js
@@ -10,19 +10,15 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- checkTenantMigrationAccessBlockerForConcurrentWritesTest,
- makeTestOptionsForConcurrentWritesTest,
- runCommandForConcurrentWritesTest,
- setupTestForConcurrentWritesTest,
- TenantMigrationConcurrentWriteUtil
-} from "jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+load("jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -179,3 +175,4 @@ assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migration
tenantMigrationTest.waitForMigrationGarbageCollection(migrationOpts.migrationIdString);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_aborted.js b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_aborted.js
index 2dc3e2546b9..9d1d99bb941 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_aborted.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_aborted.js
@@ -10,18 +10,15 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- checkTenantMigrationAccessBlockerForConcurrentWritesTest,
- runCommandForConcurrentWritesTest,
- runTestForConcurrentWritesTest,
- TenantMigrationConcurrentWriteUtil
-} from "jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+load("jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -39,10 +36,14 @@ const kTenantDefinedDbName = "0";
* To be used to resume a migration that is paused after entering the blocking state. Waits for the
* number of blocked reads to reach 'targetNumBlockedWrites' and unpauses the migration.
*/
-async function resumeMigrationAfterBlockingWrite(host, tenantId, targetNumBlockedWrites) {
- const {getNumBlockedWrites} = await import("jstests/replsets/libs/tenant_migration_util.js");
+function resumeMigrationAfterBlockingWrite(host, tenantId, targetNumBlockedWrites) {
+ load("jstests/libs/fail_point_util.js");
+ load("jstests/replsets/libs/tenant_migration_util.js");
const primary = new Mongo(host);
- assert.soon(() => getNumBlockedWrites(primary, tenantId) == targetNumBlockedWrites);
+
+ assert.soon(() => TenantMigrationUtil.getNumBlockedWrites(primary, tenantId) ==
+ targetNumBlockedWrites);
+
assert.commandWorked(primary.adminCommand(
{configureFailPoint: "pauseTenantMigrationBeforeLeavingBlockingState", mode: "off"}));
}
@@ -125,3 +126,4 @@ for (const [commandName, testCase] of Object.entries(testCases)) {
}
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_committed.js b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_committed.js
index 17da4d0a93e..8d7b5023c19 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_committed.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_blocking_then_committed.js
@@ -10,18 +10,15 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- checkTenantMigrationAccessBlockerForConcurrentWritesTest,
- runCommandForConcurrentWritesTest,
- runTestForConcurrentWritesTest,
- TenantMigrationConcurrentWriteUtil
-} from "jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+load("jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -39,10 +36,14 @@ const kTenantDefinedDbName = "0";
* To be used to resume a migration that is paused after entering the blocking state. Waits for the
* number of blocked reads to reach 'targetNumBlockedWrites' and unpauses the migration.
*/
-async function resumeMigrationAfterBlockingWrite(host, tenantId, targetNumBlockedWrites) {
- const {getNumBlockedWrites} = await import("jstests/replsets/libs/tenant_migration_util.js");
+function resumeMigrationAfterBlockingWrite(host, tenantId, targetNumBlockedWrites) {
+ load("jstests/libs/fail_point_util.js");
+ load("jstests/replsets/libs/tenant_migration_util.js");
const primary = new Mongo(host);
- assert.soon(() => getNumBlockedWrites(primary, tenantId) == targetNumBlockedWrites);
+
+ assert.soon(() => TenantMigrationUtil.getNumBlockedWrites(primary, tenantId) ==
+ targetNumBlockedWrites);
+
assert.commandWorked(primary.adminCommand(
{configureFailPoint: "pauseTenantMigrationBeforeLeavingBlockingState", mode: "off"}));
}
@@ -124,3 +125,4 @@ for (const [commandName, testCase] of Object.entries(testCases)) {
}
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_committed.js b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_committed.js
index f77889c42c9..01aff3d2aa1 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_committed.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_committed.js
@@ -9,19 +9,15 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- checkTenantMigrationAccessBlockerForConcurrentWritesTest,
- makeTestOptionsForConcurrentWritesTest,
- runCommandForConcurrentWritesTest,
- setupTestForConcurrentWritesTest,
- TenantMigrationConcurrentWriteUtil
-} from "jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+load("jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -137,3 +133,4 @@ assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migration
tenantMigrationTest.waitForMigrationGarbageCollection(migrationOpts.migrationIdString);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js
index 19b9b3fd637..18a42e90818 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js
@@ -3,36 +3,21 @@
* tenant_migration_concurrent_writes_on_donor*tests.
*/
-import {getTenantMigrationAccessBlocker} from "jstests/replsets/libs/tenant_migration_util.js";
+'use strict';
-const kTestDoc = {
- x: -1
-};
-const kTestDoc2 = {
- x: -2
-};
-const kTestIndexKey = {
- x: 1
-};
-const kExpireAfterSeconds = 1000000;
-const kTestIndex = {
- key: kTestIndexKey,
- name: "testIndex",
- expireAfterSeconds: kExpireAfterSeconds
-};
-const kNumInitialDocs = 2; // num initial docs to insert into test collections.
-const kTxnNumber = NumberLong(0);
+var TenantMigrationConcurrentWriteUtil = (function() {});
/**
* Asserts that the TenantMigrationAccessBlocker for the given tenant on the given node has the
* expected statistics.
*/
-export function checkTenantMigrationAccessBlockerForConcurrentWritesTest(node, tenantId, {
+function checkTenantMigrationAccessBlockerForConcurrentWritesTest(node, tenantId, {
numBlockedWrites = 0,
numTenantMigrationCommittedErrors = 0,
numTenantMigrationAbortedErrors = 0
}) {
- const mtab = getTenantMigrationAccessBlocker({donorNode: node, tenantId}).donor;
+ const mtab =
+ TenantMigrationUtil.getTenantMigrationAccessBlocker({donorNode: node, tenantId}).donor;
if (!mtab) {
assert.eq(0, numBlockedWrites);
assert.eq(0, numTenantMigrationCommittedErrors);
@@ -47,7 +32,7 @@ export function checkTenantMigrationAccessBlockerForConcurrentWritesTest(node, t
assert.eq(mtab.numTenantMigrationAbortedErrors, numTenantMigrationAbortedErrors, tojson(mtab));
}
-export function runCommandForConcurrentWritesTest(testOpts, expectedError) {
+function runCommandForConcurrentWritesTest(testOpts, expectedError) {
let res;
if (testOpts.isMultiUpdate && !testOpts.testInTransaction) {
// Multi writes outside a transaction cannot be automatically retried, so we return a
@@ -116,8 +101,8 @@ export function runCommandForConcurrentWritesTest(testOpts, expectedError) {
}
}
-export function createCollectionAndInsertDocsForConcurrentWritesTest(
- primaryDB, collName, numDocs = kNumInitialDocs) {
+function createCollectionAndInsertDocsForConcurrentWritesTest(
+ primaryDB, collName, numDocs = TenantMigrationConcurrentWriteUtil.kNumInitialDocs) {
const createCollCommand = {create: collName};
assert.commandWorked(primaryDB.runCommand(createCollCommand));
@@ -135,7 +120,7 @@ function cleanUpForConcurrentWritesTest(dbName, donorPrimary) {
assert.commandWorked(donorDB.dropDatabase());
}
-export function makeTestOptionsForConcurrentWritesTest(
+function makeTestOptionsForConcurrentWritesTest(
primary, testCase, dbName, collName, testInTransaction, testAsRetryableWrite) {
assert(!testInTransaction || !testAsRetryableWrite);
@@ -146,7 +131,7 @@ export function makeTestOptionsForConcurrentWritesTest(
let command = testCase.command(dbName, collName);
if (testInTransaction || testAsRetryableWrite) {
- command.txnNumber = kTxnNumber;
+ command.txnNumber = TenantMigrationConcurrentWriteUtil.kTxnNumber;
}
if (testInTransaction) {
command.startTransaction = true;
@@ -168,7 +153,7 @@ export function makeTestOptionsForConcurrentWritesTest(
};
}
-export function runTestForConcurrentWritesTest(
+function runTestForConcurrentWritesTest(
primary, testCase, testFunc, dbName, collName, {testInTransaction, testAsRetryableWrite} = {}) {
const testOpts = makeTestOptionsForConcurrentWritesTest(
primary, testCase, dbName, collName, testInTransaction, testAsRetryableWrite);
@@ -188,7 +173,7 @@ export function runTestForConcurrentWritesTest(
cleanUpForConcurrentWritesTest(dbName, primary);
}
-export function setupTestForConcurrentWritesTest(testCase, collName, testOpts) {
+function setupTestForConcurrentWritesTest(testCase, collName, testOpts) {
if (testCase.explicitlyCreateCollection) {
createCollectionAndInsertDocsForConcurrentWritesTest(testOpts.primaryDB, collName);
}
@@ -206,17 +191,41 @@ const isOnlySupportedOnStandalone = "is only supported on standalone";
const isOnlySupportedOnShardedCluster = "is only supported on sharded cluster";
const isDeprecated = "is deprecated";
+TenantMigrationConcurrentWriteUtil.kTestDoc = {
+ x: -1
+};
+TenantMigrationConcurrentWriteUtil.kTestDoc2 = {
+ x: -2
+};
+
+TenantMigrationConcurrentWriteUtil.kTestIndexKey = {
+ x: 1
+};
+TenantMigrationConcurrentWriteUtil.kExpireAfterSeconds = 1000000;
+TenantMigrationConcurrentWriteUtil.kTestIndex = {
+ key: TenantMigrationConcurrentWriteUtil.kTestIndexKey,
+ name: "testIndex",
+ expireAfterSeconds: TenantMigrationConcurrentWriteUtil.kExpireAfterSeconds
+};
+
function insertTestDoc(primaryDB, collName) {
- assert.commandWorked(primaryDB.runCommand({insert: collName, documents: [kTestDoc]}));
+ assert.commandWorked(primaryDB.runCommand(
+ {insert: collName, documents: [TenantMigrationConcurrentWriteUtil.kTestDoc]}));
}
function insertTwoTestDocs(primaryDB, collName) {
- assert.commandWorked(
- primaryDB.runCommand({insert: collName, documents: [kTestDoc, kTestDoc2]}));
+ assert.commandWorked(primaryDB.runCommand({
+ insert: collName,
+ documents: [
+ TenantMigrationConcurrentWriteUtil.kTestDoc,
+ TenantMigrationConcurrentWriteUtil.kTestDoc2
+ ]
+ }));
}
function createTestIndex(primaryDB, collName) {
- assert.commandWorked(primaryDB.runCommand({createIndexes: collName, indexes: [kTestIndex]}));
+ assert.commandWorked(primaryDB.runCommand(
+ {createIndexes: collName, indexes: [TenantMigrationConcurrentWriteUtil.kTestIndex]}));
}
function countDocs(db, collName, query) {
@@ -241,475 +250,494 @@ function indexExists(db, collName, targetIndex) {
bsonWoCompare(index.expireAfterSeconds, targetIndex.expireAfterSeconds) === 0);
}
-export const TenantMigrationConcurrentWriteUtil = {
- kTestDoc,
- kTestDoc2,
- kTestIndexKey,
- kExpireAfterSeconds,
- kTestIndex,
- kNumInitialDocs,
- kTxnNumber,
- testCases: {
- _addShard: {skip: isNotRunOnUserDatabase},
- _cloneCollectionOptionsFromPrimaryShard: {skip: isNotRunOnUserDatabase},
- _configsvrAddShard: {skip: isNotRunOnUserDatabase},
- _configsvrAddShardToZone: {skip: isNotRunOnUserDatabase},
- _configsvrBalancerCollectionStatus: {skip: isNotRunOnUserDatabase},
- _configsvrBalancerStart: {skip: isNotRunOnUserDatabase},
- _configsvrBalancerStatus: {skip: isNotRunOnUserDatabase},
- _configsvrBalancerStop: {skip: isNotRunOnUserDatabase},
- _configsvrClearJumboFlag: {skip: isNotRunOnUserDatabase},
- _configsvrCommitChunksMerge: {skip: isNotRunOnUserDatabase},
- _configsvrCommitChunkMigration: {skip: isNotRunOnUserDatabase},
- _configsvrCommitChunkSplit: {skip: isNotRunOnUserDatabase},
- _configsvrCommitIndex: {skip: isNotRunOnUserDatabase},
- _configsvrCommitMovePrimary:
- {skip: isNotRunOnUserDatabase}, // Can be removed once 6.0 is last LTS
- _configsvrCreateDatabase: {skip: isNotRunOnUserDatabase},
- _configsvrDropIndexCatalogEntry: {skip: isNotRunOnUserDatabase},
- _configsvrEnsureChunkVersionIsGreaterThan: {skip: isNotRunOnUserDatabase},
- _configsvrMoveChunk: {skip: isNotRunOnUserDatabase}, // Can be removed once 6.0 is last LTS
- _configsvrMovePrimary: {skip: isNotRunOnUserDatabase},
- _configsvrMoveRange: {skip: isNotRunOnUserDatabase},
- _configsvrRefineCollectionShardKey: {skip: isNotRunOnUserDatabase},
- _configsvrRemoveShard: {skip: isNotRunOnUserDatabase},
- _configsvrRemoveShardFromZone: {skip: isNotRunOnUserDatabase},
- _configsvrUpdateZoneKeyRange: {skip: isNotRunOnUserDatabase},
- _flushDatabaseCacheUpdates: {skip: isNotRunOnUserDatabase},
- _flushDatabaseCacheUpdatesWithWriteConcern: {skip: isNotRunOnUserDatabase},
- _flushReshardingStateChange: {skip: isNotRunOnUserDatabase},
- _flushRoutingTableCacheUpdates: {skip: isNotRunOnUserDatabase},
- _flushRoutingTableCacheUpdatesWithWriteConcern: {skip: isNotRunOnUserDatabase},
- _getNextSessionMods: {skip: isNotRunOnUserDatabase},
- _getUserCacheGeneration: {skip: isNotRunOnUserDatabase},
- _hashBSONElement: {skip: isNotRunOnUserDatabase},
- _isSelf: {skip: isNotRunOnUserDatabase},
- _killOperations: {skip: isNotRunOnUserDatabase},
- _mergeAuthzCollections: {skip: isNotRunOnUserDatabase},
- _migrateClone: {skip: isNotRunOnUserDatabase},
- _recvChunkAbort: {skip: isNotRunOnUserDatabase},
- _recvChunkCommit: {skip: isNotRunOnUserDatabase},
- _recvChunkReleaseCritSec: {skip: isNotRunOnUserDatabase},
- _recvChunkStart: {skip: isNotRunOnUserDatabase},
- _recvChunkStatus: {skip: isNotRunOnUserDatabase},
- _shardsvrCloneCatalogData: {skip: isNotRunOnUserDatabase},
- _shardsvrCommitIndexParticipant: {skip: isOnlySupportedOnShardedCluster},
- _shardsvrCompactStructuredEncryptionData: {skip: isOnlySupportedOnShardedCluster},
- _shardsvrCreateCollection: {skip: isOnlySupportedOnShardedCluster},
- _shardsvrCreateCollectionParticipant: {skip: isOnlySupportedOnShardedCluster},
- _shardsvrRegisterIndex: {skip: isOnlySupportedOnShardedCluster},
- _shardsvrDropIndexCatalogEntryParticipant: {skip: isOnlySupportedOnShardedCluster},
- _shardsvrMovePrimary: {skip: isNotRunOnUserDatabase},
- _shardsvrSetAllowMigrations: {skip: isOnlySupportedOnShardedCluster},
- _shardsvrRenameCollection: {skip: isOnlySupportedOnShardedCluster},
- _shardsvrUnregisterIndex: {skip: isOnlySupportedOnShardedCluster},
- _transferMods: {skip: isNotRunOnUserDatabase},
- abortTransaction: {
- skip: isNotWriteCommand // aborting unprepared transaction doesn't create an abort
- // oplog entry.
- },
- aggregate: {
- explicitlyCreateCollection: true,
- command: function(dbName, collName) {
- return {
- aggregate: collName,
- pipeline: [{$out: collName + "Out"}],
- cursor: {batchSize: 1}
- };
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert(collectionExists(db, collName + "Out"));
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert(!collectionExists(db, collName + "Out"));
- }
+TenantMigrationConcurrentWriteUtil.kNumInitialDocs =
+ 2; // num initial docs to insert into test collections.
+TenantMigrationConcurrentWriteUtil.kTxnNumber = NumberLong(0);
+
+TenantMigrationConcurrentWriteUtil.testCases = {
+ _addShard: {skip: isNotRunOnUserDatabase},
+ _cloneCollectionOptionsFromPrimaryShard: {skip: isNotRunOnUserDatabase},
+ _configsvrAddShard: {skip: isNotRunOnUserDatabase},
+ _configsvrAddShardToZone: {skip: isNotRunOnUserDatabase},
+ _configsvrBalancerCollectionStatus: {skip: isNotRunOnUserDatabase},
+ _configsvrBalancerStart: {skip: isNotRunOnUserDatabase},
+ _configsvrBalancerStatus: {skip: isNotRunOnUserDatabase},
+ _configsvrBalancerStop: {skip: isNotRunOnUserDatabase},
+ _configsvrClearJumboFlag: {skip: isNotRunOnUserDatabase},
+ _configsvrCommitChunksMerge: {skip: isNotRunOnUserDatabase},
+ _configsvrCommitChunkMigration: {skip: isNotRunOnUserDatabase},
+ _configsvrCommitChunkSplit: {skip: isNotRunOnUserDatabase},
+ _configsvrCommitIndex: {skip: isNotRunOnUserDatabase},
+ _configsvrCommitMovePrimary:
+ {skip: isNotRunOnUserDatabase}, // Can be removed once 6.0 is last LTS
+ _configsvrCreateDatabase: {skip: isNotRunOnUserDatabase},
+ _configsvrDropIndexCatalogEntry: {skip: isNotRunOnUserDatabase},
+ _configsvrEnsureChunkVersionIsGreaterThan: {skip: isNotRunOnUserDatabase},
+ _configsvrMoveChunk: {skip: isNotRunOnUserDatabase}, // Can be removed once 6.0 is last LTS
+ _configsvrMovePrimary: {skip: isNotRunOnUserDatabase},
+ _configsvrMoveRange: {skip: isNotRunOnUserDatabase},
+ _configsvrRefineCollectionShardKey: {skip: isNotRunOnUserDatabase},
+ _configsvrRemoveShard: {skip: isNotRunOnUserDatabase},
+ _configsvrRemoveShardFromZone: {skip: isNotRunOnUserDatabase},
+ _configsvrUpdateZoneKeyRange: {skip: isNotRunOnUserDatabase},
+ _flushDatabaseCacheUpdates: {skip: isNotRunOnUserDatabase},
+ _flushDatabaseCacheUpdatesWithWriteConcern: {skip: isNotRunOnUserDatabase},
+ _flushReshardingStateChange: {skip: isNotRunOnUserDatabase},
+ _flushRoutingTableCacheUpdates: {skip: isNotRunOnUserDatabase},
+ _flushRoutingTableCacheUpdatesWithWriteConcern: {skip: isNotRunOnUserDatabase},
+ _getNextSessionMods: {skip: isNotRunOnUserDatabase},
+ _getUserCacheGeneration: {skip: isNotRunOnUserDatabase},
+ _hashBSONElement: {skip: isNotRunOnUserDatabase},
+ _isSelf: {skip: isNotRunOnUserDatabase},
+ _killOperations: {skip: isNotRunOnUserDatabase},
+ _mergeAuthzCollections: {skip: isNotRunOnUserDatabase},
+ _migrateClone: {skip: isNotRunOnUserDatabase},
+ _recvChunkAbort: {skip: isNotRunOnUserDatabase},
+ _recvChunkCommit: {skip: isNotRunOnUserDatabase},
+ _recvChunkReleaseCritSec: {skip: isNotRunOnUserDatabase},
+ _recvChunkStart: {skip: isNotRunOnUserDatabase},
+ _recvChunkStatus: {skip: isNotRunOnUserDatabase},
+ _shardsvrCloneCatalogData: {skip: isNotRunOnUserDatabase},
+ _shardsvrCommitIndexParticipant: {skip: isOnlySupportedOnShardedCluster},
+ _shardsvrCompactStructuredEncryptionData: {skip: isOnlySupportedOnShardedCluster},
+ _shardsvrCreateCollection: {skip: isOnlySupportedOnShardedCluster},
+ _shardsvrCreateCollectionParticipant: {skip: isOnlySupportedOnShardedCluster},
+ _shardsvrRegisterIndex: {skip: isOnlySupportedOnShardedCluster},
+ _shardsvrDropIndexCatalogEntryParticipant: {skip: isOnlySupportedOnShardedCluster},
+ _shardsvrMovePrimary: {skip: isNotRunOnUserDatabase},
+ _shardsvrSetAllowMigrations: {skip: isOnlySupportedOnShardedCluster},
+ _shardsvrRenameCollection: {skip: isOnlySupportedOnShardedCluster},
+ _shardsvrUnregisterIndex: {skip: isOnlySupportedOnShardedCluster},
+ _transferMods: {skip: isNotRunOnUserDatabase},
+ abortTransaction: {
+ skip: isNotWriteCommand // aborting unprepared transaction doesn't create an abort oplog
+ // entry.
+ },
+ aggregate: {
+ explicitlyCreateCollection: true,
+ command: function(dbName, collName) {
+ return {
+ aggregate: collName,
+ pipeline: [{$out: collName + "Out"}],
+ cursor: {batchSize: 1}
+ };
},
- appendOplogNote: {skip: isNotRunOnUserDatabase},
- applyOps: {skip: isNotSupportedInServerless},
- authenticate: {skip: isAuthCommand},
- buildInfo: {skip: isNotWriteCommand},
- captrunc: {skip: isNotSupportedInServerless},
- checkShardingIndex: {skip: isNotRunOnUserDatabase},
- cleanupOrphaned: {skip: isNotRunOnUserDatabase},
- clearLog: {skip: isNotRunOnUserDatabase},
- cloneCollectionAsCapped: {skip: isNotSupportedInServerless},
- collMod: {
- explicitlyCreateCollection: true,
- setUp: createTestIndex,
- command: function(dbName, collName) {
- return {
- collMod: collName,
- index: {keyPattern: kTestIndexKey, expireAfterSeconds: kExpireAfterSeconds + 1}
- };
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert(
- indexExists(db,
- collName,
- {key: kTestIndexKey, expireAfterSeconds: kExpireAfterSeconds + 1}));
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert(!indexExists(
- db,
- collName,
- {key: kTestIndexKey, expireAfterSeconds: kExpireAfterSeconds + 1}));
- }
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert(collectionExists(db, collName + "Out"));
},
- collStats: {skip: isNotWriteCommand},
- commitTransaction: {
- isTransactionCommand: true,
- runAgainstAdminDb: true,
- setUp: function(primaryDB, collName) {
- assert.commandWorked(primaryDB.runCommand({
- insert: collName,
- documents: [kTestDoc],
- txnNumber: NumberLong(kTxnNumber),
- startTransaction: true,
- autocommit: false
- }));
- },
- command: function(dbName, collName) {
- return {
- commitTransaction: 1,
- txnNumber: NumberLong(kTxnNumber),
- autocommit: false,
- writeConcern: {w: "majority"}
- };
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName), 1);
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName), 0);
- }
+ assertCommandFailed: function(db, dbName, collName) {
+ assert(!collectionExists(db, collName + "Out"));
+ }
+ },
+ appendOplogNote: {skip: isNotRunOnUserDatabase},
+ applyOps: {skip: isNotSupportedInServerless},
+ authenticate: {skip: isAuthCommand},
+ buildInfo: {skip: isNotWriteCommand},
+ captrunc: {skip: isNotSupportedInServerless},
+ checkShardingIndex: {skip: isNotRunOnUserDatabase},
+ cleanupOrphaned: {skip: isNotRunOnUserDatabase},
+ clearLog: {skip: isNotRunOnUserDatabase},
+ cloneCollectionAsCapped: {skip: isNotSupportedInServerless},
+ collMod: {
+ explicitlyCreateCollection: true,
+ setUp: createTestIndex,
+ command: function(dbName, collName) {
+ return {
+ collMod: collName,
+ index: {
+ keyPattern: TenantMigrationConcurrentWriteUtil.kTestIndexKey,
+ expireAfterSeconds: TenantMigrationConcurrentWriteUtil.kExpireAfterSeconds + 1
+ }
+ };
},
- compact: {skip: isNotSupportedInServerless},
- configureFailPoint: {skip: isNotRunOnUserDatabase},
- connPoolStats: {skip: isNotRunOnUserDatabase},
- connPoolSync: {skip: isNotRunOnUserDatabase},
- connectionStatus: {skip: isNotRunOnUserDatabase},
- convertToCapped: {skip: isNotSupportedInServerless},
- coordinateCommitTransaction: {skip: isNotRunOnUserDatabase},
- count: {skip: isNotWriteCommand},
- cpuload: {skip: isNotRunOnUserDatabase},
- create: {
- testInTransaction: true,
- command: function(dbName, collName) {
- return {create: collName};
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert(collectionExists(db, collName));
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert(!collectionExists(db, collName));
- }
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert(indexExists(db, collName, {
+ key: TenantMigrationConcurrentWriteUtil.kTestIndexKey,
+ expireAfterSeconds: TenantMigrationConcurrentWriteUtil.kExpireAfterSeconds + 1
+ }));
},
- createIndexes: {
- testInTransaction: true,
- explicitlyCreateCollection: true,
- setUp: function(primaryDB, collName, testInTransaction) {
- if (testInTransaction) {
- // Drop the collection that was explicitly created above since inside
- // transactions the index to create must either be on a non-existing
- // collection, or on a new empty collection created earlier in the same
- // transaction.
- assert.commandWorked(primaryDB.runCommand({drop: collName}));
- }
- },
- command: function(dbName, collName) {
- return {createIndexes: collName, indexes: [kTestIndex]};
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert(indexExists(db, collName, kTestIndex));
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert(!collectionExists(db, collName) || !indexExists(db, collName, kTestIndex));
- }
+ assertCommandFailed: function(db, dbName, collName) {
+ assert(!indexExists(db, collName, {
+ key: TenantMigrationConcurrentWriteUtil.kTestIndexKey,
+ expireAfterSeconds: TenantMigrationConcurrentWriteUtil.kExpireAfterSeconds + 1
+ }));
+ }
+ },
+ collStats: {skip: isNotWriteCommand},
+ commitTransaction: {
+ isTransactionCommand: true,
+ runAgainstAdminDb: true,
+ setUp: function(primaryDB, collName) {
+ assert.commandWorked(primaryDB.runCommand({
+ insert: collName,
+ documents: [TenantMigrationConcurrentWriteUtil.kTestDoc],
+ txnNumber: NumberLong(TenantMigrationConcurrentWriteUtil.kTxnNumber),
+ startTransaction: true,
+ autocommit: false
+ }));
},
- createRole: {skip: isAuthCommand},
- createUser: {skip: isAuthCommand},
- currentOp: {skip: isNotRunOnUserDatabase},
- dataSize: {skip: isNotWriteCommand},
- dbCheck: {skip: isNotWriteCommand},
- dbHash: {skip: isNotWriteCommand},
- dbStats: {skip: isNotWriteCommand},
- delete: {
- testInTransaction: true,
- testAsRetryableWrite: true,
- setUp: insertTestDoc,
- command: function(dbName, collName) {
- return {delete: collName, deletes: [{q: kTestDoc, limit: 1}]};
- },
- isBatchWrite: true,
- assertCommandSucceeded: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, kTestDoc), 0);
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, kTestDoc), 1);
- }
+ command: function(dbName, collName) {
+ return {
+ commitTransaction: 1,
+ txnNumber: NumberLong(TenantMigrationConcurrentWriteUtil.kTxnNumber),
+ autocommit: false,
+ writeConcern: {w: "majority"}
+ };
},
- distinct: {skip: isNotWriteCommand},
- donorForgetMigration: {skip: isNotRunOnUserDatabase},
- donorStartMigration: {skip: isNotRunOnUserDatabase},
- donorWaitForMigrationToCommit: {skip: isNotRunOnUserDatabase},
- driverOIDTest: {skip: isNotRunOnUserDatabase},
- drop: {
- explicitlyCreateCollection: true,
- command: function(dbName, collName) {
- return {drop: collName};
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert(!collectionExists(db, collName));
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert(collectionExists(db, collName));
- }
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName), 1);
},
- dropAllRolesFromDatabase: {skip: isAuthCommand},
- dropAllUsersFromDatabase: {skip: isAuthCommand},
- dropConnections: {skip: isNotRunOnUserDatabase},
- dropDatabase: {
- explicitlyCreateCollection: true,
- command: function(dbName, collName) {
- return {dropDatabase: 1};
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert(!databaseExists(db, dbName));
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert(databaseExists(db, dbName));
- }
+ assertCommandFailed: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName), 0);
+ }
+ },
+ compact: {skip: isNotSupportedInServerless},
+ configureFailPoint: {skip: isNotRunOnUserDatabase},
+ connPoolStats: {skip: isNotRunOnUserDatabase},
+ connPoolSync: {skip: isNotRunOnUserDatabase},
+ connectionStatus: {skip: isNotRunOnUserDatabase},
+ convertToCapped: {skip: isNotSupportedInServerless},
+ coordinateCommitTransaction: {skip: isNotRunOnUserDatabase},
+ count: {skip: isNotWriteCommand},
+ cpuload: {skip: isNotRunOnUserDatabase},
+ create: {
+ testInTransaction: true,
+ command: function(dbName, collName) {
+ return {create: collName};
},
- dropIndexes: {
- explicitlyCreateCollection: true,
- setUp: createTestIndex,
- command: function(dbName, collName) {
- return {dropIndexes: collName, index: "*"};
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert(!indexExists(db, collName, kTestIndex));
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert(indexExists(db, collName, kTestIndex));
- }
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert(collectionExists(db, collName));
},
- dropRole: {skip: isAuthCommand},
- dropUser: {skip: isAuthCommand},
- echo: {skip: isNotRunOnUserDatabase},
- emptycapped: {skip: isNotSupportedInServerless},
- endSessions: {skip: isNotRunOnUserDatabase},
- explain: {skip: isNotRunOnUserDatabase},
- features: {skip: isNotRunOnUserDatabase},
- filemd5: {skip: isNotWriteCommand},
- find: {skip: isNotWriteCommand},
- findAndModify: {
- testInTransaction: true,
- testAsRetryableWrite: true,
- setUp: insertTestDoc,
- command: function(dbName, collName) {
- return {findAndModify: collName, query: kTestDoc, remove: true};
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, kTestDoc), 0);
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, kTestDoc), 1);
+ assertCommandFailed: function(db, dbName, collName) {
+ assert(!collectionExists(db, collName));
+ }
+ },
+ createIndexes: {
+ testInTransaction: true,
+ explicitlyCreateCollection: true,
+ setUp: function(primaryDB, collName, testInTransaction) {
+ if (testInTransaction) {
+ // Drop the collection that was explicitly created above since inside transactions
+ // the index to create must either be on a non-existing collection, or on a new
+ // empty collection created earlier in the same transaction.
+ assert.commandWorked(primaryDB.runCommand({drop: collName}));
}
},
- flushRouterConfig: {skip: isNotRunOnUserDatabase},
- fsync: {skip: isNotRunOnUserDatabase},
- fsyncUnlock: {skip: isNotRunOnUserDatabase},
- getCmdLineOpts: {skip: isNotRunOnUserDatabase},
- getDatabaseVersion: {skip: isNotRunOnUserDatabase},
- getDefaultRWConcern: {skip: isNotRunOnUserDatabase},
- getDiagnosticData: {skip: isNotRunOnUserDatabase},
- getFreeMonitoringStatus: {skip: isNotRunOnUserDatabase},
- getLog: {skip: isNotRunOnUserDatabase},
- getMore: {skip: isNotWriteCommand},
- getParameter: {skip: isNotRunOnUserDatabase},
- getShardMap: {skip: isNotRunOnUserDatabase},
- getShardVersion: {skip: isNotRunOnUserDatabase},
- getnonce: {skip: "removed in v6.3"},
- godinsert: {skip: isNotRunOnUserDatabase},
- grantPrivilegesToRole: {skip: isAuthCommand},
- grantRolesToRole: {skip: isAuthCommand},
- grantRolesToUser: {skip: isAuthCommand},
- hello: {skip: isNotRunOnUserDatabase},
- hostInfo: {skip: isNotRunOnUserDatabase},
- httpClientRequest: {skip: isNotRunOnUserDatabase},
- insert: {
- testInTransaction: true,
- testAsRetryableWrite: true,
- explicitlyCreateCollection: true,
- command: function(dbName, collName) {
- return {insert: collName, documents: [kTestDoc]};
- },
- isBatchWrite: true,
- assertCommandSucceeded: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, kTestDoc), 1);
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, kTestDoc), 0);
- }
+ command: function(dbName, collName) {
+ return {
+ createIndexes: collName,
+ indexes: [TenantMigrationConcurrentWriteUtil.kTestIndex]
+ };
},
- internalRenameIfOptionsAndIndexesMatch: {skip: isNotRunOnUserDatabase},
- invalidateUserCache: {skip: isNotRunOnUserDatabase},
- killAllSessions: {skip: isNotRunOnUserDatabase},
- killAllSessionsByPattern: {skip: isNotRunOnUserDatabase},
- killCursors: {skip: isNotWriteCommand},
- killOp: {skip: isNotRunOnUserDatabase},
- killSessions: {skip: isNotRunOnUserDatabase},
- listCollections: {skip: isNotRunOnUserDatabase},
- listCommands: {skip: isNotRunOnUserDatabase},
- listDatabases: {skip: isNotRunOnUserDatabase},
- listIndexes: {skip: isNotWriteCommand},
- lockInfo: {skip: isNotRunOnUserDatabase},
- logRotate: {skip: isNotRunOnUserDatabase},
- logout: {skip: isNotRunOnUserDatabase},
- makeSnapshot: {skip: isNotRunOnUserDatabase},
- mapReduce: {
- command: function(dbName, collName) {
- return {
- mapReduce: collName,
- map: function mapFunc() {
- emit(this.x, 1);
- },
- reduce: function reduceFunc(key, values) {
- return Array.sum(values);
- },
- out: {replace: collName + "MrOut"},
- };
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert(collectionExists(db, collName + "MrOut"));
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert(!collectionExists(db, collName + "MrOut"));
- }
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert(indexExists(db, collName, TenantMigrationConcurrentWriteUtil.kTestIndex));
},
- mergeChunks: {skip: isNotRunOnUserDatabase},
- moveChunk: {skip: isNotRunOnUserDatabase},
- ping: {skip: isNotRunOnUserDatabase},
- planCacheClear: {skip: isNotWriteCommand},
- planCacheClearFilters: {skip: isNotWriteCommand},
- planCacheListFilters: {skip: isNotWriteCommand},
- planCacheSetFilter: {skip: isNotWriteCommand},
- prepareTransaction: {skip: isOnlySupportedOnShardedCluster},
- profile: {skip: isNotRunOnUserDatabase},
- reIndex: {skip: isOnlySupportedOnStandalone},
- reapLogicalSessionCacheNow: {skip: isNotRunOnUserDatabase},
- refreshLogicalSessionCacheNow: {skip: isNotRunOnUserDatabase},
- refreshSessions: {skip: isNotRunOnUserDatabase},
- recipientVoteImportedFiles: {skip: isNotRunOnUserDatabase},
- renameCollection: {
- runAgainstAdminDb: true,
- explicitlyCreateCollection: true,
- command: function(dbName, collName) {
- return {
- renameCollection: dbName + "." + collName,
- to: dbName + "." + collName + "Renamed"
- };
- },
- assertCommandSucceeded: function(db, dbName, collName) {
- assert(!collectionExists(db, collName));
- assert(collectionExists(db, collName + "Renamed"));
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert(collectionExists(db, collName));
- assert(!collectionExists(db, collName + "Renamed"));
- }
+ assertCommandFailed: function(db, dbName, collName) {
+ assert(!collectionExists(db, collName) ||
+ !indexExists(db, collName, TenantMigrationConcurrentWriteUtil.kTestIndex));
+ }
+ },
+ createRole: {skip: isAuthCommand},
+ createUser: {skip: isAuthCommand},
+ currentOp: {skip: isNotRunOnUserDatabase},
+ dataSize: {skip: isNotWriteCommand},
+ dbCheck: {skip: isNotWriteCommand},
+ dbHash: {skip: isNotWriteCommand},
+ dbStats: {skip: isNotWriteCommand},
+ delete: {
+ testInTransaction: true,
+ testAsRetryableWrite: true,
+ setUp: insertTestDoc,
+ command: function(dbName, collName) {
+ return {
+ delete: collName,
+ deletes: [{q: TenantMigrationConcurrentWriteUtil.kTestDoc, limit: 1}]
+ };
},
- replSetAbortPrimaryCatchUp: {skip: isNotRunOnUserDatabase},
- replSetFreeze: {skip: isNotRunOnUserDatabase},
- replSetGetConfig: {skip: isNotRunOnUserDatabase},
- replSetGetRBID: {skip: isNotRunOnUserDatabase},
- replSetGetStatus: {skip: isNotRunOnUserDatabase},
- replSetHeartbeat: {skip: isNotRunOnUserDatabase},
- replSetInitiate: {skip: isNotRunOnUserDatabase},
- replSetMaintenance: {skip: isNotRunOnUserDatabase},
- replSetReconfig: {skip: isNotRunOnUserDatabase},
- replSetRequestVotes: {skip: isNotRunOnUserDatabase},
- replSetResizeOplog: {skip: isNotRunOnUserDatabase},
- replSetStepDown: {skip: isNotRunOnUserDatabase},
- replSetStepUp: {skip: isNotRunOnUserDatabase},
- replSetSyncFrom: {skip: isNotRunOnUserDatabase},
- replSetTest: {skip: isNotRunOnUserDatabase},
- replSetTestEgress: {skip: isNotRunOnUserDatabase},
- replSetUpdatePosition: {skip: isNotRunOnUserDatabase},
- revokePrivilegesFromRole: {skip: isAuthCommand},
- revokeRolesFromRole: {skip: isAuthCommand},
- revokeRolesFromUser: {skip: isAuthCommand},
- rolesInfo: {skip: isNotWriteCommand},
- rotateCertificates: {skip: isAuthCommand},
- saslContinue: {skip: isAuthCommand},
- saslStart: {skip: isAuthCommand},
- sbe: {skip: isNotRunOnUserDatabase},
- serverStatus: {skip: isNotRunOnUserDatabase},
- setAllowMigrations: {skip: isNotRunOnUserDatabase},
- setCommittedSnapshot: {skip: isNotRunOnUserDatabase},
- setDefaultRWConcern: {skip: isNotRunOnUserDatabase},
- setFeatureCompatibilityVersion: {skip: isNotRunOnUserDatabase},
- setFreeMonitoring: {skip: isNotRunOnUserDatabase},
- setIndexCommitQuorum: {skip: isNotRunOnUserDatabase},
- setParameter: {skip: isNotRunOnUserDatabase},
- setShardVersion: {skip: isNotRunOnUserDatabase},
- shardingState: {skip: isNotRunOnUserDatabase},
- shutdown: {skip: isNotRunOnUserDatabase},
- sleep: {skip: isNotRunOnUserDatabase},
- splitChunk: {skip: isNotRunOnUserDatabase},
- splitVector: {skip: isNotRunOnUserDatabase},
- stageDebug: {skip: isNotRunOnUserDatabase},
- startRecordingTraffic: {skip: isNotRunOnUserDatabase},
- startSession: {skip: isNotRunOnUserDatabase},
- stopRecordingTraffic: {skip: isNotRunOnUserDatabase},
- top: {skip: isNotRunOnUserDatabase},
- update: {
- testInTransaction: true,
- testAsRetryableWrite: true,
- setUp: insertTestDoc,
- command: function(dbName, collName) {
- return {
- update: collName,
- updates: [{q: kTestDoc, u: {$set: {y: 0}}, upsert: false, multi: false}]
- };
- },
- isBatchWrite: true,
- assertCommandSucceeded: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, Object.assign({y: 0}, kTestDoc)), 1);
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, Object.assign({y: 0}, kTestDoc)), 0);
- }
+ isBatchWrite: true,
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName, TenantMigrationConcurrentWriteUtil.kTestDoc), 0);
},
- multiUpdate: {
- testInTransaction: true,
- testAsRetryableWrite: false,
- setUp: insertTwoTestDocs,
- command: function(dbName, collName) {
- return {
- update: collName,
- updates: [{q: {}, u: {$set: {y: 0}}, upsert: false, multi: true}]
- };
- },
- isBatchWrite: true,
- isMultiUpdate: true,
- assertCommandSucceeded: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, Object.assign({y: 0})), 2);
- },
- assertCommandFailed: function(db, dbName, collName) {
- assert.eq(countDocs(db, collName, Object.assign({y: 0})), 0);
- }
+ assertCommandFailed: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName, TenantMigrationConcurrentWriteUtil.kTestDoc), 1);
+ }
+ },
+ distinct: {skip: isNotWriteCommand},
+ donorForgetMigration: {skip: isNotRunOnUserDatabase},
+ donorStartMigration: {skip: isNotRunOnUserDatabase},
+ donorWaitForMigrationToCommit: {skip: isNotRunOnUserDatabase},
+ driverOIDTest: {skip: isNotRunOnUserDatabase},
+ drop: {
+ explicitlyCreateCollection: true,
+ command: function(dbName, collName) {
+ return {drop: collName};
},
- updateRole: {skip: isAuthCommand},
- updateUser: {skip: isNotRunOnUserDatabase},
- usersInfo: {skip: isNotRunOnUserDatabase},
- validate: {skip: isNotWriteCommand},
- voteCommitIndexBuild: {skip: isNotRunOnUserDatabase},
- waitForFailPoint: {skip: isNotRunOnUserDatabase},
- waitForOngoingChunkSplits: {skip: isNotRunOnUserDatabase},
- whatsmysni: {skip: isNotRunOnUserDatabase},
- whatsmyuri: {skip: isNotRunOnUserDatabase}
- }
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert(!collectionExists(db, collName));
+ },
+ assertCommandFailed: function(db, dbName, collName) {
+ assert(collectionExists(db, collName));
+ }
+ },
+ dropAllRolesFromDatabase: {skip: isAuthCommand},
+ dropAllUsersFromDatabase: {skip: isAuthCommand},
+ dropConnections: {skip: isNotRunOnUserDatabase},
+ dropDatabase: {
+ explicitlyCreateCollection: true,
+ command: function(dbName, collName) {
+ return {dropDatabase: 1};
+ },
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert(!databaseExists(db, dbName));
+ },
+ assertCommandFailed: function(db, dbName, collName) {
+ assert(databaseExists(db, dbName));
+ }
+ },
+ dropIndexes: {
+ explicitlyCreateCollection: true,
+ setUp: createTestIndex,
+ command: function(dbName, collName) {
+ return {dropIndexes: collName, index: "*"};
+ },
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert(!indexExists(db, collName, TenantMigrationConcurrentWriteUtil.kTestIndex));
+ },
+ assertCommandFailed: function(db, dbName, collName) {
+ assert(indexExists(db, collName, TenantMigrationConcurrentWriteUtil.kTestIndex));
+ }
+ },
+ dropRole: {skip: isAuthCommand},
+ dropUser: {skip: isAuthCommand},
+ echo: {skip: isNotRunOnUserDatabase},
+ emptycapped: {skip: isNotSupportedInServerless},
+ endSessions: {skip: isNotRunOnUserDatabase},
+ explain: {skip: isNotRunOnUserDatabase},
+ features: {skip: isNotRunOnUserDatabase},
+ filemd5: {skip: isNotWriteCommand},
+ find: {skip: isNotWriteCommand},
+ findAndModify: {
+ testInTransaction: true,
+ testAsRetryableWrite: true,
+ setUp: insertTestDoc,
+ command: function(dbName, collName) {
+ return {
+ findAndModify: collName,
+ query: TenantMigrationConcurrentWriteUtil.kTestDoc,
+ remove: true
+ };
+ },
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName, TenantMigrationConcurrentWriteUtil.kTestDoc), 0);
+ },
+ assertCommandFailed: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName, TenantMigrationConcurrentWriteUtil.kTestDoc), 1);
+ }
+ },
+ flushRouterConfig: {skip: isNotRunOnUserDatabase},
+ fsync: {skip: isNotRunOnUserDatabase},
+ fsyncUnlock: {skip: isNotRunOnUserDatabase},
+ getCmdLineOpts: {skip: isNotRunOnUserDatabase},
+ getDatabaseVersion: {skip: isNotRunOnUserDatabase},
+ getDefaultRWConcern: {skip: isNotRunOnUserDatabase},
+ getDiagnosticData: {skip: isNotRunOnUserDatabase},
+ getFreeMonitoringStatus: {skip: isNotRunOnUserDatabase},
+ getLog: {skip: isNotRunOnUserDatabase},
+ getMore: {skip: isNotWriteCommand},
+ getParameter: {skip: isNotRunOnUserDatabase},
+ getShardMap: {skip: isNotRunOnUserDatabase},
+ getShardVersion: {skip: isNotRunOnUserDatabase},
+ getnonce: {skip: "removed in v6.3"},
+ godinsert: {skip: isNotRunOnUserDatabase},
+ grantPrivilegesToRole: {skip: isAuthCommand},
+ grantRolesToRole: {skip: isAuthCommand},
+ grantRolesToUser: {skip: isAuthCommand},
+ hello: {skip: isNotRunOnUserDatabase},
+ hostInfo: {skip: isNotRunOnUserDatabase},
+ httpClientRequest: {skip: isNotRunOnUserDatabase},
+ insert: {
+ testInTransaction: true,
+ testAsRetryableWrite: true,
+ explicitlyCreateCollection: true,
+ command: function(dbName, collName) {
+ return {insert: collName, documents: [TenantMigrationConcurrentWriteUtil.kTestDoc]};
+ },
+ isBatchWrite: true,
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName, TenantMigrationConcurrentWriteUtil.kTestDoc), 1);
+ },
+ assertCommandFailed: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName, TenantMigrationConcurrentWriteUtil.kTestDoc), 0);
+ }
+ },
+ internalRenameIfOptionsAndIndexesMatch: {skip: isNotRunOnUserDatabase},
+ invalidateUserCache: {skip: isNotRunOnUserDatabase},
+ killAllSessions: {skip: isNotRunOnUserDatabase},
+ killAllSessionsByPattern: {skip: isNotRunOnUserDatabase},
+ killCursors: {skip: isNotWriteCommand},
+ killOp: {skip: isNotRunOnUserDatabase},
+ killSessions: {skip: isNotRunOnUserDatabase},
+ listCollections: {skip: isNotRunOnUserDatabase},
+ listCommands: {skip: isNotRunOnUserDatabase},
+ listDatabases: {skip: isNotRunOnUserDatabase},
+ listIndexes: {skip: isNotWriteCommand},
+ lockInfo: {skip: isNotRunOnUserDatabase},
+ logRotate: {skip: isNotRunOnUserDatabase},
+ logout: {skip: isNotRunOnUserDatabase},
+ makeSnapshot: {skip: isNotRunOnUserDatabase},
+ mapReduce: {
+ command: function(dbName, collName) {
+ return {
+ mapReduce: collName,
+ map: function mapFunc() {
+ emit(this.x, 1);
+ },
+ reduce: function reduceFunc(key, values) {
+ return Array.sum(values);
+ },
+ out: {replace: collName + "MrOut"},
+ };
+ },
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert(collectionExists(db, collName + "MrOut"));
+ },
+ assertCommandFailed: function(db, dbName, collName) {
+ assert(!collectionExists(db, collName + "MrOut"));
+ }
+ },
+ mergeChunks: {skip: isNotRunOnUserDatabase},
+ moveChunk: {skip: isNotRunOnUserDatabase},
+ ping: {skip: isNotRunOnUserDatabase},
+ planCacheClear: {skip: isNotWriteCommand},
+ planCacheClearFilters: {skip: isNotWriteCommand},
+ planCacheListFilters: {skip: isNotWriteCommand},
+ planCacheSetFilter: {skip: isNotWriteCommand},
+ prepareTransaction: {skip: isOnlySupportedOnShardedCluster},
+ profile: {skip: isNotRunOnUserDatabase},
+ reIndex: {skip: isOnlySupportedOnStandalone},
+ reapLogicalSessionCacheNow: {skip: isNotRunOnUserDatabase},
+ refreshLogicalSessionCacheNow: {skip: isNotRunOnUserDatabase},
+ refreshSessions: {skip: isNotRunOnUserDatabase},
+ recipientVoteImportedFiles: {skip: isNotRunOnUserDatabase},
+ renameCollection: {
+ runAgainstAdminDb: true,
+ explicitlyCreateCollection: true,
+ command: function(dbName, collName) {
+ return {
+ renameCollection: dbName + "." + collName,
+ to: dbName + "." + collName + "Renamed"
+ };
+ },
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert(!collectionExists(db, collName));
+ assert(collectionExists(db, collName + "Renamed"));
+ },
+ assertCommandFailed: function(db, dbName, collName) {
+ assert(collectionExists(db, collName));
+ assert(!collectionExists(db, collName + "Renamed"));
+ }
+ },
+ replSetAbortPrimaryCatchUp: {skip: isNotRunOnUserDatabase},
+ replSetFreeze: {skip: isNotRunOnUserDatabase},
+ replSetGetConfig: {skip: isNotRunOnUserDatabase},
+ replSetGetRBID: {skip: isNotRunOnUserDatabase},
+ replSetGetStatus: {skip: isNotRunOnUserDatabase},
+ replSetHeartbeat: {skip: isNotRunOnUserDatabase},
+ replSetInitiate: {skip: isNotRunOnUserDatabase},
+ replSetMaintenance: {skip: isNotRunOnUserDatabase},
+ replSetReconfig: {skip: isNotRunOnUserDatabase},
+ replSetRequestVotes: {skip: isNotRunOnUserDatabase},
+ replSetResizeOplog: {skip: isNotRunOnUserDatabase},
+ replSetStepDown: {skip: isNotRunOnUserDatabase},
+ replSetStepUp: {skip: isNotRunOnUserDatabase},
+ replSetSyncFrom: {skip: isNotRunOnUserDatabase},
+ replSetTest: {skip: isNotRunOnUserDatabase},
+ replSetTestEgress: {skip: isNotRunOnUserDatabase},
+ replSetUpdatePosition: {skip: isNotRunOnUserDatabase},
+ revokePrivilegesFromRole: {skip: isAuthCommand},
+ revokeRolesFromRole: {skip: isAuthCommand},
+ revokeRolesFromUser: {skip: isAuthCommand},
+ rolesInfo: {skip: isNotWriteCommand},
+ rotateCertificates: {skip: isAuthCommand},
+ saslContinue: {skip: isAuthCommand},
+ saslStart: {skip: isAuthCommand},
+ sbe: {skip: isNotRunOnUserDatabase},
+ serverStatus: {skip: isNotRunOnUserDatabase},
+ setAllowMigrations: {skip: isNotRunOnUserDatabase},
+ setCommittedSnapshot: {skip: isNotRunOnUserDatabase},
+ setDefaultRWConcern: {skip: isNotRunOnUserDatabase},
+ setFeatureCompatibilityVersion: {skip: isNotRunOnUserDatabase},
+ setFreeMonitoring: {skip: isNotRunOnUserDatabase},
+ setIndexCommitQuorum: {skip: isNotRunOnUserDatabase},
+ setParameter: {skip: isNotRunOnUserDatabase},
+ setShardVersion: {skip: isNotRunOnUserDatabase},
+ shardingState: {skip: isNotRunOnUserDatabase},
+ shutdown: {skip: isNotRunOnUserDatabase},
+ sleep: {skip: isNotRunOnUserDatabase},
+ splitChunk: {skip: isNotRunOnUserDatabase},
+ splitVector: {skip: isNotRunOnUserDatabase},
+ stageDebug: {skip: isNotRunOnUserDatabase},
+ startRecordingTraffic: {skip: isNotRunOnUserDatabase},
+ startSession: {skip: isNotRunOnUserDatabase},
+ stopRecordingTraffic: {skip: isNotRunOnUserDatabase},
+ top: {skip: isNotRunOnUserDatabase},
+ update: {
+ testInTransaction: true,
+ testAsRetryableWrite: true,
+ setUp: insertTestDoc,
+ command: function(dbName, collName) {
+ return {
+ update: collName,
+ updates: [{
+ q: TenantMigrationConcurrentWriteUtil.kTestDoc,
+ u: {$set: {y: 0}},
+ upsert: false,
+ multi: false
+ }]
+ };
+ },
+ isBatchWrite: true,
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert.eq(countDocs(db,
+ collName,
+ Object.assign({y: 0}, TenantMigrationConcurrentWriteUtil.kTestDoc)),
+ 1);
+ },
+ assertCommandFailed: function(db, dbName, collName) {
+ assert.eq(countDocs(db,
+ collName,
+ Object.assign({y: 0}, TenantMigrationConcurrentWriteUtil.kTestDoc)),
+ 0);
+ }
+ },
+ multiUpdate: {
+ testInTransaction: true,
+ testAsRetryableWrite: false,
+ setUp: insertTwoTestDocs,
+ command: function(dbName, collName) {
+ return {
+ update: collName,
+ updates: [{q: {}, u: {$set: {y: 0}}, upsert: false, multi: true}]
+ };
+ },
+ isBatchWrite: true,
+ isMultiUpdate: true,
+ assertCommandSucceeded: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName, Object.assign({y: 0})), 2);
+ },
+ assertCommandFailed: function(db, dbName, collName) {
+ assert.eq(countDocs(db, collName, Object.assign({y: 0})), 0);
+ }
+ },
+ updateRole: {skip: isAuthCommand},
+ updateUser: {skip: isNotRunOnUserDatabase},
+ usersInfo: {skip: isNotRunOnUserDatabase},
+ validate: {skip: isNotWriteCommand},
+ voteCommitIndexBuild: {skip: isNotRunOnUserDatabase},
+ waitForFailPoint: {skip: isNotRunOnUserDatabase},
+ waitForOngoingChunkSplits: {skip: isNotRunOnUserDatabase},
+ whatsmysni: {skip: isNotRunOnUserDatabase},
+ whatsmyuri: {skip: isNotRunOnUserDatabase}
};
function validateTestCase(testCase) {
diff --git a/jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js b/jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js
index 5ce9f27a128..c2acc7b800b 100644
--- a/jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js
+++ b/jstests/replsets/tenant_migration_concurrent_writes_on_recipient.js
@@ -11,16 +11,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), quickGarbageCollection: true});
@@ -59,12 +57,13 @@ function cleanup(dbName) {
let waitForRejectReadsBeforeTsFp = configureFailPoint(
recipientPrimary, "fpAfterWaitForRejectReadsBeforeTimestamp", {action: "hang"});
- const donorRstArgs = createRstArgs(donorRst);
- const runMigrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
+ const runMigrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
runMigrationThread.start();
startOplogFetcherFp.wait();
- if (!isShardMergeEnabled(donorPrimary.getDB("adminDB"))) {
+ if (!TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("adminDB"))) {
// Write before cloning is done.
assert.commandFailedWithCode(tenantCollOnRecipient.remove({_id: 1}),
ErrorCodes.SnapshotTooOld);
@@ -179,3 +178,4 @@ function cleanup(dbName) {
cleanup(donorDB);
})();
tenantMigrationTest.stop();
+})();
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 9cbd20de21f..a5be8afa983 100644
--- a/jstests/replsets/tenant_migration_conflicting_donor_start_migration_cmds.js
+++ b/jstests/replsets/tenant_migration_conflicting_donor_start_migration_cmds.js
@@ -10,15 +10,11 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- getCertificateAndPrivateKey,
- isShardMergeEnabled,
- makeX509OptionsForTest,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+'use strict';
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
function getRecipientSyncDataMetrics(recipientPrimary) {
return recipientPrimary.adminCommand({serverStatus: 1}).metrics.commands.recipientSyncData;
@@ -51,7 +47,7 @@ function assertNoCertificateOrPrivateKey(string) {
assert(!string.includes("PRIVATE KEY"), "found private key");
}
-const {donor: donorNodeOptions} = makeX509OptionsForTest();
+const {donor: donorNodeOptions} = TenantMigrationUtil.makeX509OptionsForTest();
donorNodeOptions.setParameter = donorNodeOptions.setParameter || {};
Object.assign(donorNodeOptions.setParameter, {
tenantMigrationGarbageCollectionDelayMS: 1 * 1000,
@@ -274,7 +270,7 @@ function testConcurrentConflictingMigrations({
// Test different tenantIds.
(() => {
- if (isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
jsTestLog(
"Skip: featureFlagShardMerge is enabled and this test tests migrations with different tenant ids.");
return;
@@ -329,7 +325,7 @@ function testConcurrentConflictingMigrations({
// Test different cloning read preference.
(() => {
- if (isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
jsTestLog(
"Skip: featureFlagShardMerge is enabled and this test tests migration's secondary read preference.");
return;
@@ -355,13 +351,13 @@ function testConcurrentConflictingMigrations({
})();
const kDonorCertificateAndPrivateKey =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_donor.pem");
-const kExpiredDonorCertificateAndPrivateKey =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_donor_expired.pem");
+ TenantMigrationUtil.getCertificateAndPrivateKey("jstests/libs/tenant_migration_donor.pem");
+const kExpiredDonorCertificateAndPrivateKey = TenantMigrationUtil.getCertificateAndPrivateKey(
+ "jstests/libs/tenant_migration_donor_expired.pem");
const kRecipientCertificateAndPrivateKey =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem");
-const kExpiredRecipientCertificateAndPrivateKey =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient_expired.pem");
+ TenantMigrationUtil.getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem");
+const kExpiredRecipientCertificateAndPrivateKey = TenantMigrationUtil.getCertificateAndPrivateKey(
+ "jstests/libs/tenant_migration_recipient_expired.pem");
// Test different donor certificates.
(() => {
@@ -412,3 +408,4 @@ const kExpiredRecipientCertificateAndPrivateKey =
})();
teardown();
+})();
diff --git a/jstests/replsets/tenant_migration_conflicting_recipient_sync_data_cmds.js b/jstests/replsets/tenant_migration_conflicting_recipient_sync_data_cmds.js
index e916860da16..a8278e285dc 100644
--- a/jstests/replsets/tenant_migration_conflicting_recipient_sync_data_cmds.js
+++ b/jstests/replsets/tenant_migration_conflicting_recipient_sync_data_cmds.js
@@ -10,18 +10,16 @@
* serverless,
* ]
*/
+(function() {
-import {
- getCertificateAndPrivateKey,
- makeX509OptionsForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
-
-load("jstests/libs/fail_point_util.js");
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
-var rst = new ReplSetTest({nodes: 1, nodeOptions: makeX509OptionsForTest().donor});
+var rst =
+ new ReplSetTest({nodes: 1, nodeOptions: TenantMigrationUtil.makeX509OptionsForTest().donor});
rst.startSet();
rst.initiate();
const primary = rst.getPrimary();
@@ -37,9 +35,9 @@ const kSecondaryReadPreference = {
mode: "secondary"
};
const kRecipientCertificateForDonor =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem");
-const kExpiredRecipientCertificateForDonor =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient_expired.pem");
+ TenantMigrationUtil.getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem");
+const kExpiredRecipientCertificateForDonor = TenantMigrationUtil.getCertificateAndPrivateKey(
+ "jstests/libs/tenant_migration_recipient_expired.pem");
TestData.stopFailPointErrorCode = 4880402;
@@ -298,3 +296,4 @@ function testConcurrentConflictingMigration(migrationOpts0, migrationOpts1) {
})();
rst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_abort_state_transition.js b/jstests/replsets/tenant_migration_donor_abort_state_transition.js
index 34541c6f078..2cb3de475e2 100644
--- a/jstests/replsets/tenant_migration_donor_abort_state_transition.js
+++ b/jstests/replsets/tenant_migration_donor_abort_state_transition.js
@@ -9,14 +9,14 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {runMigrationAsync} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/parallelTester.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
/**
* Starts a migration and forces the write to insert the donor's state doc to abort on the first few
@@ -43,11 +43,12 @@ function testAbortInitialState() {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
// Run the migration in its own thread, since the initial 'donorStartMigration' command will
// hang due to the failpoint.
- let migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ let migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
writeConflictFp.wait();
@@ -148,3 +149,4 @@ jsTest.log("Test aborting donor's state doc update");
}].forEach(({pauseFailPoint, setUpFailPoints = [], nextState}) => {
testAbortStateTransition(pauseFailPoint, setUpFailPoints, nextState);
});
+}());
diff --git a/jstests/replsets/tenant_migration_donor_current_op.js b/jstests/replsets/tenant_migration_donor_current_op.js
index 62c17b21862..6c922ff185f 100644
--- a/jstests/replsets/tenant_migration_donor_current_op.js
+++ b/jstests/replsets/tenant_migration_donor_current_op.js
@@ -12,11 +12,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {isShardMergeEnabled} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
// An object that mirrors the donor migration states.
const migrationStates = {
@@ -48,7 +50,8 @@ function checkStandardFieldsOK(ops, {
assert(op.migrationStart instanceof Date);
assert.eq(op.recipientConnectionString, tenantMigrationTest.getRecipientRst().getURL());
- if (isShardMergeEnabled(tenantMigrationTest.getDonorPrimary().getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(
+ tenantMigrationTest.getDonorPrimary().getDB("admin"))) {
assert.eq(op.tenantId, undefined);
} else {
assert.eq(bsonWoCompare(op.tenantId, kTenantId), 0);
@@ -234,3 +237,4 @@ function checkStandardFieldsOK(ops, {
tenantMigrationTest.stop();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_directly_deletes_its_state_doc.js b/jstests/replsets/tenant_migration_donor_directly_deletes_its_state_doc.js
index 2646c9c2943..e90a8ab4ce7 100644
--- a/jstests/replsets/tenant_migration_donor_directly_deletes_its_state_doc.js
+++ b/jstests/replsets/tenant_migration_donor_directly_deletes_its_state_doc.js
@@ -14,9 +14,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
(() => {
jsTest.log("Test case where the TTL monitor deletes the state doc first");
@@ -133,3 +136,4 @@ load("jstests/libs/uuid_util.js");
tmt.stop();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_initial_sync_cloning.js b/jstests/replsets/tenant_migration_donor_initial_sync_cloning.js
index 4f3971a1cee..cafe4f72af1 100644
--- a/jstests/replsets/tenant_migration_donor_initial_sync_cloning.js
+++ b/jstests/replsets/tenant_migration_donor_initial_sync_cloning.js
@@ -24,9 +24,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
load('jstests/replsets/rslib.js'); // for waitForNewlyAddedRemovalForNodeToBeCommitted
const testDBName = 'testDB';
@@ -108,3 +111,4 @@ TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComple
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js b/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js
index 4d08a30524a..f8943e56854 100644
--- a/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js
+++ b/jstests/replsets/tenant_migration_donor_initial_sync_recovery.js
@@ -12,16 +12,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- getServerlessOperationLock,
- ServerlessLockType
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+const {ServerlessLockType, getServerlessOperationLock} = TenantMigrationUtil;
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -175,3 +174,4 @@ if (kMigrationFpNames[index] === "abortTenantMigrationBeforeLeavingBlockingState
}
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 d423aa0e02c..d5eba83be7c 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
@@ -10,18 +10,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- forgetMigrationAsync,
- isShardMergeEnabled,
- runMigrationAsync,
- tryAbortMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kMaxSleepTimeMS = 100;
const kTenantId = "testTenantId";
@@ -43,7 +39,7 @@ function testDonorStartMigrationInterrupt(interruptFunc, verifyCmdResponseFunc)
const donorRst = tenantMigrationTest.getDonorRst();
const donorPrimary = tenantMigrationTest.getDonorPrimary();
- if (isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
// TODO SERVER-63390: Remove this conditional and ensure test(s) run
// successfully for shard merge.
jsTestLog("Skipping Shard Merge-incompatible test");
@@ -58,9 +54,10 @@ function testDonorStartMigrationInterrupt(interruptFunc, verifyCmdResponseFunc)
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
- const runMigrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const runMigrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
runMigrationThread.start();
// Wait for donorStartMigration command to start.
@@ -85,7 +82,7 @@ function testDonorForgetMigrationInterrupt(interruptFunc, verifyCmdResponseFunc)
const donorRst = tenantMigrationTest.getDonorRst();
const donorPrimary = tenantMigrationTest.getDonorPrimary();
- if (isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
// TODO SERVER-63390: Remove this conditional and ensure test(s) run
// successfully for shard merge.
jsTestLog("Skipping Shard Merge-incompatible test");
@@ -100,12 +97,12 @@ function testDonorForgetMigrationInterrupt(interruptFunc, verifyCmdResponseFunc)
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
TenantMigrationTest.assertCommitted(
tenantMigrationTest.runMigration(migrationOpts, {automaticForgetMigration: false}));
- const forgetMigrationThread =
- new Thread(forgetMigrationAsync, migrationOpts.migrationIdString, donorRstArgs);
+ const forgetMigrationThread = new Thread(
+ TenantMigrationUtil.forgetMigrationAsync, migrationOpts.migrationIdString, donorRstArgs);
forgetMigrationThread.start();
// Wait for the donorForgetMigration command to start.
@@ -133,7 +130,7 @@ function testDonorAbortMigrationInterrupt(interruptFunc, verifyCmdResponseFunc,
const donorRst = tenantMigrationTest.getDonorRst();
const donorPrimary = tenantMigrationTest.getDonorPrimary();
- if (isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
// TODO SERVER-63390: Remove this conditional and ensure test(s) run
// successfully for shard merge.
jsTestLog("Skipping Shard Merge-incompatible test");
@@ -148,7 +145,7 @@ function testDonorAbortMigrationInterrupt(interruptFunc, verifyCmdResponseFunc,
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
// If we passed in a valid failpoint we set it, otherwise we let the migration run normally.
if (fpName) {
@@ -157,8 +154,9 @@ function testDonorAbortMigrationInterrupt(interruptFunc, verifyCmdResponseFunc,
assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
- const tryAbortThread = new Thread(
- tryAbortMigrationAsync, {migrationIdString: migrationOpts.migrationIdString}, donorRstArgs);
+ const tryAbortThread = new Thread(TenantMigrationUtil.tryAbortMigrationAsync,
+ {migrationIdString: migrationOpts.migrationIdString},
+ donorRstArgs);
tryAbortThread.start();
// Wait for donorAbortMigration command to start.
@@ -262,3 +260,4 @@ function assertCmdSucceededOrInterruptedDueToShutDown(cmdThread) {
}, assertCmdSucceededOrInterruptedDueToShutDown, fpName);
});
})();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_kill_op_retry.js b/jstests/replsets/tenant_migration_donor_kill_op_retry.js
index 69dc32f9853..2b747d21130 100644
--- a/jstests/replsets/tenant_migration_donor_kill_op_retry.js
+++ b/jstests/replsets/tenant_migration_donor_kill_op_retry.js
@@ -11,23 +11,20 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- createTenantMigrationDonorRoleIfNotExist,
- createTenantMigrationRecipientRoleIfNotExist,
- forgetMigrationAsync,
- makeX509OptionsForTest,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kGarbageCollectionDelayMS = 5 * 1000;
+const kDelayMS = 100000; // Set some arbitrarily large blockTimeMS to let recipientSyncData command
+ // hang until we use kill op to kill it.
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const garbageCollectionOpts = {
// Set the delay before a donor state doc is garbage collected to be short to speed
// up the test.
@@ -62,9 +59,10 @@ function makeTenantId() {
const donorPrimary = tenantMigrationTest.getDonorPrimary();
let fp = configureFailPoint(donorPrimary, fpName);
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
- const runMigrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const runMigrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
runMigrationThread.start();
fp.wait();
@@ -105,7 +103,8 @@ function makeTenantId() {
// waits for a rebuild, which is why this test is tagged as 'multiversion_incompatible'.
tenantMigrationTest.getDonorRst().initiate(
null, null, {doNotWaitForPrimaryOnlyServices: true});
- createTenantMigrationRecipientRoleIfNotExist(tenantMigrationTest.getDonorRst());
+ TenantMigrationUtil.createTenantMigrationRecipientRoleIfNotExist(
+ tenantMigrationTest.getDonorRst());
jsTestLog(
"Setting failpoint \"" + fpName +
@@ -119,8 +118,9 @@ function makeTenantId() {
};
const donorPrimary = tenantMigrationTest.getDonorPrimary();
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
- const runMigrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+ const runMigrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
runMigrationThread.start();
const res = assert.commandWorked(donorPrimary.adminCommand({
@@ -154,13 +154,15 @@ function makeTenantId() {
tenantMigrationTest.getDonorRst().startSet(
Object.assign({}, migrationX509Options.donor, {setParameter: garbageCollectionOpts}));
tenantMigrationTest.getDonorRst().initiate();
- createTenantMigrationRecipientRoleIfNotExist(tenantMigrationTest.getDonorRst());
+ TenantMigrationUtil.createTenantMigrationRecipientRoleIfNotExist(
+ tenantMigrationTest.getDonorRst());
tenantMigrationTest.getRecipientRst().stopSet();
tenantMigrationTest.getRecipientRst().startSet(Object.assign(
{}, migrationX509Options.recipient, {setParameter: garbageCollectionOpts}));
tenantMigrationTest.getRecipientRst().initiate();
- createTenantMigrationDonorRoleIfNotExist(tenantMigrationTest.getRecipientRst());
+ TenantMigrationUtil.createTenantMigrationDonorRoleIfNotExist(
+ tenantMigrationTest.getRecipientRst());
jsTestLog(
"Setting failpoint \"" + fpName +
@@ -180,9 +182,10 @@ function makeTenantId() {
tenantMigrationTest.runMigration(migrationOpts, {automaticForgetMigration: false}));
const donorPrimary = tenantMigrationTest.getDonorPrimary();
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
- const forgetMigrationThread =
- new Thread(forgetMigrationAsync, migrationOpts.migrationIdString, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+ const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ donorRstArgs);
forgetMigrationThread.start();
fp.wait();
@@ -202,3 +205,4 @@ function makeTenantId() {
tenantMigrationTest.stop();
}
}
+})();
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 f6db7adcdac..d6cbe11b703 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
@@ -16,19 +16,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- forgetMigrationAsync,
- isShardMergeEnabled,
- makeX509OptionsForTest,
- runMigrationAsync,
- tryAbortMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kMaxSleepTimeMS = 100;
const kTenantId = "testTenantId";
@@ -46,7 +41,7 @@ const kGarbageCollectionDelayMS = 30 * 1000;
// Set the TTL monitor to run at a smaller interval to speed up the test.
const kTTLMonitorSleepSecs = 1;
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
/**
* Runs the donorStartMigration command to start a migration, and interrupts the migration on the
@@ -65,7 +60,8 @@ function testDonorStartMigrationInterrupt(interruptFunc,
let donorPrimary = tenantMigrationTest.getDonorPrimary();
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
- if (disableForShardMerge && isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
+ if (disableForShardMerge &&
+ TenantMigrationUtil.isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
jsTest.log("Skipping test for shard merge");
tenantMigrationTest.stop();
donorRst.stopSet();
@@ -78,10 +74,12 @@ function testDonorStartMigrationInterrupt(interruptFunc,
tenantId: kTenantId,
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
- const runMigrationThread =
- new Thread(runMigrationAsync, migrationOpts, donorRstArgs, {retryOnRetryableErrors: true});
+ const runMigrationThread = new Thread(TenantMigrationUtil.runMigrationAsync,
+ migrationOpts,
+ donorRstArgs,
+ {retryOnRetryableErrors: true});
runMigrationThread.start();
// Wait for donorStartMigration command to start.
@@ -163,11 +161,11 @@ function testDonorForgetMigrationInterrupt(interruptFunc) {
tenantId: kTenantId,
recipientConnString: recipientRst.getURL(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
TenantMigrationTest.assertCommitted(
tenantMigrationTest.runMigration(migrationOpts, {automaticForgetMigration: false}));
- const forgetMigrationThread = new Thread(forgetMigrationAsync,
+ const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
migrationOpts.migrationIdString,
donorRstArgs,
true /* retryOnRetryableErrors */);
@@ -237,7 +235,7 @@ function testDonorAbortMigrationInterrupt(
tenantId: kTenantId,
recipientConnString: recipientRst.getURL(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
let donorPrimary = tenantMigrationTest.getDonorPrimary();
// If we passed in a valid failpoint we set it, otherwise we let the migration run normally.
@@ -252,7 +250,7 @@ function testDonorAbortMigrationInterrupt(
fp.wait();
}
- const tryAbortThread = new Thread(tryAbortMigrationAsync,
+ const tryAbortThread = new Thread(TenantMigrationUtil.tryAbortMigrationAsync,
{migrationIdString: migrationOpts.migrationIdString},
donorRstArgs,
true /* retryOnRetryableErrors */);
@@ -482,3 +480,4 @@ function testStateDocPersistenceOnFailover(interruptFunc, fpName, isShutdown = f
}, fpName);
});
})();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_retry.js b/jstests/replsets/tenant_migration_donor_retry.js
index 02264a41445..c81a08e85b8 100644
--- a/jstests/replsets/tenant_migration_donor_retry.js
+++ b/jstests/replsets/tenant_migration_donor_retry.js
@@ -12,16 +12,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- makeX509OptionsForTest,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kTenantIdPrefix = "testTenantId";
let testNum = 0;
@@ -30,7 +28,7 @@ function setup() {
const donorRst = new ReplSetTest({
name: "donorRst",
nodes: 1,
- nodeOptions: Object.assign(makeX509OptionsForTest().donor, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
setParameter: {
// Set the delay before a donor state doc is garbage collected to be short to speed
// up the test.
@@ -249,11 +247,12 @@ const kWriteErrorTimeMS = 50;
collectionNS: TenantMigrationTest.kConfigDonorsNS,
});
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
// Start up a new thread to run this migration, since the 'failCollectionInserts' failpoint will
// cause the initial 'donorStartMigration' command to loop forever without returning.
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
// Make the insert keep failing for some time.
@@ -285,7 +284,7 @@ const kWriteErrorTimeMS = 50;
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
// Use a random number of skips to fail a random update to config.tenantMigrationDonors.
const fp = configureFailPoint(tenantMigrationTest.getDonorPrimary(),
@@ -297,12 +296,11 @@ const kWriteErrorTimeMS = 50;
// Start up a new thread to run this migration, since we want to continuously send
// 'donorStartMigration' commands while the 'failCollectionUpdates' failpoint is on.
- const migrationThread = new Thread(async (migrationOpts, donorRstArgs) => {
- const {runMigrationAsync, forgetMigrationAsync} =
- await import("jstests/replsets/libs/tenant_migration_util.js");
- assert.commandWorked(await runMigrationAsync(migrationOpts, donorRstArgs));
- assert.commandWorked(
- await forgetMigrationAsync(migrationOpts.migrationIdString, donorRstArgs));
+ const migrationThread = new Thread((migrationOpts, donorRstArgs) => {
+ load("jstests/replsets/libs/tenant_migration_util.js");
+ assert.commandWorked(TenantMigrationUtil.runMigrationAsync(migrationOpts, donorRstArgs));
+ assert.commandWorked(TenantMigrationUtil.forgetMigrationAsync(
+ migrationOpts.migrationIdString, donorRstArgs));
}, migrationOpts, donorRstArgs);
migrationThread.start();
@@ -318,3 +316,4 @@ const kWriteErrorTimeMS = 50;
teardown();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_rollback_during_cloning.js b/jstests/replsets/tenant_migration_donor_rollback_during_cloning.js
index 1f124b70b81..7451055c3aa 100644
--- a/jstests/replsets/tenant_migration_donor_rollback_during_cloning.js
+++ b/jstests/replsets/tenant_migration_donor_rollback_during_cloning.js
@@ -15,14 +15,16 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
load("jstests/libs/write_concern_util.js"); // for 'stopReplicationOnSecondaries'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const recipientRst =
new ReplSetTest({name: "recipientRst", nodes: 1, nodeOptions: migrationX509Options.recipient});
@@ -351,3 +353,4 @@ runTest('tenantId3',
"tenantCollectionClonerHangAfterGettingOperationTime");
recipientRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_rollback_recovery.js b/jstests/replsets/tenant_migration_donor_rollback_recovery.js
index 8c4ddd86e60..9c12c0c8c30 100644
--- a/jstests/replsets/tenant_migration_donor_rollback_recovery.js
+++ b/jstests/replsets/tenant_migration_donor_rollback_recovery.js
@@ -12,19 +12,15 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- forgetMigrationAsync,
- makeX509OptionsForTest,
- runMigrationAsync,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/replsets/libs/rollback_test.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kTenantId = ObjectId().str;
@@ -35,7 +31,7 @@ const kMaxSleepTimeMS = 250;
// state.
const kGarbageCollectionDelayMS = 30 * 1000;
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const recipientRst = new ReplSetTest({
name: "recipientRst",
@@ -87,7 +83,7 @@ function testRollBack(setUpFunc, rollbackOpsFunc, steadyStateFunc) {
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), donorRst, recipientRst});
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
setUpFunc(tenantMigrationTest, donorRstArgs);
let originalDonorPrimary = donorRst.getPrimary();
@@ -133,8 +129,10 @@ function testRollbackInitialState() {
const donorPrimary = tenantMigrationTest.getDonorPrimary();
// Start the migration asynchronously and wait for the primary to insert the state doc.
- migrationThread = new Thread(
- runMigrationAsync, migrationOpts, donorRstArgs, {retryOnRetryableErrors: true});
+ migrationThread = new Thread(TenantMigrationUtil.runMigrationAsync,
+ migrationOpts,
+ donorRstArgs,
+ {retryOnRetryableErrors: true});
migrationThread.start();
assert.soon(() => {
return 1 === donorPrimary.getCollection(TenantMigrationTest.kConfigDonorsNS).count({
@@ -177,8 +175,10 @@ function testRollBackStateTransition(pauseFailPoint, setUpFailPoints, nextState)
setUpFailPoints.forEach(failPoint => configureFailPoint(donorPrimary, failPoint));
pauseFp = configureFailPoint(donorPrimary, pauseFailPoint);
- migrationThread = new Thread(
- runMigrationAsync, migrationOpts, donorRstArgs, {retryOnRetryableErrors: true});
+ migrationThread = new Thread(TenantMigrationUtil.runMigrationAsync,
+ migrationOpts,
+ donorRstArgs,
+ {retryOnRetryableErrors: true});
migrationThread.start();
pauseFp.wait();
};
@@ -230,7 +230,7 @@ function testRollBackMarkingStateGarbageCollectable() {
// Run donorForgetMigration and wait for the primary to do the write to mark the state doc
// as garbage collectable.
- forgetMigrationThread = new Thread(forgetMigrationAsync,
+ forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
migrationOpts.migrationIdString,
donorRstArgs,
true /* retryOnRetryableErrors */);
@@ -273,12 +273,11 @@ function testRollBackRandom() {
let migrationThread;
let setUpFunc = (tenantMigrationTest, donorRstArgs) => {
- migrationThread = new Thread(async (donorRstArgs, migrationOpts) => {
- const {runMigrationAsync, forgetMigrationAsync} =
- await import("jstests/replsets/libs/tenant_migration_util.js");
- assert.commandWorked(await runMigrationAsync(
+ migrationThread = new Thread((donorRstArgs, migrationOpts) => {
+ load("jstests/replsets/libs/tenant_migration_util.js");
+ assert.commandWorked(TenantMigrationUtil.runMigrationAsync(
migrationOpts, donorRstArgs, {retryOnRetryableErrors: true}));
- assert.commandWorked(await forgetMigrationAsync(
+ assert.commandWorked(TenantMigrationUtil.forgetMigrationAsync(
migrationOpts.migrationIdString, donorRstArgs, true /* retryOnRetryableErrors */));
}, donorRstArgs, migrationOpts);
@@ -329,3 +328,4 @@ jsTest.log("Test roll back random");
testRollBackRandom();
recipientRst.stopSet();
+}());
diff --git a/jstests/replsets/tenant_migration_donor_shutdown_while_blocking_reads.js b/jstests/replsets/tenant_migration_donor_shutdown_while_blocking_reads.js
index 010408b8d49..eb992df328f 100644
--- a/jstests/replsets/tenant_migration_donor_shutdown_while_blocking_reads.js
+++ b/jstests/replsets/tenant_migration_donor_shutdown_while_blocking_reads.js
@@ -11,12 +11,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {getNumBlockedReads} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/parallelTester.js");
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -60,9 +62,10 @@ let readThread = new Thread((host, dbName, collName, afterClusterTime) => {
readThread.start();
// Shut down the donor after the read starts blocking.
-assert.soon(() => getNumBlockedReads(donorPrimary, kTenantId) == 1);
+assert.soon(() => TenantMigrationUtil.getNumBlockedReads(donorPrimary, kTenantId) == 1);
donorRst.stop(donorPrimary);
readThread.join();
donorRst.stopSet();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_startup_recovery.js b/jstests/replsets/tenant_migration_donor_startup_recovery.js
index 16c5139adea..7dbbcb56f8c 100644
--- a/jstests/replsets/tenant_migration_donor_startup_recovery.js
+++ b/jstests/replsets/tenant_migration_donor_startup_recovery.js
@@ -15,20 +15,18 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
-import {
- getServerlessOperationLock,
- ServerlessLockType
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+const {ServerlessLockType, getServerlessOperationLock} = TenantMigrationUtil;
const donorRst = new ReplSetTest({
nodes: 1,
name: 'donor',
- nodeOptions: Object.assign(makeX509OptionsForTest().donor, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
setParameter:
// In order to deterministically validate that in-memory state is preserved during
// recovery, this failpoint prevents active migrations from continuing on process
@@ -147,3 +145,4 @@ if (donorDoc && !donorDoc.expireAt) {
tenantMigrationTest.stop();
donorRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_state_machine.js b/jstests/replsets/tenant_migration_donor_state_machine.js
index fddbafa7051..9ce4fa86f28 100644
--- a/jstests/replsets/tenant_migration_donor_state_machine.js
+++ b/jstests/replsets/tenant_migration_donor_state_machine.js
@@ -13,15 +13,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- getTenantMigrationAccessBlocker,
- isShardMergeEnabled,
- makeX509OptionsForTest,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
let expectedNumRecipientSyncDataCmdSent = 0;
let expectedNumRecipientForgetMigrationCmdSent = 0;
@@ -48,7 +45,8 @@ function testDonorForgetMigrationAfterMigrationCompletes(
// Wait for garbage collection on donor.
donorRst.nodes.forEach((node) => {
- assert.soon(() => null == getTenantMigrationAccessBlocker({donorNode: node}));
+ assert.soon(() => null ==
+ TenantMigrationUtil.getTenantMigrationAccessBlocker({donorNode: node}));
});
assert.soon(() => 0 === donorPrimary.getCollection(TenantMigrationTest.kConfigDonorsNS).count({
@@ -64,7 +62,8 @@ function testDonorForgetMigrationAfterMigrationCompletes(
// Wait for garbage collection on recipient.
recipientRst.nodes.forEach((node) => {
- assert.soon(() => null == getTenantMigrationAccessBlocker({recipientNode: node}));
+ assert.soon(() => null ==
+ TenantMigrationUtil.getTenantMigrationAccessBlocker({recipientNode: node}));
});
assert.soon(() => 0 ===
@@ -87,7 +86,7 @@ const sharedOptions = {
ttlMonitorSleepSecs: 1,
}
};
-const x509Options = makeX509OptionsForTest();
+const x509Options = TenantMigrationUtil.makeX509OptionsForTest();
const donorRst = new ReplSetTest({
nodes: [{}, {rsConfig: {priority: 0}}, {rsConfig: {priority: 0}}],
@@ -145,7 +144,8 @@ function testStats(node, {
// Wait for the migration to enter the blocking state.
blockingFp.wait();
- let mtab = getTenantMigrationAccessBlocker({donorNode: donorPrimary, tenantId: kTenantId});
+ let mtab = TenantMigrationUtil.getTenantMigrationAccessBlocker(
+ {donorNode: donorPrimary, tenantId: kTenantId});
assert.eq(mtab.donor.state, TenantMigrationTest.DonorAccessState.kBlockWritesAndReads);
assert(mtab.donor.blockTimestamp);
@@ -158,7 +158,7 @@ function testStats(node, {
.next();
assert.eq(donorDoc.state, "blocking");
assert.eq(donorDoc.blockTimestamp, blockOplogEntry.ts);
- if (isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
assert.eq(donorDoc.protocol, "shard merge");
assert.eq(donorDoc.tenantIds, [ObjectId(kTenantId)]);
}
@@ -183,7 +183,8 @@ function testStats(node, {
assert.eq(donorDoc.commitOrAbortOpTime.ts, commitOplogEntry.ts);
assert.soon(() => {
- mtab = getTenantMigrationAccessBlocker({donorNode: donorPrimary, tenantId: kTenantId});
+ mtab = TenantMigrationUtil.getTenantMigrationAccessBlocker(
+ {donorNode: donorPrimary, tenantId: kTenantId});
return mtab.donor.state === TenantMigrationTest.DonorAccessState.kReject;
});
assert(mtab.donor.commitOpTime);
@@ -226,7 +227,8 @@ function testStats(node, {
let mtab;
assert.soon(() => {
- mtab = getTenantMigrationAccessBlocker({donorNode: donorPrimary, tenantId: kTenantId});
+ mtab = TenantMigrationUtil.getTenantMigrationAccessBlocker(
+ {donorNode: donorPrimary, tenantId: kTenantId});
return mtab.donor.state === TenantMigrationTest.DonorAccessState.kAborted;
});
assert(mtab.donor.abortOpTime);
@@ -267,7 +269,8 @@ function testStats(node, {
let mtab;
assert.soon(() => {
- mtab = getTenantMigrationAccessBlocker({donorNode: donorPrimary, tenantId: kTenantId});
+ mtab = TenantMigrationUtil.getTenantMigrationAccessBlocker(
+ {donorNode: donorPrimary, tenantId: kTenantId});
return mtab.donor.state === TenantMigrationTest.DonorAccessState.kAborted;
});
assert(mtab.donor.abortOpTime);
@@ -314,3 +317,4 @@ configDonorsColl.dropIndex({expireAt: 1});
tenantMigrationTest.stop();
donorRst.stopSet();
recipientRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_try_abort.js b/jstests/replsets/tenant_migration_donor_try_abort.js
index 8fa33cd9d86..2c1340b8422 100644
--- a/jstests/replsets/tenant_migration_donor_try_abort.js
+++ b/jstests/replsets/tenant_migration_donor_try_abort.js
@@ -10,26 +10,22 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- makeX509OptionsForTest,
- runMigrationAsync,
- tryAbortMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/write_concern_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kTenantId = ObjectId().str;
const kDelayMS =
500000; // Using some arbitrarily large delay time in to make sure that the donor is not
// waiting this long when it receives a donorAbortMigration command.
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
(() => {
jsTestLog("Test sending donorAbortMigration before an instance's future chain begins.");
@@ -47,14 +43,16 @@ const migrationX509Options = makeX509OptionsForTest();
recipientConnString: tmt.getRecipientConnString(),
};
- const donorRstArgs = createRstArgs(tmt.getDonorRst());
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tmt.getDonorRst());
- const startMigrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const startMigrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
startMigrationThread.start();
fp.wait();
- const tryAbortThread = new Thread(tryAbortMigrationAsync, migrationOpts, donorRstArgs);
+ const tryAbortThread =
+ new Thread(TenantMigrationUtil.tryAbortMigrationAsync, migrationOpts, donorRstArgs);
tryAbortThread.start();
// Wait for donorAbortMigration command to start.
@@ -83,7 +81,8 @@ const migrationX509Options = makeX509OptionsForTest();
"command repeatedly fails with retryable errors.");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
- if (isShardMergeEnabled(tenantMigrationTest.getDonorPrimary().getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(
+ tenantMigrationTest.getDonorPrimary().getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping test, Shard Merge does not support retry");
return;
@@ -123,7 +122,8 @@ const migrationX509Options = makeX509OptionsForTest();
"against admin.system.keys repeatedly fails with retryable errors.");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
- if (isShardMergeEnabled(tenantMigrationTest.getDonorPrimary().getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(
+ tenantMigrationTest.getDonorPrimary().getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping test, Shard Merge does not support retry");
return;
@@ -276,8 +276,9 @@ const migrationX509Options = makeX509OptionsForTest();
barrierBeforeFetchingKeys.wait();
- const donorRstArgs = createRstArgs(tmt.getDonorRst());
- const tryAbortThread = new Thread(tryAbortMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tmt.getDonorRst());
+ const tryAbortThread =
+ new Thread(TenantMigrationUtil.tryAbortMigrationAsync, migrationOpts, donorRstArgs);
tryAbortThread.start();
// Wait for donorAbortMigration command to start.
@@ -373,8 +374,9 @@ const migrationX509Options = makeX509OptionsForTest();
fp.wait();
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
- const tryAbortThread = new Thread(tryAbortMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+ const tryAbortThread =
+ new Thread(TenantMigrationUtil.tryAbortMigrationAsync, migrationOpts, donorRstArgs);
tryAbortThread.start();
// Wait for donorAbortMigration command to start.
@@ -416,8 +418,9 @@ const migrationX509Options = makeX509OptionsForTest();
fp.wait();
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
- const tryAbortThread = new Thread(tryAbortMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+ const tryAbortThread =
+ new Thread(TenantMigrationUtil.tryAbortMigrationAsync, migrationOpts, donorRstArgs);
tryAbortThread.start();
// Wait for donorAbortMigration command to start.
@@ -534,3 +537,4 @@ const migrationX509Options = makeX509OptionsForTest();
tenantMigrationTest.stop();
donorRst.stopSet();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_unblock_reads_and_writes_on_completion.js b/jstests/replsets/tenant_migration_donor_unblock_reads_and_writes_on_completion.js
index 2e65e8fe6d8..fb0f9795ebc 100644
--- a/jstests/replsets/tenant_migration_donor_unblock_reads_and_writes_on_completion.js
+++ b/jstests/replsets/tenant_migration_donor_unblock_reads_and_writes_on_completion.js
@@ -11,17 +11,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- getNumBlockedReads,
- getNumBlockedWrites,
- makeX509OptionsForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/parallelTester.js");
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
function startReadThread(node, dbName, collName, afterClusterTime) {
let readThread = new Thread((host, dbName, collName, afterClusterTime) => {
@@ -51,7 +49,7 @@ function setup() {
const donorRst = new ReplSetTest({
nodes: 3,
name: "donorRst",
- nodeOptions: Object.assign(makeX509OptionsForTest().donor, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
setParameter: {
tenantMigrationGarbageCollectionDelayMS: 1,
ttlMonitorSleepSecs: 1,
@@ -111,7 +109,7 @@ const kCollName = "testColl";
const donorDoc = donorsColl.findOne({_id: migrationId});
assert.neq(null, donorDoc);
const readThread = startReadThread(laggedSecondary, dbName, kCollName, donorDoc.blockTimestamp);
- assert.soon(() => getNumBlockedReads(laggedSecondary, tenantId) == 1);
+ assert.soon(() => TenantMigrationUtil.getNumBlockedReads(laggedSecondary, tenantId) == 1);
// Disable snapshotting on that secondary, and wait for the migration to abort and be garbage
// collected. That way the secondary is guaranteed to observe the write to set expireAt before
@@ -159,7 +157,7 @@ const kCollName = "testColl";
const donorDoc = donorsColl.findOne({_id: migrationId});
assert.neq(null, donorDoc);
const readThread = startReadThread(laggedSecondary, dbName, kCollName, donorDoc.blockTimestamp);
- assert.soon(() => getNumBlockedReads(laggedSecondary, tenantId) == 1);
+ assert.soon(() => TenantMigrationUtil.getNumBlockedReads(laggedSecondary, tenantId) == 1);
// Disable snapshotting on that secondary, and wait for the migration to commit and be garbage
// collected. That way the secondary is guaranteed to observe the write to set expireAt before
@@ -205,8 +203,8 @@ const kCollName = "testColl";
assert.neq(null, donorDoc);
const readThread = startReadThread(donorPrimary, dbName, kCollName, donorDoc.blockTimestamp);
const writeThread = startWriteThread(donorPrimary, dbName, kCollName);
- assert.soon(() => getNumBlockedReads(donorPrimary, tenantId) == 1);
- assert.soon(() => getNumBlockedWrites(donorPrimary, tenantId) == 1);
+ assert.soon(() => TenantMigrationUtil.getNumBlockedReads(donorPrimary, tenantId) == 1);
+ assert.soon(() => TenantMigrationUtil.getNumBlockedWrites(donorPrimary, tenantId) == 1);
// Cannot delete the donor state doc since it has not been marked as garbage collectable.
assert.commandFailedWithCode(donorsColl.remove({}), ErrorCodes.IllegalOperation);
@@ -224,3 +222,4 @@ const kCollName = "testColl";
teardown();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_donor_wont_retry_recipientsyncdata_on_non_retriable_interruption_errors.js b/jstests/replsets/tenant_migration_donor_wont_retry_recipientsyncdata_on_non_retriable_interruption_errors.js
index 0aa3d4758e4..b9790aff744 100644
--- a/jstests/replsets/tenant_migration_donor_wont_retry_recipientsyncdata_on_non_retriable_interruption_errors.js
+++ b/jstests/replsets/tenant_migration_donor_wont_retry_recipientsyncdata_on_non_retriable_interruption_errors.js
@@ -12,15 +12,18 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {runMigrationAsync} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kTenantId = ObjectId().str;
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
+
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
const donorRst = tenantMigrationTest.getDonorRst();
@@ -40,9 +43,11 @@ const migrationOpts = {
tenantId: kTenantId,
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
-const donorRstArgs = createRstArgs(donorRst);
-const runMigrationThread =
- new Thread(runMigrationAsync, migrationOpts, donorRstArgs, {retryOnRetryableErrors: true});
+const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
+const runMigrationThread = new Thread(TenantMigrationUtil.runMigrationAsync,
+ migrationOpts,
+ donorRstArgs,
+ {retryOnRetryableErrors: true});
runMigrationThread.start();
TenantMigrationTest.assertAborted(runMigrationThread.returnData());
@@ -51,3 +56,4 @@ tenantMigrationTest.waitForDonorNodesToReachState(
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_drop_collection.js b/jstests/replsets/tenant_migration_drop_collection.js
index 007fd2f9497..74529b9107c 100644
--- a/jstests/replsets/tenant_migration_drop_collection.js
+++ b/jstests/replsets/tenant_migration_drop_collection.js
@@ -15,24 +15,22 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- makeX509OptionsForTest,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load('jstests/replsets/libs/two_phase_drops.js');
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
function runDropTest({failPointName, failPointData, expectedLog, createNew}) {
// Configure batch size for recipient clone.
const recipientRst = new ReplSetTest({
nodes: 1,
name: "recipient",
- nodeOptions: Object.assign(makeX509OptionsForTest().recipient,
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().recipient,
{setParameter: {collectionClonerBatchSize: 1}})
});
@@ -63,14 +61,15 @@ function runDropTest({failPointName, failPointData, expectedLog, createNew}) {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId: tenantId,
};
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
// Set failpoint for recipient.
const failPoint = configureFailPoint(recipientPrimary, failPointName, failPointData);
// Start migration and wait for failpoint.
jsTestLog("Waiting to hit recipient failpoint");
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
failPoint.wait();
@@ -197,3 +196,4 @@ runDropTest({
'{code: 5289701, attr: { namespace: nss, uuid: (x)=>(x.uuid.$uuid === uuid), tenantId: tenantId}}',
createNew: true
});
+})();
diff --git a/jstests/replsets/tenant_migration_drop_state_doc_collection.js b/jstests/replsets/tenant_migration_drop_state_doc_collection.js
index 505d2c4e2a7..378a1c6a289 100644
--- a/jstests/replsets/tenant_migration_drop_state_doc_collection.js
+++ b/jstests/replsets/tenant_migration_drop_state_doc_collection.js
@@ -10,9 +10,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kMigrationFpNames = [
"pauseTenantMigrationAfterPersistingInitialDonorStateDoc",
@@ -205,3 +209,4 @@ kMigrationFpNames.forEach(fpName => {
});
tenantMigrationTest.stop();
});
+})();
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 4eb0c9378ee..df689030730 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
@@ -10,17 +10,14 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- makeX509OptionsForTest,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+'use strict';
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kGarbageCollectionParams = {
// Set the delay before a donor state doc is garbage collected to be short to speed up the test.
@@ -35,8 +32,8 @@ const kTenantDefinedDbName = "0";
const donorRst = new ReplSetTest({
nodes: 1,
name: 'donor',
- nodeOptions:
- Object.assign(makeX509OptionsForTest().donor, {setParameter: kGarbageCollectionParams})
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor,
+ {setParameter: kGarbageCollectionParams})
});
function insertDocument(primaryHost, dbName, collName) {
@@ -67,7 +64,7 @@ function insertDocument(primaryHost, dbName, collName) {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId,
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
const dbName = tenantMigrationTest.tenantDB(tenantId, kTenantDefinedDbName);
const primary = donorRst.getPrimary();
@@ -79,7 +76,8 @@ function insertDocument(primaryHost, dbName, collName) {
assert.commandWorked(primaryDB.runCommand({create: kCollName}));
const blockFp = configureFailPoint(primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
blockFp.wait();
@@ -123,7 +121,7 @@ function insertDocument(primaryHost, dbName, collName) {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId,
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
const dbName = tenantMigrationTest.tenantDB(tenantId, kTenantDefinedDbName);
const primary = donorRst.getPrimary();
@@ -136,7 +134,8 @@ function insertDocument(primaryHost, dbName, collName) {
const abortFp = configureFailPoint(primaryDB, "abortTenantMigrationBeforeLeavingBlockingState");
const blockFp = configureFailPoint(primaryDB, "pauseTenantMigrationBeforeLeavingBlockingState");
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
blockFp.wait();
@@ -163,3 +162,4 @@ function insertDocument(primaryHost, dbName, collName) {
tenantMigrationTest.stop();
donorRst.stopSet();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_external_cluster_validation.js b/jstests/replsets/tenant_migration_external_cluster_validation.js
index c9d116ffd61..8b9df026a64 100644
--- a/jstests/replsets/tenant_migration_external_cluster_validation.js
+++ b/jstests/replsets/tenant_migration_external_cluster_validation.js
@@ -11,11 +11,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
// Multiple users cannot be authenticated on one connection within a session.
TestData.disableImplicitSessions = true;
@@ -51,7 +52,7 @@ const kDbName = kTenantId + "_" +
"testDb";
const kCollName = "testColl";
-const x509Options = makeX509OptionsForTest();
+const x509Options = TenantMigrationUtil.makeX509OptionsForTest();
const donorRst = new ReplSetTest({
nodes: 2,
name: "donor",
@@ -173,3 +174,4 @@ recipientSecondaryTestDB.logout();
tenantMigrationTest.stop();
donorRst.stopSet();
recipientRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_external_keys_ttl.js b/jstests/replsets/tenant_migration_external_keys_ttl.js
index 246c3af0197..0006d9e63f5 100644
--- a/jstests/replsets/tenant_migration_external_keys_ttl.js
+++ b/jstests/replsets/tenant_migration_external_keys_ttl.js
@@ -14,19 +14,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- forgetMigrationAsync,
- getExternalKeys,
- isShardMergeEnabled,
- kExternalKeysNs,
- makeX509OptionsForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/libs/parallelTester.js");
-load("jstests/replsets/rslib.js"); // `createRstArgs`
const kExternalKeysTTLIndexName = "ExternalKeysTTLIndex";
const kTenantIdPrefix = "testTenantId";
@@ -41,7 +35,7 @@ let makeTenantId = function() {
function waitForExternalKeysTTLIndex(conn) {
assert.soon(() => {
- const indexSpecs = conn.getCollection(kExternalKeysNs).getIndexSpecs();
+ const indexSpecs = conn.getCollection(TenantMigrationUtil.kExternalKeysNs).getIndexSpecs();
const hasIndex = indexSpecs.some(indexSpec => {
return indexSpec.name === kExternalKeysTTLIndexName &&
indexSpec.key.ttlExpiresAt === 1 && indexSpec.expireAfterSeconds === 0;
@@ -57,14 +51,15 @@ function waitForExternalKeysTTLIndex(conn) {
function waitForExternalKeysToBeDeleted(conn, migrationId) {
assert.soonNoExcept(() => {
- const externalKeys = getExternalKeys(conn, migrationId);
+ const externalKeys = TenantMigrationUtil.getExternalKeys(conn, migrationId);
assert.eq(0, externalKeys.length, tojson(externalKeys));
return true;
});
}
function verifyExternalKeys(conn, {migrationId, expectTTLValue}) {
- const externalKeys = conn.getCollection(kExternalKeysNs).find({migrationId}).toArray();
+ const externalKeys =
+ conn.getCollection(TenantMigrationUtil.kExternalKeysNs).find({migrationId}).toArray();
assert.gt(externalKeys.length, 0);
externalKeys.forEach(key => {
@@ -123,7 +118,7 @@ function makeTestParams() {
(() => {
jsTestLog("Basic case with multiple migrations");
const {tmt, teardown} = setup();
- if (isShardMergeEnabled(tmt.getDonorPrimary().getDB("admin"))) {
+ if (TenantMigrationUtil.isShardMergeEnabled(tmt.getDonorPrimary().getDB("admin"))) {
// This test runs multiple concurrent migrations, which shard merge can't handle.
jsTestLog(
"Skip: featureFlagShardMerge is enabled and this test runs multiple concurrent migrations, which shard merge can't handle.");
@@ -221,7 +216,7 @@ function makeTestParams() {
(() => {
function setup() {
- const migrationX509Options = makeX509OptionsForTest();
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const donorRst = new ReplSetTest({
nodes: 3,
name: "donorRst",
@@ -336,8 +331,10 @@ function makeTestParams() {
const fp = configureFailPoint(
donorPrimary, "pauseTenantMigrationBeforeMarkingExternalKeysGarbageCollectable");
- const forgetMigrationThread = new Thread(
- forgetMigrationAsync, migrationOpts.migrationIdString, createRstArgs(donorRst), true);
+ const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(donorRst),
+ true);
forgetMigrationThread.start();
fp.wait();
@@ -372,8 +369,10 @@ function makeTestParams() {
const fp = configureFailPoint(
recipientPrimary, "pauseTenantMigrationBeforeMarkingExternalKeysGarbageCollectable");
- const forgetMigrationThread = new Thread(
- forgetMigrationAsync, migrationOpts.migrationIdString, createRstArgs(donorRst), true);
+ const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(donorRst),
+ true);
forgetMigrationThread.start();
fp.wait();
@@ -412,8 +411,10 @@ function makeTestParams() {
const fp = configureFailPoint(
donorPrimary, "pauseTenantMigrationDonorBeforeMarkingStateGarbageCollectable");
- const forgetMigrationThread = new Thread(
- forgetMigrationAsync, migrationOpts.migrationIdString, createRstArgs(donorRst), true);
+ const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(donorRst),
+ true);
forgetMigrationThread.start();
fp.wait();
@@ -456,8 +457,10 @@ function makeTestParams() {
const fp = configureFailPoint(
recipientPrimary, "fpAfterReceivingRecipientForgetMigration", {action: "hang"});
- const forgetMigrationThread = new Thread(
- forgetMigrationAsync, migrationOpts.migrationIdString, createRstArgs(donorRst), true);
+ const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(donorRst),
+ true);
forgetMigrationThread.start();
fp.wait();
@@ -479,3 +482,4 @@ function makeTestParams() {
teardown();
}
})();
+})();
diff --git a/jstests/replsets/tenant_migration_fetch_committed_transactions.js b/jstests/replsets/tenant_migration_fetch_committed_transactions.js
index b4d7b42de23..77040de41ad 100644
--- a/jstests/replsets/tenant_migration_fetch_committed_transactions.js
+++ b/jstests/replsets/tenant_migration_fetch_committed_transactions.js
@@ -14,8 +14,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/core/txns/libs/prepare_helpers.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/replsets/rslib.js");
load("jstests/libs/uuid_util.js");
@@ -135,3 +139,4 @@ TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComple
validateTransactionEntryonRecipient(sessionIdBeforeMigration);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js b/jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js
index 2e5dce38cf7..6f2f8a6a4c4 100644
--- a/jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js
+++ b/jstests/replsets/tenant_migration_fetch_committed_transactions_retry.js
@@ -18,9 +18,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/aggregation/extras/utils.js");
load("jstests/libs/fail_point_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/libs/uuid_util.js");
let tenantMigrationTest = new TenantMigrationTest({name: jsTestName(), sharedOptions: {nodes: 1}});
@@ -271,3 +274,4 @@ const assertTransactionEntries = (donorTxnEntries, recipientTxnEntries) => {
tenantMigrationTest.stop();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_fetch_committed_transactions_shard_merge.js b/jstests/replsets/tenant_migration_fetch_committed_transactions_shard_merge.js
index 9a0a9fa8dd4..c99f57a789b 100644
--- a/jstests/replsets/tenant_migration_fetch_committed_transactions_shard_merge.js
+++ b/jstests/replsets/tenant_migration_fetch_committed_transactions_shard_merge.js
@@ -13,12 +13,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/core/txns/libs/prepare_helpers.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/replsets/rslib.js");
load("jstests/libs/uuid_util.js");
@@ -39,10 +39,10 @@ const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
function validateTransactionEntryonRecipient(sessionId) {
@@ -153,3 +153,4 @@ validateTransactionEntryonRecipient(sessionIdBeforeMigration);
validateTransactionEntryonRecipient(sessionIdForOtherTenant);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_filters_tenant_id.js b/jstests/replsets/tenant_migration_filters_tenant_id.js
index 591b7d0bbcf..a9e48122006 100644
--- a/jstests/replsets/tenant_migration_filters_tenant_id.js
+++ b/jstests/replsets/tenant_migration_filters_tenant_id.js
@@ -11,12 +11,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isNamespaceForTenant,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantIdPrefix = "tenantId";
const baseDBName = "testDB";
@@ -32,7 +32,7 @@ const runTest = (baseTenantId, dbName, shouldMatch) => {
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
- assert.eq(shouldMatch, isNamespaceForTenant(baseTenantId, dbName));
+ assert.eq(shouldMatch, TenantMigrationUtil.isNamespaceForTenant(baseTenantId, dbName));
tenantMigrationTest.insertDonorDB(dbName, collName);
// Run a migration with the base tenant ID.
@@ -66,3 +66,4 @@ for (const {makeTenantId, shouldMatch} of testCases) {
const tenantId = makeTenantId(baseTenantId);
runTest(baseTenantId, `${tenantId}_${baseDBName}`, shouldMatch);
}
+})();
diff --git a/jstests/replsets/tenant_migration_find_and_modify_retry.js b/jstests/replsets/tenant_migration_find_and_modify_retry.js
index 0c6dcdd81a2..91d408f59ab 100644
--- a/jstests/replsets/tenant_migration_find_and_modify_retry.js
+++ b/jstests/replsets/tenant_migration_find_and_modify_retry.js
@@ -14,7 +14,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
@@ -95,3 +99,4 @@ jsTestLog("Retry findAndModify on recipient: " + tojson(res));
assert.eq(2, res.value.y);
tenantMigrationTest.stop();
+})();
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 92f8fa54091..c3a942ee6b9 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
@@ -13,7 +13,10 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
@@ -55,3 +58,4 @@ hangAfterRetrievingStartOpTime.off();
TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_index_oplog_entries.js b/jstests/replsets/tenant_migration_index_oplog_entries.js
index 3a1d5af954d..0d0961ddd84 100644
--- a/jstests/replsets/tenant_migration_index_oplog_entries.js
+++ b/jstests/replsets/tenant_migration_index_oplog_entries.js
@@ -13,6 +13,7 @@
"use strict";
load("jstests/libs/fail_point_util.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kDbName = "testDb";
const kCollName = "testColl";
diff --git a/jstests/replsets/tenant_migration_invalid_inputs.js b/jstests/replsets/tenant_migration_invalid_inputs.js
index c6ba021d761..ef2406522a8 100644
--- a/jstests/replsets/tenant_migration_invalid_inputs.js
+++ b/jstests/replsets/tenant_migration_invalid_inputs.js
@@ -14,11 +14,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- donorStartMigrationWithProtocol,
- makeMigrationCertificatesForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), enableRecipientTesting: false});
@@ -30,97 +30,103 @@ const tenantId = "testTenantId";
const readPreference = {
mode: 'primary'
};
-const migrationCertificates = makeMigrationCertificatesForTest();
+const migrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest();
jsTestLog("Testing 'donorStartMigration' command provided with invalid options.");
// Test missing tenantId field for protocol 'multitenant migrations'.
assert.commandFailedWithCode(
- donorPrimary.adminCommand(donorStartMigrationWithProtocol({
- donorStartMigration: 1,
- migrationId: UUID(),
- recipientConnectionString: tenantMigrationTest.getRecipientRst().getURL(),
- readPreference,
- donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
- recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
- },
- donorPrimary.getDB("admin"))),
- ErrorCodes.InvalidOptions);
-
-// Test empty tenantId and unsupported database prefixes.
-const unsupportedtenantIds = ['', 'admin', 'local', 'config'];
-unsupportedtenantIds.forEach((invalidTenantId) => {
- assert.commandFailedWithCode(
- donorPrimary.adminCommand(donorStartMigrationWithProtocol({
+ donorPrimary.adminCommand(
+ TenantMigrationUtil.donorStartMigrationWithProtocol({
donorStartMigration: 1,
migrationId: UUID(),
recipientConnectionString: tenantMigrationTest.getRecipientRst().getURL(),
- tenantId: invalidTenantId,
readPreference,
donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
},
- donorPrimary.getDB("admin"))),
+ donorPrimary.getDB("admin"))),
+ ErrorCodes.InvalidOptions);
+
+// Test empty tenantId and unsupported database prefixes.
+const unsupportedtenantIds = ['', 'admin', 'local', 'config'];
+unsupportedtenantIds.forEach((invalidTenantId) => {
+ assert.commandFailedWithCode(
+ donorPrimary.adminCommand(
+ TenantMigrationUtil.donorStartMigrationWithProtocol({
+ donorStartMigration: 1,
+ migrationId: UUID(),
+ recipientConnectionString: tenantMigrationTest.getRecipientRst().getURL(),
+ tenantId: invalidTenantId,
+ readPreference,
+ donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
+ recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
+ },
+ donorPrimary.getDB("admin"))),
[ErrorCodes.InvalidOptions, ErrorCodes.BadValue]);
});
// Test migrating a tenant to the donor itself.
assert.commandFailedWithCode(
- donorPrimary.adminCommand(donorStartMigrationWithProtocol({
- donorStartMigration: 1,
- migrationId: UUID(),
- recipientConnectionString: tenantMigrationTest.getDonorRst().getURL(),
- tenantId,
- readPreference,
- donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
- recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
- },
- donorPrimary.getDB("admin"))),
+ donorPrimary.adminCommand(
+ TenantMigrationUtil.donorStartMigrationWithProtocol({
+ donorStartMigration: 1,
+ migrationId: UUID(),
+ recipientConnectionString: tenantMigrationTest.getDonorRst().getURL(),
+ tenantId,
+ readPreference,
+ donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
+ recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
+ },
+ donorPrimary.getDB("admin"))),
ErrorCodes.BadValue);
// Test migrating a tenant to a recipient that shares one or more hosts with the donor.
assert.commandFailedWithCode(
- donorPrimary.adminCommand(donorStartMigrationWithProtocol({
- donorStartMigration: 1,
- migrationId: UUID(),
- recipientConnectionString:
- tenantMigrationTest.getRecipientRst().getURL() + "," + donorPrimary.host,
- tenantId,
- readPreference,
- donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
- recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
- },
- donorPrimary.getDB("admin"))),
+ donorPrimary.adminCommand(
+ TenantMigrationUtil.donorStartMigrationWithProtocol({
+ donorStartMigration: 1,
+ migrationId: UUID(),
+ recipientConnectionString:
+ tenantMigrationTest.getRecipientRst().getURL() + "," + donorPrimary.host,
+ tenantId,
+ readPreference,
+ donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
+ recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
+ },
+ donorPrimary.getDB("admin"))),
ErrorCodes.BadValue);
// Test setting tenantIds field for protocol 'multitenant migrations'.
assert.commandFailedWithCode(
- donorPrimary.adminCommand(donorStartMigrationWithProtocol({
- donorStartMigration: 1,
- migrationId: UUID(),
- recipientConnectionString:
- tenantMigrationTest.getRecipientRst().getURL() + "," + donorPrimary.host,
- tenantId,
- tenantIds: [ObjectId(), ObjectId()],
- readPreference,
- donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
- recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
- },
- donorPrimary.getDB("admin"))),
+ donorPrimary.adminCommand(
+ TenantMigrationUtil.donorStartMigrationWithProtocol({
+ donorStartMigration: 1,
+ migrationId: UUID(),
+ recipientConnectionString:
+ tenantMigrationTest.getRecipientRst().getURL() + "," + donorPrimary.host,
+ tenantId,
+ tenantIds: [ObjectId(), ObjectId()],
+ readPreference,
+ donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
+ recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
+ },
+ donorPrimary.getDB("admin"))),
ErrorCodes.BadValue);
// Test migrating a tenant to a standalone recipient.
assert.commandFailedWithCode(
- donorPrimary.adminCommand(donorStartMigrationWithProtocol({
- donorStartMigration: 1,
- migrationId: UUID(),
- recipientConnectionString: recipientPrimary.host,
- tenantId,
- readPreference,
- donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
- recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
- },
- donorPrimary.getDB("admin"))),
+ donorPrimary.adminCommand(
+ TenantMigrationUtil.donorStartMigrationWithProtocol({
+ donorStartMigration: 1,
+ migrationId: UUID(),
+ recipientConnectionString: recipientPrimary.host,
+ tenantId,
+ readPreference,
+ donorCertificateForRecipient: migrationCertificates.donorCertificateForRecipient,
+ recipientCertificateForDonor: migrationCertificates.recipientCertificateForDonor,
+ },
+ donorPrimary.getDB("admin"))),
ErrorCodes.BadValue);
jsTestLog("Testing 'recipientSyncData' command provided with invalid options.");
@@ -215,3 +221,4 @@ nullTimestamps.forEach((nullTs) => {
});
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_large_txn.js b/jstests/replsets/tenant_migration_large_txn.js
index 689ed9f5fc8..8cad28dc9fa 100644
--- a/jstests/replsets/tenant_migration_large_txn.js
+++ b/jstests/replsets/tenant_migration_large_txn.js
@@ -14,15 +14,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- runMigrationAsync,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load('jstests/replsets/rslib.js'); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -62,12 +61,13 @@ const migrationOpts = {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId: kTenantId,
};
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
// Start a migration, and pause it after the donor has majority-committed the initial state doc.
const dataSyncFp =
configureFailPoint(donorPrimary, "pauseTenantMigrationBeforeLeavingDataSyncState");
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
dataSyncFp.wait();
@@ -96,3 +96,4 @@ txnThread.join();
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_logs.js b/jstests/replsets/tenant_migration_logs.js
index 1e399d5b37f..51dde90ee75 100644
--- a/jstests/replsets/tenant_migration_logs.js
+++ b/jstests/replsets/tenant_migration_logs.js
@@ -10,7 +10,10 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/libs/uuid_util.js");
function assertNoCertificateOrPrivateKeyLogsForCmd(conn, cmdName) {
@@ -56,3 +59,4 @@ const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
})();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_metrics_output.js b/jstests/replsets/tenant_migration_metrics_output.js
index 49b763ec058..6a117ac64a3 100644
--- a/jstests/replsets/tenant_migration_metrics_output.js
+++ b/jstests/replsets/tenant_migration_metrics_output.js
@@ -10,13 +10,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- makeX509OptionsForTest,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/ftdc.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
// Verify that the server status response has the fields that we expect.
function verifyServerStatus(conn) {
@@ -36,7 +36,7 @@ const testPath = MongoRunner.toRealPath("ftdc_dir_repl_node");
const donorRst = new ReplSetTest({
nodes: 1,
name: "donorRst",
- nodeOptions: Object.assign(makeX509OptionsForTest().donor,
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor,
{setParameter: {diagnosticDataCollectionDirectoryPath: testPath}})
});
@@ -61,3 +61,4 @@ verifyFTDCOutput(tenantMigrationTest.getDonorPrimary());
tenantMigrationTest.stop();
donorRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_multi_writes.js b/jstests/replsets/tenant_migration_multi_writes.js
index 534ba4d8228..79b20c1a1f8 100644
--- a/jstests/replsets/tenant_migration_multi_writes.js
+++ b/jstests/replsets/tenant_migration_multi_writes.js
@@ -16,19 +16,19 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- makeX509OptionsForTest,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const donorRst = new ReplSetTest({
nodes: [{}, {rsConfig: {priority: 0}}, {rsConfig: {priority: 0}}],
name: "TenantMigrationTest_donor",
- nodeOptions: Object.assign(makeX509OptionsForTest().donor, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
setParameter: {
// Set the delay before a donor state doc is garbage collected to be short to speed up
// the test.
@@ -156,3 +156,4 @@ readWriteConcerns.forEach(concerns => {
tenantMigrationTest.stop();
donorRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_multikey_index.js b/jstests/replsets/tenant_migration_multikey_index.js
index 14e6ff23bd0..d639cb62305 100644
--- a/jstests/replsets/tenant_migration_multikey_index.js
+++ b/jstests/replsets/tenant_migration_multikey_index.js
@@ -11,14 +11,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- makeX509OptionsForTest,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/analyze_plan.js");
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const getQueryExplainIndexScanStage = function(coll) {
const explain = coll.find().hint({"a.b": 1, "a.c": 1}).explain();
@@ -35,7 +35,7 @@ const verifyMultiKeyIndex = function(coll, isMultiKey, multiKeyPath) {
const recipientRst = new ReplSetTest({
nodes: 2,
name: jsTestName() + "_recipient",
- nodeOptions: Object.assign(makeX509OptionsForTest().recipient, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().recipient, {
setParameter: {
// Allow reads on recipient before migration completes for testing.
'failpoint.tenantMigrationRecipientNotRejectReads': tojson({mode: 'alwaysOn'}),
@@ -132,3 +132,4 @@ verifyMultiKeyIndex(recipientColl2, true, {"a.b": ["a", "a.b"], "a.c": ["a"]});
tenantMigrationTest.stop();
recipientRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_network_error_via_rollback.js b/jstests/replsets/tenant_migration_network_error_via_rollback.js
index 63e27ae506c..b1ca2c5e166 100644
--- a/jstests/replsets/tenant_migration_network_error_via_rollback.js
+++ b/jstests/replsets/tenant_migration_network_error_via_rollback.js
@@ -17,17 +17,17 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- makeX509OptionsForTest,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/replsets/rslib.js"); // for 'stopServerReplication'
function runTest({failPointName, failPointData = {}, batchSize = 10 * 1000}) {
- const migrationX509Options = makeX509OptionsForTest();
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const donorRst = new ReplSetTest({
name: "recipientRst",
@@ -295,3 +295,4 @@ switch (caseNum) {
// Unreachable.
assert(false);
}
+})();
diff --git a/jstests/replsets/tenant_migration_no_failover.js b/jstests/replsets/tenant_migration_no_failover.js
index b561b903e70..e074d68a397 100644
--- a/jstests/replsets/tenant_migration_no_failover.js
+++ b/jstests/replsets/tenant_migration_no_failover.js
@@ -10,9 +10,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
const tenantId = ObjectId().str;
@@ -44,3 +47,4 @@ for (const db of [...tenantDBs, ...nonTenantDBs]) {
}
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_on_clustered_collection.js b/jstests/replsets/tenant_migration_on_clustered_collection.js
index b9d827de0fb..6e31f1f6a89 100644
--- a/jstests/replsets/tenant_migration_on_clustered_collection.js
+++ b/jstests/replsets/tenant_migration_on_clustered_collection.js
@@ -15,15 +15,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- runMigrationAsync,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/clustered_collections/clustered_collection_util.js"); // ClusteredCollectionUtil
load("jstests/libs/parallelTester.js"); // Thread()
load("jstests/libs/uuid_util.js"); // extractUUIDFromObject()
-load('jstests/replsets/rslib.js'); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js"); // TenantMigrationTest
+load("jstests/replsets/libs/tenant_migration_util.js"); // TenantMigrationUtil
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -63,8 +62,9 @@ const runTenantMigration = () => {
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId: kTenantId,
};
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
TenantMigrationTest.assertCommitted(migrationThread.returnData());
@@ -98,3 +98,4 @@ runTenantMigration();
validateMigrationResults();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_oplog_view.js b/jstests/replsets/tenant_migration_oplog_view.js
index 764cf86494e..7738ebee2ef 100644
--- a/jstests/replsets/tenant_migration_oplog_view.js
+++ b/jstests/replsets/tenant_migration_oplog_view.js
@@ -10,8 +10,10 @@
* serverless,
* ]
*/
+(function() {
+"use strict";
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+load("jstests/replsets/libs/tenant_migration_test.js");
const kGarbageCollectionDelayMS = 5 * 1000;
const donorRst = new ReplSetTest({
@@ -107,3 +109,4 @@ const collection = session.getDatabase(dbName)[collName];
donorRst.stopSet();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_read_your_own_writes.js b/jstests/replsets/tenant_migration_read_your_own_writes.js
index 2c6b4837740..39c45a212fe 100644
--- a/jstests/replsets/tenant_migration_read_your_own_writes.js
+++ b/jstests/replsets/tenant_migration_read_your_own_writes.js
@@ -12,7 +12,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
@@ -115,3 +119,4 @@ tenantMigrationTest.getDonorRst().nodes.forEach(
{configureFailPoint: "tenantMigrationDonorAllowsNonTimestampedReads", mode: "alwaysOn"})));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_aborts_merge_on_donor_failure.js b/jstests/replsets/tenant_migration_recipient_aborts_merge_on_donor_failure.js
index f84056679a6..c6c1bbbc591 100644
--- a/jstests/replsets/tenant_migration_recipient_aborts_merge_on_donor_failure.js
+++ b/jstests/replsets/tenant_migration_recipient_aborts_merge_on_donor_failure.js
@@ -11,11 +11,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {isShardMergeEnabled} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
(() => {
const tenantMigrationTest =
@@ -23,7 +25,7 @@ load("jstests/libs/uuid_util.js");
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
- if (!isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
+ if (!TenantMigrationUtil.isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
return;
@@ -76,3 +78,4 @@ load("jstests/libs/uuid_util.js");
tenantMigrationTest.stop();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_access_blocker_rollback.js b/jstests/replsets/tenant_migration_recipient_access_blocker_rollback.js
index 5cc3a9dd7c5..f0d74342f6f 100644
--- a/jstests/replsets/tenant_migration_recipient_access_blocker_rollback.js
+++ b/jstests/replsets/tenant_migration_recipient_access_blocker_rollback.js
@@ -10,19 +10,16 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- getCertificateAndPrivateKey,
- makeX509OptionsForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
-
+(function() {
+"use strict";
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/write_concern_util.js"); // for 'stopReplicationOnSecondaries'
load("jstests/libs/parallelTester.js"); // For Thread()
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const recipientRst = new ReplSetTest({
name: "recipRst",
@@ -121,8 +118,8 @@ function runRollbackAfterLoneRecipientForgetMigrationCommand(tenantId) {
const kMigrationId = UUID();
const kTenantId = tenantId;
const kReadPreference = {mode: "primary"};
- const recipientCertificateForDonor =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem");
+ const recipientCertificateForDonor = TenantMigrationUtil.getCertificateAndPrivateKey(
+ "jstests/libs/tenant_migration_recipient.pem");
const dbName = tenantMigrationTest.tenantDB(kTenantId, "testDB");
const collName = "testColl";
@@ -221,3 +218,4 @@ runRollbackAfterMigrationCommitted(ObjectId().str);
runRollbackAfterLoneRecipientForgetMigrationCommand(ObjectId().str);
recipientRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_current_op.js b/jstests/replsets/tenant_migration_recipient_current_op.js
index df00c781e1f..581014be9e9 100644
--- a/jstests/replsets/tenant_migration_recipient_current_op.js
+++ b/jstests/replsets/tenant_migration_recipient_current_op.js
@@ -17,13 +17,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {forgetMigrationAsync} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/parallelTester.js"); // For the Thread().
-load('jstests/replsets/rslib.js'); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -275,10 +276,11 @@ assert.commandWorked(
}
jsTestLog("Issuing a forget migration command.");
-const forgetMigrationThread = new Thread(forgetMigrationAsync,
- migrationOpts.migrationIdString,
- createRstArgs(tenantMigrationTest.getDonorRst()),
- true /* retryOnRetryableErrors */);
+const forgetMigrationThread =
+ new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst()),
+ true /* retryOnRetryableErrors */);
forgetMigrationThread.start();
{
@@ -338,3 +340,4 @@ forgetMigrationThread.start();
}
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_directly_deletes_its_state_doc.js b/jstests/replsets/tenant_migration_recipient_directly_deletes_its_state_doc.js
index 6f6e7e360a2..cc5bda3efaf 100644
--- a/jstests/replsets/tenant_migration_recipient_directly_deletes_its_state_doc.js
+++ b/jstests/replsets/tenant_migration_recipient_directly_deletes_its_state_doc.js
@@ -14,9 +14,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
(() => {
jsTest.log("Test case where the TTL monitor deletes the state doc first");
@@ -127,3 +130,4 @@ load("jstests/libs/uuid_util.js");
tmt.stop();
})();
+})();
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 5ccc64e3957..b6039175c44 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
@@ -15,11 +15,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
// Verify the recipient's current sync source is the expected one.
const verifySyncSource = function(conn, migrationId, expectedSyncSource) {
@@ -34,7 +36,7 @@ const batchSize = 2;
const recipientRst = new ReplSetTest({
nodes: 2,
name: jsTestName() + "_recipient",
- nodeOptions: Object.assign(makeX509OptionsForTest().recipient, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().recipient, {
setParameter: {
// Use a batch size of 2 so that collection cloner requires more than a single
// batch to complete.
@@ -117,3 +119,4 @@ verifySyncSource(recipientPrimary, migrationId, donorPrimary.host);
tenantMigrationTest.stop();
recipientRst.stopSet();
+})();
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 da8e9757b23..8999d7b0513 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
@@ -12,9 +12,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+
+"use strict";
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), sharedOptions: {nodes: 2}});
@@ -52,3 +56,4 @@ jsTestLog("Waiting for migration to complete.");
TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_entry_after_committed_snapshot.js b/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_entry_after_committed_snapshot.js
index cd57e11b98c..7d5745bd566 100644
--- a/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_entry_after_committed_snapshot.js
+++ b/jstests/replsets/tenant_migration_recipient_fetches_retryable_writes_entry_after_committed_snapshot.js
@@ -15,12 +15,9 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- makeX509OptionsForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
-
+(function() {
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/write_concern_util.js");
@@ -63,7 +60,7 @@ const donorRst = new ReplSetTest({
// stopReplProducerOnDocument failpoint. Also disable primary catchup because some replicated
// retryable write statements are intentionally not being made majority committed.
settings: {chainingAllowed: false, catchUpTimeoutMillis: 0},
- nodeOptions: Object.assign(makeX509OptionsForTest().donor, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
setParameter: {
tenantMigrationExcludeDonorHostTimeoutMS: 30 * 1000,
// Allow non-timestamped reads on donor after migration completes for testing.
@@ -77,12 +74,12 @@ const donorPrimary = donorRst.getPrimary();
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName(), donorRst: donorRst});
-if (isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
jsTestLog(
"Skip: incompatible with featureFlagShardMerge. Only 'primary' read preference is supported.");
donorRst.stopSet();
tenantMigrationTest.stop();
- quit();
+ return;
}
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
@@ -246,3 +243,4 @@ assert.eq(docAfterMigration.counter, counterTotal);
donorRst.stopSet();
tenantMigrationTest.stop();
+})();
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 84d5cc55bc3..52a25a277f9 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
@@ -10,10 +10,10 @@
* serverless,
* ]
*/
+(function() {
+"use strict";
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {isShardMergeEnabled} from "jstests/replsets/libs/tenant_migration_util.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/parallelTester.js"); // For Thread.
@@ -64,7 +64,8 @@ function runTest({storeFindAndModifyImagesInSideCollection = false}) {
const secondTenantSession = rsConn.startSession({retryWrites: true});
const secondTenantCollection = secondTenantSession.getDatabase(kDbName2)[kCollName];
- const isShardMergeEnabledOnDonor = isShardMergeEnabled(donorRst.getPrimary().getDB("adminDB"));
+ const isShardMergeEnabled =
+ TenantMigrationUtil.isShardMergeEnabled(donorRst.getPrimary().getDB("adminDB"));
jsTestLog("Run retryable writes prior to the migration");
@@ -171,7 +172,7 @@ function runTest({storeFindAndModifyImagesInSideCollection = false}) {
// Only for shardMerge we expect to have the other tenantId. Otherwise only for the provided
// tenantId.
- assert.eq(isShardMergeEnabledOnDonor ? 1 : 0,
+ assert.eq(isShardMergeEnabled ? 1 : 0,
recipientOplogBuffer.find({"entry.o._id": "retryableWrite1"}).itcount());
// Ensure the retryable write oplog entries that should not be in `kOplogBufferNS` are in fact
@@ -193,3 +194,4 @@ function runTest({storeFindAndModifyImagesInSideCollection = false}) {
runTest({storeFindAndModifyImagesInSideCollection: false});
runTest({storeFindAndModifyImagesInSideCollection: true});
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_fetches_synthetic_find_and_modify_oplog_entries.js b/jstests/replsets/tenant_migration_recipient_fetches_synthetic_find_and_modify_oplog_entries.js
index 3a206b498a3..94d751e8811 100644
--- a/jstests/replsets/tenant_migration_recipient_fetches_synthetic_find_and_modify_oplog_entries.js
+++ b/jstests/replsets/tenant_migration_recipient_fetches_synthetic_find_and_modify_oplog_entries.js
@@ -11,8 +11,10 @@
* serverless,
* ]
*/
+(function() {
+"use strict";
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/parallelTester.js"); // For Thread.
@@ -104,3 +106,4 @@ assert.eq(0, bsonWoCompare(cmdResponse, retryResponse), retryResponse);
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_forget_migration.js b/jstests/replsets/tenant_migration_recipient_forget_migration.js
index 145d837c63a..c26f96301bd 100644
--- a/jstests/replsets/tenant_migration_recipient_forget_migration.js
+++ b/jstests/replsets/tenant_migration_recipient_forget_migration.js
@@ -10,16 +10,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- forgetMigrationAsync,
- isShardMergeEnabled
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/parallelTester.js"); // For Thread(), used for async forgetMigration.
-load('jstests/replsets/rslib.js'); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -32,8 +30,8 @@ const kReadPreference = {
mode: "primary"
};
-const isShardMergeEnabledOnDonorPrimary =
- isShardMergeEnabled(tenantMigrationTest.getDonorPrimary().getDB("admin"));
+const isShardMergeEnabled =
+ TenantMigrationUtil.isShardMergeEnabled(tenantMigrationTest.getDonorPrimary().getDB("admin"));
const oplogBufferCollectionName = (migrationIdString) =>
`repl.migration.oplog_${migrationIdString}`;
@@ -42,7 +40,7 @@ const donatedFilesCollectionName = (migrationIdString) => `donatedFiles.${migrat
const assertTempCollectionsExist = (conn, migrationIdString) => {
const collections = conn.getDB("config").getCollectionNames();
assert(collections.includes(oplogBufferCollectionName(migrationIdString)), collections);
- if (isShardMergeEnabledOnDonorPrimary) {
+ if (isShardMergeEnabled) {
assert(collections.includes(donatedFilesCollectionName(migrationIdString)), collections);
}
};
@@ -50,7 +48,7 @@ const assertTempCollectionsExist = (conn, migrationIdString) => {
const assertTempCollectionsDoNotExist = (conn, migrationIdString) => {
const collections = conn.getDB("config").getCollectionNames();
assert(!collections.includes(oplogBufferCollectionName(migrationIdString)), collections);
- if (isShardMergeEnabledOnDonorPrimary) {
+ if (isShardMergeEnabled) {
assert(!collections.includes(donatedFilesCollectionName(migrationIdString)), collections);
}
};
@@ -73,10 +71,11 @@ const assertTempCollectionsDoNotExist = (conn, migrationIdString) => {
{action: "hang"});
jsTestLog("Issuing a forget migration command.");
- const forgetMigrationThread = new Thread(forgetMigrationAsync,
- migrationOpts.migrationIdString,
- createRstArgs(tenantMigrationTest.getDonorRst()),
- true /* retryOnRetryableErrors */);
+ const forgetMigrationThread =
+ new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst()),
+ true /* retryOnRetryableErrors */);
forgetMigrationThread.start();
fpBeforeDroppingTempCollections.wait();
@@ -115,10 +114,11 @@ const assertTempCollectionsDoNotExist = (conn, migrationIdString) => {
{action: "hang"});
jsTestLog("Issuing a forget migration command.");
- const forgetMigrationThread = new Thread(forgetMigrationAsync,
- migrationOpts.migrationIdString,
- createRstArgs(tenantMigrationTest.getDonorRst()),
- true /* retryOnRetryableErrors */);
+ const forgetMigrationThread =
+ new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst()),
+ true /* retryOnRetryableErrors */);
forgetMigrationThread.start();
fpBeforeDroppingTempCollections.wait();
@@ -142,3 +142,4 @@ const assertTempCollectionsDoNotExist = (conn, migrationIdString) => {
})();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_has_tenant_data.js b/jstests/replsets/tenant_migration_recipient_has_tenant_data.js
index f04f662e20a..ef61d84540e 100644
--- a/jstests/replsets/tenant_migration_recipient_has_tenant_data.js
+++ b/jstests/replsets/tenant_migration_recipient_has_tenant_data.js
@@ -12,11 +12,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const kGarbageCollectionParams = {
// Set the delay before a donor state doc is garbage collected to be short to speed up
@@ -30,8 +31,8 @@ const kGarbageCollectionParams = {
const donorRst = new ReplSetTest({
nodes: 1,
name: "donor",
- nodeOptions:
- Object.assign(makeX509OptionsForTest().donor, {setParameter: kGarbageCollectionParams})
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor,
+ {setParameter: kGarbageCollectionParams})
});
donorRst.startSet();
@@ -73,3 +74,4 @@ TenantMigrationTest.assertAborted(tenantMigrationTest.runMigration(migrationOpts
donorRst.stopSet();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_initial_sync_cloning.js b/jstests/replsets/tenant_migration_recipient_initial_sync_cloning.js
index d085b7645d3..1f4f377f59c 100644
--- a/jstests/replsets/tenant_migration_recipient_initial_sync_cloning.js
+++ b/jstests/replsets/tenant_migration_recipient_initial_sync_cloning.js
@@ -14,14 +14,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
load('jstests/replsets/rslib.js'); // for waitForNewlyAddedRemovalForNodeToBeCommitted
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const testDBName = 'testDB';
const testCollName = 'testColl';
@@ -200,3 +201,4 @@ runTestCase('tenantId4',
"fpAfterWaitForRejectReadsBeforeTimestamp",
true /* checkMtab */,
restartNodeAndCheckStateWithoutOplogApplication);
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js b/jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js
index a371023fc05..1012be2670c 100644
--- a/jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js
+++ b/jstests/replsets/tenant_migration_recipient_initial_sync_recovery.js
@@ -13,15 +13,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- getServerlessOperationLock,
- ServerlessLockType
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+const {ServerlessLockType, getServerlessOperationLock} = TenantMigrationUtil;
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -111,3 +110,4 @@ if (recipientDoc && !recipientDoc.expireAt) {
restartServerReplication(initialSyncNode);
tenantMigrationTest.stop();
+})();
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 b1f4bfbc63d..d06af9fb500 100644
--- a/jstests/replsets/tenant_migration_recipient_invalidates_in_memory_txns.js
+++ b/jstests/replsets/tenant_migration_recipient_invalidates_in_memory_txns.js
@@ -23,7 +23,10 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/replsets/rslib.js");
load("jstests/libs/uuid_util.js");
@@ -111,3 +114,4 @@ const migrationOpts2 = {
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 0336593795b..01d98b34097 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
@@ -13,17 +13,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- forgetMigrationAsync,
- makeX509OptionsForTest,
- runMigrationAsync,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load('jstests/replsets/rslib.js'); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kMaxSleepTimeMS = 100;
const kTenantId = "testTenantId";
@@ -35,7 +32,7 @@ const kGarbageCollectionDelayMS = 30 * 1000;
// Set the TTL monitor to run at a smaller interval to speed up the test.
const kTTLMonitorSleepSecs = 1;
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
/**
* Runs the donorStartMigration command to start a migration, and interrupts the migration on the
@@ -61,9 +58,10 @@ function testRecipientSyncDataInterrupt(interruptFunc, recipientRestarted) {
tenantId: kTenantId,
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
- const runMigrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const runMigrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
runMigrationThread.start();
// Wait for recipientSyncData command to start.
@@ -131,11 +129,11 @@ function testRecipientForgetMigrationInterrupt(interruptFunc) {
tenantId: kTenantId,
recipientConnString: recipientRst.getURL(),
};
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
TenantMigrationTest.assertCommitted(
tenantMigrationTest.runMigration(migrationOpts, {automaticForgetMigration: false}));
- const forgetMigrationThread = new Thread(forgetMigrationAsync,
+ const forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
migrationOpts.migrationIdString,
donorRstArgs,
false /* retryOnRetryableErrors */);
@@ -203,3 +201,4 @@ function testRecipientForgetMigrationInterrupt(interruptFunc) {
recipientRst.getPrimary();
});
})();
+})();
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 fa41dcc7afa..019e6d8b89b 100644
--- a/jstests/replsets/tenant_migration_recipient_resumes_on_donor_failover.js
+++ b/jstests/replsets/tenant_migration_recipient_resumes_on_donor_failover.js
@@ -18,19 +18,21 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load('jstests/replsets/rslib.js');
function runTest(failPoint) {
const recipientRst = new ReplSetTest({
nodes: 2,
name: jsTestName() + "_recipient",
- nodeOptions: Object.assign(makeX509OptionsForTest().recipient, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().recipient, {
setParameter: {
// Use a batch size of 2 so that collection cloner requires more than a single batch
// to complete.
@@ -141,3 +143,4 @@ if (testEnabled) {
// 'RecipientSyncData' cmd, indicating that the data is consistent.
runTest('fpAfterDataConsistentMigrationRecipientInstance');
}
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_retry_forget_migration.js b/jstests/replsets/tenant_migration_recipient_retry_forget_migration.js
index af00f5b0ae7..4bc8302c8a3 100644
--- a/jstests/replsets/tenant_migration_recipient_retry_forget_migration.js
+++ b/jstests/replsets/tenant_migration_recipient_retry_forget_migration.js
@@ -10,19 +10,21 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {getCertificateAndPrivateKey} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/parallelTester.js"); // For Thread()
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
const migrationId = UUID();
const tenantId = 'testTenantId';
const recipientCertificateForDonor =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem");
+ TenantMigrationUtil.getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem");
const dbName = tenantMigrationTest.tenantDB(tenantId, "test");
const collName = "coll";
@@ -113,3 +115,4 @@ assert.eq(currOp.state, 3 /* kDone */, currOp);
assert(currOp.hasOwnProperty("expireAt"), currOp);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js b/jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js
index 816584bf075..9db0cb6a56b 100644
--- a/jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js
+++ b/jstests/replsets/tenant_migration_recipient_retryable_writes_failover.js
@@ -12,9 +12,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+
+"use strict";
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
+load("jstests/replsets/libs/tenant_migration_test.js");
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), sharedOptions: {nodes: 2}});
@@ -108,3 +111,4 @@ jsTestLog("Waiting for migration to complete.");
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 5bdd59683b8..02a707d9443 100644
--- a/jstests/replsets/tenant_migration_recipient_rollback_recovery.js
+++ b/jstests/replsets/tenant_migration_recipient_rollback_recovery.js
@@ -10,19 +10,15 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- forgetMigrationAsync,
- makeX509OptionsForTest,
- runMigrationAsync,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/replsets/libs/rollback_test.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kTenantId = "testTenantId";
@@ -33,7 +29,7 @@ const kMaxSleepTimeMS = 250;
// state.
const kGarbageCollectionDelayMS = 30 * 1000;
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
function makeMigrationOpts(tenantMigrationTest, migrationId, tenantId) {
return {
@@ -65,7 +61,7 @@ function testRollBack(setUpFunc, rollbackOpsFunc, steadyStateFunc) {
donorRst.startSet();
donorRst.initiate();
- const donorRstArgs = createRstArgs(donorRst);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
const recipientRst = new ReplSetTest({
name: "recipientRst",
@@ -133,7 +129,8 @@ function testRollbackInitialState() {
// Start the migration asynchronously and wait for the primary to insert the state doc.
migrationOpts = makeMigrationOpts(tenantMigrationTest, migrationId, kTenantId + "-initial");
- migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
assert.soon(() => {
return 1 ===
@@ -182,7 +179,8 @@ function testRollBackStateTransition(pauseFailPoint, setUpFailPoints, nextState,
migrationOpts =
makeMigrationOpts(tenantMigrationTest, migrationId, kTenantId + "-" + nextState);
- migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
pauseFp.wait();
};
@@ -235,7 +233,7 @@ function testRollBackMarkingStateGarbageCollectable() {
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
// Run donorForgetMigration and wait for the primary to do the write to mark the state doc
// as garbage collectable.
- forgetMigrationThread = new Thread(forgetMigrationAsync,
+ forgetMigrationThread = new Thread(TenantMigrationUtil.forgetMigrationAsync,
migrationOpts.migrationIdString,
donorRstArgs,
false /* retryOnRetryableErrors */);
@@ -272,11 +270,11 @@ function testRollBackRandom() {
let setUpFunc = (tenantMigrationTest, donorRstArgs) => {
migrationOpts = makeMigrationOpts(tenantMigrationTest, migrationId, kTenantId + "-random");
- migrationThread = new Thread(async (donorRstArgs, migrationOpts) => {
- const {runMigrationAsync, forgetMigrationAsync} =
- await import("jstests/replsets/libs/tenant_migration_util.js");
- assert.commandWorked(await runMigrationAsync(migrationOpts, donorRstArgs));
- assert.commandWorked(await forgetMigrationAsync(
+ migrationThread = new Thread((donorRstArgs, migrationOpts) => {
+ load("jstests/replsets/libs/tenant_migration_util.js");
+ assert.commandWorked(
+ TenantMigrationUtil.runMigrationAsync(migrationOpts, donorRstArgs));
+ assert.commandWorked(TenantMigrationUtil.forgetMigrationAsync(
migrationOpts.migrationIdString, donorRstArgs, false /* retryOnRetryableErrors */));
}, donorRstArgs, migrationOpts);
@@ -333,3 +331,4 @@ testRollBackMarkingStateGarbageCollectable();
jsTest.log("Test roll back random");
testRollBackRandom();
+}());
diff --git a/jstests/replsets/tenant_migration_recipient_shard_merge_learn_files.js b/jstests/replsets/tenant_migration_recipient_shard_merge_learn_files.js
index 10ccacb62ad..7215e7b1088 100644
--- a/jstests/replsets/tenant_migration_recipient_shard_merge_learn_files.js
+++ b/jstests/replsets/tenant_migration_recipient_shard_merge_learn_files.js
@@ -11,11 +11,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {isShardMergeEnabled} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), sharedOptions: {nodes: 3}});
@@ -26,10 +28,10 @@ const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
jsTestLog(
@@ -83,3 +85,4 @@ tenantMigrationTest.getRecipientRst().nodes.forEach(node => {
});
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_shard_merge_oplog_catchup.js b/jstests/replsets/tenant_migration_recipient_shard_merge_oplog_catchup.js
index b9951427d87..35623bff5f9 100644
--- a/jstests/replsets/tenant_migration_recipient_shard_merge_oplog_catchup.js
+++ b/jstests/replsets/tenant_migration_recipient_shard_merge_oplog_catchup.js
@@ -11,11 +11,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {isShardMergeEnabled} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), sharedOptions: {nodes: 3}});
@@ -25,10 +27,10 @@ const donorPrimary = tenantMigrationTest.getDonorPrimary();
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
// Insert some documents before migration start so that this collection gets cloned by file cloner.
@@ -89,3 +91,4 @@ tenantMigrationTest.getRecipientRst().nodes.forEach(node => {
});
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_shard_merge_ttl.js b/jstests/replsets/tenant_migration_recipient_shard_merge_ttl.js
index 579c16fd1cb..7dd50a1eeb8 100644
--- a/jstests/replsets/tenant_migration_recipient_shard_merge_ttl.js
+++ b/jstests/replsets/tenant_migration_recipient_shard_merge_ttl.js
@@ -12,13 +12,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), quickGarbageCollection: true});
@@ -29,10 +29,10 @@ const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
const tenantId = ObjectId().str;
@@ -104,3 +104,4 @@ assert.eq(documentCount, 0);
hangTTLMonitorBetweenPasses.off();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_startup_recovery.js b/jstests/replsets/tenant_migration_recipient_startup_recovery.js
index 640a94d4a96..fe8913939be 100644
--- a/jstests/replsets/tenant_migration_recipient_startup_recovery.js
+++ b/jstests/replsets/tenant_migration_recipient_startup_recovery.js
@@ -13,16 +13,17 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const recipientRst = new ReplSetTest({
nodes: 1,
name: 'recipient',
- nodeOptions: Object.assign(makeX509OptionsForTest().recipient, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().recipient, {
setParameter:
{"failpoint.PrimaryOnlyServiceSkipRebuildingInstances": tojson({mode: "alwaysOn"})}
})
@@ -107,3 +108,4 @@ if (recipientDoc) {
tenantMigrationTest.stop();
recipientRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_sync_data_timeout.js b/jstests/replsets/tenant_migration_recipient_sync_data_timeout.js
index e3f1fb55225..6e37a8c48c0 100644
--- a/jstests/replsets/tenant_migration_recipient_sync_data_timeout.js
+++ b/jstests/replsets/tenant_migration_recipient_sync_data_timeout.js
@@ -10,9 +10,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -34,3 +37,4 @@ TenantMigrationTest.assertCommitted(tenantMigrationTest.runMigration(migrationOp
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 72d9a71b293..4a2a3dbfda9 100644
--- a/jstests/replsets/tenant_migration_recipient_sync_donor_timestamp.js
+++ b/jstests/replsets/tenant_migration_recipient_sync_donor_timestamp.js
@@ -14,9 +14,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject()
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
// Make the batch size small so that we can pause before all the batches are applied.
const tenantMigrationTest = new TenantMigrationTest(
@@ -92,3 +96,4 @@ jsTestLog("Waiting for migration to complete.");
TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_ttl.js b/jstests/replsets/tenant_migration_recipient_ttl.js
index dd776653a05..8945eaafa97 100644
--- a/jstests/replsets/tenant_migration_recipient_ttl.js
+++ b/jstests/replsets/tenant_migration_recipient_ttl.js
@@ -10,8 +10,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+
+"use strict";
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kGarbageCollectionParams = {
// Set the delay to 20s so that we can see the `expireAt` set prior to the document vanishing.
@@ -81,3 +85,4 @@ jsTestLog("Waiting for the state document to have been deleted.");
tenantMigrationTest.waitForMigrationGarbageCollection(kMigrationId, kTenantId);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_recipient_vote_imported_files.js b/jstests/replsets/tenant_migration_recipient_vote_imported_files.js
index 318837ab94d..0cd364c998d 100644
--- a/jstests/replsets/tenant_migration_recipient_vote_imported_files.js
+++ b/jstests/replsets/tenant_migration_recipient_vote_imported_files.js
@@ -11,16 +11,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
-load('jstests/replsets/rslib.js'); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({
name: jsTestName(),
@@ -33,10 +31,10 @@ const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
const kTenantId = ObjectId();
@@ -71,7 +69,7 @@ const migrationOpts = {
tenantIds: tojson([kTenantId]),
};
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
jsTestLog("Test that recipientVoteImportedFiles fails with no migration started");
voteShouldFail(migrationId);
@@ -79,7 +77,8 @@ voteShouldFail(migrationId);
jsTestLog("Start a migration and pause after cloning");
const fpAfterStartingOplogApplierMigrationRecipientInstance = configureFailPoint(
recipientPrimary, "fpAfterStartingOplogApplierMigrationRecipientInstance", {action: "hang"});
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
jsTestLog("Wait for recipient to log 'Waiting for all nodes to call recipientVoteImportedFiles'");
@@ -104,3 +103,4 @@ tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, kTenantId.str
jsTestLog("Test that recipientVoteImportedFiles fails after migration is forgotten");
voteShouldFail(migrationId);
tenantMigrationTest.stop();
+})();
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 1b1d1f9a674..035cbacd900 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
@@ -11,21 +11,20 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- checkTenantDBHashes,
- makeX509OptionsForTest,
-} from "jstests/replsets/libs/tenant_migration_util.js";
-
-load("jstests/libs/fail_point_util.js");
-load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+(function() {
+"use strict";
const tenantMigrationFailoverTest = function(isTimeSeries, createCollFn, docs) {
+ load("jstests/libs/fail_point_util.js");
+ load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+ load("jstests/replsets/libs/tenant_migration_test.js");
+ load("jstests/replsets/libs/tenant_migration_util.js");
+
const batchSize = 2;
const recipientRst = new ReplSetTest({
nodes: 2,
name: jsTestName() + "_recipient",
- nodeOptions: Object.assign(makeX509OptionsForTest().recipient, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().recipient, {
setParameter: {
// Use a batch size of 2 so that collection cloner requires more than a single
// batch to complete.
@@ -102,7 +101,7 @@ const tenantMigrationFailoverTest = function(isTimeSeries, createCollFn, docs) {
recipientColl = newRecipientPrimary.getDB(dbName).getCollection(collName);
assert.eq(docs.length, recipientColl.find().itcount());
assert.docEq(docs, recipientColl.find().sort({_id: 1}).toArray());
- checkTenantDBHashes({
+ TenantMigrationUtil.checkTenantDBHashes({
donorRst: tenantMigrationTest.getDonorRst(),
recipientRst: tenantMigrationTest.getRecipientRst(),
tenantId
@@ -129,3 +128,4 @@ jsTestLog("Running tenant migration test for regular collection");
tenantMigrationFailoverTest(false,
(db, collName) => db.createCollection(collName),
[{_id: 0}, {_id: "string"}, {_id: UUID()}, {_id: new Date()}]);
+})();
diff --git a/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover_with_dropped_views.js b/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover_with_dropped_views.js
index e2b3d9618ef..de499f06f34 100644
--- a/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover_with_dropped_views.js
+++ b/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover_with_dropped_views.js
@@ -11,17 +11,19 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
-
-load("jstests/libs/fail_point_util.js");
-load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+(function() {
+"use strict";
const tenantMigrationFailoverTest = function(isTimeSeries, createCollFn) {
+ load("jstests/libs/fail_point_util.js");
+ load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
+ load("jstests/replsets/libs/tenant_migration_test.js");
+ load("jstests/replsets/libs/tenant_migration_util.js");
+
const recipientRst = new ReplSetTest({
nodes: 2,
name: jsTestName() + "_recipient",
- nodeOptions: Object.assign(makeX509OptionsForTest().recipient, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().recipient, {
setParameter: {
// Allow reads on recipient before migration completes for testing.
'failpoint.tenantMigrationRecipientNotRejectReads': tojson({mode: 'alwaysOn'}),
@@ -130,3 +132,4 @@ tenantMigrationFailoverTest(true,
jsTestLog("Running tenant migration test for regular view");
tenantMigrationFailoverTest(false,
(db, collName) => db.createView(collName, "sourceCollection", []));
+})();
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 275d1706f03..d97e6986a1a 100644
--- a/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js
+++ b/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js
@@ -11,22 +11,19 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- checkTenantDBHashes,
- makeX509OptionsForTest,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
load("jstests/libs/parallelTester.js"); // for 'Thread'
-load('jstests/replsets/rslib.js'); // 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const recipientRst = new ReplSetTest({
nodes: 2,
name: jsTestName() + "_recipient",
- nodeOptions: Object.assign(makeX509OptionsForTest().recipient, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().recipient, {
setParameter: {
// Use a batch size of 2 so that collection cloner requires more than a single batch to
// complete.
@@ -70,8 +67,9 @@ const hangDuringCollectionClone =
{nss: recipientColl.getFullName()});
// Start a migration and wait for recipient to hang after cloning 2 documents.
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
hangDuringCollectionClone.wait();
assert.soon(() => recipientColl.find().itcount() === 2);
@@ -113,7 +111,7 @@ TenantMigrationTest.assertCommitted(migrationThread.returnData());
recipientColl = newRecipientPrimary.getDB(dbName).getCollection(collNameRenamed);
assert.eq(4, recipientColl.find().itcount());
assert.eq(recipientColl.find().sort({_id: 1}).toArray(), docs);
-checkTenantDBHashes({
+TenantMigrationUtil.checkTenantDBHashes({
donorRst: tenantMigrationTest.getDonorRst(),
recipientRst: tenantMigrationTest.getRecipientRst(),
tenantId
@@ -121,3 +119,4 @@ checkTenantDBHashes({
tenantMigrationTest.stop();
recipientRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_resume_oplog_application.js b/jstests/replsets/tenant_migration_resume_oplog_application.js
index 8571519c536..9d6661753ab 100644
--- a/jstests/replsets/tenant_migration_resume_oplog_application.js
+++ b/jstests/replsets/tenant_migration_resume_oplog_application.js
@@ -11,25 +11,22 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- checkTenantDBHashes,
- makeX509OptionsForTest,
- runMigrationAsync,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js"); // for 'extractUUIDFromObject'
load("jstests/libs/parallelTester.js"); // for 'Thread'
load("jstests/libs/write_concern_util.js"); // for 'stopReplicationOnSecondaries'
load("jstests/aggregation/extras/utils.js"); // For assertArrayEq.
-load('jstests/replsets/rslib.js'); // For 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const recipientRst = new ReplSetTest({
nodes: 3,
name: jsTestName() + "_recipient",
// Use a batch size of 2 so that we can hang in the middle of tenant oplog application.
- nodeOptions: Object.assign(makeX509OptionsForTest().recipient,
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().recipient,
{setParameter: {tenantApplierBatchSizeOps: 2}})
});
@@ -68,8 +65,9 @@ let waitAfterDatabaseClone = configureFailPoint(
let waitInOplogApplier = configureFailPoint(recipientPrimary, "hangInTenantOplogApplication");
// Start a migration and wait for recipient to hang in the tenant database cloner.
-const donorRstArgs = createRstArgs(donorRst);
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
waitAfterDatabaseClone.wait();
@@ -109,10 +107,11 @@ resultsArr = appliedNoOps.toArray();
assert.eq(3, appliedNoOps.count(), appliedNoOps);
assert.eq(docsToApply[2], resultsArr[2].o2.o, resultsArr);
-checkTenantDBHashes({
+TenantMigrationUtil.checkTenantDBHashes({
donorRst: tenantMigrationTest.getDonorRst(),
recipientRst: tenantMigrationTest.getRecipientRst(),
tenantId
});
tenantMigrationTest.stop();
recipientRst.stopSet();
+})();
diff --git a/jstests/replsets/tenant_migration_retry_session_migration.js b/jstests/replsets/tenant_migration_retry_session_migration.js
index aa322f4ef63..7d75a0d506a 100644
--- a/jstests/replsets/tenant_migration_retry_session_migration.js
+++ b/jstests/replsets/tenant_migration_retry_session_migration.js
@@ -15,9 +15,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {checkTenantDBHashes} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/replsets/rslib.js");
load("jstests/libs/uuid_util.js");
@@ -154,10 +156,11 @@ assert.commandWorked(recipientPrimary.getDB(kDbName).runCommand({
// The dbhash between the donor and the recipient should still match after retrying
// commitTransaction and the retryable writes because they should be noop.
-checkTenantDBHashes({
+TenantMigrationUtil.checkTenantDBHashes({
donorRst: tenantMigrationTest.getDonorRst(),
recipientRst: tenantMigrationTest.getRecipientRst(),
tenantId: kTenantId
});
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_retryable_write_retry.js b/jstests/replsets/tenant_migration_retryable_write_retry.js
index 6c913e94cb0..a895fd9e788 100644
--- a/jstests/replsets/tenant_migration_retryable_write_retry.js
+++ b/jstests/replsets/tenant_migration_retryable_write_retry.js
@@ -15,15 +15,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- makeX509OptionsForTest,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const donorRst = new ReplSetTest({
nodes: 1,
@@ -327,3 +327,4 @@ assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migration
donorRst.stopSet();
recipientRst.stopSet();
+})();
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 8fb9b8fcb07..c18c8dfd0dd 100644
--- a/jstests/replsets/tenant_migration_retryable_write_retry_on_recipient.js
+++ b/jstests/replsets/tenant_migration_retryable_write_retry_on_recipient.js
@@ -11,16 +11,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- runMigrationAsync
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js"); // for 'Thread'
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -38,10 +36,10 @@ const recipientDb = recipientPrimary.getDB(kDbName);
// wrongly restarts the Shard Merge protocol. It copies and imports donor files again, and
// eventually hits an invariant in TenantFileImporterService, which doesn't support restart.
// Once we fix Shard Merge to not resume on stepup, this test will work as-is.
-if (isShardMergeEnabled(donorPrimary.getDB("adminDB"))) {
+if (TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("adminDB"))) {
jsTestLog("Skip: featureFlagShardMerge enabled, but shard merge does not survive stepup");
tenantMigrationTest.stop();
- quit();
+ return;
}
jsTestLog("Run a migration to the end of cloning");
@@ -166,8 +164,9 @@ assert.commandWorked(
assert.commandWorked(
donorDb.runCommand(beforeWrites.retryableFindAndModifyUpdateWithPreImageCommand));
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
waitBeforeFetchingTransactions.wait();
@@ -296,3 +295,4 @@ testRecipientRetryableWrites(recipient2Db, duringWrites);
tenantMigrationTest2.stop();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_shard_merge_import_write_conflict_retry.js b/jstests/replsets/tenant_migration_shard_merge_import_write_conflict_retry.js
index 2849b2e5109..5b7a8c5b064 100644
--- a/jstests/replsets/tenant_migration_shard_merge_import_write_conflict_retry.js
+++ b/jstests/replsets/tenant_migration_shard_merge_import_write_conflict_retry.js
@@ -14,11 +14,11 @@
* serverless,
* ]
*/
-
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {isShardMergeEnabled} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/libs/fail_point_util.js");
const migrationId = UUID();
@@ -26,10 +26,10 @@ const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
const donorPrimary = tenantMigrationTest.getDonorPrimary();
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
-if (!isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
const kDataDir =
@@ -87,3 +87,4 @@ tenantMigrationTest.getRecipientRst().nodes.forEach(node => {
});
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_shard_merge_invalid_inputs.js b/jstests/replsets/tenant_migration_shard_merge_invalid_inputs.js
index 6294e154480..d8342a24b10 100644
--- a/jstests/replsets/tenant_migration_shard_merge_invalid_inputs.js
+++ b/jstests/replsets/tenant_migration_shard_merge_invalid_inputs.js
@@ -14,11 +14,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
- makeMigrationCertificatesForTest,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), enableRecipientTesting: false});
@@ -29,10 +29,10 @@ const donorPrimary = tenantMigrationTest.getDonorPrimary();
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
@@ -41,7 +41,7 @@ const tenantId = "testTenantId";
const readPreference = {
mode: 'primary'
};
-const migrationCertificates = makeMigrationCertificatesForTest();
+const migrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest();
jsTestLog("Testing 'donorStartMigration' command provided with invalid options.");
@@ -198,3 +198,4 @@ assert.commandFailedWithCode(recipientPrimary.adminCommand({
}),
ErrorCodes.InvalidOptions);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_shard_merge_read_preference.js b/jstests/replsets/tenant_migration_shard_merge_read_preference.js
index dbfd63ae0a8..d2768626210 100644
--- a/jstests/replsets/tenant_migration_shard_merge_read_preference.js
+++ b/jstests/replsets/tenant_migration_shard_merge_read_preference.js
@@ -12,22 +12,21 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- isShardMergeEnabled,
-} from "jstests/replsets/libs/tenant_migration_util.js";
-
+(function() {
+"use strict";
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest =
new TenantMigrationTest({name: jsTestName(), enableRecipientTesting: false});
const donorPrimary = tenantMigrationTest.getDonorPrimary();
-if (!isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
const failingMigrationOpts = {
@@ -46,3 +45,4 @@ const succeessfulMigrationOpts = {
assert.commandWorked(tenantMigrationTest.startMigration(succeessfulMigrationOpts));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_shard_merge_recipient_current_op.js b/jstests/replsets/tenant_migration_shard_merge_recipient_current_op.js
index c5021286ed2..f8aba60ba46 100644
--- a/jstests/replsets/tenant_migration_shard_merge_recipient_current_op.js
+++ b/jstests/replsets/tenant_migration_shard_merge_recipient_current_op.js
@@ -14,16 +14,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- forgetMigrationAsync,
- isShardMergeEnabled,
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/parallelTester.js"); // For the Thread().
-load('jstests/replsets/rslib.js'); // For 'createRstArgs'
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -31,10 +29,11 @@ const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(tenantMigrationTest.getDonorPrimary().getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(
+ tenantMigrationTest.getDonorPrimary().getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
const kMigrationId = UUID();
@@ -210,10 +209,11 @@ const fpBeforePersistingRejectReadsBeforeTimestamp = configureFailPoint(
}
jsTestLog("Issuing a forget migration command.");
-const forgetMigrationThread = new Thread(forgetMigrationAsync,
- migrationOpts.migrationIdString,
- createRstArgs(tenantMigrationTest.getDonorRst()),
- true /* retryOnRetryableErrors */);
+const forgetMigrationThread =
+ new Thread(TenantMigrationUtil.forgetMigrationAsync,
+ migrationOpts.migrationIdString,
+ TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst()),
+ true /* retryOnRetryableErrors */);
forgetMigrationThread.start();
{
@@ -246,3 +246,4 @@ forgetMigrationThread.start();
}
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_shard_merge_recipient_fetches_synthetic_find_and_modify_entries.js b/jstests/replsets/tenant_migration_shard_merge_recipient_fetches_synthetic_find_and_modify_entries.js
index a44b25e0d62..b11b7209c47 100644
--- a/jstests/replsets/tenant_migration_shard_merge_recipient_fetches_synthetic_find_and_modify_entries.js
+++ b/jstests/replsets/tenant_migration_shard_merge_recipient_fetches_synthetic_find_and_modify_entries.js
@@ -13,10 +13,10 @@
* serverless,
* ]
*/
+(function() {
+"use strict";
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {isShardMergeEnabled} from "jstests/replsets/libs/tenant_migration_util.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
load("jstests/libs/uuid_util.js"); // For extractUUIDFromObject().
load("jstests/libs/fail_point_util.js"); // For configureFailPoint().
load("jstests/libs/parallelTester.js"); // For Thread.
@@ -34,10 +34,10 @@ const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
// suites will execute this test without featureFlagShardMerge enabled (despite the
// presence of the featureFlagShardMerge tag above), which means the test will attempt
// to run a multi-tenant migration and fail.
-if (!isShardMergeEnabled(donorPrimary.getDB("admin"))) {
+if (!TenantMigrationUtil.isShardMergeEnabled(donorPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
jsTestLog("Skipping Shard Merge-specific test");
- quit();
+ return;
}
const tenantCollection = donorPrimary.getDB(kDbName)[kCollName];
@@ -121,3 +121,4 @@ assert.eq(0, bsonWoCompare(cmdResponse2, retryResponse2), retryResponse2);
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_ssl_configuration.js b/jstests/replsets/tenant_migration_ssl_configuration.js
index de4032102cc..406979b8776 100644
--- a/jstests/replsets/tenant_migration_ssl_configuration.js
+++ b/jstests/replsets/tenant_migration_ssl_configuration.js
@@ -12,26 +12,22 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- donorStartMigrationWithProtocol,
- getCertificateAndPrivateKey,
- isMigrationCompleted,
- makeMigrationCertificatesForTest,
- makeX509OptionsForTest,
- runTenantMigrationCommand
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kTenantId = ObjectId().str;
const kReadPreference = {
mode: "primary"
};
-const kValidMigrationCertificates = makeMigrationCertificatesForTest();
+const kValidMigrationCertificates = TenantMigrationUtil.makeMigrationCertificatesForTest();
const kExpiredMigrationCertificates = {
- donorCertificateForRecipient:
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_donor_expired.pem"),
- recipientCertificateForDonor:
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient_expired.pem")
+ donorCertificateForRecipient: TenantMigrationUtil.getCertificateAndPrivateKey(
+ "jstests/libs/tenant_migration_donor_expired.pem"),
+ recipientCertificateForDonor: TenantMigrationUtil.getCertificateAndPrivateKey(
+ "jstests/libs/tenant_migration_recipient_expired.pem")
};
(() => {
@@ -45,29 +41,33 @@ const kExpiredMigrationCertificates = {
jsTest.log("Test that donorStartMigration requires 'donorCertificateForRecipient' when " +
"tenantMigrationDisableX509Auth=false");
assert.commandFailedWithCode(
- donorPrimary.adminCommand(donorStartMigrationWithProtocol({
- donorStartMigration: 1,
- migrationId: UUID(),
- recipientConnectionString: tenantMigrationTest.getRecipientRst().getURL(),
- tenantId: kTenantId,
- readPreference: kReadPreference,
- recipientCertificateForDonor: kValidMigrationCertificates.recipientCertificateForDonor,
- },
- donorPrimary.getDB("admin"))),
+ donorPrimary.adminCommand(
+ TenantMigrationUtil.donorStartMigrationWithProtocol({
+ donorStartMigration: 1,
+ migrationId: UUID(),
+ recipientConnectionString: tenantMigrationTest.getRecipientRst().getURL(),
+ tenantId: kTenantId,
+ readPreference: kReadPreference,
+ recipientCertificateForDonor:
+ kValidMigrationCertificates.recipientCertificateForDonor,
+ },
+ donorPrimary.getDB("admin"))),
ErrorCodes.InvalidOptions);
jsTest.log("Test that donorStartMigration requires 'recipientCertificateForDonor' when " +
"tenantMigrationDisableX509Auth=false");
assert.commandFailedWithCode(
- donorPrimary.adminCommand(donorStartMigrationWithProtocol({
- donorStartMigration: 1,
- migrationId: UUID(),
- recipientConnectionString: tenantMigrationTest.getRecipientRst().getURL(),
- tenantId: kTenantId,
- readPreference: kReadPreference,
- donorCertificateForRecipient: kValidMigrationCertificates.donorCertificateForRecipient,
- },
- donorPrimary.getDB("admin"))),
+ donorPrimary.adminCommand(
+ TenantMigrationUtil.donorStartMigrationWithProtocol({
+ donorStartMigration: 1,
+ migrationId: UUID(),
+ recipientConnectionString: tenantMigrationTest.getRecipientRst().getURL(),
+ tenantId: kTenantId,
+ readPreference: kReadPreference,
+ donorCertificateForRecipient:
+ kValidMigrationCertificates.donorCertificateForRecipient,
+ },
+ donorPrimary.getDB("admin"))),
ErrorCodes.InvalidOptions);
jsTest.log("Test that recipientSyncData requires 'recipientCertificateForDonor' when " +
@@ -108,16 +108,19 @@ const kExpiredMigrationCertificates = {
const donorPrimary = tenantMigrationTest.getDonorPrimary();
assert.commandFailedWithCode(
- donorPrimary.adminCommand(donorStartMigrationWithProtocol({
- donorStartMigration: 1,
- migrationId: UUID(),
- recipientConnectionString: tenantMigrationTest.getRecipientRst().getURL(),
- tenantId: kTenantId,
- readPreference: kReadPreference,
- donorCertificateForRecipient: kValidMigrationCertificates.donorCertificateForRecipient,
- recipientCertificateForDonor: kValidMigrationCertificates.recipientCertificateForDonor,
- },
- donorPrimary.getDB("admin"))),
+ donorPrimary.adminCommand(
+ TenantMigrationUtil.donorStartMigrationWithProtocol({
+ donorStartMigration: 1,
+ migrationId: UUID(),
+ recipientConnectionString: tenantMigrationTest.getRecipientRst().getURL(),
+ tenantId: kTenantId,
+ readPreference: kReadPreference,
+ donorCertificateForRecipient:
+ kValidMigrationCertificates.donorCertificateForRecipient,
+ recipientCertificateForDonor:
+ kValidMigrationCertificates.recipientCertificateForDonor,
+ },
+ donorPrimary.getDB("admin"))),
ErrorCodes.IllegalOperation);
donorRst.stopSet();
@@ -153,7 +156,7 @@ const kExpiredMigrationCertificates = {
(() => {
jsTest.log("Test that recipientSyncData doesn't require 'recipientCertificateForDonor' when " +
"tenantMigrationDisableX509Auth=true");
- const migrationX509Options = makeX509OptionsForTest();
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const recipientRst = new ReplSetTest({
nodes: 1,
name: "recipient",
@@ -184,7 +187,7 @@ const kExpiredMigrationCertificates = {
jsTest.log(
"Test that recipientForgetMigration doesn't require 'recipientCertificateForDonor' when " +
"tenantMigrationDisableX509Auth=true");
- const migrationX509Options = makeX509OptionsForTest();
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const recipientRst = new ReplSetTest({
nodes: 1,
name: "recipient",
@@ -214,7 +217,7 @@ const kExpiredMigrationCertificates = {
(() => {
jsTest.log("Test that donorStartMigration doesn't require certificate fields when " +
"tenantMigrationDisableX509Auth=true");
- const migrationX509Options = makeX509OptionsForTest();
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const donorRst = new ReplSetTest({
nodes: 1,
name: "donor",
@@ -245,10 +248,10 @@ const kExpiredMigrationCertificates = {
tenantId: kTenantId,
readPreference: kReadPreference
};
- const stateRes = assert.commandWorked(runTenantMigrationCommand(
+ const stateRes = assert.commandWorked(TenantMigrationUtil.runTenantMigrationCommand(
donorStartMigrationCmdObj,
donorRst,
- {retryOnRetryableErrors: false, shouldStopFunc: isMigrationCompleted}));
+ {retryOnRetryableErrors: false, shouldStopFunc: TenantMigrationUtil.isMigrationCompleted}));
assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
assert.commandWorked(
donorRst.getPrimary().adminCommand({donorForgetMigration: 1, migrationId: migrationId}));
@@ -290,10 +293,10 @@ const kExpiredMigrationCertificates = {
readPreference: kReadPreference
};
- const stateRes = assert.commandWorked(runTenantMigrationCommand(
+ const stateRes = assert.commandWorked(TenantMigrationUtil.runTenantMigrationCommand(
donorStartMigrationCmdObj,
donorRst,
- {retryOnRetryableErrors: false, shouldStopFunc: isMigrationCompleted}));
+ {retryOnRetryableErrors: false, shouldStopFunc: TenantMigrationUtil.isMigrationCompleted}));
assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
donorRst.stopSet();
@@ -304,7 +307,7 @@ const kExpiredMigrationCertificates = {
(() => {
jsTest.log(
"Test that input certificate fields are not used when tenantMigrationDisableX509Auth=true");
- const migrationX509Options = makeX509OptionsForTest();
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const donorRst = new ReplSetTest({
nodes: 1,
name: "donor",
@@ -336,13 +339,14 @@ const kExpiredMigrationCertificates = {
donorCertificateForRecipient: kExpiredMigrationCertificates.donorCertificateForRecipient,
recipientCertificateForDonor: kExpiredMigrationCertificates.recipientCertificateForDonor,
};
- const stateRes = assert.commandWorked(runTenantMigrationCommand(
+ const stateRes = assert.commandWorked(TenantMigrationUtil.runTenantMigrationCommand(
donorStartMigrationCmdObj,
donorRst,
- {retryOnRetryableErrors: false, shouldStopFunc: isMigrationCompleted}));
+ {retryOnRetryableErrors: false, shouldStopFunc: TenantMigrationUtil.isMigrationCompleted}));
assert.eq(stateRes.state, TenantMigrationTest.DonorState.kCommitted);
donorRst.stopSet();
recipientRst.stopSet();
tenantMigrationTest.stop();
})();
+})();
diff --git a/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js b/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js
index ca708b301d5..9603b611a5c 100644
--- a/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js
+++ b/jstests/replsets/tenant_migration_stepup_recovery_after_abort.js
@@ -10,11 +10,12 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
// Set the delay before a state doc is garbage collected to be short to speed up the test.
const kGarbageCollectionParams = {
@@ -25,8 +26,8 @@ const kGarbageCollectionParams = {
const donorRst = new ReplSetTest({
nodes: 3,
name: "donor",
- nodeOptions:
- Object.assign(makeX509OptionsForTest().donor, {setParameter: kGarbageCollectionParams})
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor,
+ {setParameter: kGarbageCollectionParams})
});
donorRst.startSet();
@@ -66,3 +67,4 @@ tenantMigrationTest.waitForMigrationGarbageCollection(migrationId, tenantId);
donorRst.stopSet();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_sync_source_too_stale.js b/jstests/replsets/tenant_migration_sync_source_too_stale.js
index 50b2b0f0b5a..47376d19f66 100644
--- a/jstests/replsets/tenant_migration_sync_source_too_stale.js
+++ b/jstests/replsets/tenant_migration_sync_source_too_stale.js
@@ -23,19 +23,20 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
load('jstests/replsets/rslib.js');
const donorRst = new ReplSetTest({
name: `${jsTestName()}_donor`,
nodes: 3,
settings: {chainingAllowed: false},
- nodeOptions: Object.assign(makeX509OptionsForTest().donor, {
+ nodeOptions: Object.assign(TenantMigrationUtil.makeX509OptionsForTest().donor, {
setParameter: {
// Allow non-timestamped reads on donor after migration completes for testing.
'failpoint.tenantMigrationDonorAllowsNonTimestampedReads': tojson({mode: 'alwaysOn'}),
@@ -167,3 +168,4 @@ TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComple
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 97115f3c764..6c831d650f3 100644
--- a/jstests/replsets/tenant_migration_test_max_bson_limit.js
+++ b/jstests/replsets/tenant_migration_test_max_bson_limit.js
@@ -9,11 +9,14 @@
* serverless,
* ]
*/
+(function() {
+'use strict';
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
const kCollName = "testColl";
const kTenantDefinedDbName = "0";
@@ -87,3 +90,4 @@ assert.lte(Object.bsonsize(bulkWriteRes),
assert.commandWorked(primaryDB.hello()).maxBsonObjectSize);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_timeseries_collections.js b/jstests/replsets/tenant_migration_timeseries_collections.js
index 3474a6405a6..8499bf857e6 100644
--- a/jstests/replsets/tenant_migration_timeseries_collections.js
+++ b/jstests/replsets/tenant_migration_timeseries_collections.js
@@ -10,8 +10,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -49,3 +52,4 @@ tenantMigrationTest.getRecipientRst().nodes.forEach(node => {
});
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_timeseries_retryable_write_oplog_cloning.js b/jstests/replsets/tenant_migration_timeseries_retryable_write_oplog_cloning.js
index 96a04e013b2..3715b23efca 100644
--- a/jstests/replsets/tenant_migration_timeseries_retryable_write_oplog_cloning.js
+++ b/jstests/replsets/tenant_migration_timeseries_retryable_write_oplog_cloning.js
@@ -14,13 +14,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function testOplogCloning(ordered) {
- const migrationX509Options = makeX509OptionsForTest();
+ const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
const kGarbageCollectionParams = {
// Set the delay before a donor state doc is garbage collected to be short to speed up
// the test.
@@ -280,3 +282,4 @@ function testOplogCloning(ordered) {
testOplogCloning(true);
testOplogCloning(false);
+})();
diff --git a/jstests/replsets/tenant_migration_timeseries_retryable_write_retry_on_recipient.js b/jstests/replsets/tenant_migration_timeseries_retryable_write_retry_on_recipient.js
index e9725f537ec..410269bd268 100644
--- a/jstests/replsets/tenant_migration_timeseries_retryable_write_retry_on_recipient.js
+++ b/jstests/replsets/tenant_migration_timeseries_retryable_write_retry_on_recipient.js
@@ -16,13 +16,14 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {runMigrationAsync} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js"); // for 'Thread'
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // 'createRstArgs'
function testRetryOnRecipient(ordered) {
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -92,8 +93,9 @@ function testRetryOnRecipient(ordered) {
jsTestLog("Run retryable writes before the migration");
assert.commandWorked(donorDb.runCommand(beforeWrites.retryableInsertCommand));
- const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
- const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+ const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+ const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
pauseTenantMigrationBeforeLeavingDataSyncState.wait();
@@ -163,3 +165,4 @@ function testRetryOnRecipient(ordered) {
testRetryOnRecipient(true);
testRetryOnRecipient(false);
+})();
diff --git a/jstests/replsets/tenant_migration_transaction_boundary.js b/jstests/replsets/tenant_migration_transaction_boundary.js
index c8bdbfdc0a3..6e92e801849 100644
--- a/jstests/replsets/tenant_migration_transaction_boundary.js
+++ b/jstests/replsets/tenant_migration_transaction_boundary.js
@@ -21,7 +21,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/replsets/rslib.js");
load("jstests/libs/uuid_util.js");
@@ -81,3 +85,4 @@ TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComple
assert.eq(recipientPrimary.getCollection(tenantNS).countDocuments({}), 3);
assert.eq(recipientPrimary.getCollection(tenantNS).count(), 3);
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_v1_id_index.js b/jstests/replsets/tenant_migration_v1_id_index.js
index 6203be453fa..8ab9aa227da 100644
--- a/jstests/replsets/tenant_migration_v1_id_index.js
+++ b/jstests/replsets/tenant_migration_v1_id_index.js
@@ -11,8 +11,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -59,3 +62,4 @@ TenantMigrationTest.assertCommitted(tenantMigrationTest.waitForMigrationToComple
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migration_x509.js b/jstests/replsets/tenant_migration_x509.js
index e0bce5e192d..5344ef04e40 100644
--- a/jstests/replsets/tenant_migration_x509.js
+++ b/jstests/replsets/tenant_migration_x509.js
@@ -11,9 +11,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {getCertificateAndPrivateKey} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function makeTestNs(tenantId) {
@@ -31,9 +33,9 @@ function setup() {
}
const kDonorCertificateAndPrivateKey =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_donor.pem");
+ TenantMigrationUtil.getCertificateAndPrivateKey("jstests/libs/tenant_migration_donor.pem");
const kRecipientCertificateAndPrivateKey =
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem");
+ TenantMigrationUtil.getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient.pem");
(() => {
jsTest.log("Test valid donor and recipient certificates");
@@ -183,8 +185,8 @@ const kRecipientCertificateAndPrivateKey =
const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationId),
tenantId: tenantId,
- donorCertificateForRecipient:
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_donor_expired.pem"),
+ donorCertificateForRecipient: TenantMigrationUtil.getCertificateAndPrivateKey(
+ "jstests/libs/tenant_migration_donor_expired.pem"),
recipientCertificateForDonor: kRecipientCertificateAndPrivateKey,
};
const {dbName, collName} = makeTestNs(tenantId);
@@ -302,8 +304,8 @@ const kRecipientCertificateAndPrivateKey =
migrationIdString: extractUUIDFromObject(migrationId),
tenantId: tenantId,
donorCertificateForRecipient: kDonorCertificateAndPrivateKey,
- recipientCertificateForDonor:
- getCertificateAndPrivateKey("jstests/libs/tenant_migration_recipient_expired.pem"),
+ recipientCertificateForDonor: TenantMigrationUtil.getCertificateAndPrivateKey(
+ "jstests/libs/tenant_migration_recipient_expired.pem"),
};
const {dbName, collName} = makeTestNs(tenantId);
@@ -341,7 +343,7 @@ const kRecipientCertificateAndPrivateKey =
if (!TestData.auth) {
jsTestLog("Skipping testing authorization since auth is not enabled");
- quit();
+ return;
}
(() => {
@@ -352,7 +354,7 @@ if (!TestData.auth) {
const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationId),
tenantId: tenantId,
- donorCertificateForRecipient: getCertificateAndPrivateKey(
+ donorCertificateForRecipient: TenantMigrationUtil.getCertificateAndPrivateKey(
"jstests/libs/tenant_migration_donor_insufficient_privileges.pem"),
recipientCertificateForDonor: kRecipientCertificateAndPrivateKey,
};
@@ -375,7 +377,7 @@ if (!TestData.auth) {
migrationIdString: extractUUIDFromObject(migrationId),
tenantId: tenantId,
donorCertificateForRecipient: kDonorCertificateAndPrivateKey,
- recipientCertificateForDonor: getCertificateAndPrivateKey(
+ recipientCertificateForDonor: TenantMigrationUtil.getCertificateAndPrivateKey(
"jstests/libs/tenant_migration_recipient_insufficient_privileges.pem"),
};
const {dbName, collName} = makeTestNs(tenantId);
@@ -387,3 +389,4 @@ if (!TestData.auth) {
tenantId, dbName, collName, false /* migrationCommitted */);
teardown();
})();
+})();
diff --git a/jstests/replsets/tenant_migrations_back_to_back.js b/jstests/replsets/tenant_migrations_back_to_back.js
index b5dbba6b9f9..cab9b9b70da 100644
--- a/jstests/replsets/tenant_migrations_back_to_back.js
+++ b/jstests/replsets/tenant_migrations_back_to_back.js
@@ -13,13 +13,15 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {runMigrationAsync} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/fail_point_util.js");
load("jstests/libs/parallelTester.js"); // for 'Thread'
load("jstests/libs/uuid_util.js");
-load("jstests/replsets/rslib.js"); // for 'getLastOpTime', 'createRstArgs'
+load("jstests/replsets/rslib.js"); // for 'getLastOpTime'
const kTenantId = ObjectId().str;
const tenantMigrationTest =
@@ -44,8 +46,9 @@ const preMigrationTimestamp = getLastOpTime(donorPrimary).ts;
let waitForRejectReadsBeforeTsFp = configureFailPoint(
recipientPrimary, "fpAfterWaitForRejectReadsBeforeTimestamp", {action: "hang"});
-const donorRstArgs = createRstArgs(tenantMigrationTest.getDonorRst());
-const migrationThread = new Thread(runMigrationAsync, migrationOpts, donorRstArgs);
+const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
+const migrationThread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
waitForRejectReadsBeforeTsFp.wait();
@@ -77,7 +80,7 @@ jsTestLog("Running a back-to-back migration");
const tenantMigrationTest2 = new TenantMigrationTest(
{name: jsTestName() + "2", donorRst: tenantMigrationTest.getRecipientRst()});
const donor2Primary = tenantMigrationTest2.getDonorPrimary();
-const donor2RstArgs = createRstArgs(tenantMigrationTest2.getDonorRst());
+const donor2RstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest2.getDonorRst());
const migration2Id = UUID();
const migrationOpts2 = {
migrationIdString: extractUUIDFromObject(migration2Id),
@@ -89,7 +92,8 @@ const newDonorRst = recipientRst;
let waitAfterCreatingMtab =
configureFailPoint(donor2Primary, "pauseTenantMigrationBeforeLeavingBlockingState");
-const migration2Thread = new Thread(runMigrationAsync, migrationOpts2, donor2RstArgs);
+const migration2Thread =
+ new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts2, donor2RstArgs);
migration2Thread.start();
// At this point, 'donor2Primary' should have both a recipient and donor access blocker. The donor
// access blocker has entered the blocking state, and the recipient access blocker should
@@ -154,3 +158,4 @@ TenantMigrationTest.assertCommitted(migration2Thread.returnData());
tenantMigrationTest2.stop();
tenantMigrationTest.stop();
+})();
diff --git a/jstests/replsets/tenant_migrations_noop_writes.js b/jstests/replsets/tenant_migrations_noop_writes.js
index 3cfd8445423..6101c339f16 100644
--- a/jstests/replsets/tenant_migrations_noop_writes.js
+++ b/jstests/replsets/tenant_migrations_noop_writes.js
@@ -11,21 +11,19 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- getTenantMigrationAccessBlocker,
- makeX509OptionsForTest
-} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
load("jstests/libs/write_concern_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
load('jstests/libs/parallel_shell_helpers.js');
// During "shard merge" tenant migrations, writes to internal DBs are still allowed.
const kUnrelatedDbName = "admin";
const collName = "foo";
-const migrationX509Options = makeX509OptionsForTest();
+const migrationX509Options = TenantMigrationUtil.makeX509OptionsForTest();
let makeTenantId = function() {
return ObjectId().str;
@@ -51,7 +49,8 @@ function advanceClusterTime(conn, dbName, collName) {
}
function getBlockTimestamp(conn, tenantId) {
- const mtabServerStatus = getTenantMigrationAccessBlocker({donorNode: conn, tenantId}).donor;
+ const mtabServerStatus =
+ TenantMigrationUtil.getTenantMigrationAccessBlocker({donorNode: conn, tenantId}).donor;
assert(mtabServerStatus.blockTimestamp, tojson(mtabServerStatus));
return mtabServerStatus.blockTimestamp;
}
@@ -233,3 +232,4 @@ function setup() {
awaitReadOnDonor();
teardown();
}
+})();
diff --git a/jstests/replsets/tenant_migrations_transaction_with_create_collection.js b/jstests/replsets/tenant_migrations_transaction_with_create_collection.js
index be97a065689..d3a6e5b9ce2 100644
--- a/jstests/replsets/tenant_migrations_transaction_with_create_collection.js
+++ b/jstests/replsets/tenant_migrations_transaction_with_create_collection.js
@@ -11,10 +11,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
+(function() {
+"use strict";
+
load("jstests/aggregation/extras/utils.js");
load("jstests/libs/fail_point_util.js");
load("jstests/libs/uuid_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
@@ -70,3 +73,4 @@ assertArrayEq({
});
tenantMigrationTest.stop();
+})();
diff --git a/jstests/serverless/libs/shard_split_test.js b/jstests/serverless/libs/shard_split_test.js
index b816b8fd55b..bc153ef8bcb 100644
--- a/jstests/serverless/libs/shard_split_test.js
+++ b/jstests/serverless/libs/shard_split_test.js
@@ -1,6 +1,4 @@
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {makeX509OptionsForTest} from "jstests/replsets/libs/tenant_migration_util.js";
-
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/replsets/rslib.js");
load("jstests/libs/parallelTester.js");
load("jstests/libs/uuid_util.js");
@@ -56,7 +54,7 @@ export function doWriteOperations(rstArgs, tenantIds) {
export function addRecipientNodes({rst, numNodes, recipientTagName}) {
numNodes = numNodes || 3; // default to three nodes
const recipientNodes = [];
- const options = makeX509OptionsForTest();
+ const options = TenantMigrationUtil.makeX509OptionsForTest();
jsTestLog(`Adding ${numNodes} non-voting recipient nodes to donor`);
for (let i = 0; i < numNodes; ++i) {
recipientNodes.push(rst.add(options.donor));
diff --git a/jstests/serverless/serverless_reject_multiple_ops_access_blocker.js b/jstests/serverless/serverless_reject_multiple_ops_access_blocker.js
index 3ef2b7e8806..e1073ddeb92 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_access_blocker.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_access_blocker.js
@@ -6,9 +6,9 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {addRecipientNodes, commitSplitAsync} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function cannotStartMigrationWhenThereIsAnExistingAccessBlocker(protocol) {
diff --git a/jstests/serverless/serverless_reject_multiple_ops_migration_after_garbage_collection.js b/jstests/serverless/serverless_reject_multiple_ops_migration_after_garbage_collection.js
index 92cde29bed9..115ceacf9fb 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_migration_after_garbage_collection.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_migration_after_garbage_collection.js
@@ -6,13 +6,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
addRecipientNodes,
commitSplitAsync,
waitForGarbageCollectionForSplit
} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function canStartMigrationAfterSplitGarbageCollection(protocol) {
diff --git a/jstests/serverless/serverless_reject_multiple_ops_migration_different_tenant.js b/jstests/serverless/serverless_reject_multiple_ops_migration_different_tenant.js
index bd4195f88b4..be93b69b91d 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_migration_different_tenant.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_migration_different_tenant.js
@@ -6,13 +6,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
addRecipientNodes,
commitSplitAsync,
waitForGarbageCollectionForSplit
} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function cannotStartMigrationWithDifferentTenantWhileShardSplitIsInProgress(protocol) {
diff --git a/jstests/serverless/serverless_reject_multiple_ops_migration_donor.js b/jstests/serverless/serverless_reject_multiple_ops_migration_donor.js
index 92cde29bed9..115ceacf9fb 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_migration_donor.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_migration_donor.js
@@ -6,13 +6,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
addRecipientNodes,
commitSplitAsync,
waitForGarbageCollectionForSplit
} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function canStartMigrationAfterSplitGarbageCollection(protocol) {
diff --git a/jstests/serverless/serverless_reject_multiple_ops_migration_donor_retry.js b/jstests/serverless/serverless_reject_multiple_ops_migration_donor_retry.js
index 3428cbf040d..2516c4611d4 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_migration_donor_retry.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_migration_donor_retry.js
@@ -6,13 +6,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
addRecipientNodes,
commitSplitAsync,
waitForGarbageCollectionForSplit
} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function retryMigrationAfterSplitCompletes(protocol) {
diff --git a/jstests/serverless/serverless_reject_multiple_ops_migration_fail.js b/jstests/serverless/serverless_reject_multiple_ops_migration_fail.js
index d9f0f8d51de..13f311ffe80 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_migration_fail.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_migration_fail.js
@@ -6,13 +6,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
addRecipientNodes,
commitSplitAsync,
waitForGarbageCollectionForSplit
} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function cannotStartMigrationWhileShardSplitIsInProgress(protocol) {
diff --git a/jstests/serverless/serverless_reject_multiple_ops_migration_fail_on_recipient.js b/jstests/serverless/serverless_reject_multiple_ops_migration_fail_on_recipient.js
index bc498eb7a30..1ab2ac05996 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_migration_fail_on_recipient.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_migration_fail_on_recipient.js
@@ -6,13 +6,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
addRecipientNodes,
commitSplitAsync,
waitForGarbageCollectionForSplit
} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function cannotStartMigrationWhileShardSplitIsInProgressOnRecipient(protocol) {
diff --git a/jstests/serverless/serverless_reject_multiple_ops_migration_recipient_retry.js b/jstests/serverless/serverless_reject_multiple_ops_migration_recipient_retry.js
index 96d4fa9fc6e..9567fe2e325 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_migration_recipient_retry.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_migration_recipient_retry.js
@@ -6,13 +6,13 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
addRecipientNodes,
commitSplitAsync,
waitForGarbageCollectionForSplit
} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function cannotStartMigrationWhileShardSplitIsInProgressOnRecipient(protocol) {
diff --git a/jstests/serverless/serverless_reject_multiple_ops_split.js b/jstests/serverless/serverless_reject_multiple_ops_split.js
index 969e1763f97..0531094f164 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_split.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_split.js
@@ -6,9 +6,9 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {addRecipientNodes, commitSplitAsync} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function cannotStartShardSplitWithMigrationInProgress(
diff --git a/jstests/serverless/serverless_reject_multiple_ops_split_retry.js b/jstests/serverless/serverless_reject_multiple_ops_split_retry.js
index c80af377b80..0955e0b0802 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_split_retry.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_split_retry.js
@@ -6,9 +6,9 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {addRecipientNodes, commitSplitAsync} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function retrySplit({protocol, recipientTagName, recipientSetName, tenantIds, test, splitRst}) {
diff --git a/jstests/serverless/serverless_reject_multiple_ops_split_success.js b/jstests/serverless/serverless_reject_multiple_ops_split_success.js
index 9eaa6cbc7b8..d0660710a30 100644
--- a/jstests/serverless/serverless_reject_multiple_ops_split_success.js
+++ b/jstests/serverless/serverless_reject_multiple_ops_split_success.js
@@ -6,9 +6,9 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {addRecipientNodes, commitSplitAsync} from "jstests/serverless/libs/shard_split_test.js";
-
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
load("jstests/libs/uuid_util.js");
function canStartShardSplitWithAbortedMigration({protocol, runOnRecipient}) {
diff --git a/jstests/serverless/shard_split_buildindex.js b/jstests/serverless/shard_split_buildindex.js
index a4b16bf383d..70f57619a58 100644
--- a/jstests/serverless/shard_split_buildindex.js
+++ b/jstests/serverless/shard_split_buildindex.js
@@ -12,10 +12,10 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {assertMigrationState, ShardSplitTest} from "jstests/serverless/libs/shard_split_test.js";
load("jstests/libs/fail_point_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
const shardSplitTest = new ShardSplitTest({quickGarbageCollection: true});
shardSplitTest.addRecipientNodes();
diff --git a/jstests/serverless/shard_split_concurrent_writes_on_donor_aborted.js b/jstests/serverless/shard_split_concurrent_writes_on_donor_aborted.js
index 9f8210a0cca..db4f269e3c3 100644
--- a/jstests/serverless/shard_split_concurrent_writes_on_donor_aborted.js
+++ b/jstests/serverless/shard_split_concurrent_writes_on_donor_aborted.js
@@ -11,16 +11,11 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {
- createCollectionAndInsertDocsForConcurrentWritesTest,
- makeTestOptionsForConcurrentWritesTest,
- runCommandForConcurrentWritesTest,
- TenantMigrationConcurrentWriteUtil
-} from "jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js";
import {assertMigrationState, ShardSplitTest} from "jstests/serverless/libs/shard_split_test.js";
load("jstests/libs/fail_point_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js");
TestData.skipCheckDBHashes = true;
const tenantMigrationTest = new ShardSplitTest({
diff --git a/jstests/serverless/shard_split_concurrent_writes_on_donor_blocking.js b/jstests/serverless/shard_split_concurrent_writes_on_donor_blocking.js
index 2f4105c31a1..7f434139146 100644
--- a/jstests/serverless/shard_split_concurrent_writes_on_donor_blocking.js
+++ b/jstests/serverless/shard_split_concurrent_writes_on_donor_blocking.js
@@ -12,18 +12,14 @@
* ]
*/
-import {
- createCollectionAndInsertDocsForConcurrentWritesTest,
- makeTestOptionsForConcurrentWritesTest,
- runCommandForConcurrentWritesTest,
- TenantMigrationConcurrentWriteUtil
-} from "jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js";
import {ShardSplitTest} from "jstests/serverless/libs/shard_split_test.js";
load("jstests/libs/fail_point_util.js");
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js");
TestData.skipCheckDBHashes = true;
-const shardSplitTest = new ShardSplitTest({
+const tenantMigrationTest = new ShardSplitTest({
quickGarbageCollection: true,
allowStaleReadsOnDonor: true,
initiateWithShortElectionTimeout: true,
@@ -31,7 +27,7 @@ const shardSplitTest = new ShardSplitTest({
nodeOptions: {setParameter: {shardSplitTimeoutMS: 100000}}
});
-const donorPrimary = shardSplitTest.getDonorPrimary();
+const donorPrimary = tenantMigrationTest.getDonorPrimary();
const kCollName = "testColl";
const kTenantDefinedDbName = "0";
@@ -157,9 +153,9 @@ function runTestsAfterMigrationCommitted() {
}
}
-shardSplitTest.addRecipientNodes();
+tenantMigrationTest.addRecipientNodes();
const tenantIds = [kTenantID];
-const operation = shardSplitTest.createSplitOperation(tenantIds);
+const operation = tenantMigrationTest.createSplitOperation(tenantIds);
setupTestsBeforeMigration();
@@ -186,4 +182,4 @@ runTestsAfterMigrationCommitted();
ShardSplitTest.checkShardSplitAccessBlocker(
donorPrimary, kTenantID, {numBlockedWrites: countBlockedWrites});
-shardSplitTest.stop();
+tenantMigrationTest.stop();
diff --git a/jstests/serverless/shard_split_concurrent_writes_on_donor_committed.js b/jstests/serverless/shard_split_concurrent_writes_on_donor_committed.js
index 6443f8a3199..16dfc9394f1 100644
--- a/jstests/serverless/shard_split_concurrent_writes_on_donor_committed.js
+++ b/jstests/serverless/shard_split_concurrent_writes_on_donor_committed.js
@@ -11,15 +11,10 @@
* ]
*/
-import {
- createCollectionAndInsertDocsForConcurrentWritesTest,
- makeTestOptionsForConcurrentWritesTest,
- runCommandForConcurrentWritesTest,
- TenantMigrationConcurrentWriteUtil
-} from "jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js";
import {ShardSplitTest} from "jstests/serverless/libs/shard_split_test.js";
load("jstests/libs/fail_point_util.js");
+load("jstests/replsets/tenant_migration_concurrent_writes_on_donor_util.js");
TestData.skipCheckDBHashes = true;
const test = new ShardSplitTest({
diff --git a/jstests/serverless/shard_split_recipient_removes_serverless_lock.js b/jstests/serverless/shard_split_recipient_removes_serverless_lock.js
index cc7be614a57..d1829e0e3b7 100644
--- a/jstests/serverless/shard_split_recipient_removes_serverless_lock.js
+++ b/jstests/serverless/shard_split_recipient_removes_serverless_lock.js
@@ -5,13 +5,11 @@
* @tags: [requires_fcv_62, serverless]
*/
-import {
- getServerlessOperationLock,
- ServerlessLockType
-} from "jstests/replsets/libs/tenant_migration_util.js";
import {ShardSplitTest} from "jstests/serverless/libs/shard_split_test.js";
load("jstests/libs/fail_point_util.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+const {ServerlessLockType, getServerlessOperationLock} = TenantMigrationUtil;
// Skip db hash check because secondary is left with a different config.
TestData.skipCheckDBHashes = true;
diff --git a/jstests/serverless/shard_split_startup_recovery_aborted.js b/jstests/serverless/shard_split_startup_recovery_aborted.js
index e50f14ffcf1..ccf0a5fecd5 100644
--- a/jstests/serverless/shard_split_startup_recovery_aborted.js
+++ b/jstests/serverless/shard_split_startup_recovery_aborted.js
@@ -5,7 +5,6 @@
* @tags: [requires_fcv_62, serverless]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
assertMigrationState,
findSplitOperation,
@@ -13,6 +12,7 @@ import {
} from "jstests/serverless/libs/shard_split_test.js";
load("jstests/libs/fail_point_util.js"); // for "configureFailPoint"
+load("jstests/replsets/libs/tenant_migration_test.js");
// Skip db hash check because secondary is left with a different config.
TestData.skipCheckDBHashes = true;
diff --git a/jstests/serverless/shard_split_startup_recovery_blocking.js b/jstests/serverless/shard_split_startup_recovery_blocking.js
index 5ac174ab7ae..972a24e6311 100644
--- a/jstests/serverless/shard_split_startup_recovery_blocking.js
+++ b/jstests/serverless/shard_split_startup_recovery_blocking.js
@@ -4,7 +4,6 @@
* @tags: [requires_fcv_62, serverless]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
assertMigrationState,
findSplitOperation,
@@ -12,6 +11,7 @@ import {
} from "jstests/serverless/libs/shard_split_test.js";
load("jstests/libs/fail_point_util.js"); // for "configureFailPoint"
+load("jstests/replsets/libs/tenant_migration_test.js");
// Skip db hash check because secondary is left with a different config.
TestData.skipCheckDBHashes = true;
diff --git a/jstests/serverless/shard_split_startup_recovery_committed.js b/jstests/serverless/shard_split_startup_recovery_committed.js
index fa37707d695..1f93304e94a 100644
--- a/jstests/serverless/shard_split_startup_recovery_committed.js
+++ b/jstests/serverless/shard_split_startup_recovery_committed.js
@@ -4,7 +4,6 @@
* @tags: [requires_fcv_62, serverless]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
import {
assertMigrationState,
findSplitOperation,
@@ -12,6 +11,7 @@ import {
} from "jstests/serverless/libs/shard_split_test.js";
load("jstests/libs/fail_point_util.js"); // for "configureFailPoint"
+load("jstests/replsets/libs/tenant_migration_test.js");
// Skip db hash check because secondary is left with a different config.
TestData.skipCheckDBHashes = true;
diff --git a/jstests/serverless/shard_split_startup_recovery_initially_aborted.js b/jstests/serverless/shard_split_startup_recovery_initially_aborted.js
index 9ed278b6730..b3ab18fcfe4 100644
--- a/jstests/serverless/shard_split_startup_recovery_initially_aborted.js
+++ b/jstests/serverless/shard_split_startup_recovery_initially_aborted.js
@@ -7,15 +7,15 @@
*/
import {
- getServerlessOperationLock,
- ServerlessLockType
-} from "jstests/replsets/libs/tenant_migration_util.js";
-import {
assertMigrationState,
findSplitOperation,
ShardSplitTest
} from "jstests/serverless/libs/shard_split_test.js";
+
load("jstests/libs/fail_point_util.js"); // for "configureFailPoint"
+load("jstests/replsets/libs/tenant_migration_test.js");
+load("jstests/replsets/libs/tenant_migration_util.js");
+const {ServerlessLockType, getServerlessOperationLock} = TenantMigrationUtil;
// Skip db hash check because secondary is left with a different config.
TestData.skipCheckDBHashes = true;
diff --git a/jstests/sharding/tenant_migration_disallowed_on_config_server.js b/jstests/sharding/tenant_migration_disallowed_on_config_server.js
index 3b82018a22c..ca8078e1288 100644
--- a/jstests/sharding/tenant_migration_disallowed_on_config_server.js
+++ b/jstests/sharding/tenant_migration_disallowed_on_config_server.js
@@ -10,8 +10,10 @@
* ]
*/
-import {TenantMigrationTest} from "jstests/replsets/libs/tenant_migration_test.js";
-import {donorStartMigrationWithProtocol} from "jstests/replsets/libs/tenant_migration_util.js";
+(function() {
+"use strict";
+
+load("jstests/replsets/libs/tenant_migration_test.js");
const st = new ShardingTest({shards: 1});
const donorRstShard = st.rs0;
@@ -26,14 +28,14 @@ const tenantMigrationTest =
// Run tenant migration commands on config servers.
let donorPrimary = donorRstConfig.getPrimary();
-let cmdObj = donorStartMigrationWithProtocol({
+let cmdObj = TenantMigrationUtil.donorStartMigrationWithProtocol({
donorStartMigration: 1,
tenantId: ObjectId().str,
migrationId: UUID(),
recipientConnectionString: tenantMigrationTest.getRecipientConnString(),
readPreference: {mode: "primary"}
},
- donorPrimary.getDB("admin"));
+ donorPrimary.getDB("admin"));
assert.commandFailedWithCode(donorPrimary.adminCommand(cmdObj), ErrorCodes.IllegalOperation);
cmdObj = {
@@ -70,3 +72,4 @@ assert.commandFailedWithCode(donorPrimary.adminCommand(cmdObj), ErrorCodes.Illeg
tenantMigrationTest.stop();
recipientRst.stopSet();
st.stop();
+})();