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
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/**
* Tests the voteCommitMigrationProgress command.
*
* @tags: [
* incompatible_with_eft,
* incompatible_with_macos,
* incompatible_with_windows_tls,
* requires_majority_read_concern,
* requires_persistence,
* requires_fcv_52,
* serverless,
* ]
*/
(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()});
const kTenantId = "testTenantId1";
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
function runVoteCmd(migrationId, step) {
return recipientPrimary.adminCommand({
voteCommitMigrationProgress: 1,
migrationId: migrationId,
from: tenantMigrationTest.getRecipientPrimary().host,
step: step,
success: true
});
}
function voteShouldFail(migrationId, steps) {
for (let step of steps) {
const reply = runVoteCmd(migrationId, step);
jsTestLog(`Vote with migrationId ${migrationId}, step '${step}', reply` +
` (should fail): ${tojson(reply)}`);
assert.commandFailed(reply);
}
}
function voteShouldSucceed(migrationId, steps) {
for (let step of steps) {
assert.commandWorked(runVoteCmd(migrationId, step));
}
}
const migrationId = UUID();
const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationId),
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId: kTenantId,
};
const donorRstArgs = TenantMigrationUtil.createRstArgs(tenantMigrationTest.getDonorRst());
jsTestLog("Test that voteCommitMigrationProgress fails with no migration in flight");
voteShouldFail(migrationId, ["copied files", "imported files"]);
jsTestLog("Start a migration and pause after cloning");
const fpAfterCollectionClonerDone =
configureFailPoint(recipientPrimary, "fpAfterCollectionClonerDone", {action: "hang"});
const fpAfterDataConsistentMigrationRecipientInstance = configureFailPoint(
recipientPrimary, "fpAfterDataConsistentMigrationRecipientInstance", {action: "hang"});
const migrationThread =
new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
fpAfterCollectionClonerDone.wait();
fpAfterCollectionClonerDone.off();
if (TenantMigrationUtil.isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
jsTestLog("Test that voteCommitMigrationProgress succeeds with step 'imported files'");
voteShouldSucceed(migrationId, ["imported files"]);
} else {
jsTestLog("Test that voteCommitMigrationProgress fails with shard merge disabled");
voteShouldFail(migrationId, ["imported files"]);
}
jsTestLog("Test that voteCommitMigrationProgress fails with wrong 'step'");
voteShouldFail(migrationId, ["copied files"]);
fpAfterDataConsistentMigrationRecipientInstance.wait();
fpAfterDataConsistentMigrationRecipientInstance.off();
TenantMigrationTest.assertCommitted(migrationThread.returnData());
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
voteShouldFail(migrationId, ["copied files", "imported files"]);
tenantMigrationTest.stop();
})();
|