From 5d556fc310a6dc5ea9988bc6fc9a89132e749010 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 24 May 2017 08:45:53 +0200 Subject: [PATCH] REL-0.10 Cleanup shell scripts --- .tests/.lib.sh | 16 ++++++++-------- .tests/test_single.sh | 24 ++++++++---------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/.tests/.lib.sh b/.tests/.lib.sh index 54727473..4a85b5bc 100644 --- a/.tests/.lib.sh +++ b/.tests/.lib.sh @@ -397,21 +397,19 @@ devilbox_stop() { devilbox_print_errors() { _url="${1}" - print_h1 "Error output" - - print_h2 "Curl" + print_h2 "[ERROR] Curl" curl -vv "${_url}" || true echo - print_h2 "docker-compose ps" + print_h2 "[ERROR] docker-compose ps" docker-compose ps echo - print_h2 "docker-compose logs" + print_h2 "[ERROR] docker-compose logs" docker-compose logs echo - print_h2 "log files" + print_h2 "[ERROR] log files" ls -lap log/ sudo find log -type f -exec sh -c 'echo "{}:\n-----------------"; cat "{}"; echo "\n\n"' \; } @@ -452,8 +450,10 @@ devilbox_test_url() { _count="$( curl -q "${_url}" 2>/dev/null | grep -c "${_pattern}" || true )" if [ "${_count}" != "${_number}" ]; then + echo "[ERR]: Found ${_count}/${_number} of '${_pattern}'" return 1 - else - return 0 fi + + echo "[OK]: Found ${_count}/${_number} of '${_pattern}'" + return 0 } diff --git a/.tests/test_single.sh b/.tests/test_single.sh index 5fbb1106..a566e4bc 100755 --- a/.tests/test_single.sh +++ b/.tests/test_single.sh @@ -74,19 +74,18 @@ DEF_PGSQL="9.6" # ################################################################################ -# Print Headline -print_h1 "Configuration: ${DVL_SRV1}-${DVL_VER1} vs ${DVL_SRV2}-${DVL_VER2}" - ### ### Configure ### +print_h1 "Configuration: ${DVL_SRV1}-${DVL_VER1} vs ${DVL_SRV2}-${DVL_VER2}" devilbox_configure "${DVL_SRV1}" "${DVL_VER1}" "${DVL_SRV2}" "${DVL_VER2}" "${DEF_PHP}" "${DEF_HTTPD}" "${DEF_MYSQL}" "${DEF_PGSQL}" ### ### Download and run ### +print_h1 "Downloading and Run" devilbox_pull devilbox_start devilbox_show @@ -98,27 +97,19 @@ devilbox_show print_h1 "Testing" print_h2 "docker-compose" -if devilbox_test_compose; then - echo "[OK]: all container running" -else +if ! devilbox_test_compose; then devilbox_print_errors "http://localhost/index.php" exit 1 fi -print_h2 "Testing 'dvlbox-ok: index.php" -if devilbox_test_url "http://localhost/index.php" "dvlbox-ok" "20"; then - echo "[OK]: All 'dvlbox-ok' found" -else - echo "[ERR]: Not all 'dvlbox-ok' found" +print_h2 "Testing 'dvlbox-ok': index.php" +if ! devilbox_test_url "http://localhost/index.php" "dvlbox-ok" "20"; then devilbox_print_errors "http://localhost/index.php" exit 1 fi -print_h2 "Testing 'dvlbox-err: index.php" -if devilbox_test_url "http://localhost/index.php" "dvlbox-err" "0"; then - echo "[OK]: No 'dvlbox-err' found" -else - echo "[ERR]: 'dvlbox-err' found" +print_h2 "Testing 'dvlbox-err': index.php" +if ! devilbox_test_url "http://localhost/index.php" "dvlbox-err" "0"; then devilbox_print_errors "http://localhost/index.php" exit 1 fi @@ -127,4 +118,5 @@ fi ### ### Stop ### +print_h1 "Shutdown and exit" devilbox_stop