From fcddd4685d313beaa80c9d9225cc848b83198568 Mon Sep 17 00:00:00 2001 From: Marina Date: Mon, 18 Mar 2024 17:03:00 +0300 Subject: [PATCH] docker_check_tests.sh: logs are added, while-true is removed --- tests/scripts/docker_check_tests.sh | 62 ++++++++++++----------------- 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/tests/scripts/docker_check_tests.sh b/tests/scripts/docker_check_tests.sh index a4dcbe6c..67deee05 100755 --- a/tests/scripts/docker_check_tests.sh +++ b/tests/scripts/docker_check_tests.sh @@ -3,42 +3,30 @@ service="selenium-tests" container_id=$(docker-compose -f docker-compose.yml -f docker-compose-selenium.yml ps -q $service) - -while true; do - - if docker ps -a -q --no-trunc| grep -q "^${container_id}$"; then - if docker inspect --format='{{.State.Running}}' "$container_id" | grep -q "false"; then - echo "tests are finished" - EXIT_CODE=$(docker inspect "$container_id" --format='{{.State.ExitCode}}') - docker-compose -f docker-compose.yml -f docker-compose-selenium.yml logs selenium-tests - if [ "$EXIT_CODE" -eq 0 ]; then - echo "tests finished with code $EXIT_CODE (OK)" - exit 0 - else - echo "tests are failed, code $EXIT_CODE" - exit 1 - fi - else - echo "tests in progress" - sleep 30 - fi - else - echo "Контейнер сервиса $service не найден." - exit 1 - fi - +if [ -z "$container_id" ]; then + echo "Контейнер сервиса $service не найден." + exit 1 +fi + +while [ "$(docker inspect --format='{{.State.Running}}' "$container_id")" == "true" ]; do + echo "tests in progress" + sleep 30 done - -# in case of return logs: -# while true; do -# test_end=$(docker-compose -f docker-compose-tests.yml logs selenium-tests | grep -q "Ran"; echo $?) - -# if [ "$test_end" -eq 0 ]; then -# echo "tests are finished" -# exit 0 -# else -# sleep 60 -# echo "in progress" -# fi -# done +echo "tests are finished" + +EXIT_CODE=$(docker inspect "$container_id" --format='{{.State.ExitCode}}') +echo "tests logs:" +docker-compose -f docker-compose.yml -f docker-compose-selenium.yml logs selenium-tests +echo "web logs:" +docker-compose logs web +echo "worker logs:" +docker-compose logs worker + +if [ "$EXIT_CODE" -eq 0 ]; then + echo "tests finished with code $EXIT_CODE (OK)" + exit 0 +else + echo "tests are failed, code $EXIT_CODE" + exit 1 +fi