From 888390515874a9debd1b6c5d36559ca86b44babd Mon Sep 17 00:00:00 2001 From: Ramon Fernandez Date: Thu, 20 Apr 2017 17:43:42 -0400 Subject: Revert "SERVER-28480/27966 last_vote.js should await replication and call stepUp before reconfig" This reverts commit 7a6d8274f57cf141fd1d5c754ea1e2a1a6d2f372. --- jstests/replsets/last_vote.js | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/jstests/replsets/last_vote.js b/jstests/replsets/last_vote.js index 84a6c206865..f087330846e 100644 --- a/jstests/replsets/last_vote.js +++ b/jstests/replsets/last_vote.js @@ -24,7 +24,7 @@ // Lower the election timeout to make the test run faster since it waits for multiple elections. var conf = rst.getReplSetConfig(); conf.settings = { - electionTimeoutMillis: 6000, + electionTimeoutMillis: 3000, }; rst.initiate(conf); @@ -56,45 +56,35 @@ jsTestLog("Test that last vote is set on successive elections"); - // Run a few successive elections, alternating who becomes primary. - var numElections = 3; - for (var i = 0; i < numElections; i++) { + for (var i = 0; i < 3; i++) { var primary = rst.getPrimary(); - var secondary = rst.getSecondary(); var term = getLatestOp(primary).t; - + jsTestLog("Last vote should have term: " + term + " and candidate: " + primary.host + + ", index: " + rst.getNodeId(primary)); // SERVER-20844 ReplSetTest starts up a single node replica set then reconfigures to the // correct size, so secondaries didn't vote in the first election. if (i > 0) { - jsTestLog("Last vote should have term: " + term + " and candidate: " + primary.host + - ", index: " + rst.getNodeId(primary)); rst.nodes.forEach(function(node) { assertNodeHasLastVote(node, term, primary); }); } assert.throws(function() { - primary.adminCommand({replSetStepDown: 60 * 10, force: true}); + primary.adminCommand({replSetStepDown: 5, force: true}); }); - - // Make sure a new primary has been established. rst.waitForState(primary, ReplSetTest.State.SECONDARY); - rst.waitForState(secondary, ReplSetTest.State.PRIMARY); - - // Reset election timeout for the old primary. - assert.commandWorked(primary.adminCommand({replSetFreeze: 0})); } var term = getLatestOp(rst.getPrimary()).t + 100; jsTestLog("Test that last vote is loaded on startup"); - - // Ensure that all ops are replicated before stepping up node 1. - rst.awaitReplication(); - - // We cannot reconfig node 0 to have priority 0 if it is currently the primary, - // so we make sure node 1 is primary. - jsTestLog("Stepping up node 1"); - rst.stepUp(rst.nodes[1]); + // We cannot reconfig nodes[0] to have priority 0 if it is currently the primary. + if (rst.getPrimary() === rst.nodes[0]) { + jsTestLog("Stepping down node 0 before reconfig"); + assert.throws(function() { + rst.nodes[0].adminCommand({replSetStepDown: 5, force: true}); + }); + rst.waitForState(rst.nodes[0], ReplSetTest.State.SECONDARY); + } jsTestLog("Reconfiguring cluster to make node 0 unelectable so it stays SECONDARY on restart"); conf = rst.getReplSetConfigFromNode(); -- cgit v1.2.1