1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/**
* Tests running 50 concurrent migrations against the same recipient.
*
* Incompatible with shard merge, which can't handle concurrent migrations.
*
* @tags: [
* incompatible_with_amazon_linux,
* incompatible_with_eft,
* incompatible_with_macos,
* incompatible_with_shard_merge,
* incompatible_with_windows_tls,
* requires_majority_read_concern,
* requires_persistence,
* serverless,
* ]
*/
(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}
};
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
// Set up tenant data for the 50 migrations.
const tenantIds = [...Array(50).keys()].map((i) => `testTenantId-${i}`);
let migrationOptsArray = [];
tenantIds.forEach((tenantId) => {
const dbName = tenantMigrationTest.tenantDB(tenantId, "testDB");
const collName = "testColl";
tenantMigrationTest.insertDonorDB(dbName, collName, [{_id: 1}]);
const migrationId = UUID();
const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationId),
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId: tenantId,
};
migrationOptsArray.push(migrationOpts);
});
// Hang all migrations during the cloning phase to avoid some finishing before others so that we
// know we can truly support 50 concurrent migrations.
const hangDuringCollectionClone =
configureFailPoint(recipientPrimary, "tenantCollectionClonerHangAfterCreateCollection");
// Start the 50 migrations.
migrationOptsArray.forEach((migrationOpts) => {
jsTestLog("Starting migration for tenant: " + migrationOpts.tenantId);
assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
});
jsTestLog("Waiting for failpoint to be hit for all 50 migrations");
assert.commandWorked(recipientPrimary.adminCommand({
waitForFailPoint: "tenantCollectionClonerHangAfterCreateCollection",
timesEntered: hangDuringCollectionClone.timesEntered + 50,
maxTimeMS: kDefaultWaitForFailPointTimeout
}));
// Release the failpoint and allow all migration to continue.
hangDuringCollectionClone.off();
migrationOptsArray.forEach((migrationOpts) => {
jsTestLog("Waiting for migration for tenant: " + migrationOpts.tenantId + " to complete");
TenantMigrationTest.assertCommitted(
tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
// Forget migrations first before shutting down the test to prevent unnecessary failover
// retries.
jsTestLog("Forgetting migration for tenant: " + migrationOpts.tenantId);
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
});
tenantMigrationTest.stop();
})();
|