Browse code

Update e2e script

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2018/02/23 23:56:03
Showing 1 changed files
... ...
@@ -1,41 +1,71 @@
1 1
 #!/usr/bin/env bash
2
-set -e
2
+set -e -u -o pipefail
3 3
 
4
-TESTFLAGS=${TESTFLAGS:-""}
5
-# Currently only DockerSuite and DockerNetworkSuite have been adapted for E2E testing
6
-TESTFLAGS_LEGACY=${TESTFLAGS_LEGACY:-""}
7
-TIMEOUT=${TIMEOUT:-60m}
4
+ARCH=$(uname -m)
5
+if [ "$ARCH" == "x86_64" ]; then
6
+  ARCH="amd64"
7
+fi
8 8
 
9
-SCRIPTDIR="$(dirname ${BASH_SOURCE[0]})"
9
+export DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:-${ARCH}}
10 10
 
11
-export DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:-amd64}
11
+# Set defaults
12
+: ${TESTFLAGS:=}
13
+: ${TESTDEBUG:=}
14
+
15
+integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
16
+	find ./integration -type d |
17
+	grep -vE '(^./integration($|/internal)|/testdata)')"}
12 18
 
13 19
 run_test_integration() {
14
-  run_test_integration_suites
15
-  run_test_integration_legacy_suites
20
+	[[ "$TESTFLAGS" != *-check.f* ]] && run_test_integration_suites
21
+	run_test_integration_legacy_suites
16 22
 }
17 23
 
18 24
 run_test_integration_suites() {
19
-  local flags="-test.timeout=${TIMEOUT} $TESTFLAGS"
20
-  for dir in /tests/integration/*; do
21
-    if ! (
22
-      cd $dir
23
-      echo "Running $PWD"
24
-      ./test.main $flags
25
-    ); then exit 1; fi
26
-  done
25
+	local flags="-test.v -test.timeout=${TIMEOUT:=10m} $TESTFLAGS"
26
+	for dir in $integration_api_dirs; do
27
+		if ! (
28
+			cd $dir
29
+			echo "Running $PWD"
30
+			test_env ./test.main $flags
31
+		); then exit 1; fi
32
+	done
27 33
 }
28 34
 
29 35
 run_test_integration_legacy_suites() {
30
-  (
31
-    flags="-check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS_LEGACY"
32
-    cd /tests/integration-cli
33
-    echo "Running $PWD"
34
-    ./test.main $flags
35
-  )
36
+	(
37
+		flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS"
38
+		cd test/integration-cli
39
+		echo "Running $PWD"
40
+		test_env ./test.main $flags
41
+	)
36 42
 }
37 43
 
38
-bash $SCRIPTDIR/ensure-emptyfs.sh
44
+# use "env -i" to tightly control the environment variables that bleed into the tests
45
+test_env() {
46
+	(
47
+		set -e +u
48
+		[ -n "$TESTDEBUG" ] && set -x
49
+		env -i \
50
+			DOCKER_API_VERSION="$DOCKER_API_VERSION" \
51
+			DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \
52
+			DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \
53
+			DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \
54
+			DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \
55
+			DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \
56
+			DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \
57
+			DOCKER_HOST="$DOCKER_HOST" \
58
+			DOCKER_REMAP_ROOT="$DOCKER_REMAP_ROOT" \
59
+			DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \
60
+			DOCKERFILE="$DOCKERFILE" \
61
+			GOPATH="$GOPATH" \
62
+			GOTRACEBACK=all \
63
+			HOME="$ABS_DEST/fake-HOME" \
64
+			PATH="$PATH" \
65
+			TEMP="$TEMP" \
66
+			TEST_CLIENT_BINARY="$TEST_CLIENT_BINARY" \
67
+			"$@"
68
+	)
69
+}
39 70
 
40
-echo "Run integration tests"
41 71
 run_test_integration