Skip to content

Commit

Permalink
Add small time buffer to loaded TestCase duration
Browse files Browse the repository at this point in the history
  • Loading branch information
tysmith committed Dec 12, 2023
1 parent 553882f commit 144b2ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions grizzly/common/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def test_configure_logging_01(mocker, env, log_level):
# use defaults instead of low test values
(None, None, [1], (DEFAULT_TIME_LIMIT, DEFAULT_TIME_LIMIT + TIMEOUT_DELAY)),
# use duration from test case
(None, None, [99.1], (100, 100 + TIMEOUT_DELAY)),
(None, None, [90.1], (100, 100 + TIMEOUT_DELAY)),
# multiple tests
(None, None, [99.9, 10, 25], (100, 100 + TIMEOUT_DELAY)),
(None, None, [90.9, 10, 25], (100, 100 + TIMEOUT_DELAY)),
# specify time limit
(100, None, [0], (100, 100 + TIMEOUT_DELAY)),
# specify timeout (> DEFAULT_TIME_LIMIT)
Expand Down
8 changes: 4 additions & 4 deletions grizzly/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from importlib.metadata import PackageNotFoundError, version
from ipaddress import IPv4Address
from logging import DEBUG, basicConfig, getLogger
from math import ceil
from os import getenv, getpid
from pathlib import Path
from shutil import rmtree
Expand Down Expand Up @@ -243,8 +242,8 @@ def time_limits(
time_limit (int): Test time limit.
timeout (int): Iteration timeout.
tests (iterable): Testcases that may contain time limit values.
default_limit (int): Value to used as default time limit.
timeout_delay (int): Value to used as delay when calculating timeout.
default_limit (int): Value to use as default time limit.
timeout_delay (int): Value to use as delay when calculating timeout.
Returns:
tuple (int, int): Time limit and timeout.
Expand All @@ -257,7 +256,8 @@ def time_limits(
# use default_limit as a minimum
test_limits = [default_limit]
if tests:
test_limits.extend(int(ceil(x.duration)) for x in tests if x.duration)
# add small time buffer to duration
test_limits.extend(int(x.duration) + 10 for x in tests if x.duration)
time_limit = max(test_limits)
assert time_limit > 0
# calculate timeout
Expand Down

0 comments on commit 144b2ea

Please sign in to comment.