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 <santiago@redhat.com>
This commit is contained in:
Ed Santiago 2024-10-22 14:08:39 -06:00
parent 2f6fca6edc
commit 743a0d49eb
2 changed files with 10 additions and 0 deletions

View File

@ -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
}

View File

@ -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
}