summaryrefslogtreecommitdiff
path: root/jstests/multiVersion/genericSetFCVUsage/feature_compatibility_version_lagging_secondary.js
blob: 0d06214c7b9cbdfe2c94ed848c95b99e0b548268 (plain)
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
// Tests that a primary with upgrade featureCompatibilityVersion cannot connect with a secondary
// with a lower binary version.
(function() {
"use strict";

load("jstests/libs/write_concern_util.js");

const latest = "latest";
const downgrade = "last-stable";

// Start a new replica set with two latest version nodes.
let rst = new ReplSetTest({
    nodes: [{binVersion: latest}, {binVersion: latest, rsConfig: {priority: 0}}],
    settings: {chainingAllowed: false}
});
rst.startSet();
rst.initiate();

let primary = rst.getPrimary();
let latestSecondary = rst.getSecondary();

// Set the featureCompatibilityVersion to the downgrade version so that a downgrade node can
// join the set.
assert.commandWorked(
    primary.getDB("admin").runCommand({setFeatureCompatibilityVersion: lastStableFCV}));

// Add a downgrade node to the set.
let downgradeSecondary = rst.add({binVersion: downgrade, rsConfig: {priority: 0}});
rst.reInitiate();

// Wait for the downgrade secondary to finish initial sync.
rst.awaitSecondaryNodes();
rst.awaitReplication();

// Stop replication on the downgrade secondary.
stopServerReplication(downgradeSecondary);

// Set the featureCompatibilityVersion to the upgrade version. This will not replicate to
// the downgrade secondary, but the downgrade secondary will no longer be able to
// communicate with the rest of the set.
assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: latestFCV}));

// Shut down the latest version secondary.
rst.stop(latestSecondary);

// The primary should step down, since it can no longer see a majority of the replica set.
rst.waitForState(primary, ReplSetTest.State.SECONDARY);

restartServerReplication(downgradeSecondary);
rst.stopSet();
})();