From 8a271dc1e8fefa1fbb656944d2d3566c242a59cb Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Fri, 17 Mar 2023 14:32:01 +0100 Subject: [PATCH] Print diagnostic messages to stderr when testing docker image --- core/docker/container-test.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/docker/container-test.sh b/core/docker/container-test.sh index 1ff5f4ec2fd3..388c58d6bc26 100644 --- a/core/docker/container-test.sh +++ b/core/docker/container-test.sh @@ -22,7 +22,7 @@ function test_trino_starts { I=0 until docker inspect "${CONTAINER_ID}" --format "{{json .State.Health.Status }}" | grep -q '"healthy"'; do if [[ $((I++)) -ge ${QUERY_RETRIES} ]]; then - echo "🚨 Too many retries waiting for Trino to start" + echo "🚨 Too many retries waiting for Trino to start" >&2 echo "Logs from ${CONTAINER_ID} follow..." docker logs "${CONTAINER_ID}" break @@ -30,15 +30,19 @@ function test_trino_starts { sleep ${QUERY_PERIOD} done if ! RESULT=$(docker exec "${CONTAINER_ID}" trino --execute "SELECT 'success'" 2>/dev/null); then - echo "🚨 Failed to execute a query after Trino container started" + echo "🚨 Failed to execute a query after Trino container started" >&2 fi set -e cleanup trap - EXIT - # Return proper exit code. - [[ ${RESULT} == '"success"' ]] + if ! [[ ${RESULT} == '"success"' ]]; then + echo "🚨 Test query didn't return expected result (\"success\")" >&2 + return 1 + fi + + return 0 } function test_javahome {