From 42e4609faf2adc4c6c81a1fb700b064b28497781 Mon Sep 17 00:00:00 2001
From: Paul Holzinger <paul.holzinger@web.de>
Date: Wed, 7 Apr 2021 11:41:15 +0200
Subject: [PATCH] Fix flaking rootless compose test

The compose port test is flaking with an empty curl result. The curl retry
does not work properly. Given the the tests never expect an empty result
lets just wait one second and retry again.
Unfortunately there is no way for me to actually verify if this will fix
the flake.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
---
 test/compose/test-compose | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/compose/test-compose b/test/compose/test-compose
index 704c71a9fa..7693041acf 100755
--- a/test/compose/test-compose
+++ b/test/compose/test-compose
@@ -163,7 +163,13 @@ function test_port() {
     local op="$2"                # '=' or '~'
     local expect="$3"            # what to expect from curl output
 
-    local actual=$(curl --retry 10 --retry-all-errors -s http://127.0.0.1:$port/)
+    local actual=$(curl --retry 3 --retry-all-errors -s http://127.0.0.1:$port/)
+    # The test is flaking with an empty result. The curl retry doesn't solve this.
+    # If the result is empty sleep one second and try again.
+    if [[ "$actual" == "" ]]; then
+        sleep 1
+        local actual=$(curl --retry 3 --retry-all-errors -s http://127.0.0.1:$port/)
+    fi
     local curl_rc=$?
     if [ $curl_rc -ne 0 ]; then
         _show_ok 0 "$testname - curl failed with status $curl_rc"