diff --git a/xyz-hub-test/src/test/resources/mock-servers/localstack/docker-entrypoint-initaws.d/01-create-bucket.sh b/xyz-hub-test/src/test/resources/mock-servers/localstack/docker-entrypoint-initaws.d/01-create-bucket.sh index b3cf839f50..2f459b9ed9 100755 --- a/xyz-hub-test/src/test/resources/mock-servers/localstack/docker-entrypoint-initaws.d/01-create-bucket.sh +++ b/xyz-hub-test/src/test/resources/mock-servers/localstack/docker-entrypoint-initaws.d/01-create-bucket.sh @@ -19,4 +19,25 @@ # License-Filename: LICENSE # -awslocal s3api create-bucket --bucket test-bucket --create-bucket-configuration LocationConstraint=eu-west-1 +check_localstack_health() { + local RETRIES=10 + local RETRY_DELAY=5 + local SERVICE="healthy" + + for ((i=0; i < RETRIES; i++)); do + if awslocal s3api list-buckets >/dev/null 2>&1; then + echo "LocalStack S3 service is ready." + return 0 + else + echo "Waiting for LocalStack S3 service to be ready... (attempt $((i+1))/${RETRIES})" + sleep $RETRY_DELAY + fi + done + + echo "LocalStack S3 service is not ready after ${RETRIES} attempts. Exiting..." + exit 1 +} + +check_localstack_health + +awslocal s3api create-bucket --bucket test-bucket --create-bucket-configuration LocationConstraint=eu-west-1 \ No newline at end of file