зеркало из https://github.com/microsoft/lisa.git
testsuite: remove retry from test case level.
This commit is contained in:
Родитель
209395fa2d
Коммит
74a24928e6
|
@ -13,7 +13,6 @@ from typing import Any, Callable, Dict, List, Optional, Type, Union
|
||||||
|
|
||||||
from func_timeout import FunctionTimedOut, func_timeout # type: ignore
|
from func_timeout import FunctionTimedOut, func_timeout # type: ignore
|
||||||
from retry import retry
|
from retry import retry
|
||||||
from retry.api import retry_call
|
|
||||||
|
|
||||||
from lisa import notifier, schema, search_space
|
from lisa import notifier, schema, search_space
|
||||||
from lisa.environment import Environment, EnvironmentSpace, EnvironmentStatus
|
from lisa.environment import Environment, EnvironmentSpace, EnvironmentStatus
|
||||||
|
@ -48,11 +47,9 @@ _all_suites: Dict[str, TestSuiteMetadata] = {}
|
||||||
_all_cases: Dict[str, TestCaseMetadata] = {}
|
_all_cases: Dict[str, TestCaseMetadata] = {}
|
||||||
|
|
||||||
|
|
||||||
def _call_with_retry_and_timeout(
|
def _call_with_timeout(
|
||||||
method: Callable[..., Any],
|
method: Callable[..., Any],
|
||||||
retries: int,
|
|
||||||
timeout: int,
|
timeout: int,
|
||||||
log: Logger,
|
|
||||||
test_kwargs: Dict[str, Any],
|
test_kwargs: Dict[str, Any],
|
||||||
) -> None:
|
) -> None:
|
||||||
try:
|
try:
|
||||||
|
@ -61,25 +58,13 @@ def _call_with_retry_and_timeout(
|
||||||
# will raise exception, if the timeout value is greater than 7 days. So
|
# will raise exception, if the timeout value is greater than 7 days. So
|
||||||
# not to call it, if timeout is not a positive value.
|
# not to call it, if timeout is not a positive value.
|
||||||
if timeout > 0:
|
if timeout > 0:
|
||||||
retry_call(
|
func_timeout(
|
||||||
func_timeout,
|
timeout=timeout,
|
||||||
fkwargs={
|
func=method,
|
||||||
"timeout": timeout,
|
kwargs=test_kwargs,
|
||||||
"func": method,
|
|
||||||
"kwargs": test_kwargs,
|
|
||||||
},
|
|
||||||
exceptions=Exception,
|
|
||||||
tries=retries + 1,
|
|
||||||
logger=log,
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
retry_call(
|
method(**test_kwargs)
|
||||||
f=method,
|
|
||||||
fkwargs=test_kwargs,
|
|
||||||
exceptions=Exception,
|
|
||||||
tries=retries + 1,
|
|
||||||
logger=log,
|
|
||||||
)
|
|
||||||
except FunctionTimedOut:
|
except FunctionTimedOut:
|
||||||
# FunctionTimedOut is a special exception. If it's not captured
|
# FunctionTimedOut is a special exception. If it's not captured
|
||||||
# explicitly, it will make the whole program exit.
|
# explicitly, it will make the whole program exit.
|
||||||
|
@ -748,11 +733,9 @@ class TestSuite:
|
||||||
|
|
||||||
timer = create_timer()
|
timer = create_timer()
|
||||||
try:
|
try:
|
||||||
_call_with_retry_and_timeout(
|
_call_with_timeout(
|
||||||
self.before_case,
|
self.before_case,
|
||||||
retries=case_result.runtime_data.retry,
|
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
log=log,
|
|
||||||
test_kwargs=test_kwargs,
|
test_kwargs=test_kwargs,
|
||||||
)
|
)
|
||||||
except Exception as identifier:
|
except Exception as identifier:
|
||||||
|
@ -771,11 +754,9 @@ class TestSuite:
|
||||||
) -> None:
|
) -> None:
|
||||||
timer = create_timer()
|
timer = create_timer()
|
||||||
try:
|
try:
|
||||||
_call_with_retry_and_timeout(
|
_call_with_timeout(
|
||||||
self.after_case,
|
self.after_case,
|
||||||
retries=case_result.runtime_data.retry,
|
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
log=log,
|
|
||||||
test_kwargs=test_kwargs,
|
test_kwargs=test_kwargs,
|
||||||
)
|
)
|
||||||
except Exception as identifier:
|
except Exception as identifier:
|
||||||
|
@ -795,11 +776,9 @@ class TestSuite:
|
||||||
test_method = getattr(self, case_name)
|
test_method = getattr(self, case_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_call_with_retry_and_timeout(
|
_call_with_timeout(
|
||||||
test_method,
|
test_method,
|
||||||
retries=case_result.runtime_data.retry,
|
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
log=log,
|
|
||||||
test_kwargs=test_kwargs,
|
test_kwargs=test_kwargs,
|
||||||
)
|
)
|
||||||
case_result.set_status(TestStatus.PASSED, "")
|
case_result.set_status(TestStatus.PASSED, "")
|
||||||
|
|
Загрузка…
Ссылка в новой задаче