Skip to content

Commit 804c7ea

Browse files
committed
improve cleanup
1 parent fc68dfc commit 804c7ea

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docker_compose_test/docker_compose_test.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,17 @@ cleanup() {
6565
# SIGINT: sent on Ctrl+C.
6666
trap cleanup EXIT
6767

68-
# bring up compose file & get exit status-code from the integration test container
68+
# bring up compose file & get exit status-code from the integration test container.
6969
docker_compose_up_cmd="$docker_compose_bin -f $ABSOLUTE_COMPOSE_FILE_PATH up --abort-on-container-failure --exit-code-from $DOCKER_COMPOSE_TEST_CONTAINER $EXTRA_DOCKER_COMPOSE_UP_ARGS"
7070
echo "running: $docker_compose_up_cmd"
7171
echo "$docker_compose_up_cmd" | bash
7272
result=$?
7373

74+
# Figure out the exit code of the test container incase it never actually started.
75+
EXIT_CODE=$(docker inspect $(docker compose -f $ABSOLUTE_COMPOSE_FILE_PATH ps -qa $DOCKER_COMPOSE_TEST_CONTAINER) --format='{{.State.ExitCode}}' 2>/dev/null)
76+
if [ "$EXIT_CODE" != "0" ] || [ -z "$EXIT_CODE" ]; then
77+
echo "Error: $DOCKER_COMPOSE_TEST_CONTAINER container failed or never started!"
78+
exit 1
79+
fi
80+
7481
exit $result

0 commit comments

Comments
 (0)