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
|
/**
* Tests tenant migration timeout scenarios.
*
* @tags: [requires_fcv_47, incompatible_with_eft, requires_majority_read_concern,
* incompatible_with_windows_tls, incompatible_with_macos, requires_persistence]
*/
(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/tenant_migration_test.js");
load("jstests/replsets/libs/tenant_migration_util.js");
const kTenantIdPrefix = "testTenantId";
const tenantMigrationTest = new TenantMigrationTest({name: jsTestName()});
if (!tenantMigrationTest.isFeatureFlagEnabled()) {
jsTestLog("Skipping test because the tenant migrations feature flag is disabled");
return;
}
function testTimeoutBlockingState() {
const donorRst = tenantMigrationTest.getDonorRst();
const donorPrimary = donorRst.getPrimary();
let savedTimeoutParam = assert.commandWorked(donorPrimary.adminCommand({
getParameter: 1,
tenantMigrationBlockingStateTimeoutMS: 1
}))['tenantMigrationBlockingStateTimeoutMS'];
assert.commandWorked(
donorPrimary.adminCommand({setParameter: 1, tenantMigrationBlockingStateTimeoutMS: 5000}));
const tenantId = `${kTenantIdPrefix}-blockingTimeout`;
const migrationId = UUID();
const migrationOpts = {
migrationIdString: extractUUIDFromObject(migrationId),
tenantId,
recipientConnString: tenantMigrationTest.getRecipientConnString(),
};
const donorRstArgs = TenantMigrationUtil.createRstArgs(donorRst);
// Fail point to pause right before entering the blocking mode.
let afterDataSyncFp =
configureFailPoint(donorPrimary, "pauseTenantMigrationBeforeLeavingDataSyncState");
// Run the migration in its own thread, since the initial 'donorStartMigration' command will
// hang due to the fail point.
let migrationThread =
new Thread(TenantMigrationUtil.runMigrationAsync, migrationOpts, donorRstArgs);
migrationThread.start();
afterDataSyncFp.wait();
// Fail point to pause the '_sendRecipientSyncDataCommand()' call inside the blocking state
// until the cancellation token for the method is cancelled.
let inCallFp =
configureFailPoint(donorPrimary, "pauseScheduleCallWithCancelTokenUntilCanceled");
afterDataSyncFp.off();
tenantMigrationTest.waitForDonorNodesToReachState(
donorRst.nodes, migrationId, tenantId, TenantMigrationTest.DonorState.kAborted);
TenantMigrationTest.assertAborted(migrationThread.returnData(), ErrorCodes.ExceededTimeLimit);
// This fail point is pausing all calls to recipient, so it has to be disabled to make
// the 'forget migration' command to work.
inCallFp.off();
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
assert.commandWorked(donorPrimary.adminCommand(
{setParameter: 1, tenantMigrationBlockingStateTimeoutMS: savedTimeoutParam}));
}
jsTest.log("Test timeout of the blocking state");
testTimeoutBlockingState();
tenantMigrationTest.stop();
}());
|