Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3006.x] Removing tech debt and restoring original pytest.skip for tests #66806

Merged
merged 4 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions tests/pytests/pkg/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,30 +350,15 @@ def salt_master(salt_factories, install_salt, pkg_tests_account):

master_script = False
if platform.is_windows():
if install_salt.classic:
master_script = True
if install_salt.relenv:
master_script = True
elif not install_salt.upgrade:
master_script = True
if (
not install_salt.relenv
and install_salt.use_prev_version
and not install_salt.classic
):
master_script = False
master_script = True

if master_script:
salt_factories.system_service = False
salt_factories.generate_scripts = True
scripts_dir = salt_factories.root_dir / "Scripts"
scripts_dir.mkdir(exist_ok=True)
salt_factories.scripts_dir = scripts_dir
python_executable = install_salt.bin_dir / "Scripts" / "python.exe"
if install_salt.classic:
python_executable = install_salt.bin_dir / "python.exe"
if install_salt.relenv:
python_executable = install_salt.install_dir / "Scripts" / "python.exe"
python_executable = install_salt.install_dir / "Scripts" / "python.exe"
salt_factories.python_executable = python_executable
factory = salt_factories.salt_master_daemon(
random_string("master-"),
Expand All @@ -384,10 +369,6 @@ def salt_master(salt_factories, install_salt, pkg_tests_account):
)
salt_factories.system_service = True
else:

if install_salt.classic and platform.is_darwin():
os.environ["PATH"] += ":/opt/salt/bin"

factory = salt_factories.salt_master_daemon(
random_string("master-"),
defaults=config_defaults,
Expand Down Expand Up @@ -458,12 +439,6 @@ def salt_minion(salt_factories, salt_master, install_salt):
)
config_overrides["winrepo_source_dir"] = r"salt://win/repo_ng"

if install_salt.classic and platform.is_windows():
salt_factories.python_executable = None

if install_salt.classic and platform.is_darwin():
os.environ["PATH"] += ":/opt/salt/bin"

