From eda91cc55610ed9731351e2e2a6a1c42f0199bab Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 30 Dec 2023 21:32:04 +0000 Subject: [PATCH] tests --- .../docker-compose-latest-lite-security.yml | 4 +-- .../docker-compose-latest-lite.yml | 4 +-- .../docker-compose-latest-security.yml | 4 +-- ...ker-compose-latest-ultra-lite-security.yml | 4 +-- .../docker-compose-latest-ultra-lite.yml | 4 +-- exampleYmlFiles/docker-compose-latest.yml | 4 +-- test.sh | 28 +++++++++++-------- 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/exampleYmlFiles/docker-compose-latest-lite-security.yml b/exampleYmlFiles/docker-compose-latest-lite-security.yml index 98b95058..cb82fdb0 100644 --- a/exampleYmlFiles/docker-compose-latest-lite-security.yml +++ b/exampleYmlFiles/docker-compose-latest-lite-security.yml @@ -9,9 +9,9 @@ services: memory: 1G healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/api/v1/info/status | grep -q 'UP' && curl -fL http://localhost:8080/ | grep -q 'Please sign in'"] - interval: 30s + interval: 5s timeout: 10s - retries: 3 + retries: 16 ports: - 8080:8080 volumes: diff --git a/exampleYmlFiles/docker-compose-latest-lite.yml b/exampleYmlFiles/docker-compose-latest-lite.yml index c2f18efe..920ae8d8 100644 --- a/exampleYmlFiles/docker-compose-latest-lite.yml +++ b/exampleYmlFiles/docker-compose-latest-lite.yml @@ -9,9 +9,9 @@ services: memory: 1G healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/api/v1/info/status | grep -q 'UP' && curl -fL http://localhost:8080/ | grep -qv 'Please sign in'"] - interval: 20s + interval: 5s timeout: 10s - retries: 3 + retries: 16 ports: - 8080:8080 volumes: diff --git a/exampleYmlFiles/docker-compose-latest-security.yml b/exampleYmlFiles/docker-compose-latest-security.yml index b36a08a3..a480c27d 100644 --- a/exampleYmlFiles/docker-compose-latest-security.yml +++ b/exampleYmlFiles/docker-compose-latest-security.yml @@ -9,9 +9,9 @@ services: memory: 1G healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/api/v1/info/status | grep -q 'UP' && curl -fL http://localhost:8080/ | grep -q 'Please sign in'"] - interval: 20s + interval: 5s timeout: 10s - retries: 3 + retries: 16 ports: - 8080:8080 volumes: diff --git a/exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml b/exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml index 7b0d6c43..a8de634f 100644 --- a/exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml +++ b/exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml @@ -9,9 +9,9 @@ services: memory: 1G healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/api/v1/info/status | grep -q 'UP' && curl -fL http://localhost:8080/ | grep -q 'Please sign in'"] - interval: 30s + interval: 5s timeout: 10s - retries: 3 + retries: 16 ports: - 8080:8080 volumes: diff --git a/exampleYmlFiles/docker-compose-latest-ultra-lite.yml b/exampleYmlFiles/docker-compose-latest-ultra-lite.yml index 5848873d..b3ad7b00 100644 --- a/exampleYmlFiles/docker-compose-latest-ultra-lite.yml +++ b/exampleYmlFiles/docker-compose-latest-ultra-lite.yml @@ -9,9 +9,9 @@ services: memory: 1G healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/api/v1/info/status | grep -q 'UP' && curl -fL http://localhost:8080/ | grep -qv 'Please sign in'"] - interval: 20s + interval: 5s timeout: 10s - retries: 3 + retries: 16 ports: - 8080:8080 volumes: diff --git a/exampleYmlFiles/docker-compose-latest.yml b/exampleYmlFiles/docker-compose-latest.yml index e319695f..21fff579 100644 --- a/exampleYmlFiles/docker-compose-latest.yml +++ b/exampleYmlFiles/docker-compose-latest.yml @@ -9,9 +9,9 @@ services: memory: 1G healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/api/v1/info/status | grep -q 'UP' && curl -fL http://localhost:8080/ | grep -qv 'Please sign in'"] - interval: 30s + interval: 5s timeout: 10s - retries: 3 + retries: 16 ports: - 8080:8080 volumes: diff --git a/test.sh b/test.sh index 3b84ef42..9617ba14 100644 --- a/test.sh +++ b/test.sh @@ -6,16 +6,17 @@ check_health() { local compose_file=$2 local end=$((SECONDS+60)) - echo "Waiting for $service_name to become healthy..." - until [ "$(docker inspect --format='{{json .State.Health.Status}}' "$service_name")" == '"healthy"' ] || [ $SECONDS -ge $end ]; do - sleep 10 - echo "Waiting..." - if [ $SECONDS -ge $end ]; then - echo "$service_name health check timed out after 80 seconds." - return 1 - fi - done - echo "$service_name is healthy!" + echo -n "Waiting for $service_name to become healthy..." + until [ "$(docker inspect --format='{{json .State.Health.Status}}' "$service_name")" == '"healthy"' ] || [ $SECONDS -ge $end ]; do + sleep 3 + echo -n "." + if [ $SECONDS -ge $end ]; then + echo -e "\n$service_name health check timed out after 80 seconds." + return 1 + fi + done + echo -e "\n$service_name is healthy!" + return 0 } @@ -63,6 +64,8 @@ run_tests() { # Main testing routine main() { + SECONDS=0 + export DOCKER_ENABLE_SECURITY=false ./gradlew clean build @@ -90,8 +93,7 @@ main() { run_tests "Stirling-PDF-Security" "./exampleYmlFiles/docker-compose-latest-security.yml" # Report results - echo "All tests completed." - + echo "All tests completed in $SECONDS seconds." if [ ${#passed_tests[@]} -ne 0 ]; then @@ -108,6 +110,8 @@ main() { echo -e "\e[31m$test\e[0m" # Red color for failed tests done + + # Check if there are any failed tests and exit with an error code if so if [ ${#failed_tests[@]} -ne 0 ]; then echo "Some tests failed."