diff options
author | Judah Schvimer <judah@mongodb.com> | 2017-01-18 16:13:17 -0500 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2017-01-23 10:51:31 -0500 |
commit | 76af3d246d482d62520b386e5c1f0b777c367fc6 (patch) | |
tree | 8445cba1579ab7c95f8103ec2b1199a37dd3575c | |
parent | f7c338674e5877db373837e957e7109417617988 (diff) | |
download | mongo-76af3d246d482d62520b386e5c1f0b777c367fc6.tar.gz |
SERVER-27657 wait for nodes to agree on config version after reconfig in last_vote.js
(cherry picked from commit 6daec9687bb98fd4d2e6f4627afd9ad85a11d66b)
-rw-r--r-- | jstests/replsets/last_vote.js | 1 | ||||
-rw-r--r-- | src/mongo/shell/replsettest.js | 24 |
2 files changed, 24 insertions, 1 deletions
diff --git a/jstests/replsets/last_vote.js b/jstests/replsets/last_vote.js index 5aa6da56d20..bf1079884f8 100644 --- a/jstests/replsets/last_vote.js +++ b/jstests/replsets/last_vote.js @@ -90,6 +90,7 @@ conf.version++; conf.members[0].priority = 0; reconfig(rst, conf); + rst.awaitNodesAgreeOnConfigVersion(); jsTestLog("Restarting node 0 as a standalone"); var node0 = rst.restart(0, {noReplSet: true}); // Restart as a standalone node. diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index fb0807909fb..0cd9a181889 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -626,6 +626,28 @@ var ReplSetTest = function(opts) { }; /** + * Blocks until all nodes in the replica set have the same config version as the primary. + **/ + this.awaitNodesAgreeOnConfigVersion = function(timeout) { + timeout = timeout || this.kDefaultTimeoutMS; + + assert.soonNoExcept(function() { + var primaryVersion = self.getPrimary().adminCommand({ismaster: 1}).setVersion; + + for (var i = 0; i < self.nodes.length; i++) { + var version = self.nodes[i].adminCommand({ismaster: 1}).setVersion; + assert.eq(version, + primaryVersion, + "waiting for secondary node " + self.nodes[i].host + + " with config version of " + version + + " to match the version of the primary " + primaryVersion); + } + + return true; + }, "Awaiting nodes to agree on config version", timeout); + }; + + /** * Waits for the last oplog entry on the primary to be visible in the committed snapshop view * of the oplog on *all* secondaries. * Returns last oplog entry. @@ -752,7 +774,7 @@ var ReplSetTest = function(opts) { ", but expected config version #" + configVersion); if (slaveConfigVersion > configVersion) { - master = this.getPrimary(); + master = self.getPrimary(); configVersion = master.getDB("local")['system.replset'].findOne().version; masterOpTime = _getLastOpTime(master); |