From a5698575a234ab14b95c529f7e14e1d659390f64 Mon Sep 17 00:00:00 2001 From: Anton Agestam Date: Wed, 3 May 2023 15:29:53 +0200 Subject: [PATCH] fix: Make smoke-tests retry on failure --- .github/workflows/container-smoke-test.yml | 17 ++------------- bin/smoke-test-registry.sh | 25 ++++++++++++++++++++++ bin/smoke-test-rest.sh | 20 +++++++++++++++++ 3 files changed, 47 insertions(+), 15 deletions(-) create mode 100755 bin/smoke-test-registry.sh create mode 100755 bin/smoke-test-rest.sh diff --git a/.github/workflows/container-smoke-test.yml b/.github/workflows/container-smoke-test.yml index c0dcf877a..484172e23 100644 --- a/.github/workflows/container-smoke-test.yml +++ b/.github/workflows/container-smoke-test.yml @@ -18,20 +18,7 @@ jobs: run: docker compose --file=container/compose.yml up --build --wait --detach - name: Smoke test registry - run: | - response=$( - curl --silent --verbose --fail --request POST \ - --header 'Content-Type: application/vnd.schemaregistry.v1+json' \ - --data '{"schema": "{\"type\": \"record\", \"name\": \"Obj\", \"fields\":[{\"name\": \"age\", \"type\": \"int\"}]}"}' \ - http://localhost:8081/subjects/test-key/versions - ) - echo "$response" - [[ $response == '{"id":1}' ]] || exit 1 - echo "Ok!" + run: bin/smoke-test-registry.sh - name: Smoke test REST proxy - run: | - response=$(curl --silent --verbose --fail http://localhost:8082/topics) - echo "$response" - [[ $response == '["_schemas","__consumer_offsets"]' ]] || exit 1 - echo "Ok!" + run: bin/smoke-test-rest.sh diff --git a/bin/smoke-test-registry.sh b/bin/smoke-test-registry.sh new file mode 100755 index 000000000..71f4e4fc7 --- /dev/null +++ b/bin/smoke-test-registry.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +retries=5 + +for ((i = 0; i <= retries; i++)); do + response=$( + curl --silent --verbose --fail --request POST \ + --header 'Content-Type: application/vnd.schemaregistry.v1+json' \ + --data '{"schema": "{\"type\": \"record\", \"name\": \"Obj\", \"fields\":[{\"name\": \"age\", \"type\": \"int\"}]}"}' \ + http://localhost:8081/subjects/test-key/versions + ) + + if [[ $response == '{"id":1}' ]]; then + echo "Ok!" + break + fi + + if ((i == retries)); then + echo "Still failing after $i retries, giving up." + exit 1 + fi + + echo "Smoke test failed, retrying in 5 seconds ..." + sleep 5 +done diff --git a/bin/smoke-test-rest.sh b/bin/smoke-test-rest.sh new file mode 100755 index 000000000..665ab08e5 --- /dev/null +++ b/bin/smoke-test-rest.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +retries=5 + +for ((i = 0; i <= retries; i++)); do + response=$(curl --silent --verbose --fail http://localhost:8082/topics) + + if [[ $response == '["_schemas","__consumer_offsets"]' ]]; then + echo "Ok!" + break + fi + + if ((i == retries)); then + echo "Still failing after $i retries, giving up." + exit 1 + fi + + echo "Smoke test failed, retrying in 5 seconds ..." + sleep 5 +done