Skip to content

Commit

Permalink
testdrive: exit with non-zero code on timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
RTXUX committed Apr 7, 2024
1 parent 4dcb611 commit 4c5dc61
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions testdrive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SUFFIX="$RANDOM"

cleanup() {
docker stop "gitlab-${SUFFIX}" || kill -TERM "$(jobs -p)" || true
docker stop "gitlab-${SUFFIX}" || kill -TERM "$(jobs -pr)" || true
docker stop "gitlab-redis-${SUFFIX}" || true
docker stop "gitlab-postgresql-${SUFFIX}" || true
}
Expand Down Expand Up @@ -36,7 +36,7 @@ docker run --rm --name "gitlab-${SUFFIX}" \
"$IMAGE_NAME":"$TAG" &

check() {
local url="http://localhost:10080"
local url="http://localhost:10081"
status_code=$(curl --write-out '%{http_code}' --silent --output /dev/null "$url")
# Check if the status code is not in the success range (200-399)
if [[ $status_code -lt 200 || $status_code -gt 399 ]]; then
Expand All @@ -55,6 +55,6 @@ RETRIES="48"
RETRIED=0
WAIT_TIME="5s"

until check || [[ "$((RETRIED++))" == "${RETRIES}" ]]; do
until check || { [[ "$((RETRIED++))" == "${RETRIES}" ]] && exit 1; } ; do
sleep "${WAIT_TIME}"
done

0 comments on commit 4c5dc61

Please sign in to comment.