Skip to content

Commit

Permalink
More verbosity in order to debug why health_check apparently don't run
Browse files Browse the repository at this point in the history
  • Loading branch information
apotek committed Jan 12, 2024
1 parent e586068 commit cf791d4
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ setup() {
export DDEV_NON_INTERACTIVE=true
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 || true
cd "${TESTDIR}"
ddev config --project-name=${PROJNAME}
# @todo Work to get multiple database server types to be installable here.
# ddev doesn't natively support more than one database per environment, so
# perhaps some hacking will be necessary so we can test support for other
# server types down the road.
ddev config --project-name=${PROJNAME} --database=mariadb:10.4
ddev start -y >/dev/null
}

health_checks() {
# Do something useful here that verifies the add-on
# ddev exec "curl -s elasticsearch:9200" | grep "${PROJNAME}-elasticsearch"
state=$(ddev mysql -u root -proot -e "show variables like 'general_log';" | grep general_log | cut -f 2)
echo "# Captured state is $state"
case "$state" in
OFF)
echo "# Turning dblog on..."
ddev dblog on
on=$(ddev mysql -u root -proot -e "show variables like 'general_log';" | grep general_log | cut -f 2)
if [ "$on" != "ON"]; then
Expand All @@ -25,6 +31,7 @@ health_checks() {
fi
;;
ON)
echo "# Turning dblog off..."
ddev dblog off
off=$(ddev mysql -u root -proot -e "show variables like 'general_log';" | grep general_log | cut -f 2)
if [ "$off" != "OFF"]; then
Expand All @@ -33,7 +40,7 @@ health_checks() {
fi
;;
*)
echo "Could not determine log state"
echo "# Could not determine log state"
failed_db_log_test
;;
esac
Expand All @@ -52,6 +59,7 @@ teardown() {
echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${DIR}
ddev restart
echo "# Running health checks..."
health_checks
}

Expand All @@ -60,7 +68,8 @@ teardown() {
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
echo "# ddev get chromatichq/ddev-dblog with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get chromatichq/ddev-dblog
ddev restart >/dev/null
ddev restart #>/dev/null
echo "# Running health checks..."
health_checks
}

0 comments on commit cf791d4

Please sign in to comment.