Skip to content

Commit d0abfba

Browse files
authored
Fix for flaky straggler test (#587)
1 parent 87db8ba commit d0abfba

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cubed/tests/runtime/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def write_int_to_file(path, i):
1717
f.write(str(i))
1818

1919

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

44-
timing_code = 0
45+
timing_code = default_sleep
4546
if i in timing_map:
4647
timing_codes = timing_map[i]
4748
if invocation_count >= len(timing_codes):
48-
timing_code = 0
49+
timing_code = default_sleep
4950
else:
5051
timing_code = timing_codes[invocation_count]
5152

0 commit comments

Comments
 (0)