diff options
Diffstat (limited to 'jstests/replsets/priority_takeover_two_nodes_equal_priority.js')
-rw-r--r-- | jstests/replsets/priority_takeover_two_nodes_equal_priority.js | 79 |
1 files changed, 37 insertions, 42 deletions
diff --git a/jstests/replsets/priority_takeover_two_nodes_equal_priority.js b/jstests/replsets/priority_takeover_two_nodes_equal_priority.js index 1cffd1ecef5..717e9b945e7 100644 --- a/jstests/replsets/priority_takeover_two_nodes_equal_priority.js +++ b/jstests/replsets/priority_takeover_two_nodes_equal_priority.js @@ -4,56 +4,51 @@ // Step down the primary and confirm that the next highest priority node becomes primary. load('jstests/replsets/rslib.js'); -(function () { -'use strict'; +(function() { + 'use strict'; -var name = 'priority_takeover_two_nodes_equal_priority'; -var replSet = new ReplSetTest({name: name, nodes: [ - {rsConfig: {priority: 3}}, - {rsConfig: {priority: 3}}, - {}, -]}); -replSet.startSet(); -replSet.initiate(); + var name = 'priority_takeover_two_nodes_equal_priority'; + var replSet = new ReplSetTest( + {name: name, nodes: [{rsConfig: {priority: 3}}, {rsConfig: {priority: 3}}, {}, ]}); + replSet.startSet(); + replSet.initiate(); -var primary; -var primaryIndex = -1; -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 -); + var primary; + var primaryIndex = -1; + 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 + ); -try { - assert.commandWorked(primary.getDB('admin').runCommand({replSetStepDown: 90})); -} catch (x) { - // expected -} -var newPrimaryIndex = primaryIndex === 0 ? 1 : 0; + try { + assert.commandWorked(primary.getDB('admin').runCommand({replSetStepDown: 90})); + } catch (x) { + // expected + } + var newPrimaryIndex = primaryIndex === 0 ? 1 : 0; -// Refresh connections to nodes. -replSet.status(); + // Refresh connections to nodes. + replSet.status(); -assert.commandWorked( - replSet.nodes[newPrimaryIndex].adminCommand({ + assert.commandWorked(replSet.nodes[newPrimaryIndex].adminCommand({ replSetTest: 1, waitForMemberState: ReplSetTest.State.PRIMARY, timeoutMillis: 60 * 1000, }), - 'node ' + newPrimaryIndex + ' ' + replSet.nodes[newPrimaryIndex].host + - ' failed to become primary' -); + 'node ' + newPrimaryIndex + ' ' + replSet.nodes[newPrimaryIndex].host + + ' failed to become primary'); })(); |