Added more debugging

This commit is contained in:
David Murphy 2024-08-05 10:03:32 -06:00 committed by Daniel Wozniak
parent dab09a47b8
commit c7fa80cccc
2 changed files with 64 additions and 5 deletions

View file

@ -56,7 +56,7 @@ def test_salt_downgrade_minion(salt_call_cli, install_salt):
original_py_version = install_salt.package_python_version()
# Verify current install version is setup correctly and works
ret = salt_call_cli.run("test.version")
ret = salt_call_cli.run("--local", "test.version")
assert ret.returncode == 0
assert packaging.version.parse(ret.data) == packaging.version.parse(
install_salt.artifact_version
@ -89,6 +89,33 @@ def test_salt_downgrade_minion(salt_call_cli, install_salt):
# Downgrade Salt to the previous version and test
install_salt.install(downgrade=True)
## DGM test code
time.sleep(10) # give it some time
# a downgrade install will stop services on Debian/Ubuntu (why they didn't worry about Redhat family)
# This is probably due to RedHat systems are not active after an install, but Debian/Ubuntu are active after an install
# this leads to issues depending on what the sequence of tests are run , leaving the systems systemd active or not
# Q. why are RedHat systems passing these tests, perhaps there is a case being missed where the RedHat systems are active
# since they were not explicitly stopped, but the Debian/Ubuntu are, but in testing Ubuntu 24.04 amd64 passed but arm64 did not ?
# Also MacOS 13 also failed ????
test_list = ["salt-syndic", "salt-minion", "salt-master"]
for test_item in test_list:
test_cmd = f"systemctl status {test_item}"
ret = salt_call_cli.run("--local", "cmd.run", test_cmd)
print(
f"DGM test_salt_downgrade_minion systemctl status for service '{test_item}' ret '{ret}'",
flush=True,
)
# trying restart for Debian/Ubuntu to see the outcome
if install.distro_id in ("ubuntu", "debian"):
print(
f"DGM test_salt_downgrade_minion, ubuntu or debian, restart services for distro id '{install.distro_id}'",
flush=True,
)
install.restart_services()
time.sleep(60) # give it some time
# Verify there is a new running minion by getting its PID and comparing it

View file

@ -591,10 +591,10 @@ class SaltPkgInstall:
self._install_pkgs(upgrade=upgrade, downgrade=downgrade)
if self.distro_id in ("ubuntu", "debian"):
print(
f"DGM install_salt install, ubuntu or debian, stop services distro id '{self.distro_id}' but don't ",
f"DGM install_salt install, ubuntu or debian, stop services distro id '{self.distro_id}'",
flush=True,
)
## DGM self.stop_services()
self.stop_services()
def stop_services(self):
"""
@ -627,6 +627,38 @@ class SaltPkgInstall:
self._check_retcode(stop_service)
return retval
def restart_services(self):
"""
Debian distros automatically start the services
We want to ensure our tests start with the config settings we have set.
This will also verify the expected services are up and running.
## DGM Why this comment stop_services, surely when Debian/Ubuntu restart automatically, they pick up the configuration already defined - unless there is some env override on configuration file to pick up.
## DGM Created this to restart services after an install which will stop. Need to find out the underlying reason Caleb added code to stop_services, what problem was he trying to fix,
## DGM for example: stopping service on Debian/Ubuntu when getting the _default_version ????????
"""
print("DGM install_salt restart_services, entry", flush=True)
retval = True
for service in ["salt-syndic", "salt-master", "salt-minion"]:
check_run = self.proc.run("systemctl", "status", service)
if check_run.returncode != 0:
# The system was not started automatically and we
# are expecting it to be on install
print(
f"DGM install_salt restart_services systemctl status, The service '{service}' was not started on install, ret '{check_run}'",
flush=True,
)
log.debug("The service %s was not started on install.", service)
retval = False
else:
restart_service = self.proc.run("systemctl", "restart", service)
print(
f"DGM install_salt restart_services systemctl restart, service '{service}', ret '{restart_service}'",
flush=True,
)
self._check_retcode(restart_service)
return retval
def install_previous(self, downgrade=False):
"""
Install previous version. This is used for
@ -810,10 +842,10 @@ class SaltPkgInstall:
if downgrade:
pref_file.unlink()
print(
"DGM install, install_previous , about to stop services, but do not",
"DGM install, install_previous , about to stop services",
flush=True,
)
## DGM self.stop_services()
self.stop_services()
elif platform.is_windows():
self.bin_dir = self.install_dir / "bin"
self.run_root = self.bin_dir / "salt.exe"