diff options
author | Suganthi Mani <suganthi.mani@mongodb.com> | 2020-07-31 13:16:54 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-29 21:44:14 +0000 |
commit | e9d91a9e26701f4940fcc9329dbb505812e5520f (patch) | |
tree | b088d1d593bb28991b98eeeccc0cb8989f0e1a17 | |
parent | 9b56acc6c6c0ccf9bf882a0786c037e04bac753f (diff) | |
download | mongo-e9d91a9e26701f4940fcc9329dbb505812e5520f.tar.gz |
SERVER-50049 assert.soonNoExcept() should not access TestData.traceExceptions for non-resmoke tests.
(cherry picked from commit d57c783b60d548c3173058d70343537b6df6c1e9)
-rw-r--r-- | src/mongo/shell/assert.js | 33 | ||||
-rw-r--r-- | src/mongo/shell/replsettest.js | 2 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js index 3a36cecf006..c89c2a0c294 100644 --- a/src/mongo/shell/assert.js +++ b/src/mongo/shell/assert.js @@ -352,19 +352,28 @@ assert = (function() { assert.soonNoExcept = function(func, msg, timeout, interval) { var safeFunc = _convertExceptionToReturnStatus(func, "assert.soonNoExcept caught exception"); - var safeFuncwithMinimizedNoise = () => { - // Turns off printing the JavaScript stacktrace in doassert() to avoid generating an - // overwhelming amount of log messages when handling transient errors. - const origTraceExceptions = TestData.traceExceptions; - TestData.traceExceptions = false; - - const res = safeFunc(); - - // Restore it's value to original value. - TestData.traceExceptions = origTraceExceptions; - return res; + var getFunc = () => { + // No TestData means not running from resmoke. Non-resmoke tests usually don't trace + // exceptions. + if (typeof TestData === "undefined") { + return safeFunc; + } + return () => { + // Turns off printing the JavaScript stacktrace in doassert() to avoid + // generating an overwhelming amount of log messages when handling transient + // errors. + const origTraceExceptions = TestData.traceExceptions; + TestData.traceExceptions = false; + + const res = safeFunc(); + + // Restore it's value to original value. + TestData.traceExceptions = origTraceExceptions; + return res; + }; }; - assert.soon(safeFuncwithMinimizedNoise, msg, timeout, interval); + + assert.soon(getFunc(), msg, timeout, interval); }; /* diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index 930ab24bd72..d39f6d69129 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -1253,7 +1253,7 @@ var ReplSetTest = function(opts) { // awaitNodesAgreeOnPrimary() timeout as 1 minute to allow retry of replSetStepUp // command on failure of the replica set to agree on the primary. const timeout = 60 * 100; - this.awaitNodesAgreeOnPrimary(timeout, this.nodes, node); + this.awaitNodesAgreeOnPrimary(timeout, this.nodes, this.getNodeId(node)); // getPrimary() guarantees that there will be only one writable primary for a replica // set. |