devilbox/.tests/intra-tests/homepage.sh

76 lines
1.8 KiB
Bash
Raw Normal View History

2018-12-09 00:55:12 +00:00
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
#
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
#
2018-12-09 00:55:12 +00:00
NUM_OK="20"
NUM_ERR="0"
###
### dvlbox-ok
###
printf "[TEST] dvlbox-ok"
# 1st Try
TEST_OK="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true )"
2018-12-09 00:55:12 +00:00
if [ "${TEST_OK}" != "${NUM_OK}" ]; then
# 2nd Try
sleep 1
TEST_OK="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true )"
2018-12-09 00:55:12 +00:00
if [ "${TEST_OK}" != "${NUM_OK}" ]; then
# 3rd Try
sleep 1
TEST_OK="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true )"
2018-12-09 00:55:12 +00:00
if [ "${TEST_OK}" != "${NUM_OK}" ]; then
printf "\r[FAIL] dvlbox-ok\n"
curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true
2018-12-09 00:55:12 +00:00
exit 1
else
printf "\r[OK] dvlbox-ok (3 rounds)\n"
fi
else
printf "\r[OK] dvlbox-ok (2 rounds)\n"
fi
else
printf "\r[OK] dvlbox-ok (1 round)\n"
fi
###
### dvlbox-err
###
printf "[TEST] dvlbox-err"
# 1st Try
TEST_ERR="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true )"
2018-12-09 00:55:12 +00:00
if [ "${TEST_ERR}" != "${NUM_ERR}" ]; then
# 2nd Try
sleep 1
TEST_ERR="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true )"
2018-12-09 00:55:12 +00:00
if [ "${TEST_ERR}" != "${NUM_ERR}" ]; then
# 3rd Try
sleep 1
TEST_ERR="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true )"
2018-12-09 00:55:12 +00:00
if [ "${TEST_ERR}" != "${NUM_ERR}" ]; then
printf "\r[FAIL] dvlbox-err\n"
curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true
2018-12-09 00:55:12 +00:00
exit 1
else
printf "\r[OK] dvlbox-err (3 rounds)\n"
fi
else
printf "\r[OK] dvlbox-err (2 rounds)\n"
fi
else
printf "\r[OK] dvlbox-err (1 round)\n"
fi