Skip to content

Commit 1b9357e

Browse files
committed
update
1 parent 804c7ea commit 1b9357e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docker_compose_test.patch

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/docker_compose_test/docker_compose_test.sh b/docker_compose_test/docker_compose_test.sh
2+
index 2e6110f..292c216 100755
3+
--- a/docker_compose_test/docker_compose_test.sh
4+
+++ b/docker_compose_test/docker_compose_test.sh
5+
@@ -53,12 +53,29 @@ if [ $? -eq 0 ]; then
6+
docker_compose_bin="docker-compose"
7+
fi
8+
9+
-# bring up compose file & get exit status-code from the integration test container
10+
-docker_compose_up_cmd="$docker_compose_bin -f $ABSOLUTE_COMPOSE_FILE_PATH up --exit-code-from $DOCKER_COMPOSE_TEST_CONTAINER $EXTRA_DOCKER_COMPOSE_UP_ARGS"
11+
+cleanup() {
12+
+ echo "Cleaning up docker-compose resources..."
13+
+ docker_compose_down_cmd="$docker_compose_bin -f $ABSOLUTE_COMPOSE_FILE_PATH down --volumes --remove-orphans"
14+
+ echo "running: $docker_compose_down_cmd"
15+
+ echo "$docker_compose_down_cmd" | bash
16+
+}
17+
+
18+
+# Ensure cleanup runs on EXIT (covers normal exit, errors, and signals).
19+
+# SIGTERM: sent by Bazel on test timeout or cancellation.
20+
+# SIGINT: sent on Ctrl+C.
21+
+trap cleanup EXIT
22+
+
23+
+# bring up compose file & get exit status-code from the integration test container.
24+
+docker_compose_up_cmd="$docker_compose_bin -f $ABSOLUTE_COMPOSE_FILE_PATH up --exit-code-from $DOCKER_COMPOSE_TEST_CONTAINER $EXTRA_DOCKER_COMPOSE_UP_ARGS"
25+
echo "running: $docker_compose_up_cmd"
26+
echo "$docker_compose_up_cmd" | bash
27+
result=$?
28+
29+
-$docker_compose_bin -f $ABSOLUTE_COMPOSE_FILE_PATH down
30+
+# Figure out the exit code of the test container incase it never actually started.
31+
+EXIT_CODE=$(docker inspect $(docker compose -f $ABSOLUTE_COMPOSE_FILE_PATH ps -qa $DOCKER_COMPOSE_TEST_CONTAINER) --format='{{.State.ExitCode}}' 2>/dev/null)
32+
+if [ "$EXIT_CODE" != "0" ] || [ -z "$EXIT_CODE" ]; then
33+
+ echo "Error: $DOCKER_COMPOSE_TEST_CONTAINER container failed or never started!"
34+
+ exit 1
35+
+fi
36+
37+
exit $result

0 commit comments

Comments
 (0)