summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2016-09-16 13:59:32 -0400
committerRandolph Tan <randolph@10gen.com>2016-09-16 17:28:04 -0400
commit84f4c2dd3e9098b2fed8281d40c89f251b51db2a (patch)
tree12cfefc13f8e1bc9bc7d185d21bd8c42de97ae36
parentf4600bb330c1ed7975fe4ec7562dbda40efb2d8f (diff)
downloadmongo-84f4c2dd3e9098b2fed8281d40c89f251b51db2a.tar.gz
SERVER-26132 Ensure that the desired primary gets elected in config_version_rollback.js
-rw-r--r--jstests/sharding/config_version_rollback.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/jstests/sharding/config_version_rollback.js b/jstests/sharding/config_version_rollback.js
index cba395d86f7..cafb2b8195a 100644
--- a/jstests/sharding/config_version_rollback.js
+++ b/jstests/sharding/config_version_rollback.js
@@ -64,9 +64,26 @@
});
jsTest.log("Forcing original primary to step back up and become primary again.");
+
+ // Do prep work to make original primary transtion to primary again smoother by
+ // waiting for all nodes to catch up to make them eligible to become primary and
+ // step down the current primary to make it stop generating new oplog entries.
+ configRS.awaitReplication(60 * 1000);
+
+ try {
+ newPriConn.adminCommand({replSetStepDown: 60, force: true});
+ } catch (x) {
+ // replSetStepDown closes all connections, thus a network exception is expected here.
+ }
+
// Ensure former primary is eligible to become primary once more.
assert.commandWorked(origPriConn.adminCommand({replSetFreeze: 0}));
- assert.commandWorked(origPriConn.adminCommand({replSetStepUp: 1}));
+
+ // Keep on trying until this node becomes the primary. One reason it can fail is when the other
+ // nodes have newer oplog entries and will thus refuse to vote for this node.
+ assert.soon(function() {
+ return (origPriConn.adminCommand({replSetStepUp: 1})).ok;
+ });
assert.soon(function() {
return origPriConn == configRS.getPrimary();