diff --git a/.tests/intra-tests/homepage.sh b/.tests/intra-tests/homepage.sh index f029a7ac..67a6192d 100755 --- a/.tests/intra-tests/homepage.sh +++ b/.tests/intra-tests/homepage.sh @@ -4,6 +4,13 @@ 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 +# + + NUM_OK="20" NUM_ERR="0" @@ -14,18 +21,18 @@ NUM_ERR="0" printf "[TEST] dvlbox-ok" # 1st Try -TEST_OK="$( curl -sS localhost/index.php | grep -c 'dvlbox-ok' || true )" +TEST_OK="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true )" if [ "${TEST_OK}" != "${NUM_OK}" ]; then # 2nd Try sleep 1 - TEST_OK="$( curl -sS localhost/index.php | grep -c 'dvlbox-ok' || true )" + TEST_OK="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true )" if [ "${TEST_OK}" != "${NUM_OK}" ]; then # 3rd Try sleep 1 - TEST_OK="$( curl -sS localhost/index.php | grep -c 'dvlbox-ok' || true )" + TEST_OK="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true )" if [ "${TEST_OK}" != "${NUM_OK}" ]; then printf "\r[FAIL] dvlbox-ok\n" - curl -sS localhost/index.php | grep -c 'dvlbox-ok' || true + curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-ok' || true exit 1 else printf "\r[OK] dvlbox-ok (3 rounds)\n" @@ -44,18 +51,18 @@ fi printf "[TEST] dvlbox-err" # 1st Try -TEST_ERR="$( curl -sS localhost/index.php | grep -c 'dvlbox-err' || true )" +TEST_ERR="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true )" if [ "${TEST_ERR}" != "${NUM_ERR}" ]; then # 2nd Try sleep 1 - TEST_ERR="$( curl -sS localhost/index.php | grep -c 'dvlbox-err' || true )" + TEST_ERR="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true )" if [ "${TEST_ERR}" != "${NUM_ERR}" ]; then # 3rd Try sleep 1 - TEST_ERR="$( curl -sS localhost/index.php | grep -c 'dvlbox-err' || true )" + TEST_ERR="$( curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true )" if [ "${TEST_ERR}" != "${NUM_ERR}" ]; then printf "\r[FAIL] dvlbox-err\n" - curl -sS localhost/index.php | grep -c 'dvlbox-err' || true + curl -sS localhost/index.php | tac | tac | grep -c 'dvlbox-err' || true exit 1 else printf "\r[OK] dvlbox-err (3 rounds)\n" diff --git a/.tests/intra-tests/memcached.sh b/.tests/intra-tests/memcached.sh index 4196e9eb..28f98b38 100755 --- a/.tests/intra-tests/memcached.sh +++ b/.tests/intra-tests/memcached.sh @@ -5,13 +5,19 @@ 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 +# + + printf "[TEST] devilbox-version key in Memcached" # 1st Try -if ! curl -sS localhost/db_memcd.php | grep -q 'devilbox-version'; then +if ! curl -sS localhost/db_memcd.php | tac | tac | grep -q 'devilbox-version'; then sleep 1 - if ! curl -sS localhost/db_memcd.php | grep -q 'devilbox-version'; then + if ! curl -sS localhost/db_memcd.php | tac | tac | grep -q 'devilbox-version'; then sleep 1 - if ! curl -sS localhost/db_memcd.php | grep -q 'devilbox-version'; then + if ! curl -sS localhost/db_memcd.php | tac | tac | grep -q 'devilbox-version'; then printf "\r[FAIL] devilbox-version key in Memcached\n" curl -sS localhost/db_memcd.php || true exit 1 diff --git a/.tests/intra-tests/redis.sh b/.tests/intra-tests/redis.sh index 4ce521a5..57445340 100755 --- a/.tests/intra-tests/redis.sh +++ b/.tests/intra-tests/redis.sh @@ -4,14 +4,19 @@ 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 +# + printf "[TEST] devilbox-version key in Redis" # 1st Try -if ! curl -sS localhost/db_redis.php | grep -q 'devilbox-version'; then +if ! curl -sS localhost/db_redis.php | tac | tac | grep -q 'devilbox-version'; then sleep 1 - if ! curl -sS localhost/db_redis.php | grep -q 'devilbox-version'; then + if ! curl -sS localhost/db_redis.php | tac | tac | grep -q 'devilbox-version'; then sleep 1 - if ! curl -sS localhost/db_redis.php | grep -q 'devilbox-version'; then + if ! curl -sS localhost/db_redis.php | tac | tac | grep -q 'devilbox-version'; then printf "\r[FAIL] devilbox-version key in Redis\n" curl -sS localhost/db_redis.php || true exit 1 diff --git a/.tests/intra-tests/vendor-adminer.sh b/.tests/intra-tests/vendor-adminer.sh index 9ee02783..0dd6cfe1 100755 --- a/.tests/intra-tests/vendor-adminer.sh +++ b/.tests/intra-tests/vendor-adminer.sh @@ -5,21 +5,27 @@ 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 +# + + ### ### Retrieve URL for current Adminer version. ### printf "[TEST] Retrieve Adminer URL" # 1st Try -if ! URL="$( curl -sS localhost/index.php | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" )"; then +if ! URL="$( curl -sS localhost/index.php | tac | tac | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" )"; then # 2nd Try sleep 1 - if ! URL="$( curl -sS localhost/index.php | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" )"; then + if ! URL="$( curl -sS localhost/index.php | tac | tac | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" )"; then # 3rd Try sleep 1 - if ! URL="$( curl -sS localhost/index.php | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" )"; then + if ! URL="$( curl -sS localhost/index.php | tac | tac | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" )"; then printf "\r[FAILED] Retrieve Adminer URL\n" - curl -sS localhost/index.php | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" || true + curl -sS localhost/index.php | tac | tac | grep -Eo "/vendor/adminer-[.0-9]+-en\.php" || true exit 1 else printf "\r[OK] Retrieve Adminer URL (3 rounds): ${URL}\n" @@ -38,13 +44,13 @@ fi printf "[TEST] Fetch ${URL}" # 1st Try -if ! curl -sS localhost${URL} | grep -Eiq "Login.+Adminer"; then +if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "Login.+Adminer"; then # 2nd Try sleep 1 - if ! curl -sS localhost${URL} | grep -Eiq "Login.+Adminer"; then + if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "Login.+Adminer"; then # 3rd Try sleep 1 - if ! curl -sS localhost${URL} | grep -Eiq "Login.+Adminer"; then + if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "Login.+Adminer"; then printf "\r[FAIL] Fetch ${URL}\n" curl -sS localhost${URL} || true curl -sSI localhost${URL} || true @@ -66,13 +72,13 @@ fi printf "[TEST] Adminer MySQL login" # 1st Try -if ! curl -sS "localhost${URL}?server=127.0.0.1&username=root" | grep -Eiq "Database.+Collation.+Tables"; then +if ! curl -sS "localhost${URL}?server=127.0.0.1&username=root" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then # 2nd Try sleep 1 - if ! curl -sS "localhost${URL}?server=127.0.0.1&username=root" | grep -Eiq "Database.+Collation.+Tables"; then + if ! curl -sS "localhost${URL}?server=127.0.0.1&username=root" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then # 3rd Try sleep 1 - if ! curl -sS "localhost${URL}?server=127.0.0.1&username=root" | grep -Eiq "Database.+Collation.+Tables"; then + if ! curl -sS "localhost${URL}?server=127.0.0.1&username=root" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then printf "\r[FAIL] Adminer MySQL login\n" curl -sS "localhost${URL}?server=127.0.0.1&username=root" || true curl -sSI "localhost${URL}?server=127.0.0.1&username=root" || true @@ -94,13 +100,13 @@ fi printf "[TEST] Adminer PgSQL login" # 1st Try -if ! curl -sS "localhost${URL}?pgsql=127.0.0.1&username=postgres" | grep -Eiq "Database.+Collation.+Tables"; then +if ! curl -sS "localhost${URL}?pgsql=127.0.0.1&username=postgres" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then # 2nd Try sleep 1 - if ! curl -sS "localhost${URL}?pgsql=127.0.0.1&username=postgres" | grep -Eiq "Database.+Collation.+Tables"; then + if ! curl -sS "localhost${URL}?pgsql=127.0.0.1&username=postgres" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then # 3rd Try sleep 1 - if ! curl -sS "localhost${URL}?pgsql=127.0.0.1&username=postgres" | grep -Eiq "Database.+Collation.+Tables"; then + if ! curl -sS "localhost${URL}?pgsql=127.0.0.1&username=postgres" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then printf "\r[FAIL] Adminer PgSQL login\n" curl -sS "localhost${URL}?pgsql=127.0.0.1&username=postgres" || true curl -sSI "localhost${URL}?pgsql=127.0.0.1&username=postgres" || true @@ -122,13 +128,13 @@ fi printf "[TEST] Adminer Mongo login" # 1st Try -if ! curl -sS "localhost${URL}?mongo=127.0.0.1&username=" | grep -Eiq "Database.+Collation.+Tables"; then +if ! curl -sS "localhost${URL}?mongo=127.0.0.1&username=" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then # 2nd Try sleep 1 - if ! curl -sS "localhost${URL}?mongo=127.0.0.1&username=" | grep -Eiq "Database.+Collation.+Tables"; then + if ! curl -sS "localhost${URL}?mongo=127.0.0.1&username=" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then # 3rd Try sleep 1 - if ! curl -sS "localhost${URL}?mongo=127.0.0.1&username=" | grep -Eiq "Database.+Collation.+Tables"; then + if ! curl -sS "localhost${URL}?mongo=127.0.0.1&username=" | tac | tac | grep -Eiq "Database.+Collation.+Tables"; then printf "\r[FAIL] Adminer Mongo login\n" curl -sS "localhost${URL}?mongo=127.0.0.1&username=" || true curl -sSI "localhost${URL}?mongo=127.0.0.1&username=" || true diff --git a/.tests/intra-tests/vendor-phpmyadmin.sh b/.tests/intra-tests/vendor-phpmyadmin.sh index 33b14caf..eaecf2c1 100755 --- a/.tests/intra-tests/vendor-phpmyadmin.sh +++ b/.tests/intra-tests/vendor-phpmyadmin.sh @@ -5,6 +5,12 @@ 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 +# + + ### ### Retrieve URL for current PHP version. ### Older PHP versions are presented a link with a different version due to compatibility. @@ -39,13 +45,13 @@ fi printf "[TEST] Fetch ${URL}" # 1st Try -if ! curl -sS localhost${URL} | grep -Eiq "welcome to.+phpMyAdmin"; then +if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "welcome to.+phpMyAdmin"; then # 2nd Try sleep 1 - if ! curl -sS localhost${URL} | grep -Eiq "welcome to.+phpMyAdmin"; then + if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "welcome to.+phpMyAdmin"; then # 3rd Try sleep 1 - if ! curl -sS localhost${URL} | grep -Eiq "welcome to.+phpMyAdmin"; then + if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "welcome to.+phpMyAdmin"; then printf "\r[FAIL] Fetch ${URL}\n" curl -sS localhost/${URL} || true curl -sSI localhost/${URL} || true