summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2016-11-28 15:05:22 -0500
committerEric Milkie <milkie@10gen.com>2016-11-29 09:54:37 -0500
commit993464ff5157f11a6f31938400014b2740d52aad (patch)
tree894b18ef8eca60e6dffc9514982a606968c8eda7 /jstests
parente876419bebadd6468c402e85e1fcf6eff5a374d4 (diff)
downloadmongo-993464ff5157f11a6f31938400014b2740d52aad.tar.gz
SERVER-27196 add wtimeouts to stepdown_needs_electable_secondary.js and stepdown_needs_majority.js
Diffstat (limited to 'jstests')
-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 403b783354f..f19f0c9ffcb 100644
--- a/jstests/replsets/stepdown_needs_majority.js
+++ b/jstests/replsets/stepdown_needs_majority.js
@@ -52,6 +52,7 @@
var testDB = primary.getDB('testdb');
var coll = testDB[name];
var dummy_doc = {"dummy_key": "dummy_val"};
+ var timeout = 5 * 60 * 1000;
//
// Block writes to all secondaries
@@ -63,7 +64,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);
@@ -76,7 +77,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);
@@ -89,7 +90,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);