Enable fallback to sleep if nc not installed

Fixture test scripts use `nc` to wait for the port to determine
whether a test fixture is up and running. This commit adds a fall
back option to sleep if `nc` is not available - it is not installed
on Jenkins centos worker nodes.

Fixes #11942
This commit is contained in:
Rob Bavey 2020-05-28 17:07:07 -04:00 committed by Robert Bavey
parent b2da4449a5
commit e4a5134760

View file

@ -12,6 +12,14 @@ setup_install_dir() {
}
wait_for_port() {
if command -v nc 2>/dev/null; then
wait_for_port_nc "$@"
else
wait_for_port_sleep "$@"
fi
}
wait_for_port_nc() {
count=$PORT_WAIT_COUNT
port=$1
while ! nc -z localhost $port && [[ $count -ne 0 ]]; do
@ -21,6 +29,12 @@ wait_for_port() {
done
# just in case, one more time
nc -z localhost $port
}
wait_for_port_sleep() {
echo "nc not installed on this machine. Sleeping for 10 seconds"
sleep 10
}
clean_install_dir() {