Skip to content
1 change: 1 addition & 0 deletions changelog/67765.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added back support for init.d service scripts
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions tests/pytests/pkg/upgrade/test_salt_upgrade.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os
import subprocess
import sys
import time

Expand All @@ -7,6 +9,8 @@
import pytest
from pytestskipmarkers.utils import platform

import salt.utils.path

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -126,6 +130,55 @@ def _get_running_named_salt_pid(process_name):
return pids


def test_salt_sysv_service_files(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")

test_pkgs = install_salt.pkgs
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]
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", "-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 test_initd_name in line:
found_line = True
break

assert found_line


def test_salt_upgrade(salt_call_cli, install_salt):
"""
Test an upgrade of Salt, Minion and Master
Expand Down
Loading