diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-06-21 13:49:29 -0400 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-06-21 13:49:29 -0400 |
commit | 56bbe6c5ef73b626b0bf3ed85dd128f03702a62c (patch) | |
tree | a6df11ca96ad26a8693ac2a0c771eb6f84105321 /src/mongo/shell | |
parent | 55f4ab7dc9ae6ec27ce9f9687be9c78a21d4f59d (diff) | |
download | mongo-56bbe6c5ef73b626b0bf3ed85dd128f03702a62c.tar.gz |
SERVER-24201 jsTest.authenticateNodes doesn't handle temp network errors
Diffstat (limited to 'src/mongo/shell')
-rw-r--r-- | src/mongo/shell/assert.js | 20 | ||||
-rw-r--r-- | src/mongo/shell/utils.js | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js index 81e52d4ef2f..b1f2a94a735 100644 --- a/src/mongo/shell/assert.js +++ b/src/mongo/shell/assert.js @@ -202,6 +202,26 @@ assert.soon = function(f, msg, timeout /*ms*/, interval) { } }; +/** + * Wraps assert.soon to try...catch any function passed in. + */ +assert.soonNoExcept = function(func, msg, timeout /*ms*/) { + /** + * Surrounds a function call by a try...catch to convert any exception to a print statement + * and return false. + */ + function _convertExceptionToReturnStatus(func) { + try { + return func(); + } catch (e) { + print("caught exception " + e); + return false; + } + } + + assert.soon((() => _convertExceptionToReturnStatus(func)), msg, timeout); +}; + assert.time = function(f, msg, timeout /*ms*/) { if (assert._debug && msg) print("in assert for: " + msg); diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js index b296cb9a048..43925df86a4 100644 --- a/src/mongo/shell/utils.js +++ b/src/mongo/shell/utils.js @@ -280,7 +280,7 @@ jsTest.authenticate = function(conn) { }; jsTest.authenticateNodes = function(nodes) { - assert.soon(function() { + assert.soonNoExcept(function() { for (var i = 0; i < nodes.length; i++) { // Don't try to authenticate to arbiters res = nodes[i].getDB("admin").runCommand({replSetGetStatus: 1}); |