summaryrefslogtreecommitdiff
path: root/jstests/replsets
diff options
context:
space:
mode:
authorCarolyn Duan <carolyn.duan@mongodb.com>2021-06-17 20:20:02 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-07-01 15:42:37 +0000
commit7422c1b638d2e4b200e7b72041d76f5702364d2b (patch)
tree7007d85a532f16915652b7b8b596e0deca1552a4 /jstests/replsets
parenta0e6f77bef9000d50e55a6c8239aaaf01cab4aa1 (diff)
downloadmongo-7422c1b638d2e4b200e7b72041d76f5702364d2b.tar.gz
SERVER-37904 Add enableOverrideClusterChainingSetting server parameter
Diffstat (limited to 'jstests/replsets')
-rw-r--r--jstests/replsets/cluster_chaining_override.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/jstests/replsets/cluster_chaining_override.js b/jstests/replsets/cluster_chaining_override.js
new file mode 100644
index 00000000000..69b50c0a924
--- /dev/null
+++ b/jstests/replsets/cluster_chaining_override.js
@@ -0,0 +1,41 @@
+/**
+ * Tests that if chaining is disabled, enabling the server parameter
+ * 'enableOverrideClusterChainingSetting' will allow the node to chain anyway.
+ * @tags: [requires_fcv_50]
+ */
+
+(function() {
+"use strict";
+load("jstests/replsets/rslib.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();
+}()); \ No newline at end of file