test: add wait script/build data

This commit is contained in:
Alessandro Pezzè 2021-05-27 20:38:25 +02:00
parent fb804babeb
commit 734aa0a9ad
2 changed files with 29 additions and 2 deletions

View file

@ -1,4 +1,4 @@
name: Create Cluster
name: kustomize
on:
push:
@ -21,4 +21,8 @@ jobs:
kubectl cluster-info
kubectl get storageclass standard
cp Resources/k8s/kustomize/secrets/postgres.env.sample Resources/k8s/kustomize/secrets/postgres.env
kubectl apply -k Resources/k8s/kustomize/
make kustomize-apply
bash Resources/scripts/wait.sh http://localhost/api/v2/
make k8s-migrate
make k8s-build-db
bash Resources/scripts/wait.sh http://localhost/api/v2/pal-park-area/5/

23
Resources/scripts/wait.sh Normal file
View file

@ -0,0 +1,23 @@
#!/bin/bash
wait_for_http() {
local url="$1"
local max_seconds=1000
local end_time=$(( $(date +%s) + max_seconds ))
local success='false'
echo "Waiting for $url"
while [ "$(date +%s)" -lt "$end_time" ]; do # Loop until interval has elapsed.
sleep 2
if [ "$(curl -s -o /dev/null -L -w '%{http_code}' "$url")" == "200" ]; then
success='true'
break
fi
done
if [ "$success" = 'true' ]; then
exit 0
else
exit 1
fi
}
wait_for_http "${1:-http://localhost/api/v2/}"