Browse code

Fix integration suite and propagate failures

Failures from the integration suite were not propagating to the outter shell
for some reason. Handle the failure with an if exit 1.

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2017/08/31 01:01:01
Showing 4 changed files
... ...
@@ -35,6 +35,7 @@ DOCKER_ENVS := \
35 35
 	-e DOCKER_REMAP_ROOT \
36 36
 	-e DOCKER_STORAGE_OPTS \
37 37
 	-e DOCKER_USERLANDPROXY \
38
+	-e TEST_INTEGRATION_DIR \
38 39
 	-e TESTDIRS \
39 40
 	-e TESTFLAGS \
40 41
 	-e TIMEOUT \
... ...
@@ -8,22 +8,32 @@
8 8
 
9 9
 source "$SCRIPTDIR/make/.go-autogen"
10 10
 
11
+# Set defaults
11 12
 : ${TEST_REPEAT:=1}
13
+: ${TESTFLAGS:=}
14
+: ${TESTDEBUG:=}
12 15
 
13
-integration_api_dirs=("$(
16
+integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
14 17
 	find ./integration -type d |
15
-	grep -vE '^(./integration$|./integration/util)')")
18
+	grep -vE '^(./integration$|./integration/util)')"}
16 19
 
17 20
 run_test_integration() {
21
+	[[ "$TESTFLAGS" != *-check.f* ]] && run_test_integration_suites
22
+	run_test_integration_legacy_suites
23
+}
24
+
25
+run_test_integration_suites() {
18 26
 	local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS"
19 27
 	for dir in $integration_api_dirs; do
20
-		(
28
+		if ! (
21 29
 			cd $dir
22 30
 			echo "Running $PWD"
23 31
 			test_env ./test.main $flags
24
-		)
32
+		); then exit 1; fi
25 33
 	done
34
+}
26 35
 
36
+run_test_integration_legacy_suites() {
27 37
 	(
28 38
 		flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS"
29 39
 		cd integration-cli
... ...
@@ -33,7 +43,7 @@ run_test_integration() {
33 33
 }
34 34
 
35 35
 build_test_suite_binaries() {
36
-	if [ $DOCKER_INTEGRATION_TESTS_VERIFIED ]; then
36
+	if [ ${DOCKER_INTEGRATION_TESTS_VERIFIED-} ]; then
37 37
 		echo "Skipping building test binaries; as DOCKER_INTEGRATION_TESTS_VERIFIED is set"
38 38
 		return
39 39
 	fi
... ...
@@ -1,5 +1,5 @@
1 1
 #!/usr/bin/env bash
2
-set -e
2
+set -e -o pipefail
3 3
 
4 4
 source "${MAKEDIR}/.go-autogen"
5 5
 source hack/make/.integration-test-helpers
... ...
@@ -18,6 +18,7 @@ import (
18 18
 )
19 19
 
20 20
 func TestInspect(t *testing.T) {
21
+	defer setupTest(t)()
21 22
 	d := newSwarm(t)
22 23
 	defer d.Stop(t)
23 24
 	client, err := request.NewClientForHost(d.Sock())