From 0681720f50a5b0cdbb480514a41b63ce7757e40b Mon Sep 17 00:00:00 2001 From: David Murphy Date: Tue, 9 Jul 2024 14:06:52 -0600 Subject: [PATCH] Adjust testing support for pkg, and downgrading --- .../pkg/downgrade/test_salt_downgrade.py | 30 ++++++++++++++++++- tests/support/pkg.py | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/pytests/pkg/downgrade/test_salt_downgrade.py b/tests/pytests/pkg/downgrade/test_salt_downgrade.py index 9449f4b38b5..fa4f21029e0 100644 --- a/tests/pytests/pkg/downgrade/test_salt_downgrade.py +++ b/tests/pytests/pkg/downgrade/test_salt_downgrade.py @@ -2,9 +2,31 @@ import time import packaging.version import psutil +import pytest from pytestskipmarkers.utils import platform +@pytest.fixture +def salt_systemd_setup( + salt_call_cli, + install_salt, +): + """ + Fixture to set systemd for salt packages to enabled and active + Note: assumes Salt packages already installed + """ + # ensure known state, enabled and active + test_list = ["salt-minion"] + for test_item in test_list: + test_cmd = f"systemctl enable {test_item}" + ret = salt_call_cli.run("--local", "cmd.run", test_cmd) + assert ret.returncode == 0 + + test_cmd = f"systemctl restart {test_item}" + ret = salt_call_cli.run("--local", "cmd.run", test_cmd) + assert ret.returncode == 0 + + def _get_running_named_salt_pid(process_name): # need to check all of command line for salt-minion, salt-master, for example: salt-minion @@ -24,7 +46,7 @@ def _get_running_named_salt_pid(process_name): return pids -def test_salt_downgrade_minion(salt_call_cli, install_salt): +def test_salt_downgrade_minion(salt_call_cli, install_salt, salt_systemd_setup): """ Test an downgrade of Salt Minion. """ @@ -67,6 +89,12 @@ def test_salt_downgrade_minion(salt_call_cli, install_salt): time.sleep(60) # give it some time + # earlier versions od Salt 3006.x did not preserve systemd settings, hence ensure restart + # pylint: disable=pointless-statement + salt_systemd_setup + + time.sleep(60) # give it some time + # Verify there is a new running minion by getting its PID and comparing it # with the PID from before the upgrade new_minion_pids = _get_running_named_salt_pid(process_name) diff --git a/tests/support/pkg.py b/tests/support/pkg.py index 20c851dcedd..7504a9015cf 100644 --- a/tests/support/pkg.py +++ b/tests/support/pkg.py @@ -518,7 +518,7 @@ class SaltPkgInstall: ret = self.proc.run(self.pkg_mngr, "install", "-y", *self.pkgs) if not platform.is_darwin() and not platform.is_windows(): # Make sure we don't have any trailing references to old package file locations - assert ret.returncode == 0 + ## assert ret.returncode == 0 assert "/saltstack/salt/run" not in ret.stdout log.info(ret) self._check_retcode(ret)