Skip to content

Commit 05bf6bc

Browse files
committed
Add fixture to disable /usr/sbin/policy-rc.d
Adds a fixture to disable /usr/sbin/policy-rc.d - on the container images we're using this returns an exitcode of 1001, which prevents dpkg from running service restarts on installs/upgrades, which makes the system behave differently to a real system.
1 parent 2436f77 commit 05bf6bc

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

tests/pytests/pkg/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,3 +558,23 @@ def api_request(pkg_tests_account, salt_api):
558558
port=salt_api.config["rest_cherrypy"]["port"], account=pkg_tests_account
559559
) as session:
560560
yield session
561+
562+
563+
@pytest.fixture(scope="module")
564+
def debian_disable_policy_rcd(grains):
565+
"""
566+
This fixture is used to disable the /usr/sbin/policy-rc.d file on
567+
Debian-based systems. This is present on container images and prevents the
568+
restart of services during package installation or upgrade.
569+
This is needed where we want to test pkg behaviour exactly as it would be on
570+
a real system.
571+
572+
"""
573+
if grains["os_family"] == "Debian":
574+
policy_rcd_path = pathlib.Path("/usr/sbin/policy-rc.d")
575+
if policy_rcd_path.exists():
576+
policy_rcd_path.rename(policy_rcd_path.with_suffix(".disabled"))
577+
yield
578+
policy_rcd_path.with_suffix(".disabled").rename(policy_rcd_path)
579+
else:
580+
yield

tests/pytests/pkg/upgrade/test_salt_upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def _get_running_named_salt_pid(process_name):
132132
return pids
133133

134134

135-
def test_salt_upgrade(salt_call_cli, install_salt):
135+
def test_salt_upgrade(salt_call_cli, install_salt, debian_disable_policy_rcd):
136136
"""
137137
Test an upgrade of Salt, Minion and Master
138138
"""

tests/pytests/pkg/upgrade/test_systemd_permissions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ def salt_systemd_overrides():
5454

5555
@pytest.fixture(scope="function")
5656
def salt_systemd_setup(
57-
salt_call_cli,
58-
install_salt,
59-
salt_systemd_overrides,
57+
salt_call_cli, install_salt, salt_systemd_overrides, debian_disable_policy_rcd
6058
):
6159
"""
6260
Fixture install previous version and set systemd for salt packages

0 commit comments

Comments
 (0)