Skip to content

Commit

Permalink
Skip problematic tests due to system python being too recent
Browse files Browse the repository at this point in the history
  • Loading branch information
s0undt3ch committed May 13, 2024
1 parent 602e05e commit 2635ac6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
8 changes: 4 additions & 4 deletions tests/integration/cli/test_custom_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ def recho(text):
from tests.support.case import SSHCase

pytestmark = [
pytest.mark.skip_on_windows,
pytest.mark.skipif(
"grains['osfinger'] == 'Fedora Linux-40'",
reason="Fedora 40 ships with Python 3.12. Test can't run with system Python on 3.12",
'grains["osfinger"].startswith(("Fedora Linux-40", "Ubuntu-24.04", "Arch Linux"))',
reason="System ships with a version of python that is too recent for salt-ssh tests",
# Actually, the problem is that the tornado we ship is not prepared for Python 3.12,
# and it imports `ssl` and checks if the `match_hostname` function is defined, which
# has been deprecated since Python 3.7, so, the logic goes into trying to import
# backports.ssl-match-hostname which is not installed on the system.
)
),
]


@pytest.mark.skip_on_windows
class SSHCustomModuleTest(SSHCase):
"""
Test sls with custom module functionality using ssh
Expand Down
24 changes: 5 additions & 19 deletions tests/integration/ssh/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
from tests.support.runtests import RUNTIME_VARS

pytestmark = [
pytest.mark.slow_test,
pytest.mark.timeout_unless_on_windows(120),
pytest.mark.skipif(
"grains['osfinger'] == 'Fedora Linux-40'",
reason="Fedora 40 ships with Python 3.12. Test can't run with system Python on 3.12",
'grains["osfinger"].startswith(("Fedora Linux-40", "Ubuntu-24.04", "Arch Linux"))',
reason="System ships with a version of python that is too recent for salt-ssh tests",
# Actually, the problem is that the tornado we ship is not prepared for Python 3.12,
# and it imports `ssl` and checks if the `match_hostname` function is defined, which
# has been deprecated since Python 3.7, so, the logic goes into trying to import
# backports.ssl-match-hostname which is not installed on the system.
)
),
]

SSH_SLS = "ssh_state_tests"
Expand All @@ -28,8 +30,6 @@
log = logging.getLogger(__name__)


@pytest.mark.slow_test
@pytest.mark.timeout_unless_on_windows(120)
class SSHStateTest(SSHCase):
"""
testing the state system with salt-ssh
Expand All @@ -55,7 +55,6 @@ def _check_request(self, empty=False):
exp_ret=SSH_SLS,
)

@pytest.mark.slow_test
def test_state_apply(self):
"""
test state.apply with salt-ssh
Expand All @@ -66,7 +65,6 @@ def test_state_apply(self):
check_file = self.run_function("file.file_exists", [SSH_SLS_FILE])
self.assertTrue(check_file)

@pytest.mark.slow_test
def test_state_sls_id(self):
"""
test state.sls_id with salt-ssh
Expand All @@ -93,7 +91,6 @@ def test_state_sls_id(self):
check_file = self.run_function("file.file_exists", [SSH_SLS_FILE])
self.assertTrue(check_file)

@pytest.mark.slow_test
def test_state_sls_wrong_id(self):
"""
test state.sls_id when id does not exist
Expand All @@ -102,7 +99,6 @@ def test_state_sls_wrong_id(self):
ret = self.run_function("state.sls_id", ["doesnotexist", SSH_SLS])
assert "No matches for ID" in ret

@pytest.mark.slow_test
def test_state_sls_id_with_pillar(self):
"""
test state.sls_id with pillar data
Expand All @@ -116,7 +112,6 @@ def test_state_sls_id_with_pillar(self):
)
self.assertTrue(check_file)

@pytest.mark.slow_test
def test_state_show_sls(self):
"""
test state.show_sls with salt-ssh
Expand All @@ -127,7 +122,6 @@ def test_state_show_sls(self):
check_file = self.run_function("file.file_exists", [SSH_SLS_FILE], wipe=False)
self.assertFalse(check_file)

@pytest.mark.slow_test
def test_state_show_top(self):
"""
test state.show_top with salt-ssh
Expand All @@ -154,7 +148,6 @@ def test_state_show_top(self):
ret = self.run_function("state.show_top")
self.assertEqual(ret, {"base": ["core", "master_tops_test"]})

