From 6743cefc1cf4cdad79ff5201d888b5b13b6794fb Mon Sep 17 00:00:00 2001 From: David Murphy Date: Wed, 19 Jun 2024 16:12:50 -0600 Subject: [PATCH] Revised tests --- .../pytests/pkg/integration/test_salt_user.py | 11 +------- tests/pytests/pkg/integration/test_version.py | 17 ++++++++++--- .../pkg/upgrade/test_systemd_permissions.py | 25 +++++++++++++++++++ tests/support/pkg.py | 1 - 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/tests/pytests/pkg/integration/test_salt_user.py b/tests/pytests/pkg/integration/test_salt_user.py index 61508ca993b..347215e25ca 100644 --- a/tests/pytests/pkg/integration/test_salt_user.py +++ b/tests/pytests/pkg/integration/test_salt_user.py @@ -8,16 +8,7 @@ import psutil import pytest from saltfactories.utils.tempfiles import temp_directory -pytestmark = [ - pytest.mark.skip_unless_on_linux, - pytest.mark.skipif( - True, - reason=( - "Package permissions are getting reworked in " - "https://github.com/saltstack/salt/pull/66218" - ), - ), -] +pytestmark = [pytest.mark.skip_unless_on_linux] @pytest.fixture diff --git a/tests/pytests/pkg/integration/test_version.py b/tests/pytests/pkg/integration/test_version.py index d59377c31d6..c484684b9d5 100644 --- a/tests/pytests/pkg/integration/test_version.py +++ b/tests/pytests/pkg/integration/test_version.py @@ -11,12 +11,20 @@ def test_salt_version(version, install_salt): """ Test version output from salt --version """ - if install_salt.upgrade: - install_salt.install() - + actual = [] test_bin = os.path.join(*install_salt.binary_paths["salt"]) ret = install_salt.proc.run(test_bin, "--version") - actual = ret.stdout.strip().split(" ")[:2] + actual_ver = ret.stdout.strip().split(" ")[:2] + actual_ver_salt = actual_ver[1] # get salt version + if "+" in actual_ver_salt: + actual_ver_salt_stripped = actual_ver_salt.split("+")[ + 0 + ] # strip any git versioning + actual.append(actual_ver[0]) + actual.append(actual_ver_salt_stripped) + else: + pytest.skip("Not testing a non-release build artifact, do not run") + expected = ["salt", version] assert actual == expected @@ -28,6 +36,7 @@ def test_salt_versions_report_master(install_salt): """ 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") diff --git a/tests/pytests/pkg/upgrade/test_systemd_permissions.py b/tests/pytests/pkg/upgrade/test_systemd_permissions.py index 33ccb635a38..12afeb5f656 100644 --- a/tests/pytests/pkg/upgrade/test_systemd_permissions.py +++ b/tests/pytests/pkg/upgrade/test_systemd_permissions.py @@ -316,3 +316,28 @@ def test_salt_ownership_permission(salt_call_cli, install_salt, salt_systemd_set assert test_group == f"{test_minion_user}" else: assert test_group == f"{test_master_user}" + + # restore to defaults to ensure further tests run fine + ret = salt_call_cli.run( + "--local", "file.comment_line", "/etc/salt/master", "^user:" + ) + assert ret.returncode == 0 + + ret = salt_call_cli.run( + "--local", "file.comment_line", "/etc/salt/minion", "^user:" + ) + assert ret.returncode == 0 + + test_string = "\nuser: salt\n" + ret = salt_call_cli.run("--local", "file.append", "/etc/salt/master", test_string) + + test_string = "\nuser: root\n" + ret = salt_call_cli.run("--local", "file.append", "/etc/salt/minion", test_string) + + # restart and check ownership is correct + test_list = ["salt-api", "salt-minion", "salt-master"] + for test_item in test_list: + test_cmd = f"systemctl restart {test_item}" + ret = salt_call_cli.run("--local", "cmd.run", test_cmd) + + time.sleep(10) # allow some time for restart diff --git a/tests/support/pkg.py b/tests/support/pkg.py index d8b2dea8aab..20c851dcedd 100644 --- a/tests/support/pkg.py +++ b/tests/support/pkg.py @@ -484,7 +484,6 @@ class SaltPkgInstall: ret = self.proc.run("installer", "-pkg", str(pkg), "-target", "/") self._check_retcode(ret) - ## DGM TBD ? if not upgrade: # Stop the service installed by the installer self.proc.run("launchctl", "disable", f"system/{service_name}") self.proc.run("launchctl", "bootout", "system", str(plist_file))