mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 13:37:30 +00:00
Check whether the infra dependencies are ready before E2E test (#870)
Fixes #848
This commit is contained in:
parent
567950d5f0
commit
06b2e564e6
2 changed files with 59 additions and 0 deletions
58
.github/scripts/check-infra-dependencies.sh
vendored
Executable file
58
.github/scripts/check-infra-dependencies.sh
vendored
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eou pipefail
|
||||
|
||||
usage() {
|
||||
echo "${0} <INFRA_NAME> 'CHECK WHETHER THE SPECIFIED INFRA DEPENDENCE IS READY"
|
||||
}
|
||||
|
||||
if [ "$#" -ne 1 ] || [ -z "$1" ]; then
|
||||
echo "Error: Missing the infra name which needs to check"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# infra is one of 'mysql', 'redis', 'mailhog', 'saml_idp'.
|
||||
# use 'all' to check all these infras.
|
||||
INFRA_NAME=${1}
|
||||
INFRAS=()
|
||||
RETRYNUM=10
|
||||
|
||||
if [ "$INFRA_NAME" == "all" ]; then
|
||||
INFRAS=("mysql" "redis" "mailhog" "saml_idp")
|
||||
else
|
||||
INFRAS=("$INFRA_NAME")
|
||||
fi
|
||||
|
||||
checkInfraFun() {
|
||||
INFRA=$1
|
||||
echo "check whether the $INFRA is ready"
|
||||
if [ "$INFRA" == "mysql" ]; then
|
||||
! docker-compose exec -T mysql_test bash -c 'echo "SHOW DATABASES;" | mysql -uroot -ptoor' && return 1
|
||||
echo "mysql is ready!"
|
||||
elif [ "$INFRA" == "redis" ]; then
|
||||
! docker-compose exec -T redis bash -c "redis-cli ping" && return 1
|
||||
echo "redis is ready!"
|
||||
elif [ "$INFRA" == "mailhog" ]; then
|
||||
echo "TODO"
|
||||
echo "mailhog is ready!"
|
||||
elif [ "$INFRA" == "saml_idp" ]; then
|
||||
echo "TODO"
|
||||
echo "saml_idp is ready!"
|
||||
fi
|
||||
}
|
||||
|
||||
for INFRA in ${INFRAS[@]}; do
|
||||
n=0
|
||||
success=false
|
||||
until [ "$n" -ge $RETRYNUM ]; do
|
||||
checkInfraFun $INFRA && success=true && break
|
||||
n=$((n+1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ ! $success ]; then
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
|
|
@ -66,6 +66,7 @@ jobs:
|
|||
|
||||
- name: Run E2E Tests
|
||||
run: |
|
||||
.github/scripts/check-infra-dependencies.sh all
|
||||
make e2e-reset-db
|
||||
make e2e-serve &
|
||||
sleep 3
|
||||
|
|
|
|||
Loading…
Reference in a new issue