From 144b2ead72df8f02181dda3fdfa128d7104f1b79 Mon Sep 17 00:00:00 2001 From: Tyson Smith Date: Mon, 11 Dec 2023 14:46:13 -0800 Subject: [PATCH] Add small time buffer to loaded TestCase duration --- grizzly/common/test_utils.py | 4 ++-- grizzly/common/utils.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grizzly/common/test_utils.py b/grizzly/common/test_utils.py index 112542e7..8b8011cd 100644 --- a/grizzly/common/test_utils.py +++ b/grizzly/common/test_utils.py @@ -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) diff --git a/grizzly/common/utils.py b/grizzly/common/utils.py index 042a9a60..dd4f1049 100644 --- a/grizzly/common/utils.py +++ b/grizzly/common/utils.py @@ -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 @@ -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. @@ -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