From 54641f5f761dff9f2392548f275e41953352796e Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 18 Mar 2022 16:56:09 +0100 Subject: 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 --- test/compose/slirp4netns_opts/tests.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/compose') diff --git a/test/compose/slirp4netns_opts/tests.sh b/test/compose/slirp4netns_opts/tests.sh index 1efce45c4..cfa84e1e4 100644 --- a/test/compose/slirp4netns_opts/tests.sh +++ b/test/compose/slirp4netns_opts/tests.sh @@ -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" -- cgit v1.2.3-54-g00ecf