-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
Copy pathcluster_chaining_override.js
37 lines (30 loc) · 1.17 KB
/
cluster_chaining_override.js
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
/**
* Tests that if chaining is disabled, enabling the server parameter
* 'enableOverrideClusterChainingSetting' will allow the node to chain anyway.
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
let rst = new ReplSetTest({
nodes: {
n0: {},
n1: {rsConfig: {priority: 0}},
n2: {rsConfig: {priority: 0}, setParameter: {enableOverrideClusterChainingSetting: true}}
},
// Enable the periodic noop writer to aid sync source selection.
nodeOptions: {setParameter: {writePeriodicNoops: true}},
settings: {chainingAllowed: false},
useBridge: true
});
rst.startSet();
rst.initiate();
const primary = rst.getPrimary();
rst.awaitSecondaryNodes();
const [n1, n2] = rst.getSecondaries();
// Create a network partition between n2 and the primary.
n2.disconnect(primary);
// Since n2 has enabled the parameter 'enableOverrideClusterChainingSetting', n2 should eventually
// chain from n1.
rst.awaitSyncSource(n2, n1);
// A write with write concern {w:3} should still reach n2.
var options = {writeConcern: {w: 3, wtimeout: ReplSetTest.kDefaultTimeoutMS}};
assert.commandWorked(primary.getDB("admin").foo.insert({x: 1}, options));
rst.stopSet();