summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/topotest.py
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-09-13 10:23:51 +0300
committerDonatas Abraitis <donatas@opensourcerouting.org>2024-09-13 10:23:51 +0300
commit7cc6c9325ebe5904de67184b1858a60b6d038d86 (patch)
tree98d822552b86e238ff682fc83af821e9639ae912 /tests/topotests/lib/topotest.py
parentafe37c8698d0e6a6e992658ab9bd91d593058880 (diff)
tests: Adjust minimum wait/count timers for run_and_expect() if they are too low
If the developer pass way too low timers, we end up with most likely false-positive situations for random tests under a high load of the system. It would be better to fallback to the minimum default values for such a cases. E.g.: ``` WARNING: topo: Waiting time is too small (count=1, wait=0.5), using default values (count=20, wait=3) ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'tests/topotests/lib/topotest.py')
-rw-r--r--tests/topotests/lib/topotest.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py
index 5a8c2e5964..dc6107bbef 100644
--- a/tests/topotests/lib/topotest.py
+++ b/tests/topotests/lib/topotest.py
@@ -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.
@@ -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(