@pytest.mark.slow_test
def test_state_single(self):
"""
state.single with salt-ssh
Expand All @@ -172,7 +165,6 @@ def test_state_single(self):
self.assertEqual(value["result"], ret_out["result"])
self.assertEqual(value["comment"], ret_out["comment"])

@pytest.mark.slow_test
def test_show_highstate(self):
"""
state.show_highstate with salt-ssh
Expand Down Expand Up @@ -202,7 +194,6 @@ def test_show_highstate(self):
self.assertIn(destpath, high)
self.assertEqual(high[destpath]["__env__"], "base")

@pytest.mark.slow_test
def test_state_high(self):
"""
state.high with salt-ssh
Expand All @@ -220,7 +211,6 @@ def test_state_high(self):
self.assertEqual(value["result"], ret_out["result"])
self.assertEqual(value["comment"], ret_out["comment"])

@pytest.mark.slow_test
def test_show_lowstate(self):
"""
state.show_lowstate with salt-ssh
Expand Down Expand Up @@ -248,7 +238,6 @@ def test_show_lowstate(self):
self.assertIsInstance(low, list)
self.assertIsInstance(low[0], dict)

@pytest.mark.slow_test
def test_state_low(self):
"""
state.low with salt-ssh
Expand All @@ -267,7 +256,6 @@ def test_state_low(self):
self.assertEqual(value["result"], ret_out["result"])
self.assertEqual(value["comment"], ret_out["comment"])

@pytest.mark.slow_test
def test_state_request_check_clear(self):
"""
test state.request system with salt-ssh
Expand All @@ -281,7 +269,6 @@ def test_state_request_check_clear(self):
clear = self.run_function("state.clear_request", wipe=False)
self._check_request(empty=True)

@pytest.mark.slow_test
def test_state_run_request(self):
"""
test state.request system with salt-ssh
Expand All @@ -295,7 +282,6 @@ def test_state_run_request(self):
check_file = self.run_function("file.file_exists", [SSH_SLS_FILE], wipe=False)
self.assertTrue(check_file)

@pytest.mark.slow_test
def test_state_running(self):
"""
test state.running with salt-ssh
Expand Down
4 changes: 2 additions & 2 deletions tests/pytests/integration/netapi/test_ssh_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
pytest.mark.slow_test,
pytest.mark.requires_sshd_server,
pytest.mark.skipif(
"grains['osfinger'] == 'Fedora Linux-40'",
reason="Fedora 40 ships with Python 3.12. Test can't run with system Python on 3.12",
'grains["osfinger"].startswith(("Fedora Linux-40", "Ubuntu-24.04", "Arch Linux"))',
reason="System ships with a version of python that is too recent for salt-ssh tests",
# Actually, the problem is that the tornado we ship is not prepared for Python 3.12,
# and it imports `ssl` and checks if the `match_hostname` function is defined, which
# has been deprecated since Python 3.7, so, the logic goes into trying to import
Expand Down
11 changes: 7 additions & 4 deletions tests/pytests/integration/ssh/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@


@pytest.fixture(scope="package", autouse=True)
def _auto_skip_on_fedora_40(grains):
if grains["osfinger"] == "Fedora Linux-40":
def _auto_skip_on_system_python_too_recent(grains):
if (
grains["osfinger"] in ("Fedora Linux-40", "Ubuntu-24.04")
or grains["os_family"] == "Arch"
):
pytest.skip(
"Fedora 40 ships with Python 3.12. Test can't run with system Python on 3.12"
"System ships with a version of python that is too recent for salt-ssh tests",
# Actually, the problem is that the tornado we ship is not prepared for Python 3.12,
# and it imports `ssl` and checks if the `match_hostname` function is defined, which
# has been deprecated since Python 3.7, so, the logic goes into trying to import
Expand All @@ -16,7 +19,7 @@ def _auto_skip_on_fedora_40(grains):


@pytest.fixture(autouse=True)
def _reap_stray_processes(grains):
def _reap_stray_processes():
# when tests timeout, we migth leave child processes behind
# nuke them
with reap_stray_processes():
Expand Down

0 comments on commit 2635ac6

Please sign in to comment.