From f0105d41e5f6f78c0d03458c06c93b62d2bc6a87 Mon Sep 17 00:00:00 2001 From: Eric Milkie Date: Mon, 28 Nov 2016 15:05:22 -0500 Subject: SERVER-27196 add wtimeouts to stepdown_needs_electable_secondary.js and stepdown_needs_majority.js (cherry picked from commit 993464ff5157f11a6f31938400014b2740d52aad) --- jstests/replsets/stepdown_needs_electable_secondary.js | 13 +++++++++---- 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 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); -- cgit v1.2.1