From 743a0d49eb89dad43fe792bade74803739e9d6e8 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 22 Oct 2024 14:08:39 -0600 Subject: [PATCH] System tests: clean up unit file leaks Quadlet tests and some systemd tests leak unit files, as reported by 'systemctl list-units --failed'. Clean them up. Signed-off-by: Ed Santiago --- test/system/250-systemd.bats | 5 +++++ test/system/252-quadlet.bats | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index b3e2f9368c..89b8c80aae 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -31,6 +31,7 @@ function teardown() { echo "# WARNING: systemctl stop failed in teardown: $output" >&3 fi + run systemctl reset-failed "$SERVICE_NAME" rm -f "$UNIT_FILE" systemctl daemon-reload fi @@ -97,6 +98,8 @@ function service_cleanup() { run systemctl disable "$SERVICE_NAME" assert $status -eq 0 "Error disabling systemd unit $SERVICE_NAME: $output" + run systemctl reset-failed "$SERVICE_NAME" + rm -f "$UNIT_FILE" systemctl daemon-reload } @@ -272,6 +275,8 @@ LISTEN_FDNAMES=listen_fdnames" | sort) run systemctl stop "$INSTANCE" assert $status -eq 0 "Error stopping systemd unit $INSTANCE: $output" + run systemctl reset-failed "$INSTANCE" + rm -f $TEMPLATE_FILE systemctl daemon-reload } diff --git a/test/system/252-quadlet.bats b/test/system/252-quadlet.bats index b91030e111..ed9c040f85 100644 --- a/test/system/252-quadlet.bats +++ b/test/system/252-quadlet.bats @@ -37,6 +37,7 @@ function teardown() { if [ $status -ne 0 ]; then echo "# WARNING: systemctl stop failed in teardown: $output" >&3 fi + run systemctl reset-failed "$service" rm -f "$UNIT_FILE" fi done @@ -127,6 +128,8 @@ function service_cleanup() { "state of service $service after systemctl stop" fi + # reset-failed necessary to clean up stray systemd cruft + run systemctl reset-failed "$service" rm -f "$UNIT_DIR/$service" systemctl daemon-reload } @@ -909,6 +912,8 @@ EOF run_podman exec $QUADLET_CONTAINER_NAME cat /test_content/$file_name is "$output" "$file_content" "contents of testfile in container volume" + service_cleanup $QUADLET_SERVICE_NAME + rm -rf $tmp_path }