summaryrefslogtreecommitdiff
path: root/test/system/helpers.bash
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-07-20 05:04:35 -0400
committerGitHub <noreply@github.com>2021-07-20 05:04:35 -0400
commit36e47768e6b2b2a78b85535695aa9e7bb7f9c3a8 (patch)
tree4cf3da693bc55f14c900a68ac51c40052bdace0a /test/system/helpers.bash
parentcea2f38e2160a62db122b8d9982e7ec1b5ac8de0 (diff)
parent80e807a1913411b6829a41ef47de285b38e27b66 (diff)
downloadpodman-36e47768e6b2b2a78b85535695aa9e7bb7f9c3a8.tar.gz
podman-36e47768e6b2b2a78b85535695aa9e7bb7f9c3a8.tar.bz2
podman-36e47768e6b2b2a78b85535695aa9e7bb7f9c3a8.zip
Merge pull request #10982 from cevich/fix_listen_flake
Flake Fix: Wait before connecting to container port
Diffstat (limited to 'test/system/helpers.bash')
-rw-r--r--test/system/helpers.bash18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index 1859a2168..02fd7252c 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -278,6 +278,24 @@ function wait_for_ready {
wait_for_output 'READY' "$@"
}
+###################
+# wait_for_port # Returns once port is available on host
+###################
+function wait_for_port() {
+ local host=$1 # Probably "localhost"
+ local port=$2 # Numeric port
+ local _timeout=${3:-5} # Optional; default to 5 seconds
+
+ # Wait
+ while [ $_timeout -gt 0 ]; do
+ { exec 3<> /dev/tcp/$host/$port; } &>/dev/null && return
+ sleep 1
+ _timeout=$(( $_timeout - 1 ))
+ done
+
+ die "Timed out waiting for $host:$port"
+}
+
# END podman helpers
###############################################################################
# BEGIN miscellaneous tools