Adjust testing support for pkg, and downgrading

This commit is contained in:
David Murphy 2024-07-09 14:06:52 -06:00 committed by Daniel Wozniak
parent aef7697f23
commit 0681720f50
2 changed files with 30 additions and 2 deletions

View file

@ -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)

View file

@ -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)