From 0d3fd8d7f1137a1fb9218bf7ae16a33ae6566a37 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Fri, 21 Mar 2025 11:29:09 -0600 Subject: [PATCH 01/11] Added back support for Sys V init.d service scripts --- changelog/67765.fixed.md | 1 + pkg/{old/deb => debian}/salt-api.init | 0 pkg/{old/deb => debian}/salt-master.init | 0 pkg/{old/deb => debian}/salt-minion.init | 0 pkg/{old/deb => debian}/salt-syndic.init | 0 .../pytests/pkg/upgrade/test_salt_upgrade.py | 63 +++++++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 changelog/67765.fixed.md rename pkg/{old/deb => debian}/salt-api.init (100%) rename pkg/{old/deb => debian}/salt-master.init (100%) rename pkg/{old/deb => debian}/salt-minion.init (100%) rename pkg/{old/deb => debian}/salt-syndic.init (100%) diff --git a/changelog/67765.fixed.md b/changelog/67765.fixed.md new file mode 100644 index 000000000000..10e44c28bccf --- /dev/null +++ b/changelog/67765.fixed.md @@ -0,0 +1 @@ +Added back support for init.d service scripts diff --git a/pkg/old/deb/salt-api.init b/pkg/debian/salt-api.init similarity index 100% rename from pkg/old/deb/salt-api.init rename to pkg/debian/salt-api.init diff --git a/pkg/old/deb/salt-master.init b/pkg/debian/salt-master.init similarity index 100% rename from pkg/old/deb/salt-master.init rename to pkg/debian/salt-master.init diff --git a/pkg/old/deb/salt-minion.init b/pkg/debian/salt-minion.init similarity index 100% rename from pkg/old/deb/salt-minion.init rename to pkg/debian/salt-minion.init diff --git a/pkg/old/deb/salt-syndic.init b/pkg/debian/salt-syndic.init similarity index 100% rename from pkg/old/deb/salt-syndic.init rename to pkg/debian/salt-syndic.init diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index 555b96d651b2..35b42a24aa11 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -1,4 +1,6 @@ import logging +import os +import subprocess import sys import time @@ -7,6 +9,8 @@ import pytest from pytestskipmarkers.utils import platform +import salt.utils.path + log = logging.getLogger(__name__) @@ -126,6 +130,65 @@ def _get_running_named_salt_pid(process_name): return pids +def test_salt_sysv_service_files(salt_call_cli, install_salt): + """ + Test an upgrade of Salt, Minion and Master + """ + if not install_salt.upgrade: + pytest.skip("Not testing an upgrade, do not run") + + if sys.platform != "linux": + pytest.skip("Not testing on a Linux platform, do not run") + + if not (salt.utils.path.which("dpkg") or salt.utils.path.which("rpm")): + pytest.skip("Not testing on a Debian or RedHat family platform, do not run") + + print( + f"DGM test_salt_sysv_service_files entry install_salt, '{install_salt}'", + flush=True, + ) + + test_pkgs = install_salt.config_path.pkgs + print(f"DGM test_salt_sysv_service_files test_pkgs, '{test_pkgs}'", flush=True) + for test_pkg_name in test_pkgs: + test_pkg_basename = os.path.bashname(test_pkg_name) + test_pkg_basename_adj = test_pkg_basename.split("_") + print( + f"DGM test_salt_sysv_service_files test_pkg_basename_adj '{test_pkg_basename_adj}' from name test_pkg_basename '{test_pkg_basename}'", + flush=True, + ) + if test_pkg_basename_adj in ( + "salt-minion", + "salt-master", + "salt-syndic", + "salt-api", + ): + test_initd_name = f"/etc/init.d/{test_pkg_basename_adj}" + if salt.utils.path.which("dpkg"): + proc = subprocess.run( + ["dpkg", "-q", "-c", f"{test_pkg_name}"], + capture_output=True, + check=True, + ) + elif salt.utils.path.which("rpm"): + proc = subprocess.run( + ["rpm", "-q", "-l", "-p", f"{test_pkg_name}"], + capture_output=True, + check=True, + ) + found_line = False + for line in proc.stdout.decode().splitlines(): + # If test_initd_name not present we should fail. + if line == test_initd_name: + found_line = True + print( + f"DGM test_salt_sysv_service_files test_initd_name, '{test_initd_name}' was FOUND", + flush=True, + ) + + assert found_line + + def test_salt_upgrade(salt_call_cli, install_salt): """ Test an upgrade of Salt, Minion and Master From bb20ceb73240f5ec70d97bb5ac0cdbbb80afbb6b Mon Sep 17 00:00:00 2001 From: David Murphy Date: Fri, 21 Mar 2025 12:47:20 -0600 Subject: [PATCH 02/11] Updated test --- tests/pytests/pkg/upgrade/test_salt_upgrade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index 35b42a24aa11..1f0c9080c5d7 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -148,7 +148,7 @@ def test_salt_sysv_service_files(salt_call_cli, install_salt): flush=True, ) - test_pkgs = install_salt.config_path.pkgs + test_pkgs = install_salt.pkgs print(f"DGM test_salt_sysv_service_files test_pkgs, '{test_pkgs}'", flush=True) for test_pkg_name in test_pkgs: test_pkg_basename = os.path.bashname(test_pkg_name) From c979b9f1704e1f0c5a2b12093ff12ea34d0d23fc Mon Sep 17 00:00:00 2001 From: David Murphy Date: Fri, 21 Mar 2025 13:41:31 -0600 Subject: [PATCH 03/11] Fixed typo --- tests/pytests/pkg/upgrade/test_salt_upgrade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index 1f0c9080c5d7..9d10c0491476 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -151,7 +151,7 @@ def test_salt_sysv_service_files(salt_call_cli, install_salt): test_pkgs = install_salt.pkgs print(f"DGM test_salt_sysv_service_files test_pkgs, '{test_pkgs}'", flush=True) for test_pkg_name in test_pkgs: - test_pkg_basename = os.path.bashname(test_pkg_name) + test_pkg_basename = os.path.basename(test_pkg_name) test_pkg_basename_adj = test_pkg_basename.split("_") print( f"DGM test_salt_sysv_service_files test_pkg_basename_adj '{test_pkg_basename_adj}' from name test_pkg_basename '{test_pkg_basename}'", From 16c842a1f46c8c9e29e42d8d84e9154df18fb243 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Mon, 24 Mar 2025 09:41:52 -0600 Subject: [PATCH 04/11] Include #67914 fix nightly build package test failures --- noxfile.py | 4 ++-- salt/version.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index 61fe311910e4..27bbae57dd19 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1911,7 +1911,7 @@ def ci_test_onedir_pkgs(session): except CommandFailed: if os.environ.get("RERUN_FAILURES", "0") == "0": # Don't rerun on failures - return + sys.exit(1) # Don't print the system information, not the test selection on reruns global PRINT_TEST_SELECTION @@ -1962,7 +1962,7 @@ def ci_test_onedir_pkgs(session): except CommandFailed: if os.environ.get("RERUN_FAILURES", "0") == "0": # Don't rerun on failures - return + sys.exit(1) cmd_args = chunks["install"] pytest_args = ( common_pytest_args[:] diff --git a/salt/version.py b/salt/version.py index c7d33f29e9f1..14e5e77df9ee 100644 --- a/salt/version.py +++ b/salt/version.py @@ -456,7 +456,7 @@ def string(self): version_string += f".{self.mbugfix}" if self.pre_type: version_string += f"{self.pre_type}{self.pre_num}" - if self.noc and self.sha: + if self.noc is not None and self.sha: noc = self.noc if noc < 0: noc = "0na" From 9c73debd25adf11def71a0e2b5c6865576b87105 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Mon, 24 Mar 2025 11:19:45 -0600 Subject: [PATCH 05/11] Updated test --- tests/pytests/pkg/upgrade/test_salt_upgrade.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index 9d10c0491476..bf31e8dc86bf 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -152,9 +152,12 @@ def test_salt_sysv_service_files(salt_call_cli, install_salt): print(f"DGM test_salt_sysv_service_files test_pkgs, '{test_pkgs}'", flush=True) for test_pkg_name in test_pkgs: test_pkg_basename = os.path.basename(test_pkg_name) - test_pkg_basename_adj = test_pkg_basename.split("_") + # Debian/Ubuntu name typically salt-minion_300xxxxxx + # Redhat name typically salt-minion-300xxxxxx + test_pkg_basename_dash_underscore = test_pkg_basename.split("300")[0] + test_pkg_basename_adj = test_pkg_basename_dash_underscore[:-1] print( - f"DGM test_salt_sysv_service_files test_pkg_basename_adj '{test_pkg_basename_adj}' from name test_pkg_basename '{test_pkg_basename}'", + f"DGM test_salt_sysv_service_files test_pkg_basename_dash_underscore '{test_pkg_basename_dash_underscore}', test_pkg_basename_adj '{test_pkg_basename_adj}' from name test_pkg_basename '{test_pkg_basename}'", flush=True, ) if test_pkg_basename_adj in ( @@ -164,6 +167,10 @@ def test_salt_sysv_service_files(salt_call_cli, install_salt): "salt-api", ): test_initd_name = f"/etc/init.d/{test_pkg_basename_adj}" + print( + f"DGM test_salt_sysv_service_files test_initd_name, '{test_initd_name}' to check against", + flush=True, + ) if salt.utils.path.which("dpkg"): proc = subprocess.run( ["dpkg", "-q", "-c", f"{test_pkg_name}"], @@ -179,12 +186,17 @@ def test_salt_sysv_service_files(salt_call_cli, install_salt): found_line = False for line in proc.stdout.decode().splitlines(): # If test_initd_name not present we should fail. + print( + f"DGM test_salt_sysv_service_files check line, '{line}'", + flush=True, + ) if line == test_initd_name: found_line = True print( f"DGM test_salt_sysv_service_files test_initd_name, '{test_initd_name}' was FOUND", flush=True, ) + break assert found_line From 114633b32b3b0ab4366d69c68ff6ab6ba6b21e5b Mon Sep 17 00:00:00 2001 From: David Murphy Date: Mon, 24 Mar 2025 11:21:30 -0600 Subject: [PATCH 06/11] Updated test to remove salt_call_cli --- tests/pytests/pkg/upgrade/test_salt_upgrade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index bf31e8dc86bf..c2fb6b464c11 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -130,7 +130,7 @@ def _get_running_named_salt_pid(process_name): return pids -def test_salt_sysv_service_files(salt_call_cli, install_salt): +def test_salt_sysv_service_files(install_salt): """ Test an upgrade of Salt, Minion and Master """ From 07a49d7154af0951a7cff0430acbc4f0651b5455 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Tue, 25 Mar 2025 10:05:42 -0600 Subject: [PATCH 07/11] Additional Fix nightly build package test failures from 67914 --- noxfile.py | 2 +- tests/pytests/pkg/integration/test_version.py | 5 +- .../pytests/pkg/upgrade/test_salt_upgrade.py | 2 +- tests/support/pkg.py | 63 ++++++++++++------- 4 files changed, 45 insertions(+), 27 deletions(-) diff --git a/noxfile.py b/noxfile.py index 27bbae57dd19..0e7bda598ee1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1947,7 +1947,7 @@ def ci_test_onedir_pkgs(session): common_pytest_args[:] + cmd_args[:] + [ - "--no-install", + "--no-uninstall", "--junitxml=artifacts/xml-unittests-output/test-results-install.xml", "--log-file=artifacts/logs/runtests-install.log", ] diff --git a/tests/pytests/pkg/integration/test_version.py b/tests/pytests/pkg/integration/test_version.py index 65a771f82cd9..8939aa240574 100644 --- a/tests/pytests/pkg/integration/test_version.py +++ b/tests/pytests/pkg/integration/test_version.py @@ -104,7 +104,10 @@ def test_compare_versions(binary, install_salt): """ Test compare versions """ - version = install_salt.artifact_version + if install_salt.use_prev_version: + version = install_salt.prev_version + else: + version = install_salt.artifact_version if binary in install_salt.binary_paths: if install_salt.upgrade: install_salt.install() diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index c2fb6b464c11..5fea95692474 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -99,7 +99,7 @@ def salt_test_upgrade( new_minion_pids = _get_running_named_salt_pid(process_minion_name) new_master_pids = _get_running_named_salt_pid(process_master_name) - if sys.platform == "linux": + if sys.platform == "linux" and install_salt.distro_id not in ("ubuntu", "debian"): assert new_minion_pids assert new_master_pids assert new_minion_pids != old_minion_pids diff --git a/tests/support/pkg.py b/tests/support/pkg.py index bc50c7edf84a..5f9d801ee4cf 100644 --- a/tests/support/pkg.py +++ b/tests/support/pkg.py @@ -724,28 +724,38 @@ def install_previous(self, downgrade=False): ) as fp: fp.write( f"deb [signed-by={gpg_full_path} arch={arch}] " - f"{root_url}/saltproject-deb/ {self.distro_codename} main" + f"{root_url}/saltproject-deb/ stable main" ) self._check_retcode(ret) + pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt-pin-1001") + pref_file.parent.mkdir(exist_ok=True) + pin = f"{self.prev_version.rsplit('.', 1)[0]}.*" + if downgrade: + pin = self.prev_version + with salt.utils.files.fopen(pref_file, "w") as fp: + fp.write( + f"Package: salt-*\n" f"Pin: version {pin}\n" f"Pin-Priority: 1001" + ) cmd = [self.pkg_mngr, "install", *self.salt_pkgs, "-y"] - if downgrade: - pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt.pref") - pref_file.parent.mkdir(exist_ok=True) - # TODO: There's probably something I should put in here to say what version - # TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs - pref_file.write_text( - textwrap.dedent( - f"""\ - Package: salt* - Pin: origin "{root_url}/saltproject-deb" - Pin-Priority: 1001 - """ - ), - encoding="utf-8", - ) - cmd.append("--allow-downgrades") + # if downgrade: + # pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt.pref") + # pref_file.parent.mkdir(exist_ok=True) + # # TODO: There's probably something I should put in here to say what version + # # TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs + # pref_file.write_text( + # textwrap.dedent( + # f"""\ + # Package: salt* + # Pin: origin "{root_url}/saltproject-deb" + # Pin-Priority: 1001 + # """ + # ), + # encoding="utf-8", + # ) + # cmd.append("--allow-downgrades") + cmd.append("--allow-downgrades") env = os.environ.copy() env["DEBIAN_FRONTEND"] = "noninteractive" extra_args = [ @@ -758,17 +768,22 @@ def install_previous(self, downgrade=False): cmd.extend(extra_args) + log.warning("Run cmd %s", cmd) + ret = self.proc.run(*cmd, env=env) + + log.warning("cmd return %r", ret) + # Pre-relenv packages down get downgraded to cleanly programmatically # They work manually, and the install tests after downgrades will catch problems with the install # Let's not check the returncode if this is the case - if not ( - downgrade - and packaging.version.parse(self.prev_version) - < packaging.version.parse("3006.0") - ): - self._check_retcode(ret) - if downgrade: + # if not ( + # downgrade + # and packaging.version.parse(self.prev_version) + # < packaging.version.parse("3006.0") + # ): + # self._check_retcode(ret) + if downgrade and not self.no_uninstall: pref_file.unlink() self.stop_services() elif platform.is_windows(): From 7d17c410da16bd5f7143ba7cfc58ea649f08d848 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Tue, 25 Mar 2025 11:44:23 -0600 Subject: [PATCH 08/11] Fixed debian test --- tests/pytests/pkg/upgrade/test_salt_upgrade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index 5fea95692474..4bd29f230a5a 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -173,7 +173,7 @@ def test_salt_sysv_service_files(install_salt): ) if salt.utils.path.which("dpkg"): proc = subprocess.run( - ["dpkg", "-q", "-c", f"{test_pkg_name}"], + ["dpkg", "-c", f"{test_pkg_name}"], capture_output=True, check=True, ) From e83b86811bc9311485301e0011752a1c10f863c8 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Tue, 25 Mar 2025 15:39:49 -0600 Subject: [PATCH 09/11] Updated test for Debian output, leading dot in path --- tests/pytests/pkg/upgrade/test_salt_upgrade.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index 4bd29f230a5a..beba7a622e46 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -190,7 +190,7 @@ def test_salt_sysv_service_files(install_salt): f"DGM test_salt_sysv_service_files check line, '{line}'", flush=True, ) - if line == test_initd_name: + if test_initd_name in line: found_line = True print( f"DGM test_salt_sysv_service_files test_initd_name, '{test_initd_name}' was FOUND", From 9e655760b0d54559d97393dd02d89468d6095ff3 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Wed, 26 Mar 2025 09:48:13 -0600 Subject: [PATCH 10/11] Remove debug statements, and additions made from 67914 WIP Fix nightly build package test failures --- noxfile.py | 6 +- salt/version.py | 2 +- tests/pytests/pkg/integration/test_version.py | 5 +- .../pytests/pkg/upgrade/test_salt_upgrade.py | 24 +------ tests/support/pkg.py | 62 +++++++------------ 5 files changed, 29 insertions(+), 70 deletions(-) diff --git a/noxfile.py b/noxfile.py index 0e7bda598ee1..61fe311910e4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1911,7 +1911,7 @@ def ci_test_onedir_pkgs(session): except CommandFailed: if os.environ.get("RERUN_FAILURES", "0") == "0": # Don't rerun on failures - sys.exit(1) + return # Don't print the system information, not the test selection on reruns global PRINT_TEST_SELECTION @@ -1947,7 +1947,7 @@ def ci_test_onedir_pkgs(session): common_pytest_args[:] + cmd_args[:] + [ - "--no-uninstall", + "--no-install", "--junitxml=artifacts/xml-unittests-output/test-results-install.xml", "--log-file=artifacts/logs/runtests-install.log", ] @@ -1962,7 +1962,7 @@ def ci_test_onedir_pkgs(session): except CommandFailed: if os.environ.get("RERUN_FAILURES", "0") == "0": # Don't rerun on failures - sys.exit(1) + return cmd_args = chunks["install"] pytest_args = ( common_pytest_args[:] diff --git a/salt/version.py b/salt/version.py index 14e5e77df9ee..c7d33f29e9f1 100644 --- a/salt/version.py +++ b/salt/version.py @@ -456,7 +456,7 @@ def string(self): version_string += f".{self.mbugfix}" if self.pre_type: version_string += f"{self.pre_type}{self.pre_num}" - if self.noc is not None and self.sha: + if self.noc and self.sha: noc = self.noc if noc < 0: noc = "0na" diff --git a/tests/pytests/pkg/integration/test_version.py b/tests/pytests/pkg/integration/test_version.py index 8939aa240574..65a771f82cd9 100644 --- a/tests/pytests/pkg/integration/test_version.py +++ b/tests/pytests/pkg/integration/test_version.py @@ -104,10 +104,7 @@ def test_compare_versions(binary, install_salt): """ Test compare versions """ - if install_salt.use_prev_version: - version = install_salt.prev_version - else: - version = install_salt.artifact_version + version = install_salt.artifact_version if binary in install_salt.binary_paths: if install_salt.upgrade: install_salt.install() diff --git a/tests/pytests/pkg/upgrade/test_salt_upgrade.py b/tests/pytests/pkg/upgrade/test_salt_upgrade.py index beba7a622e46..ac037fcc0910 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -99,7 +99,7 @@ def salt_test_upgrade( new_minion_pids = _get_running_named_salt_pid(process_minion_name) new_master_pids = _get_running_named_salt_pid(process_master_name) - if sys.platform == "linux" and install_salt.distro_id not in ("ubuntu", "debian"): + if sys.platform == "linux": assert new_minion_pids assert new_master_pids assert new_minion_pids != old_minion_pids @@ -143,23 +143,13 @@ def test_salt_sysv_service_files(install_salt): if not (salt.utils.path.which("dpkg") or salt.utils.path.which("rpm")): pytest.skip("Not testing on a Debian or RedHat family platform, do not run") - print( - f"DGM test_salt_sysv_service_files entry install_salt, '{install_salt}'", - flush=True, - ) - test_pkgs = install_salt.pkgs - print(f"DGM test_salt_sysv_service_files test_pkgs, '{test_pkgs}'", flush=True) for test_pkg_name in test_pkgs: test_pkg_basename = os.path.basename(test_pkg_name) # Debian/Ubuntu name typically salt-minion_300xxxxxx # Redhat name typically salt-minion-300xxxxxx test_pkg_basename_dash_underscore = test_pkg_basename.split("300")[0] test_pkg_basename_adj = test_pkg_basename_dash_underscore[:-1] - print( - f"DGM test_salt_sysv_service_files test_pkg_basename_dash_underscore '{test_pkg_basename_dash_underscore}', test_pkg_basename_adj '{test_pkg_basename_adj}' from name test_pkg_basename '{test_pkg_basename}'", - flush=True, - ) if test_pkg_basename_adj in ( "salt-minion", "salt-master", @@ -167,10 +157,6 @@ def test_salt_sysv_service_files(install_salt): "salt-api", ): test_initd_name = f"/etc/init.d/{test_pkg_basename_adj}" - print( - f"DGM test_salt_sysv_service_files test_initd_name, '{test_initd_name}' to check against", - flush=True, - ) if salt.utils.path.which("dpkg"): proc = subprocess.run( ["dpkg", "-c", f"{test_pkg_name}"], @@ -186,16 +172,8 @@ def test_salt_sysv_service_files(install_salt): found_line = False for line in proc.stdout.decode().splitlines(): # If test_initd_name not present we should fail. - print( - f"DGM test_salt_sysv_service_files check line, '{line}'", - flush=True, - ) if test_initd_name in line: found_line = True - print( - f"DGM test_salt_sysv_service_files test_initd_name, '{test_initd_name}' was FOUND", - flush=True, - ) break assert found_line diff --git a/tests/support/pkg.py b/tests/support/pkg.py index 5f9d801ee4cf..93c54f8a700f 100644 --- a/tests/support/pkg.py +++ b/tests/support/pkg.py @@ -724,38 +724,28 @@ def install_previous(self, downgrade=False): ) as fp: fp.write( f"deb [signed-by={gpg_full_path} arch={arch}] " - f"{root_url}/saltproject-deb/ stable main" + f"{root_url}/saltproject-deb/ {self.distro_codename} main" ) self._check_retcode(ret) - pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt-pin-1001") - pref_file.parent.mkdir(exist_ok=True) - pin = f"{self.prev_version.rsplit('.', 1)[0]}.*" - if downgrade: - pin = self.prev_version - with salt.utils.files.fopen(pref_file, "w") as fp: - fp.write( - f"Package: salt-*\n" f"Pin: version {pin}\n" f"Pin-Priority: 1001" - ) cmd = [self.pkg_mngr, "install", *self.salt_pkgs, "-y"] - # if downgrade: - # pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt.pref") - # pref_file.parent.mkdir(exist_ok=True) - # # TODO: There's probably something I should put in here to say what version - # # TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs - # pref_file.write_text( - # textwrap.dedent( - # f"""\ - # Package: salt* - # Pin: origin "{root_url}/saltproject-deb" - # Pin-Priority: 1001 - # """ - # ), - # encoding="utf-8", - # ) - # cmd.append("--allow-downgrades") - cmd.append("--allow-downgrades") + if downgrade: + pref_file = pathlib.Path("/etc", "apt", "preferences.d", "salt.pref") + pref_file.parent.mkdir(exist_ok=True) + # TODO: There's probably something I should put in here to say what version + # TODO: But maybe that's done elsewhere, hopefully in self.salt_pkgs + pref_file.write_text( + textwrap.dedent( + f"""\ + Package: salt* + Pin: origin "{root_url}/saltproject-deb" + Pin-Priority: 1001 + """ + ), + encoding="utf-8", + ) + cmd.append("--allow-downgrades") env = os.environ.copy() env["DEBIAN_FRONTEND"] = "noninteractive" extra_args = [ @@ -768,22 +758,16 @@ def install_previous(self, downgrade=False): cmd.extend(extra_args) - log.warning("Run cmd %s", cmd) - ret = self.proc.run(*cmd, env=env) - - log.warning("cmd return %r", ret) - # Pre-relenv packages down get downgraded to cleanly programmatically # They work manually, and the install tests after downgrades will catch problems with the install # Let's not check the returncode if this is the case - # if not ( - # downgrade - # and packaging.version.parse(self.prev_version) - # < packaging.version.parse("3006.0") - # ): - # self._check_retcode(ret) - if downgrade and not self.no_uninstall: + if not ( + downgrade + and packaging.version.parse(self.prev_version) + < packaging.version.parse("3006.0") + ): + self._check_retcode(ret) pref_file.unlink() self.stop_services() elif platform.is_windows(): From 544ebbe7a61950c75655ab039733ed4bdf89a7e9 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Wed, 26 Mar 2025 09:50:42 -0600 Subject: [PATCH 11/11] Fix typo --- tests/support/pkg.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/support/pkg.py b/tests/support/pkg.py index 93c54f8a700f..bc50c7edf84a 100644 --- a/tests/support/pkg.py +++ b/tests/support/pkg.py @@ -768,6 +768,7 @@ def install_previous(self, downgrade=False): < packaging.version.parse("3006.0") ): self._check_retcode(ret) + if downgrade: pref_file.unlink() self.stop_services() elif platform.is_windows():