summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2016-11-28 15:05:22 -0500
committerJudah Schvimer <judah@mongodb.com>2016-12-28 15:26:44 -0500
commitf0105d41e5f6f78c0d03458c06c93b62d2bc6a87 (patch)
tree94305bddf53281a026376ebc7bd89758d22b9f32
parentd623f873409bba46b82454ee03140f67274363a7 (diff)
downloadmongo-f0105d41e5f6f78c0d03458c06c93b62d2bc6a87.tar.gz
SERVER-27196 add wtimeouts to stepdown_needs_electable_secondary.js and stepdown_needs_majority.js
(cherry picked from commit 993464ff5157f11a6f31938400014b2740d52aad)
-rw-r--r--jstests/replsets/stepdown_needs_electable_secondary.js13
-rw-r--r--jstests/replsets/stepdown_needs_majority.js7
2 files changed, 13 insertions, 7 deletions
diff --git a/jstests/replsets/stepdown_needs_electable_secondary.js b/jstests/replsets/stepdown_needs_electable_secondary.js
index 2e6a373d788..69cebe0fcc3 100644
--- a/jstests/replsets/stepdown_needs_electable_secondary.js
+++ b/jstests/replsets/stepdown_needs_electable_secondary.js
@@ -64,7 +64,9 @@
jsTestLog("Doing a write to primary.");
var testDB = replTest.getPrimary().getDB('testdb');
var coll = testDB.stepdown_needs_electable_secondary;
- assert.writeOK(coll.insert({"dummy_key": "dummy_val"}, {writeConcern: {w: 1}}));
+ var timeout = 5 * 60 * 1000;
+ assert.writeOK(
+ coll.insert({"dummy_key": "dummy_val"}, {writeConcern: {w: 1, wtimeout: timeout}}));
// Try to step down with only the primary caught up (1 node out of 5).
// stepDown should fail.
@@ -89,7 +91,8 @@
restartServerReplication(secondaryB_unelectable);
// Wait for this secondary to catch up by issuing a write that must be replicated to 2 nodes
- assert.writeOK(coll.insert({"dummy_key": "dummy_val"}, {writeConcern: {w: 2}}));
+ assert.writeOK(
+ coll.insert({"dummy_key": "dummy_val"}, {writeConcern: {w: 2, wtimeout: timeout}}));
// Try to step down and fail
jsTestLog("Trying to step down primary with only 2 nodes out of 5 caught up.");
@@ -103,7 +106,8 @@
restartServerReplication(secondaryC_unelectable);
// Wait for this secondary to catch up by issuing a write that must be replicated to 3 nodes
- assert.writeOK(coll.insert({"dummy_key": "dummy_val"}, {writeConcern: {w: 3}}));
+ assert.writeOK(
+ coll.insert({"dummy_key": "dummy_val"}, {writeConcern: {w: 3, wtimeout: timeout}}));
// Try to step down and fail
jsTestLog("Trying to step down primary with a caught up majority that " +
@@ -118,7 +122,8 @@
restartServerReplication(secondaryA_electable);
// Wait for this secondary to catch up by issuing a write that must be replicated to 4 nodes
- assert.writeOK(coll.insert({"dummy_key": "dummy_val"}, {writeConcern: {w: 4}}));
+ assert.writeOK(
+ coll.insert({"dummy_key": "dummy_val"}, {writeConcern: {w: 4, wtimeout: timeout}}));
// Try to step down. We expect success, so catch the exception thrown by 'replSetStepDown'.
jsTestLog("Trying to step down primary with a caught up majority that " +
diff --git a/jstests/replsets/stepdown_needs_majority.js b/jstests/replsets/stepdown_needs_majority.js
index 9b52ba58eb0..60d58ec3ee1 100644
--- a/jstests/replsets/stepdown_needs_majority.js
+++ b/jstests/replsets/stepdown_needs_majority.js
@@ -54,6 +54,7 @@
var dummy_doc = {
"dummy_key": "dummy_val"
};
+ var timeout = 5 * 60 * 1000;
//
// Block writes to all secondaries
@@ -65,7 +66,7 @@
// Write to the primary and attempt stepdown
//
jsTestLog("Issuing a write to the primary(" + primary.host + ") with write_concern:1");
- assert.writeOK(coll.insert(dummy_doc, {writeConcern: {w: 1}}));
+ assert.writeOK(coll.insert(dummy_doc, {writeConcern: {w: 1, wtimeout: timeout}}));
jsTestLog("Trying to step down primary with only 1 node out of 5 caught up.");
assertStepDownFailsWithExceededTimeLimit(primary);
@@ -78,7 +79,7 @@
restartServerReplication(secondaryA);
jsTestLog("Issuing a write to the primary with write_concern:2");
- assert.writeOK(coll.insert(dummy_doc, {writeConcern: {w: 2}}));
+ assert.writeOK(coll.insert(dummy_doc, {writeConcern: {w: 2, wtimeout: timeout}}));
jsTestLog("Trying to step down primary with only 2 nodes out of 5 caught up.");
assertStepDownFailsWithExceededTimeLimit(primary);
@@ -91,7 +92,7 @@
restartServerReplication(secondaryB);
jsTestLog("Issuing a write to the primary with write_concern:3");
- assert.writeOK(coll.insert(dummy_doc, {writeConcern: {w: 3}}));
+ assert.writeOK(coll.insert(dummy_doc, {writeConcern: {w: 3, wtimeout: timeout}}));
jsTestLog("Trying to step down primary with 3 nodes out of 5 caught up.");
assertStepDownSucceeds(primary);