Increase timeouts on problematic tests and default to func_only=True

This commit is contained in:
Pedro Algarvio 2024-02-16 17:02:51 +00:00 committed by Daniel Wozniak
parent 17140c44b8
commit 1ad68fcd93
9 changed files with 16 additions and 11 deletions

View file

@ -460,9 +460,12 @@ def pytest_collection_modifyitems(config, items):
if marker is not None:
if not salt.utils.platform.is_windows():
# Apply the marker since we're not on windows
item.add_marker(
pytest.mark.timeout(*marker.args, **marker.kwargs.copy())
)
marker_kwargs = marker.kwargs.copy()
if "func_only" not in marker_kwargs:
# Default to counting only the test execution for the timeouts, ie,
# withough including the fixtures setup time towards the timeout.
marker_kwargs["func_only"] = True
item.add_marker(pytest.mark.timeout(*marker.args, **marker_kwargs))
else:
if (
not salt.utils.platform.is_windows()
@ -473,7 +476,9 @@ def pytest_collection_modifyitems(config, items):
):
# Let's apply the timeout marker on the test, if the marker
# is not already applied
item.add_marker(pytest.mark.timeout(90))
# Default to counting only the test execution for the timeouts, ie,
# withough including the fixtures setup time towards the timeout.
item.add_marker(pytest.mark.timeout(90, func_only=True))
for fixture in item.fixturenames:
if fixture not in item._fixtureinfo.name2fixturedefs:
continue

View file

@ -56,7 +56,6 @@ class SSHStateTest(SSHCase):
self.assertTrue(check_file)
@pytest.mark.slow_test
@pytest.mark.timeout_unless_on_windows(120)
def test_state_sls_id(self):
"""
test state.sls_id with salt-ssh

View file

@ -9,7 +9,7 @@ from tests.support.pytest.helpers import FakeSaltExtension
pytestmark = [
# These are slow because they create a virtualenv and install salt in it
pytest.mark.slow_test,
pytest.mark.timeout_unless_on_windows(120),
pytest.mark.timeout_unless_on_windows(240),
]

View file

@ -19,7 +19,7 @@ pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_if_not_root,
pytest.mark.destructive_test,
pytest.mark.timeout_unless_on_windows(120),
pytest.mark.timeout_unless_on_windows(240),
]

View file

@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
pytestmark = [
pytest.mark.core_test,
pytest.mark.timeout_unless_on_windows(600, func_only=True),
pytest.mark.timeout_unless_on_windows(600),
]

View file

@ -6,6 +6,7 @@ import pytest
pytestmark = [
pytest.mark.slow_test,
pytest.mark.timeout_unless_on_windows(240),
]

View file

@ -15,7 +15,7 @@ log = logging.getLogger(__name__)
pytestmark = [
pytest.mark.slow_test,
pytest.mark.timeout_unless_on_windows(120, func_only=True),
pytest.mark.timeout_unless_on_windows(120),
pytest.mark.skip_if_binaries_missing("docker"),
]

View file

@ -135,7 +135,7 @@ def test_ssh_disabled(client, auth_creds):
assert ret is None
@pytest.mark.timeout_unless_on_windows(360, func_only=True)
@pytest.mark.timeout_unless_on_windows(360)
def test_shell_inject_ssh_priv(
client, salt_ssh_roster_file, rosters_dir, tmp_path, salt_auto_account, grains
):

View file

@ -9,7 +9,7 @@ log = logging.getLogger(__name__)
@pytest.mark.slow_test
@pytest.mark.timeout_unless_on_windows(120)
@pytest.mark.timeout_unless_on_windows(240)
def test_present_absent(salt_master, salt_minion, salt_call_cli):
ret = salt_call_cli.run("beacons.reset")