From 3ca0e46c15ca342e62c35c8267fde78b63b2d768 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Thu, 15 Dec 2022 13:53:22 +0100 Subject: [PATCH] test/system/250-systemd.bats: fix flake Fix a flake in the kube-template test. After stopping the service, we want to make sure that the service container gets removed. However, ther is a small race window. `systemctl stop` will return when the service container _exits_. In between that and the `container exists` check, the service container may have not yet been removed. Hence, add a loop to account for that race. Fixes: #16047 Signed-off-by: Valentin Rothberg --- test/system/250-systemd.bats | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index c560b20667..9b9aa9bf21 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -443,7 +443,14 @@ EOF # Clean up systemctl stop $service_name - run_podman 1 container exists $service_container + for i in {0..5}; do + run_podman ? container exists $service_container + if [[ $status == 1 ]]; then + break + fi + sleep 0.5 + done + is "$status" "1" "service container should have been removed" run_podman 1 pod exists test_pod run_podman rmi $(pause_image) rm -f $UNIT_DIR/$unit_name