Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MalinAhlberg committed Sep 10, 2024
1 parent 93ad7bc commit b123dbb
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/integration/tests/sda/09_healthchecks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
set -e

# install tools if missing
for t in curl jq ; do
if [ ! "$(command -v $t)" ]; then
if [ "$(id -u)" != 0 ]; then
echo "$t is missing, unable to install it"
exit 1
fi

apt-get -o DPkg::Lock::Timeout=60 update >/dev/null
apt-get -o DPkg::Lock::Timeout=60 install -y "$t" >/dev/null
fi
done


# Test the s3inbox's healthchecks, GET /health and HEAD /
token="$(curl -s http://oidc:8080/tokens | jq -r '.[0]')"

response="$(curl -s -k -LI 'http://s3inbox:8000' -o /dev/null -w '%{http_code}\n' -H 'Authorization: Bearer $token')"
if [ "$response" != "200" ]; then
echo "Bad health response from HEAD /, expected 200 got: $response"
exit 1
fi

response="$(curl -s -k -LI 'http://s3inbox:8000/health' -o /dev/null -w '%{http_code}\n' -H 'Authorization: Bearer $token')"
if [ "$response" != "200" ]; then
echo "Bad health response from /health, expected 200 got: $response"
exit 1
fi

echo "Healthcheck tests completed successfully"

0 comments on commit b123dbb

Please sign in to comment.