Adds a new bundle `verify-integration-tests` which pre-compiles a test
binary for the integration tests.
This makes sure that the integration tests will actually compile before
doing other tasks which take much longer, such as building dockerd and
loading test fixtures.
When it comes time to actually run the tests, the pre-compiled binary
will be used so it doesn't have to compile the tests a 2nd time.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
... | ... |
@@ -125,7 +125,7 @@ test-docker-py: build ## run the docker-py tests |
125 | 125 |
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-docker-py |
126 | 126 |
|
127 | 127 |
test-integration-cli: build ## run the integration tests |
128 |
- $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration-cli |
|
128 |
+ $(DOCKER_RUN_DOCKER) hack/make.sh build-integration-test-binary dynbinary test-integration-cli |
|
129 | 129 |
|
130 | 130 |
test-unit: build ## run the unit tests |
131 | 131 |
$(DOCKER_RUN_DOCKER) hack/make.sh test-unit |
... | ... |
@@ -4,7 +4,7 @@ |
4 | 4 |
|
5 | 5 |
bundle_test_integration_cli() { |
6 | 6 |
TESTFLAGS="$TESTFLAGS -check.v -check.timeout=${TIMEOUT} -test.timeout=360m" |
7 |
- go_test_dir ./integration-cli |
|
7 |
+ go_test_dir integration-cli $DOCKER_INTEGRATION_TESTS_VERIFIED |
|
8 | 8 |
} |
9 | 9 |
|
10 | 10 |
# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. |
... | ... |
@@ -19,16 +19,17 @@ bundle_test_integration_cli() { |
19 | 19 |
# |
20 | 20 |
go_test_dir() { |
21 | 21 |
dir=$1 |
22 |
- coverpkg=$2 |
|
22 |
+ precompiled=$2 |
|
23 |
+ testbinary="$DEST/test.main" |
|
23 | 24 |
testcover=() |
24 | 25 |
testcoverprofile=() |
25 |
- testbinary="$DEST/test.main" |
|
26 | 26 |
( |
27 | 27 |
mkdir -p "$DEST/coverprofiles" |
28 |
- echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}" |
|
29 |
- cd "$dir" |
|
30 | 28 |
export DEST="$ABS_DEST" # in a subshell this is safe -- our integration-cli tests need DEST, and "cd" screws it up |
31 |
- go test -c -o "$testbinary" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" |
|
29 |
+ if [ -z $precompiled ]; then |
|
30 |
+ ensure_test_dir $1 $testbinary |
|
31 |
+ fi |
|
32 |
+ cd "$dir" |
|
32 | 33 |
i=0 |
33 | 34 |
while ((++i)); do |
34 | 35 |
test_env "$testbinary" $TESTFLAGS |
... | ... |
@@ -40,22 +41,37 @@ go_test_dir() { |
40 | 40 |
) |
41 | 41 |
} |
42 | 42 |
|
43 |
+ensure_test_dir() { |
|
44 |
+ ( |
|
45 |
+ # make sure a test dir will compile |
|
46 |
+ dir="$1" |
|
47 |
+ out="$2" |
|
48 |
+ echo Building test dir: "$dir" |
|
49 |
+ set -xe |
|
50 |
+ cd "$dir" |
|
51 |
+ go test -c -o "$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" |
|
52 |
+ ) |
|
53 |
+} |
|
54 |
+ |
|
43 | 55 |
test_env() { |
44 |
- # use "env -i" to tightly control the environment variables that bleed into the tests |
|
45 |
- env -i \ |
|
46 |
- DEST="$DEST" \ |
|
47 |
- DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ |
|
48 |
- DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \ |
|
49 |
- DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \ |
|
50 |
- DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \ |
|
51 |
- DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \ |
|
52 |
- DOCKER_HOST="$DOCKER_HOST" \ |
|
53 |
- DOCKER_REMAP_ROOT="$DOCKER_REMAP_ROOT" \ |
|
54 |
- DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \ |
|
55 |
- GOPATH="$GOPATH" \ |
|
56 |
- GOTRACEBACK=all \ |
|
57 |
- HOME="$ABS_DEST/fake-HOME" \ |
|
58 |
- PATH="$PATH" \ |
|
59 |
- TEMP="$TEMP" \ |
|
60 |
- "$@" |
|
56 |
+ ( |
|
57 |
+ set -xe |
|
58 |
+ # use "env -i" to tightly control the environment variables that bleed into the tests |
|
59 |
+ env -i \ |
|
60 |
+ DEST="$DEST" \ |
|
61 |
+ DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ |
|
62 |
+ DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \ |
|
63 |
+ DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \ |
|
64 |
+ DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \ |
|
65 |
+ DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \ |
|
66 |
+ DOCKER_HOST="$DOCKER_HOST" \ |
|
67 |
+ DOCKER_REMAP_ROOT="$DOCKER_REMAP_ROOT" \ |
|
68 |
+ DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \ |
|
69 |
+ GOPATH="$GOPATH" \ |
|
70 |
+ GOTRACEBACK=all \ |
|
71 |
+ HOME="$ABS_DEST/fake-HOME" \ |
|
72 |
+ PATH="$PATH" \ |
|
73 |
+ TEMP="$TEMP" \ |
|
74 |
+ "$@" |
|
75 |
+ ) |
|
61 | 76 |
} |
62 | 77 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,11 @@ |
0 |
+#!/bin/bash |
|
1 |
+set -e |
|
2 |
+ |
|
3 |
+rm -rf "$DEST" |
|
4 |
+DEST="$DEST/../test-integration-cli" |
|
5 |
+ |
|
6 |
+if [ -z $DOCKER_INTEGRATION_TESTS_VERIFIED ]; then |
|
7 |
+ source ${MAKEDIR}/.integration-test-helpers |
|
8 |
+ ensure_test_dir integration-cli "$DEST/test.main" |
|
9 |
+ export DOCKER_INTEGRATION_TESTS_VERIFIED=1 |
|
10 |
+fi |