From 4d3e714cfdbcf4785893193682da2dcc61b12563 Mon Sep 17 00:00:00 2001 From: Yunxe <72926033+Yunxe@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:23:53 +0800 Subject: [PATCH] Hotfix pipeline and add retry for sqlserver integration test (#711) * make tag for v0.27.0 * add retry * revert tag rc1 --- .../telemetryservice/sqlserver/checkoutput.sh | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/examples/telemetryservice/sqlserver/checkoutput.sh b/examples/telemetryservice/sqlserver/checkoutput.sh index 33fa39068..aea9301a5 100644 --- a/examples/telemetryservice/sqlserver/checkoutput.sh +++ b/examples/telemetryservice/sqlserver/checkoutput.sh @@ -1,18 +1,29 @@ #!bin/bash SQLServerOutput=2 sleep 6 -for i in {1..50} -do - output=$(docker exec sqlserver /opt/mssql-tools/bin/sqlcmd \ - -S localhost -U sa -P Some_Strong_Password \ - -Q "select name from sys.databases" | grep 'Error' | wc -l) - echo $output - if [[ $output -eq 0 ]] - then +MAX_RETRIES=5 +for retry in $(seq 1 $MAX_RETRIES); do + echo "Attempt $retry of $MAX_RETRIES" + + for i in {1..50}; do + output=$(docker exec sqlserver /opt/mssql-tools/bin/sqlcmd \ + -S localhost -U sa -P Some_Strong_Password \ + -Q "select name from sys.databases" | grep 'Error' | wc -l) + echo "Output: $output" + + if [[ $output -eq 0 ]]; then + echo "Database connection successful" + break + elif [[ $i -eq 50 ]]; then + echo "Max retries reached. Exiting script." + exit 1 + else + sleep 5 + fi + done + + if [[ $output -eq 0 ]]; then break - elif [[ $i -eq 50 ]] - then - exit 1 fi done