Skip to content

Commit

Permalink
Timeout all unit tests at 60 seconds(if not running on windows)
Browse files Browse the repository at this point in the history
We have some random test hangs and this will prevent that by forcing the
tests to fail in such cases.
Windows does not take part of this because it does not support
`signal.SIGABRT`, we would have to use threads.

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch committed Jan 19, 2024
1 parent 4fbb0f9 commit 914d436
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,22 @@ def pytest_collection_modifyitems(config, items):
from_filenames_collection_modifyitems(config, items)

log.warning("Mofifying collected tests to keep track of fixture usage")

timeout_marker_tests_paths = (
str(TESTS_DIR / "unit"),
str(PYTESTS_DIR / "unit"),
)
for item in items:
if (
not salt.utils.platform.is_windows()
and str(pathlib.Path(item.fspath).resolve()).startswith(
timeout_marker_tests_paths
)
and not item.get_closest_marker("timeout")
):
# Let's apply the timeout marker on the test, if the marker
# is not already applied
item.add_marker(pytest.mark.timeout(60))
for fixture in item.fixturenames:
if fixture not in item._fixtureinfo.name2fixturedefs:
continue
Expand Down

0 comments on commit 914d436

Please sign in to comment.