Skip to content

Commit

Permalink
More log-flake work
Browse files Browse the repository at this point in the history
[backport containers#16437]

It looks like containers#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 <[email protected]>
  • Loading branch information
edsantiago committed Nov 16, 2022
1 parent 29c4455 commit 246cc18
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/e2e/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions test/system/200-pod.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 7 additions & 0 deletions test/system/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 246cc18

Please sign in to comment.