From 882ee404b40863541f9e0bd49f3ee29a5e47e10c Mon Sep 17 00:00:00 2001 From: Ole Langbehn <ole.langbehn@inoio.de> Date: Wed, 26 Feb 2025 11:54:44 +0100 Subject: [PATCH] fix(CI): improve the wait-for-ssl.sh script about 10-20% of times smoketests were using this script to ensure availability of services, the smoketest failed after the script succeeded. This change improves the script by: * providing an early exit for already deployed services without testing multiple times for success if the first test succeeds * raising the amount of successful checks needed to 25 and sleeping a second after each successful test in order to lower the probability of the service not being available for the smoketest after the script succeeds. --- terraform/environments/scripts/wait-for-ssl.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/terraform/environments/scripts/wait-for-ssl.sh b/terraform/environments/scripts/wait-for-ssl.sh index e130aad..2a53fa6 100755 --- a/terraform/environments/scripts/wait-for-ssl.sh +++ b/terraform/environments/scripts/wait-for-ssl.sh @@ -7,7 +7,7 @@ url="$1" # google has a cdn answering on requests. This cdn takes a while to be fully updated. # Therefore, we don't return on first success, but on a number of consecutive successes. -number_of_consecutive_successful_tries_needed=10 +number_of_consecutive_successful_tries_needed=25 number_of_consecutive_successful_tries_achieved=0 [ -z "$url" ] && echo "missing url as first param" && exit 1 @@ -17,10 +17,21 @@ echo -n "Checking if SSL certificate for $url is installed: " # storage for the return value of the curl command retval=0 +# early break on success (no need to wait on existing deployments) +set +e +curl -sSLIm 10 "$url" > /dev/null 2>& 1 +retval=$? +set -e +if [ $retval -eq 0 ]; then + echo "success on first try, not checking further" + exit 0 +fi + + # shellcheck disable=SC2034 for i in {1..2500}; do set +e - out=$(curl -sSLI "$url" 2>&1) + out=$(curl -sSLIm 10 "$url" 2>& 1) retval=$? set -e # shellcheck disable=SC2181 @@ -31,6 +42,7 @@ for i in {1..2500}; do echo "test successful after $i total tries" exit 0 fi + sleep 1 else echo -n "." number_of_consecutive_successful_tries_achieved=0 -- GitLab