summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamon Fernandez <ramon@mongodb.com>2017-04-20 17:43:42 -0400
committerRamon Fernandez <ramon@mongodb.com>2017-04-20 17:43:42 -0400
commit888390515874a9debd1b6c5d36559ca86b44babd (patch)
tree6fab6144fa714d19be7ebe98c83da88825f4064e
parent94a762ba470c21db4db14afb692c1b7dc5f4c69b (diff)
downloadmongo-888390515874a9debd1b6c5d36559ca86b44babd.tar.gz
Revert "SERVER-28480/27966 last_vote.js should await replication and call stepUp before reconfig"r3.4.4
This reverts commit 7a6d8274f57cf141fd1d5c754ea1e2a1a6d2f372.
-rw-r--r--jstests/replsets/last_vote.js36
1 files 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();