From 72d4cede295404d35169e37e85d7628dbeef19f5 Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 30 May 2023 13:18:37 -0600 Subject: [PATCH] systests: fix race in quadlet tests The new exit-code propagation test is racy: 'podman wait' can fail if the service container has already been cleaned up by systemd. Solution: run the inspect and wait tests opportunistically, i.e., only if those commands succeed. If they fail, confirm that they fail with ENOSUCHCONTAINER. This may silently lose us some coverage ... but none of it is important. The important test, systemctl final status, remains. Also, as drive-bys: - add a FIXME comment documenting another race condition that I'm not bothering to fix right now - give distinct names to unit files, for readability in test failures Fixes: #18732 Signed-off-by: Ed Santiago --- test/system/252-quadlet.bats | 43 ++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/test/system/252-quadlet.bats b/test/system/252-quadlet.bats index 26e8322f4f..2076f2d650 100644 --- a/test/system/252-quadlet.bats +++ b/test/system/252-quadlet.bats @@ -91,6 +91,7 @@ function service_setup() { echo "$output" assert $status -eq 0 "Error starting systemd unit $service" + # FIXME FIXME FIXME: this is racy with short-lived containers! echo "$_LOG_PROMPT systemctl status $service" run systemctl status "$service" echo "$output" @@ -638,15 +639,16 @@ EOF } @test "quadlet - exit-code propagation" { - local quadlet_file=$PODMAN_TMPDIR/basic_$(random_string).kube - local yaml_file=$PODMAN_TMPDIR/$(random_string).yaml - exit_tests=" all | true | 0 | inactive all | false | 137 | failed none | false | 0 | inactive " while read exit_code_prop cmd exit_code service_state; do + local basename=propagate-${exit_code_prop}-${cmd}-$(random_string) + local quadlet_file=$PODMAN_TMPDIR/$basename.kube + local yaml_file=$PODMAN_TMPDIR/$basename.yaml + cat > $yaml_file <