From e9e98d997d196e4e95adca5b8f03ddc9504ad9cc Mon Sep 17 00:00:00 2001 From: Guilherme Gallo Date: Fri, 9 May 2025 13:51:41 -0300 Subject: [PATCH] ci/lava: Parametrize message burst length on unit tests We can have jobs with a lower job timeout values, given by CI_JOB_TIMEOUT environment variable, such as the pytest ones. The previously hardcoded burst length of 1000 messages at a simulated rate of 1 msg/sec caused tests to exceed these timeouts and fail unexpectedly on specific job timeouts. Reported-by: Eric Engestrom Signed-off-by: Guilherme Gallo Part-of: --- .gitlab-ci/lava/utils/__init__.py | 4 ++++ .gitlab-ci/tests/test_lava_job_submitter.py | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci/lava/utils/__init__.py b/.gitlab-ci/lava/utils/__init__.py index e2388bb6808..f4d4f997145 100644 --- a/.gitlab-ci/lava/utils/__init__.py +++ b/.gitlab-ci/lava/utils/__init__.py @@ -15,4 +15,8 @@ from .log_section import ( FALLBACK_GITLAB_SECTION_TIMEOUT, LogSection, LogSectionType, + CI_JOB_TIMEOUT_MIN, + LAVA_TEST_OVERHEAD_MIN, + LAVA_TEST_CASE_TIMEOUT, + LAVA_TEST_SUITE_TIMEOUT, ) diff --git a/.gitlab-ci/tests/test_lava_job_submitter.py b/.gitlab-ci/tests/test_lava_job_submitter.py index f4846b3b073..4df2c8014f3 100644 --- a/.gitlab-ci/tests/test_lava_job_submitter.py +++ b/.gitlab-ci/tests/test_lava_job_submitter.py @@ -26,7 +26,7 @@ from lava.lava_job_submitter import ( retriable_follow_job, wait_for_job_get_started, ) -from lava.utils import LogSectionType +from lava.utils import LogSectionType, LAVA_TEST_CASE_TIMEOUT from .lava.helpers import ( generate_n_logs, @@ -40,6 +40,10 @@ from .lava.helpers import ( NUMBER_OF_MAX_ATTEMPTS = NUMBER_OF_RETRIES_TIMEOUT_DETECTION + 1 +def max_sec_before_timeout(): + return min(1000, LAVA_TEST_CASE_TIMEOUT * 60 - 1) + + @pytest.fixture def mock_proxy_waiting_time(mock_proxy): def update_mock_proxy(frozen_time, **kwargs): @@ -104,7 +108,7 @@ PROXY_SCENARIOS = { LogSectionType.TEST_CASE: [ section_timeout(LogSectionType.TEST_CASE) + 1 ] - * 1000 + * max_sec_before_timeout() }, result="fail", exit_code=1, @@ -166,7 +170,7 @@ PROXY_SCENARIOS = { ), "long log case, no silence": ( mock_logs( - messages={LogSectionType.TEST_CASE: [1] * (1000)}, + messages={LogSectionType.TEST_CASE: [1] * (max_sec_before_timeout())}, result="pass", exit_code=0, ),