summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/retry_network_error_test.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/retry_network_error_test.js')
-rw-r--r--jstests/noPassthrough/retry_network_error_test.js67
1 files changed, 33 insertions, 34 deletions
diff --git a/jstests/noPassthrough/retry_network_error_test.js b/jstests/noPassthrough/retry_network_error_test.js
index df8da41a5d4..e8fe4a78047 100644
--- a/jstests/noPassthrough/retry_network_error_test.js
+++ b/jstests/noPassthrough/retry_network_error_test.js
@@ -4,44 +4,43 @@
*/
(function() {
- "use strict";
- let node = MongoRunner.runMongod();
- let hostname = node.host;
+"use strict";
+let node = MongoRunner.runMongod();
+let hostname = node.host;
- jsTestLog("Test connecting to a healthy node.");
- let numRetries = 5;
- let sleepMs = 50;
- let attempts = 0;
+jsTestLog("Test connecting to a healthy node.");
+let numRetries = 5;
+let sleepMs = 50;
+let attempts = 0;
+retryOnNetworkError(function() {
+ attempts++;
+ new Mongo(hostname);
+}, numRetries, sleepMs);
+assert.eq(attempts, 1);
+
+jsTestLog("Test connecting to a node that is down.");
+MongoRunner.stopMongod(node);
+attempts = 0;
+try {
retryOnNetworkError(function() {
attempts++;
new Mongo(hostname);
}, numRetries, sleepMs);
- assert.eq(attempts, 1);
-
- jsTestLog("Test connecting to a node that is down.");
- MongoRunner.stopMongod(node);
- attempts = 0;
- try {
- retryOnNetworkError(function() {
- attempts++;
- new Mongo(hostname);
- }, numRetries, sleepMs);
- } catch (e) {
- jsTestLog("Caught exception after exhausting retries: " + e);
- }
- assert.eq(attempts, numRetries + 1);
-
- jsTestLog("Test connecting to a node with an invalid hostname.");
- let invalidHostname = "very-invalid-host-name";
- attempts = 0;
- try {
- retryOnNetworkError(function() {
- attempts++;
- new Mongo(invalidHostname);
- }, numRetries, sleepMs);
- } catch (e) {
- jsTestLog("Caught exception after exhausting retries: " + e);
- }
- assert.eq(attempts, numRetries + 1);
+} catch (e) {
+ jsTestLog("Caught exception after exhausting retries: " + e);
+}
+assert.eq(attempts, numRetries + 1);
+jsTestLog("Test connecting to a node with an invalid hostname.");
+let invalidHostname = "very-invalid-host-name";
+attempts = 0;
+try {
+ retryOnNetworkError(function() {
+ attempts++;
+ new Mongo(invalidHostname);
+ }, numRetries, sleepMs);
+} catch (e) {
+ jsTestLog("Caught exception after exhausting retries: " + e);
+}
+assert.eq(attempts, numRetries + 1);
}()); \ No newline at end of file