From 74f499ba8cbbdf160847e57be0a87edf4cc5e337 Mon Sep 17 00:00:00 2001 From: Jan Was Date: Thu, 24 Feb 2022 10:33:17 +0100 Subject: [PATCH] Format container-test.sh script and add proper quotes --- core/docker/container-test.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/core/docker/container-test.sh b/core/docker/container-test.sh index ccb5a14877fb..256f585b0e6b 100644 --- a/core/docker/container-test.sh +++ b/core/docker/container-test.sh @@ -1,5 +1,7 @@ +#!/usr/bin/env bash + function cleanup { - if [[ ! -z ${CONTAINER_ID:-} ]]; then + if [[ -n ${CONTAINER_ID:-} ]]; then docker rm -f "${CONTAINER_ID}" fi } @@ -14,12 +16,11 @@ function test_trino_starts { local CONTAINER_NAME=$1 local PLATFORM=$2 # We aren't passing --rm here to make sure container is available for inspection in case of failures - CONTAINER_ID=$(docker run -d --platform ${PLATFORM} "${CONTAINER_NAME}") + CONTAINER_ID=$(docker run -d --platform "${PLATFORM}" "${CONTAINER_NAME}") set +e I=0 - until RESULT=$(docker exec "${CONTAINER_ID}" trino --execute "SELECT 'success'" 2>/dev/null) - do + until RESULT=$(docker exec "${CONTAINER_ID}" trino --execute "SELECT 'success'" 2>/dev/null); do if [[ $((I++)) -ge ${QUERY_RETRIES} ]]; then echo "🚨 Too many retries waiting for Trino to start" echo "Logs from ${CONTAINER_ID} follow..." @@ -41,17 +42,17 @@ function test_javahome { local CONTAINER_NAME=$1 local PLATFORM=$2 # Check if JAVA_HOME works - docker run --rm --platform ${PLATFORM} "${CONTAINER_NAME}" \ - /bin/bash -c '$JAVA_HOME/bin/java -version' &> /dev/null + docker run --rm --platform "${PLATFORM}" "${CONTAINER_NAME}" \ + /bin/bash -c '$JAVA_HOME/bin/java -version' &>/dev/null - [[ "$?" == "0" ]] + [[ $? == "0" ]] } function test_container { local CONTAINER_NAME=$1 local PLATFORM=$2 echo "🐢 Validating ${CONTAINER_NAME} on platform ${PLATFORM}..." - test_javahome ${CONTAINER_NAME} ${PLATFORM} - test_trino_starts ${CONTAINER_NAME} ${PLATFORM} + test_javahome "${CONTAINER_NAME}" "${PLATFORM}" + test_trino_starts "${CONTAINER_NAME}" "${PLATFORM}" echo "🎉 Validated ${CONTAINER_NAME} on platform ${PLATFORM}" }