diff options
author | Mindaugas Malinauskas <mindaugas.malinauskas@mongodb.com> | 2022-01-05 12:29:02 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-01-05 12:54:01 +0000 |
commit | 7113c62a1ad13a752571ae5842b6826ab504fead (patch) | |
tree | 5b8db7d5284bada86a4c1040f92ccf6073fb1466 | |
parent | b6d30f82753814220e360b82d0b5d87e834b279c (diff) | |
download | mongo-7113c62a1ad13a752571ae5842b6826ab504fead.tar.gz |
SERVER-62153 Made max_time_ms_repl_targeting.js to succeed if the timed test step succeeds at least once
-rw-r--r-- | jstests/noPassthrough/max_time_ms_repl_targeting.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/jstests/noPassthrough/max_time_ms_repl_targeting.js b/jstests/noPassthrough/max_time_ms_repl_targeting.js index df07f12e226..acb3ea6be1d 100644 --- a/jstests/noPassthrough/max_time_ms_repl_targeting.js +++ b/jstests/noPassthrough/max_time_ms_repl_targeting.js @@ -15,12 +15,13 @@ assert.commandWorked(mongos.adminCommand({enableSharding: kDbName})); // Since this test is timing sensitive, retry on failures since they could be transient. // If broken, this would *always* fail so if it ever passes this build is fine (or time went // backwards). -const tryFiveTimes = function(name, f) { +const retryOnFailureUpToFiveTimes = function(name, f) { jsTestLog(`Starting test ${name}`); - for (var trial = 1; trial <= 5; trial++) { + for (let trial = 1; trial <= 5; trial++) { try { f(); + break; } catch (e) { if (trial < 5) { jsTestLog(`Ignoring error during trial ${trial} of test ${name}`); @@ -60,13 +61,13 @@ const runTest = function() { }; testColl.insert({_id: 1}, {writeConcern: {w: 2}}); -tryFiveTimes("totally unsharded", runTest); +retryOnFailureUpToFiveTimes("totally unsharded", runTest); assert.commandWorked(mongos.adminCommand({enableSharding: kDbName})); -tryFiveTimes("sharded db", runTest); +retryOnFailureUpToFiveTimes("sharded db", runTest); assert.commandWorked(mongos.adminCommand({shardCollection: ns, key: {_id: 1}})); -tryFiveTimes("sharded collection", runTest); +retryOnFailureUpToFiveTimes("sharded collection", runTest); st.stop(); })(); |