summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/restart_node_with_bridge.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/restart_node_with_bridge.js')
-rw-r--r--jstests/noPassthrough/restart_node_with_bridge.js85
1 files changed, 42 insertions, 43 deletions
diff --git a/jstests/noPassthrough/restart_node_with_bridge.js b/jstests/noPassthrough/restart_node_with_bridge.js
index 004b595a208..e4398f7b13c 100644
--- a/jstests/noPassthrough/restart_node_with_bridge.js
+++ b/jstests/noPassthrough/restart_node_with_bridge.js
@@ -5,60 +5,59 @@
* @tags: [requires_persistence, requires_replication]
*/
(function() {
- "use strict";
+"use strict";
- load("jstests/replsets/rslib.js"); // for reconnect
+load("jstests/replsets/rslib.js"); // for reconnect
- const rst = new ReplSetTest({
- nodes: [{}, {rsConfig: {priority: 0, votes: 0}}],
- useBridge: true,
- });
+const rst = new ReplSetTest({
+ nodes: [{}, {rsConfig: {priority: 0, votes: 0}}],
+ useBridge: true,
+});
- rst.startSet();
- rst.initiate();
- rst.awaitNodesAgreeOnPrimary();
+rst.startSet();
+rst.initiate();
+rst.awaitNodesAgreeOnPrimary();
- const primary = rst.getPrimary();
- const secondary = rst.getSecondary();
+const primary = rst.getPrimary();
+const secondary = rst.getSecondary();
- const primaryDB = primary.getDB("test");
- const primaryColl = primaryDB.getCollection("restart_node_with_bridge");
+const primaryDB = primary.getDB("test");
+const primaryColl = primaryDB.getCollection("restart_node_with_bridge");
- function assertWriteReplicates() {
- assert.commandWorked(primaryColl.update(
- {_id: 0}, {$inc: {counter: 1}}, {upsert: true, writeConcern: {w: 2}}));
- }
+function assertWriteReplicates() {
+ assert.commandWorked(
+ primaryColl.update({_id: 0}, {$inc: {counter: 1}}, {upsert: true, writeConcern: {w: 2}}));
+}
- function assertWriteFailsToReplicate() {
- assert.commandFailedWithCode(
- primaryColl.update(
- {_id: 0}, {$inc: {counter: 1}}, {writeConcern: {w: 2, wtimeout: 1000}}),
- ErrorCodes.WriteConcernFailed);
- }
+function assertWriteFailsToReplicate() {
+ assert.commandFailedWithCode(
+ primaryColl.update({_id: 0}, {$inc: {counter: 1}}, {writeConcern: {w: 2, wtimeout: 1000}}),
+ ErrorCodes.WriteConcernFailed);
+}
- // By default, the primary should be connected to the secondary. Replicating a write should
- // therefore succeed.
- assertWriteReplicates();
+// By default, the primary should be connected to the secondary. Replicating a write should
+// therefore succeed.
+assertWriteReplicates();
- // We disconnect the primary from the secondary and verify that replicating a write fails.
- primary.disconnect(secondary);
- assertWriteFailsToReplicate();
+// We disconnect the primary from the secondary and verify that replicating a write fails.
+primary.disconnect(secondary);
+assertWriteFailsToReplicate();
- // We restart the secondary and verify that replicating a write still fails.
- rst.restart(secondary);
- assertWriteFailsToReplicate();
+// We restart the secondary and verify that replicating a write still fails.
+rst.restart(secondary);
+assertWriteFailsToReplicate();
- // We restart the primary and verify that replicating a write still fails.
- rst.restart(primary);
- rst.getPrimary();
- // Note that we specify 'primaryDB' to avoid having reconnect() send a message directly to the
- // mongod process rather than going through the mongobridge process as well.
- reconnect(primaryDB);
- assertWriteFailsToReplicate();
+// We restart the primary and verify that replicating a write still fails.
+rst.restart(primary);
+rst.getPrimary();
+// Note that we specify 'primaryDB' to avoid having reconnect() send a message directly to the
+// mongod process rather than going through the mongobridge process as well.
+reconnect(primaryDB);
+assertWriteFailsToReplicate();
- // We reconnect the primary to the secondary and verify that replicating a write succeeds.
- primary.reconnect(secondary);
- assertWriteReplicates();
+// We reconnect the primary to the secondary and verify that replicating a write succeeds.
+primary.reconnect(secondary);
+assertWriteReplicates();
- rst.stopSet();
+rst.stopSet();
}());