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-02-09 11:08:38 +0000 |
commit | 8a95c0b3ab79331b56e0c0fe713ead3d4ce5fee8 (patch) | |
tree | 79ffd9f93203fa8804a4e49a71883e71e0a74c42 | |
parent | 41dc49bc023ab53cfcf2b013803146e73f97e4ab (diff) | |
download | mongo-8a95c0b3ab79331b56e0c0fe713ead3d4ce5fee8.tar.gz |
SERVER-62153 Made max_time_ms_repl_targeting.js to succeed if the timed test step succeeds at least once
(cherry picked from commit 7113c62a1ad13a752571ae5842b6826ab504fead)
-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(); })(); |