2018-12-09 00:55:12 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
set -o pipefail
|
|
|
|
|
2018-12-15 21:58:29 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# 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
|
2018-12-15 21:58:29 +00:00
|
|
|
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
|
2018-12-10 19:21:44 +00:00
|
|
|
sleep 1
|
2018-12-15 21:58:29 +00:00
|
|
|
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
|
2018-12-10 19:21:44 +00:00
|
|
|
sleep 1
|
2018-12-15 21:58:29 +00:00
|
|
|
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"
|
2018-12-15 21:58:29 +00:00
|
|
|
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
|
2018-12-15 21:58:29 +00:00
|
|
|
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
|
2018-12-10 19:21:44 +00:00
|
|
|
sleep 1
|
2018-12-15 21:58:29 +00:00
|
|
|
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
|
2018-12-10 19:21:44 +00:00
|
|
|
sleep 1
|
2018-12-15 21:58:29 +00:00
|
|
|
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"
|
2018-12-15 21:58:29 +00:00
|
|
|
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
|