diff options
author | Eric Milkie <milkie@10gen.com> | 2016-11-28 15:05:22 -0500 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2016-12-01 11:45:14 -0500 |
commit | 248693b35195bd46c3c9124d076b850b28406866 (patch) | |
tree | 2daa672a8f1aae75b4df526f0f8b0bc690504e4a | |
parent | 86337ec3f78d6d8ff0922b57b8b63c1ab078dd45 (diff) | |
download | mongo-248693b35195bd46c3c9124d076b850b28406866.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.js | 13 | ||||
-rw-r--r-- | jstests/replsets/stepdown_needs_majority.js | 7 |
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); |