Skip to content

Commit

Permalink
add smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
hillalex committed Sep 6, 2024
1 parent 54b5f9a commit d0d42ef
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docker/smoke-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

HERE=$(realpath "$(dirname $0)")
. $HERE/common

wait_for()
{
echo "waiting up to $TIMEOUT seconds for app"
start_ts=$(date +%s)
for i in $(seq $TIMEOUT); do
result="$(curl --write-out %{http_code} --silent --output /dev/null http://localhost:8888 2>/dev/null)"
if [[ $result -eq "200" ]]; then
end_ts=$(date +%s)
echo "App available after $((end_ts - start_ts)) seconds"
break
fi
sleep 1
echo "...still waiting"
done
return $result
}

docker run -d -p 8888:8888 $DOCKER_COMMIT_TAG

# The variable expansion below is 60s by default, or the argument provided
# to this script
TIMEOUT="${1:-60}"
wait_for
RESULT=$?
if [[ $RESULT -ne 200 ]]; then
echo "App did not become available in time"
exit 1
fi
exit 0

0 comments on commit d0d42ef

Please sign in to comment.