From f58193dbebef99cb53a9562f6740645bdb6825ff Mon Sep 17 00:00:00 2001 From: Jakub Rusz Date: Thu, 5 Sep 2024 12:46:17 +0200 Subject: [PATCH] test/cases: implement retry for ssh connection in api test Fixing this by implementing a retry for the whole ssh connection attempt. --- test/cases/api/common/common.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/cases/api/common/common.sh b/test/cases/api/common/common.sh index 5b9665cda3..e4f3514532 100644 --- a/test/cases/api/common/common.sh +++ b/test/cases/api/common/common.sh @@ -19,6 +19,20 @@ function _instanceCheck() { echo "✔️ Instance checking" local _ssh="$1" + # Retry loop to wait for instance to be ready + # This is here especially because of gcp test + RETRIES=10 + for i in $(seq 1 $RETRIES); do + echo "Attempt $i of $RETRIES: Checking instance status..." + if eval "$_ssh true"; then + echo "Instance is up and ready!" + break + else + echo "Instance is still booting or SSH key not propagated, retrying in 30 seconds..." + sleep 30 + fi + done + # Check if postgres is installed $_ssh rpm -q postgresql dummy