Skip to content

Commit

Permalink
Fix for flaky straggler test
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Sep 30, 2024
1 parent 87db8ba commit dc1e4c1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cubed/tests/runtime/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def write_int_to_file(path, i):
f.write(str(i))


def deterministic_failure(path, timing_map, i, *, name=None):
def deterministic_failure(path, timing_map, i, *, default_sleep=0.01, name=None):
"""A function that can either run normally, run slowly, or raise
an exception, depending on input and invocation count.
Expand All @@ -27,7 +27,8 @@ def deterministic_failure(path, timing_map, i, *, name=None):
the sign indicates the input is returned normally (positive, or 0),
or an exception is raised (negative).
If a input is missing then all invocations will run normally.
If a input is missing then all invocations will run normally, with a
small default sleep to avoid spurious backups being launched.
If there are subsequent invocations to the ones in the sequence, then
they will all run normally.
Expand All @@ -41,11 +42,11 @@ def deterministic_failure(path, timing_map, i, *, name=None):
invocation_count = 0
write_int_to_file(invocation_count_file, invocation_count + 1)

timing_code = 0
timing_code = default_sleep
if i in timing_map:
timing_codes = timing_map[i]
if invocation_count >= len(timing_codes):
timing_code = 0
timing_code = default_sleep
else:
timing_code = timing_codes[invocation_count]

Expand Down

0 comments on commit dc1e4c1

Please sign in to comment.