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
|
/**
* Tests that the recipient cancels all migrations when its FCV changes.
* @tags: [
* requires_majority_read_concern,
* incompatible_with_windows_tls,
* serverless,
* ]
*/
(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()});
const tenantId = "testTenantId";
const dbName = tenantMigrationTest.tenantDB(tenantId, "testDB");
const collName = "testColl";
const donorRst = tenantMigrationTest.getDonorRst();
const donorPrimary = tenantMigrationTest.getDonorPrimary();
const donorDB = donorPrimary.getDB(dbName);
const recipientRst = tenantMigrationTest.getRecipientRst();
const recipientPrimary = tenantMigrationTest.getRecipientPrimary();
const recipientDB = recipientPrimary.getDB(dbName);
setLogVerbosity([recipientPrimary], {"tenantMigration": {"verbosity": 3}});
tenantMigrationTest.insertDonorDB(dbName, collName);
const migrationId = UUID();
const migrationIdString = extractUUIDFromObject(migrationId);
const migrationOpts = {
migrationIdString: migrationIdString,
recipientConnString: tenantMigrationTest.getRecipientConnString(),
tenantId: tenantId,
};
const hangWhileMigratingRecipientFP = configureFailPoint(
recipientDB, "fpAfterDataConsistentMigrationRecipientInstance", {action: "hang"});
const hangWhileMigratingDonorFP =
configureFailPoint(donorDB, "pauseTenantMigrationBeforeLeavingDataSyncState");
// Start a migration and wait for donor to hang at the failpoint.
assert.commandWorked(tenantMigrationTest.startMigration(migrationOpts));
hangWhileMigratingDonorFP.wait();
hangWhileMigratingRecipientFP.wait();
// Initiate a downgrade and let it complete.
assert.commandWorked(
recipientPrimary.adminCommand({setFeatureCompatibilityVersion: lastContinuousFCV}));
// Upgrade again and finish the test.
assert.commandWorked(recipientPrimary.adminCommand({setFeatureCompatibilityVersion: latestFCV}));
hangWhileMigratingDonorFP.off();
hangWhileMigratingRecipientFP.off();
const stateRes =
assert.commandWorked(tenantMigrationTest.waitForMigrationToComplete(migrationOpts));
assert.eq(stateRes.state, TenantMigrationTest.DonorState.kAborted);
assert.eq(stateRes.abortReason.code, ErrorCodes.TenantMigrationAborted);
tenantMigrationTest.waitForDonorNodesToReachState(
donorRst.nodes, migrationId, tenantId, TenantMigrationTest.DonorState.kAborted);
assert.commandWorked(tenantMigrationTest.forgetMigration(migrationOpts.migrationIdString));
tenantMigrationTest.stop();
})();
|