From 3d0a818bef24e7d78f29f101cb07f57bf5b5f874 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Fri, 5 Nov 2021 11:38:20 -0700 Subject: [PATCH] Quiet the output of wait-for-it (#5775) When wait-for-it is trying to connect and failing, bash emits errors on stderr. This captures those errors and sends them to /dev/null. This also replaces an internal wait_tcp_port function inside entrypoint.sh with a call to wait-for-it.sh. --- test/entrypoint.sh | 24 ++---------------------- test/wait-for-it.sh | 2 +- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/test/entrypoint.sh b/test/entrypoint.sh index 3a03f7ce1..3c6d90a3f 100755 --- a/test/entrypoint.sh +++ b/test/entrypoint.sh @@ -10,29 +10,9 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" rm -f /var/run/rsyslogd.pid service rsyslog start -wait_tcp_port() { - local host="$1" port="$2" - - # see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax. - local max_tries="120" - for n in `seq 1 $max_tries` ; do - if exec 6<>/dev/tcp/$host/$port; then - break - else - echo "$(date) - still trying to connect to $host:$port" - sleep 1 - fi - if [ "$n" -eq "$max_tries" ]; then - echo "unable to connect" - exit 1 - fi - done - exec 6>&- - echo "Connected to $host:$port" -} # make sure we can reach the mysqldb and Redis cluster is done being created. -wait_tcp_port boulder-mysql 3306 -wait_tcp_port 10.33.33.10 4218 +./test/wait-for-it.sh boulder-mysql 3306 +./test/wait-for-it.sh 10.33.33.10 4218 # create the database MYSQL_CONTAINER=1 $DIR/create_db.sh diff --git a/test/wait-for-it.sh b/test/wait-for-it.sh index 8febcbea7..35e79bcd7 100755 --- a/test/wait-for-it.sh +++ b/test/wait-for-it.sh @@ -8,7 +8,7 @@ wait_tcp_port() { # see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax. local max_tries="40" for n in `seq 1 "${max_tries}"` ; do - if exec 6<>/dev/tcp/"${host}"/"${port}"; then + if { exec 6<>/dev/tcp/"${host}"/"${port}" ; } 2>/dev/null ; then break else echo "$(date) - still trying to connect to ${host}:${port}"