From 246cc18746669727d9e680b3a3fb4362d320868e Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Mon, 7 Nov 2022 14:21:38 -0700 Subject: [PATCH] More log-flake work [backport #16437] It looks like #16132 was my fault: a missing 'wait' for a container to exit. Let's see if this fixes the flake. And, while poking through flake logs, I found another missing wait. And... in wait_for_output(), address a potential race. Signed-off-by: Ed Santiago --- test/e2e/logs_test.go | 6 +++++- test/system/200-pod.bats | 1 + test/system/helpers.bash | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index 93ef54c3a1..fe29b218da 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -65,7 +65,11 @@ var _ = Describe("Podman logs", func() { Expect(logc).To(Exit(0)) cid := logc.OutputToString() - results := podmanTest.Podman([]string{"logs", cid}) + results := podmanTest.Podman([]string{"wait", cid}) + results.WaitWithDefaultTimeout() + Expect(results).To(Exit(0)) + + results = podmanTest.Podman([]string{"logs", cid}) results.WaitWithDefaultTimeout() Expect(results).To(Exit(0)) Expect(results.OutputToStringArray()).To(HaveLen(3)) diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index 8ece6e476f..c1401c0acf 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -303,6 +303,7 @@ EOF echo "$teststring" | nc 127.0.0.1 $port_out # Confirm that the container log output is the string we sent it. + run_podman wait $cid run_podman logs $cid is "$output" "$teststring" "test string received on container" diff --git a/test/system/helpers.bash b/test/system/helpers.bash index 4bc1ba78c1..4b1cec39be 100644 --- a/test/system/helpers.bash +++ b/test/system/helpers.bash @@ -257,6 +257,13 @@ function wait_for_output { if [ $output != "true" ]; then run_podman inspect --format '{{.State.ExitCode}}' $cid exitcode=$output + + # One last chance: maybe the container exited just after logs cmd + run_podman logs $cid + if expr "$logs" : ".*$expect" >/dev/null; then + return + fi + die "Container exited (status: $exitcode) before we saw '$expect': $logs" fi