More ssh test fixes

- Fix thin dir unit tests after distro change revert
- Skip any tests that require system python of 3.9 or higher
This commit is contained in:
Daniel A. Wozniak 2025-02-19 00:26:32 -07:00
parent 2404b3222c
commit fc0b20e657
27 changed files with 155 additions and 46 deletions

View file

@ -45,7 +45,7 @@ pytestmark = [
# backports.ssl-match-hostname which is not installed on the system.
),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.8"
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -8,7 +8,7 @@ import time
import pytest
from saltfactories.utils.tempfiles import temp_file
from tests.pytests.integration.ssh.test_slsutil import check_system_python_version
from tests.pytests.integration.ssh import check_system_python_version
from tests.support.case import SSHCase
from tests.support.runtests import RUNTIME_VARS
@ -24,7 +24,7 @@ pytestmark = [
# backports.ssl-match-hostname which is not installed on the system.
),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.8"
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -4,6 +4,7 @@ import pytest
import salt.netapi
from salt.exceptions import EauthAuthenticationError, SaltInvocationError
from tests.pytests.integration.ssh import check_system_python_version
from tests.support.helpers import SaveRequestsPostHandler, Webserver
from tests.support.mock import patch
@ -19,6 +20,9 @@ pytestmark = [
# backports.ssl-match-hostname which is not installed on the system.
),
pytest.mark.timeout_unless_on_windows(120),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]
log = logging.getLogger(__name__)

View file

@ -1,3 +1,14 @@
import pytest
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]
def test_pillar_using_http_query(salt_master, salt_minion, salt_cli, tmp_path):
pillar_top = """
base:

View file

@ -0,0 +1,17 @@
import subprocess
import packaging
def check_system_python_version():
"""
Validate the system python version is greater than 3.9
"""
try:
ret = subprocess.run(
["/usr/bin/python3", "--version"], capture_output=True, check=True
)
except FileNotFoundError:
return None
ver = ret.stdout.decode().split(" ", 1)[-1]
return packaging.version.Version(ver) >= packaging.version.Version("3.9")

View file

@ -4,9 +4,14 @@ Verify salt-ssh states support ``parallel``.
import pytest
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.slow_test,
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -9,11 +9,15 @@ import json
import pytest
import salt.utils.dictupdate
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.usefixtures("pillar_tree_nested"),
pytest.mark.slow_test,
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -5,10 +5,14 @@ Verify salt-ssh fails with a retcode > 0 when a pillar rendering fails.
import pytest
from salt.defaults.exitcodes import EX_AGGREGATE
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.slow_test,
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -5,10 +5,14 @@ Verify salt-ssh fails with a retcode > 0 when a state rendering fails.
import pytest
from salt.defaults.exitcodes import EX_AGGREGATE
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.slow_test,
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -6,10 +6,14 @@ when a state rendering fails because an execution module throws an exception.
import pytest
from salt.defaults.exitcodes import EX_AGGREGATE
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.slow_test,
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -5,10 +5,14 @@ Verify salt-ssh passes on a failing retcode from state execution.
import pytest
from salt.defaults.exitcodes import EX_AGGREGATE
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.slow_test,
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -6,11 +6,15 @@ from pathlib import Path
import pytest
from saltfactories.utils import random_string
from tests.pytests.integration.ssh import check_system_python_version
from tests.support.runtests import RUNTIME_VARS
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -10,10 +10,14 @@ import pytest
import salt.utils.files
import salt.utils.yaml
from salt.defaults.exitcodes import EX_AGGREGATE
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]
@ -163,28 +167,6 @@ def test_thin_dir(salt_ssh_cli):
assert thin_dir.joinpath("running_data").exists()
def test_relenv_dir(salt_ssh_cli):
"""
test to make sure thin_dir is created
and salt-call file is included
"""
ret = salt_ssh_cli.run("--relenv", "config.get", "thin_dir")
assert ret.returncode == 0
thin_dir = pathlib.Path(ret.data)
assert thin_dir.is_dir()
assert thin_dir
assert thin_dir.joinpath("salt-call").exists()
def test_relenv_ping(salt_ssh_cli):
"""
Test a simple ping
"""
ret = salt_ssh_cli.run("--relenv", "test.ping")
assert ret.returncode == 0
assert ret.data is True
def test_wipe(salt_ssh_cli):
"""
Ensure --wipe is respected by the state module wrapper

View file

