From 52b60afb941a4b60e9afc42c7c402d388c3aae15 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Fri, 25 Sep 2026 22:02:42 +0200 Subject: [PATCH] tests: rpm: Test if all the service links are properly cleaned - Test if RPM uninstall properly removes the service links. - Remove the links in purge_cas() opeartion Signed-off-by: Robert Baldyga --- .../tests/misc/test_rpm_packaging_modes.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/functional/tests/misc/test_rpm_packaging_modes.py b/test/functional/tests/misc/test_rpm_packaging_modes.py index d0d1ea7b8..fdf4b872a 100644 --- a/test/functional/tests/misc/test_rpm_packaging_modes.py +++ b/test/functional/tests/misc/test_rpm_packaging_modes.py @@ -222,6 +222,18 @@ def stale_module_links(): return [line.strip() for line in output.stdout.splitlines() if line.strip()] +def service_links(): + output = TestRun.executor.run( + "find /etc/systemd/system -name 'open-cas*.service' 2>/dev/null" + ) + return [line.strip() for line in output.stdout.splitlines() if line.strip()] + + +def local_fs_target_starts(): + """open-cas.service is RequiredBy local-fs.target, so a dangling link breaks it.""" + return TestRun.executor.run("systemctl start local-fs.target").exit_code == 0 + + def purge_cas(): """Leave no CAS packages, modules, DKMS registration or stale links behind.""" TestRun.executor.run("rmmod cas_cache; rmmod cas_bd") @@ -229,6 +241,12 @@ def purge_cas(): f"rpm --query --all | grep '^{main_package}' | " f"xargs --no-run-if-empty rpm --erase --nodeps --noscripts" ) + # --noscripts skips %preun, which would disable the services; a dangling + # open-cas.service link fails local-fs.target and leaves / read-only on boot + TestRun.executor.run( + "find /etc/systemd/system -name 'open-cas*.service' -delete; " + "systemctl daemon-reload" + ) TestRun.executor.run( "dkms status 2>/dev/null | cut -d, -f1 | tr -d ' ' | while IFS=/ read -r m v; do " "[ -n \"$m\" ] && dkms remove -m \"$m\" -v \"$v\" --all; done" @@ -340,6 +358,7 @@ def test_rpm_packaging_install_uninstall(mode): - packages install and the CAS modules load - uninstalling removes every package, module and DKMS registration - no stale module links remain and the initramfs can still be rebuilt + - no service links remain and local-fs.target still starts """ with TestRun.step("Prepare sources and clean the DUT"): @@ -378,6 +397,12 @@ def test_rpm_packaging_install_uninstall(mode): if stale_module_links(): TestRun.fail(f"Stale module links left behind: {stale_module_links()}") + if service_links(): + TestRun.fail(f"Service links left behind: {service_links()}") + + if not local_fs_target_starts(): + TestRun.fail("local-fs.target does not start after uninstall") + if not initramfs_rebuild_works(): TestRun.fail("Initramfs could not be rebuilt after uninstall")