From fd67c0ca71932c5752b6c468c0b018aa3c4f97b5 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Fri, 21 Mar 2025 11:29:09 -0600 Subject: [PATCH 01/10] 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 1f07014571b0..7066d32b95c4 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__) @@ -132,6 +136,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 0dca98524e2604c266868006c65e9b66da3815f5 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Fri, 21 Mar 2025 12:47:20 -0600 Subject: [PATCH 02/10] 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 7066d32b95c4..d89278a38fbf 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -154,7 +154,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 576b3917ce763906e9bbb01cd2e22a5c81132d04 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Fri, 21 Mar 2025 13:41:31 -0600 Subject: [PATCH 03/10] 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 d89278a38fbf..5f6ac496c67c 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -157,7 +157,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 c2d0d00b32389fd8c3b3f24f2b177ab2d61703f5 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Mon, 24 Mar 2025 11:19:45 -0600 Subject: [PATCH 04/10] 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 5f6ac496c67c..3c30589a4da1 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -158,9 +158,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 ( @@ -170,6 +173,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}"], @@ -185,12 +192,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 8572730fdbca12946f7a5964bf10b1da4b594f2f Mon Sep 17 00:00:00 2001 From: David Murphy Date: Mon, 24 Mar 2025 11:21:30 -0600 Subject: [PATCH 05/10] 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 3c30589a4da1..b4d59d89875e 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -136,7 +136,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 38b721ba2e63c0ce845e929a187ea032e7ef6941 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Tue, 25 Mar 2025 10:05:42 -0600 Subject: [PATCH 06/10] Additional Fix nightly build package test failures from 67914 --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", ] From 1b501938d5697e7fad4ca2c7c51919889cd83117 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Tue, 25 Mar 2025 11:44:23 -0600 Subject: [PATCH 07/10] 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 b4d59d89875e..cffdd06621ec 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -179,7 +179,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 319af02c56b164556434b48accf2b05f44e93285 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Tue, 25 Mar 2025 15:39:49 -0600 Subject: [PATCH 08/10] 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 cffdd06621ec..6485a74a8dc3 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -196,7 +196,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 7d00f3d06f193ea74f4cc47420935bf21b4f3b6e Mon Sep 17 00:00:00 2001 From: David Murphy Date: Wed, 26 Mar 2025 09:48:13 -0600 Subject: [PATCH 09/10] 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 +------------------ 4 files changed, 6 insertions(+), 31 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 6485a74a8dc3..58b34ba9ab4d 100644 --- a/tests/pytests/pkg/upgrade/test_salt_upgrade.py +++ b/tests/pytests/pkg/upgrade/test_salt_upgrade.py @@ -105,7 +105,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 @@ -149,23 +149,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", @@ -173,10 +163,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}"], @@ -192,16 +178,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 From 5788c6c0c3d9d61232086fc641b4af9ad4ddc0ac Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 22 Apr 2025 11:15:12 -0600 Subject: [PATCH 10/10] Don't clobber fixes to the pipeline --- noxfile.py | 4 ++-- salt/version.py | 2 +- tests/pytests/pkg/integration/test_version.py | 5 ++++- 3 files changed, 7 insertions(+), 4 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" 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()