From f16e9acc64f244c6d93e3a827e3f65158abd1dac Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Wed, 12 Oct 2022 06:25:57 -0600 Subject: [PATCH] system tests: health-on-failure: fix broken logic Basically, in the timeout loop where we checked for new CID on the restarted container, we were running 'podman inspect' (not 'inspect --format ID'), and comparing full hundred-line output against single-line CID string. While I'm in here, add 'c_' prefix to container to make it easier for my old eyes to recognize "oh, that's a container name" vs "is that a name? a SHA? a woozle?" Signed-off-by: Ed Santiago --- test/system/250-systemd.bats | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index 5526728b63..d0dc454d39 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -314,7 +314,7 @@ LISTEN_FDNAMES=listen_fdnames" | sort) img="healthcheck_i" _build_health_check_image $img - cname=$(random_string) + cname=c_$(random_string) run_podman create --name $cname \ --health-cmd /healthcheck \ --health-on-failure=kill \ @@ -345,7 +345,11 @@ LISTEN_FDNAMES=listen_fdnames" | sort) # Wait at most 10 seconds for the service to be restarted local timeout=10 while [[ $timeout -gt 1 ]]; do - run_podman '?' container inspect $cname + # Possible outcomes: + # - status 0, old container is still terminating: sleep and retry + # - status 0, new CID: yay, break + # - status 1, container not found: sleep and retry + run_podman '?' container inspect $cname --format '{{.ID}}' if [[ $status == 0 ]]; then if [[ "$output" != "$oldID" ]]; then break