summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Mulrow <jack.mulrow@mongodb.com>2016-12-19 13:57:09 -0500
committerJudah Schvimer <judah@mongodb.com>2016-12-28 15:26:48 -0500
commit6673eaeacc7fb115b1174226377a1b6a484e1fc5 (patch)
treea93b3c0b9311a3da2975ef668d3dd13d765eed53
parent56ea371a1ebb6062cfee204e22103242bd7ec8dc (diff)
downloadmongo-6673eaeacc7fb115b1174226377a1b6a484e1fc5.tar.gz
SERVER-27461 Retry connecting to shut down primary until failure in shutdown_primary.js
(cherry picked from commit 51995ca347ff3f201b1f316dfbc13940c7b2ea93)
-rw-r--r--jstests/replsets/shutdown_primary.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/jstests/replsets/shutdown_primary.js b/jstests/replsets/shutdown_primary.js
index 0192bc41b49..2299900e21c 100644
--- a/jstests/replsets/shutdown_primary.js
+++ b/jstests/replsets/shutdown_primary.js
@@ -51,12 +51,18 @@
restartReplSetReplication(replTest);
jsTestLog("Verifying primary shut down and cannot be connected to.");
- // Successful shutdown throws network error.
+ // Successfully starting shutdown throws a network error.
var exitCode = awaitShell({checkExitSuccess: false});
assert.neq(0, exitCode, "expected shutdown to close the shell's connection");
- assert.throws(function() {
- new Mongo(primary.host);
- });
+ assert.soonNoExcept(function() {
+ // The parallel shell exits while shutdown is in progress, and if this happens early enough,
+ // the primary can still accept connections despite successfully starting to shutdown.
+ // So, retry connecting until connections cannot be established and an error is thrown.
+ assert.throws(function() {
+ new Mongo(primary.host);
+ });
+ return true;
+ }, "expected primary node to shut down and not be connectable");
replTest.stopSet();
})();