Skip to content

Commit

Permalink
Merge pull request FRRouting#16815 from opensourcerouting/fix/adjust_…
Browse files Browse the repository at this point in the history
…wait_count_default_timers_if_too_low

tests: Adjust minimum wait/count timers for run_and_expect() if they are too low
  • Loading branch information
donaldsharp authored Sep 13, 2024
2 parents 53a0724 + 7cc6c93 commit 5074633
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions tests/topotests/lib/topotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ def run_and_expect(func, what, count=20, wait=3):
waiting `wait` seconds between tries. By default it tries 20 times with
3 seconds delay between tries.
Changing default count/wait values, please change them below also for
`minimum_wait`, and `minimum_count`.
Returns (True, func-return) on success or
(False, func-return) on failure.
Expand All @@ -414,13 +417,18 @@ def run_and_expect(func, what, count=20, wait=3):

# Just a safety-check to avoid running topotests with very
# small wait/count arguments.
# If too low count/wait values are defined, override them
# with the minimum values.
minimum_count = 20
minimum_wait = 3
minimum_wait_time = 15 # The overall minimum seconds for the test to wait
wait_time = wait * count
if wait_time < 5:
assert (
wait_time >= 5
), "Waiting time is too small (count={}, wait={}), adjust timer values".format(
count, wait
if wait_time < minimum_wait_time:
logger.warn(
f"Waiting time is too small (count={count}, wait={wait}), using default values (count={minimum_count}, wait={minimum_wait})"
)
count = minimum_count
wait = minimum_wait

logger.debug(
"'{}' polling started (interval {} secs, maximum {} tries)".format(
Expand Down

0 comments on commit 5074633

Please sign in to comment.