diff --git a/lisa/schema.py b/lisa/schema.py index 80109f0aa..43ca077b5 100644 --- a/lisa/schema.py +++ b/lisa/schema.py @@ -1487,6 +1487,9 @@ class TestCase(BaseTestCaseFilter): field_function=fields.Int, validate=validate.Range(min=0) ), ) + # each test case will have this timeout + # if it is 0 it will use default timeout from test case + timeout: int = 0 # each case with this rule will be run in a new environment. use_new_environment: bool = False # Once it's set, failed test result will be rewrite to success diff --git a/lisa/testselector.py b/lisa/testselector.py index 7c68df5d2..bc7bc8e6c 100644 --- a/lisa/testselector.py +++ b/lisa/testselector.py @@ -126,6 +126,13 @@ def _apply_settings( applied_case_data.use_new_environment or case_runbook.use_new_environment ) + # check for positive value just to be clearer + applied_case_data.timeout = ( + max(case_runbook.timeout, applied_case_data.timeout) + if (case_runbook.timeout and case_runbook.timeout > 0) + else applied_case_data.timeout + ) + # use default value from selector applied_case_data.select_action = action diff --git a/lisa/testsuite.py b/lisa/testsuite.py index 07fbe49a3..ffe2dfe25 100644 --- a/lisa/testsuite.py +++ b/lisa/testsuite.py @@ -522,6 +522,7 @@ class TestCaseRuntimeData: self.select_action: str = "" self.times: int = 1 self.retry: int = 0 + self.timeout: int = metadata.timeout self.use_new_environment: bool = metadata.use_new_environment self.ignore_failure: bool = False self.environment_name: str = "" @@ -630,7 +631,19 @@ class TestSuite: constants.RUN_LOCAL_LOG_PATH ).as_posix() case_result.set_status(TestStatus.RUNNING, "") - case_timeout = case_result.runtime_data.metadata.timeout + + # check for positive value just to be clearer + case_timeout = ( + max( + case_result.runtime_data.timeout, + case_result.runtime_data.metadata.timeout, + ) + if ( + case_result.runtime_data.timeout + and case_result.runtime_data.timeout > 0 + ) + else case_result.runtime_data.metadata.timeout + ) if is_continue: is_continue = self.__before_case(