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
|
/**
* Tests that the recipient will abort a shard merge on donor failure
*
* @tags: [
* incompatible_with_eft,
* incompatible_with_macos,
* incompatible_with_windows_tls,
* requires_majority_read_concern,
* requires_persistence,
* ]
*/
(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}});
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
if (!TenantMigrationUtil.isShardMergeEnabled(recipientPrimary.getDB("admin"))) {
tenantMigrationTest.stop();
return;
}
jsTestLog("Test that a shard merge is aborted in the event of a donor failure");
const tenantId = "testTenantId";
const tenantDB = tenantMigrationTest.tenantDB(tenantId, "DB");
const collName = "testColl";
const donorRst = tenantMigrationTest.getDonorRst();
const donorPrimary = tenantMigrationTest.getDonorPrimary();
const donorSecondary = donorRst.getSecondary();
tenantMigrationTest.insertDonorDB(tenantDB, collName);
const failpoint = "fpAfterComparingRecipientAndDonorFCV";
const waitInFailPoint = configureFailPoint(recipientPrimary, failpoint, {action: "hang"});
const migrationUuid = UUID();
const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationUuid),
tenantId,
readPreference: {mode: 'primary'}
};
jsTestLog(`Starting the tenant migration to wait in failpoint: ${failpoint}`);
assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
waitInFailPoint.wait();
jsTestLog("Stopping the donor primary");
donorRst.stop(donorPrimary);
waitInFailPoint.off();
// wait until the completion path has started after the abort
const hangBeforeTaskCompletion =
configureFailPoint(recipientPrimary, "hangBeforeTaskCompletion", {action: "hang"});
hangBeforeTaskCompletion.wait();
// step up a secondary so that the migration will complete and the
// waitForMigrationToComplete call to the donor primary succeeds
assert.commandWorked(donorSecondary.adminCommand({replSetStepUp: 1}));
hangBeforeTaskCompletion.off();
TenantMigrationTest.assertAborted(
tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
tenantMigrationTest.stop();
})();
})();
|