Skip to content

Commit

Permalink
docker_check_tests.sh: logs are added, while-true is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinaProsche committed Mar 18, 2024
1 parent 38b79c4 commit fcddd46
Showing 1 changed file with 25 additions and 37 deletions.
62 changes: 25 additions & 37 deletions tests/scripts/docker_check_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fcddd46

Please sign in to comment.