factory = salt_master.salt_minion_daemon(
minion_id,
overrides=config_overrides,
Expand Down
2 changes: 0 additions & 2 deletions tests/pytests/pkg/downgrade/test_salt_downgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ def test_salt_downgrade_minion(salt_call_cli, install_salt):
bin_file = install_salt.install_dir / "salt-call.bat"
else:
bin_file = install_salt.install_dir / "salt-call.exe"
elif platform.is_darwin() and install_salt.classic:
bin_file = install_salt.bin_dir / "salt-call"

ret = install_salt.proc.run(bin_file, "--version")
assert ret.returncode == 0
Expand Down
6 changes: 0 additions & 6 deletions tests/pytests/pkg/integration/test_clean_zmq_teardown.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
log = logging.getLogger(__name__)


@pytest.fixture(autouse=True)
def _skip_on_non_relenv(install_salt):
if not install_salt.relenv:
pytest.skip("This test is for relenv versions of salt")


def test_check_no_import_error(salt_call_cli, salt_master):
"""
Test that we don't have any errors on teardown of python when using a py-rendered sls file
Expand Down
5 changes: 1 addition & 4 deletions tests/pytests/pkg/integration/test_enabled_disabled.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import pytest
from pytestskipmarkers.utils import platform

pytestmark = [
pytest.mark.skip_unless_on_linux,
]


@pytest.mark.skip_unless_on_linux(reason="Linux test only")
def test_services(install_salt, salt_call_cli):
"""
Check if Services are enabled/disabled
Expand Down
8 changes: 0 additions & 8 deletions tests/pytests/pkg/integration/test_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ def test_pip_install_extras(shell, install_salt, extras_pypath_bin):
"""
Test salt-pip installs into the correct directory
"""
if not install_salt.relenv:
pytest.skip("The extras directory is only in relenv versions")
dep = "pep8"
extras_keyword = "extras-3"
if platform.is_windows():
Expand Down Expand Up @@ -125,11 +123,7 @@ def test_pip_non_root(
pypath,
pkg_tests_account_environ,
):
if install_salt.classic:
pytest.skip("We can install non-root for classic packages")
check_path = extras_pypath_bin / "pep8"
if not install_salt.relenv and not install_salt.classic:
check_path = pypath / "pep8"
# We should be able to issue a --help without being root
ret = subprocess.run(
install_salt.binary_paths["salt"] + ["--help"],
Expand Down Expand Up @@ -179,8 +173,6 @@ def test_pip_install_salt_extension_in_extras(install_salt, extras_pypath, shell
Test salt-pip installs into the correct directory and the salt extension
is properly loaded.
"""
if not install_salt.relenv:
pytest.skip("The extras directory is only in relenv versions")
dep = "salt-analytics-framework"
dep_version = "0.1.0"

Expand Down
3 changes: 0 additions & 3 deletions tests/pytests/pkg/integration/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

@pytest.fixture
def python_script_bin(install_salt):
# Tiamat builds run scripts via `salt python`
if not install_salt.relenv and not install_salt.classic:
return install_salt.binary_paths["python"][:1] + ["python"]
return install_salt.binary_paths["python"]


Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/pkg/integration/test_salt_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

pytestmark = [
pytest.mark.skip_unless_on_linux,
pytest.mark.skip_on_windows,
]


Expand Down
4 changes: 0 additions & 4 deletions tests/pytests/pkg/integration/test_salt_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import pytest
from pytestskipmarkers.utils import platform

pytestmark = [
pytest.mark.skip_unless_on_linux,
]


def test_salt_call_local(salt_call_cli):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/pkg/integration/test_salt_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

pytestmark = [
pytest.mark.skip_unless_on_linux,
pytest.mark.skip_on_windows,
]


Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/pkg/integration/test_salt_grains.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

pytestmark = [
pytest.mark.skip_unless_on_linux,
pytest.mark.skip_on_windows,
]


Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/pkg/integration/test_salt_key.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

pytestmark = [
pytest.mark.skip_unless_on_linux,
pytest.mark.skip_on_windows,
]


Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/pkg/integration/test_salt_output.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

pytestmark = [
pytest.mark.skip_unless_on_linux,
pytest.mark.skip_on_windows,
]


Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/pkg/integration/test_salt_state_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from saltfactories.utils.functional import MultiStateResult

pytestmark = [
pytest.mark.skip_unless_on_linux,
pytest.mark.skip_on_windows,
]


Expand Down
5 changes: 4 additions & 1 deletion tests/pytests/pkg/integration/test_salt_ufw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import pytest

pytestmark = [
pytest.mark.skip_unless_on_linux,
]


@pytest.fixture
def salt_systemd_setup(
Expand All @@ -26,7 +30,6 @@ def salt_systemd_setup(
assert ret.returncode == 0


@pytest.mark.skip_on_windows
@pytest.mark.skip_if_binaries_missing("ufw")
def test_salt_ufw(salt_systemd_setup, salt_call_cli, install_salt):
"""
Expand Down
10 changes: 3 additions & 7 deletions tests/pytests/pkg/integration/test_salt_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import pytest
from saltfactories.utils.tempfiles import temp_directory

pytestmark = [pytest.mark.skip_unless_on_linux]
pytestmark = [
pytest.mark.skip_unless_on_linux,
]


@pytest.fixture
Expand Down Expand Up @@ -81,12 +83,6 @@ def pkg_paths_salt_user_exclusions():
return paths


@pytest.fixture(autouse=True)
def _skip_on_non_relenv(install_salt):
if not install_salt.relenv:
pytest.skip("The salt user only exists on relenv versions of salt")


def test_salt_user_master(salt_master, install_salt):
"""
Test the correct user is running the Salt Master
Expand Down
2 changes: 1 addition & 1 deletion tests/pytests/pkg/integration/test_systemd_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

pytestmark = [
pytest.mark.skip_on_windows(reason="Linux test only"),
pytest.mark.skip_unless_on_linux,
]


Expand Down
16 changes: 5 additions & 11 deletions tests/pytests/pkg/integration/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
import pytest
from pytestskipmarkers.utils import platform

pytestmark = [
pytest.mark.skip_unless_on_linux,
]


@pytest.mark.skip_on_windows
def test_salt_version(version, install_salt):
"""
Test version output from salt --version
Expand Down Expand Up @@ -37,13 +34,11 @@ def test_salt_version(version, install_salt):
assert actual == expected


@pytest.mark.skip_on_windows
def test_salt_versions_report_master(install_salt):
"""
Test running --versions-report on master
"""
if not install_salt.relenv and not install_salt.classic:
pytest.skip("Unable to get the python version dynamically from tiamat builds")

test_bin = os.path.join(*install_salt.binary_paths["master"])
python_bin = os.path.join(*install_salt.binary_paths["python"])
ret = install_salt.proc.run(test_bin, "--versions-report")
Expand All @@ -57,6 +52,7 @@ def test_salt_versions_report_master(install_salt):
ret.stdout.matcher.fnmatch_lines([f"*{py_version}*"])


@pytest.mark.skip_on_windows
def test_salt_versions_report_minion(salt_cli, salt_call_cli, salt_minion):
"""
Test running test.versions_report on minion
Expand Down Expand Up @@ -132,14 +128,12 @@ def test_symlinks_created(version, symlink, install_salt):
"""
Test symlinks created
"""
if install_salt.classic:
pytest.skip("Symlinks not created for classic macos builds, we adjust the path")
if not install_salt.relenv and symlink == "spm":
symlink = "salt-spm"
ret = install_salt.proc.run(pathlib.Path("/usr/local/sbin") / symlink, "--version")
ret.stdout.matcher.fnmatch_lines([f"*{version}*"])


@pytest.mark.skip_on_windows
@pytest.mark.skip_on_darwin
def test_compare_pkg_versions_redhat_rc(version, install_salt):
"""
Test compare pkg versions for redhat RC packages. A tilde should be included
Expand Down
14 changes: 6 additions & 8 deletions tests/pytests/pkg/upgrade/test_salt_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ def test_salt_upgrade(salt_call_cli, install_salt):
if not install_salt.upgrade:
pytest.skip("Not testing an upgrade, do not run")

if install_salt.relenv:
original_py_version = install_salt.package_python_version()
original_py_version = install_salt.package_python_version()

# Test pip install before an upgrade
dep = "PyGithub==1.56.0"
Expand All @@ -139,9 +138,8 @@ def test_salt_upgrade(salt_call_cli, install_salt):
# pylint: disable=pointless-statement
salt_test_upgrade

if install_salt.relenv:
new_py_version = install_salt.package_python_version()
if new_py_version == original_py_version:
# test pip install after an upgrade
use_lib = salt_call_cli.run("--local", "github.get_repo_info", repo)
assert "Authentication information could" in use_lib.stderr
new_py_version = install_salt.package_python_version()
if new_py_version == original_py_version:
# test pip install after an upgrade
use_lib = salt_call_cli.run("--local", "github.get_repo_info", repo)
assert "Authentication information could" in use_lib.stderr
Loading