diff options
author | Benety Goh <benety@mongodb.com> | 2016-01-12 15:07:52 -0500 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2016-01-29 13:38:31 -0500 |
commit | d04d195125a020c2eb75a884daa1cb190db08fb7 (patch) | |
tree | ea4335f6941d3e6bc4ada81056e45d70b9902ada | |
parent | f6fea15f85d78ac71cb8953267341e1500ea2edc (diff) | |
download | mongo-d04d195125a020c2eb75a884daa1cb190db08fb7.tar.gz |
SERVER-22152 wait for high priority node to become primary at beginning of test
(cherry picked from commit 23323e6f1a9074ade844fe364feb121d7b4d8a32)
-rw-r--r-- | jstests/replsets/priority_takeover_two_nodes_equal_priority.js | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/jstests/replsets/priority_takeover_two_nodes_equal_priority.js b/jstests/replsets/priority_takeover_two_nodes_equal_priority.js index 44e177a25f8..aee50eb3d8b 100644 --- a/jstests/replsets/priority_takeover_two_nodes_equal_priority.js +++ b/jstests/replsets/priority_takeover_two_nodes_equal_priority.js @@ -1,8 +1,7 @@ // 2 nodes with non-default priority. // 3-node replica set with priorities 3, 3 and 1 (default) // Start replica set. Ensure that highest priority node becomes primary eventually. -// Shut down the primary and confirm that the next highest priority node becomes primary. -// Repeat until 2 nodes are left standing. +// Step down the primary and confirm that the next highest priority node becomes primary. load('jstests/replsets/rslib.js'); (function () { @@ -17,19 +16,31 @@ var replSet = new ReplSetTest({name: name, nodes: [ replSet.startSet(); replSet.initiate(); -var primary = replSet.getPrimary(); +var primary; var primaryIndex = -1; -replSet.nodes.find(function(node, index, array) { - if (primary.host == node.host) { - primaryIndex = index; - return true; - } - return false; -}); -assert.neq(-1, primaryIndex, - 'expected one of the nodes with priority 3 to become primary'); +var defaultPriorityNodeIndex = 2; +assert.soon( + function() { + primary = replSet.getPrimary(); + replSet.nodes.find(function(node, index, array) { + if (primary.host == node.host) { + primaryIndex = index; + return true; + } + return false; + }); + return primaryIndex !== defaultPriorityNodeIndex; + }, + 'neither of the priority 3 nodes was elected primary', + 60000, // timeout + 1000 // interval +); -replSet.stop(primaryIndex); +try { + assert.commandWorked(primary.getDB('admin').runCommand({replSetStepDown: 30})); +} catch (x) { + // expected +} var newPrimaryIndex = primaryIndex === 0 ? 1 : 0; // Refresh connections to nodes. |