@ -0,0 +1,34 @@
"""
salt-ssh testing
"""
import pathlib
import pytest
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
]
def test_relenv_dir(salt_ssh_cli):
"""
test to make sure thin_dir is created
and salt-call file is included
"""
ret = salt_ssh_cli.run("--relenv", "config.get", "thin_dir")
assert ret.returncode == 0
thin_dir = pathlib.Path(ret.data)
assert thin_dir.is_dir()
assert thin_dir
assert thin_dir.joinpath("salt-call").exists()
def test_relenv_ping(salt_ssh_cli):
"""
Test a simple ping
"""
ret = salt_ssh_cli.run("--relenv", "test.ping")
assert ret.returncode == 0
assert ret.data is True

View file

@ -1,10 +1,14 @@
import pytest
import salt.utils.platform
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -1,9 +1,14 @@
import pytest
from saltfactories.utils.functional import StateResult
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -1,8 +1,13 @@
import pytest
from saltfactories.utils.functional import StateResult
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -10,10 +10,14 @@ from saltfactories.utils.functional import StateResult
import salt.utils.platform
import salt.utils.versions
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -2,9 +2,14 @@ import shutil
import pytest
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -1,8 +1,13 @@
import pytest
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.slow_test,
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -7,8 +7,15 @@ import textwrap
import pytest
from pytestshellutils.utils.processes import ProcessResult
from tests.pytests.integration.ssh import check_system_python_version
log = logging.getLogger(__name__)
pytestmark = [
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]
# The following fixtures are copied from pytests/functional/pillar/test_gpg.py

View file

@ -18,9 +18,13 @@ import yaml
from saltfactories.utils import random_string
import salt.utils.files
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_on_windows(reason="Salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -1,8 +1,13 @@
import pytest
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -1,8 +1,13 @@
import pytest
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_on_windows(reason="salt-ssh not available on Windows"),
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -11,7 +11,7 @@ from tests.support.pytest.helpers import FakeSaltExtension
pytestmark = [
pytest.mark.skip_unless_on_linux,
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.8"
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -1,25 +1,13 @@
import json
import subprocess
import packaging
import pytest
def check_system_python_version():
try:
ret = subprocess.run(
["/usr/bin/python3", "--version"], capture_output=True, check=True
)
except FileNotFoundError:
return None
ver = ret.stdout.decode().split(" ", 1)[-1]
return packaging.version.Version(ver) >= packaging.version.Version("3.8")
from tests.pytests.integration.ssh import check_system_python_version
pytestmark = [
pytest.mark.skip_unless_on_linux,
pytest.mark.skipif(
not check_system_python_version(), reason="Needs system python >= 3.8"
not check_system_python_version(), reason="Needs system python >= 3.9"
),
]

View file

@ -84,7 +84,6 @@ class SSHThinTestCase(TestCase):
code_dir = pathlib.Path(RUNTIME_VARS.CODE_DIR).resolve()
self.exp_ret = {
"certifi": str(code_dir / "certifi"),
"distro": str(code_dir / "distro.py"),
"idna": str(code_dir / "idna"),
"jinja2": str(code_dir / "jinja2"),
"msgpack": str(code_dir / "msgpack"),
@ -479,7 +478,6 @@ class SSHThinTestCase(TestCase):
:return:
"""
base_tops = [
"distro",
"salt",
"jinja2",
"yaml",
@ -592,7 +590,6 @@ class SSHThinTestCase(TestCase):
:return:
"""
base_tops = [
"distro",
"salt",
"jinja2",
"yaml",
@ -715,7 +712,6 @@ class SSHThinTestCase(TestCase):
:return:
"""
base_tops = [
"distro",
"salt",
"jinja2",
"yaml",
@ -1184,7 +1180,6 @@ class SSHThinTestCase(TestCase):
self._popen(
None,
side_effect=[
(bts("distro.py"), bts("")),
(bts("jinja2/__init__.py"), bts("")),
(bts("yaml/__init__.py"), bts("")),
(bts("tornado/__init__.py"), bts("")),
@ -1233,7 +1228,7 @@ class SSHThinTestCase(TestCase):
self._popen(
None,
side_effect=[
(bts("distro.py"), bts("")),
# (bts("distro.py"), bts("")),
# (bts("jinja2/__init__.py"), bts("")),
# (bts("yaml/__init__.py"), bts("")),
(bts("tornado/__init__.py"), bts("")),