Browse code

Properly fix "daemon kill" on test failure

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>

Tianon Gravi authored on 2015/01/14 13:09:11
Showing 2 changed files
... ...
@@ -7,15 +7,24 @@ DEST=$1
7 7
 (
8 8
 	source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
9 9
 
10
-	dockerPy='/docker-py'
11
-	[ -d "$dockerPy" ] || {
12
-		dockerPy="$DEST/docker-py"
13
-		git clone https://github.com/docker/docker-py.git "$dockerPy"
14
-	}
10
+	# we need to wrap up everything in between integration-daemon-start and
11
+	# integration-daemon-stop to make sure we kill the daemon and don't hang,
12
+	# even and especially on test failures
13
+	didFail=
14
+	if ! {
15
+		dockerPy='/docker-py'
16
+		[ -d "$dockerPy" ] || {
17
+			dockerPy="$DEST/docker-py"
18
+			git clone https://github.com/docker/docker-py.git "$dockerPy"
19
+		}
15 20
 
16
-	cd "$dockerPy"
17
-	export PYTHONPATH=. # import "docker" from "."
18
-	python tests/integration_test.py
21
+		export PYTHONPATH="$dockerPy" # import "docker" from our local docker-py
22
+		python "$dockerPy/tests/integration_test.py"
23
+	}; then
24
+		didFail=1
25
+	fi
19 26
 
20 27
 	source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
28
+
29
+	[ -z "$didFail" ] # "set -e" ftw
21 30
 ) 2>&1 | tee -a $DEST/test.log
... ...
@@ -11,12 +11,22 @@ bundle_test_integration_cli() {
11 11
 (
12 12
 	source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
13 13
 
14
-	# pull the busybox image before running the tests
15
-	sleep 2
14
+	# we need to wrap up everything in between integration-daemon-start and
15
+	# integration-daemon-stop to make sure we kill the daemon and don't hang,
16
+	# even and especially on test failures
17
+	didFail=
18
+	if ! {
19
+		# pull the busybox image before running the tests
20
+		sleep 2
16 21
 
17
-	source "$(dirname "$BASH_SOURCE")/.ensure-busybox"
22
+		source "$(dirname "$BASH_SOURCE")/.ensure-busybox"
18 23
 
19
-	bundle_test_integration_cli
24
+		bundle_test_integration_cli
25
+	}; then
26
+		didFail=1
27
+	fi
20 28
 
21 29
 	source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
30
+
31
+	[ -z "$didFail" ] # "set -e" ftw
22 32
 ) 2>&1 | tee -a $DEST/test.log