fix compose test flake

Reading from the nc socket is flaky because docker-compose only starts
the containers. We cannot know at this point if the container did already
send the message. Give the container 5 seconds time to send the message
to prevent flakes.

This happened rarely with compose v1 but it looks like it will happen a
lot more with compose v2.

Example failure log:
https://storage.googleapis.com/cirrus-ci-6707778565701632-fcae48/artifacts/containers/podman/6567556239589376/html/compose_v2-podman-fedora-35-rootless-host.log.html

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2022-03-18 16:56:09 +01:00
parent 3853ef9b59
commit 54641f5f76

View File

@ -3,4 +3,18 @@
output="$(cat $OUTFILE)"
expected="teststring"
# Reading from the nc socket is flaky because docker-compose only starts
# the containers. We cannot know at this point if the container did already
# send the message. Give the container 5 seconds time to send the message
# to prevent flakes.
local _timeout=5
while [ $_timeout -gt 0 ]; do
if [ -n "$output" ]; then
break
fi
sleep 1
_timeout=$(($_timeout - 1))
output="$(cat $OUTFILE)"
done
is "$output" "$expected" "$testname : nc received teststring"