summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2015-12-21 08:42:09 -0500
committerBenety Goh <benety@mongodb.com>2016-03-24 14:09:26 -0400
commitbec0b594ddde4d727b7598d46aebcefc4133bac5 (patch)
treeb171753809c60896541deb67ba4e8fefa4ddd534
parent20bafb68ae90b11883258d25a2c380843d01a1d7 (diff)
downloadmongo-bec0b594ddde4d727b7598d46aebcefc4133bac5.tar.gz
SERVER-21975 wait for secondary to become secondary before starting tests in replsets/test_command.js
change waitForMemberState to handle a potential network hangup in test_commands.js Format JS code with approved style. (cherry picked from commit adbe3cd2afe3aeda46c4576027eaa3482216f851) (cherry picked from commit b8b3c3f5962aea2931df2b8807de35d2a9ff87aa)
-rw-r--r--jstests/replsets/test_command.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/jstests/replsets/test_command.js b/jstests/replsets/test_command.js
index 37db262bd81..abaf10bc56d 100644
--- a/jstests/replsets/test_command.js
+++ b/jstests/replsets/test_command.js
@@ -26,6 +26,24 @@
}),
'node 0' + replSet.nodes[0].host + ' failed to become primary');
+ // We need the try/catch to handle that the node may have hung up the connection due
+ // to a state change.
+ try {
+ assert.commandWorked(replSet.nodes[1].adminCommand({
+ replSetTest: 1,
+ waitForMemberState: ReplSetTest.State.SECONDARY,
+ timeoutMillis: 60 * 1000,
+ }));
+ } catch (e) {
+ jsTestLog(e);
+ assert.commandWorked(replSet.nodes[1].adminCommand({
+ replSetTest: 1,
+ waitForMemberState: ReplSetTest.State.SECONDARY,
+ timeoutMillis: 60 * 1000,
+ }),
+ 'node 1' + replSet.nodes[1].host + ' failed to become secondary');
+ }
+
var primary = replSet.getPrimary();
var secondary = replSet.getSecondary();