Interactive integration testing is useful when you're developing new tests, or
making changes to cli code.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
... | ... |
@@ -201,6 +201,8 @@ ENV DOCKER_BUILDTAGS apparmor pkcs11 seccomp selinux |
201 | 201 |
|
202 | 202 |
# Let us use a .bashrc file |
203 | 203 |
RUN ln -sfv $PWD/.bashrc ~/.bashrc |
204 |
+# Add integration helps to bashrc |
|
205 |
+RUN echo "source $PWD/hack/make/.integration-test-helpers" >> /etc/bash.bashrc |
|
204 | 206 |
|
205 | 207 |
# Register Docker's bash completion. |
206 | 208 |
RUN ln -sv $PWD/contrib/completion/bash/docker /etc/bash_completion.d/docker |
... | ... |
@@ -28,8 +28,6 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
28 | 28 |
export MAKEDIR="$SCRIPTDIR/make" |
29 | 29 |
export PKG_CONFIG=${PKG_CONFIG:-pkg-config} |
30 | 30 |
|
31 |
-: ${TEST_REPEAT:=0} |
|
32 |
- |
|
33 | 31 |
# We're a nice, sexy, little shell script, and people might try to run us; |
34 | 32 |
# but really, they shouldn't. We want to be in a container! |
35 | 33 |
inContainer="AssumeSoInitially" |
... | ... |
@@ -224,65 +222,6 @@ if \ |
224 | 224 |
HAVE_GO_TEST_COVER=1 |
225 | 225 |
fi |
226 | 226 |
|
227 |
-# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. |
|
228 |
-# You can use this to select certain tests to run, eg. |
|
229 |
-# |
|
230 |
-# TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit |
|
231 |
-# |
|
232 |
-# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want |
|
233 |
-# to run certain tests on your local host, you should run with command: |
|
234 |
-# |
|
235 |
-# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration-cli |
|
236 |
-# |
|
237 |
-go_test_dir() { |
|
238 |
- dir=$1 |
|
239 |
- coverpkg=$2 |
|
240 |
- testcover=() |
|
241 |
- testcoverprofile=() |
|
242 |
- testbinary="$DEST/test.main" |
|
243 |
- if [ "$HAVE_GO_TEST_COVER" ]; then |
|
244 |
- # if our current go install has -cover, we want to use it :) |
|
245 |
- mkdir -p "$DEST/coverprofiles" |
|
246 |
- coverprofile="docker${dir#.}" |
|
247 |
- coverprofile="$ABS_DEST/coverprofiles/${coverprofile//\//-}" |
|
248 |
- testcover=( -test.cover ) |
|
249 |
- testcoverprofile=( -test.coverprofile "$coverprofile" $coverpkg ) |
|
250 |
- fi |
|
251 |
- ( |
|
252 |
- echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}" |
|
253 |
- cd "$dir" |
|
254 |
- export DEST="$ABS_DEST" # we're in a subshell, so this is safe -- our integration-cli tests need DEST, and "cd" screws it up |
|
255 |
- go test -c -o "$testbinary" ${testcover[@]} -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" |
|
256 |
- i=0 |
|
257 |
- while ((++i)); do |
|
258 |
- test_env "$testbinary" ${testcoverprofile[@]} $TESTFLAGS |
|
259 |
- if [ $i -gt "$TEST_REPEAT" ]; then |
|
260 |
- break |
|
261 |
- fi |
|
262 |
- echo "Repeating test ($i)" |
|
263 |
- done |
|
264 |
- ) |
|
265 |
-} |
|
266 |
-test_env() { |
|
267 |
- # use "env -i" to tightly control the environment variables that bleed into the tests |
|
268 |
- env -i \ |
|
269 |
- DEST="$DEST" \ |
|
270 |
- DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ |
|
271 |
- DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \ |
|
272 |
- DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \ |
|
273 |
- DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \ |
|
274 |
- DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \ |
|
275 |
- DOCKER_HOST="$DOCKER_HOST" \ |
|
276 |
- DOCKER_REMAP_ROOT="$DOCKER_REMAP_ROOT" \ |
|
277 |
- DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \ |
|
278 |
- GOPATH="$GOPATH" \ |
|
279 |
- GOTRACEBACK=all \ |
|
280 |
- HOME="$ABS_DEST/fake-HOME" \ |
|
281 |
- PATH="$PATH" \ |
|
282 |
- TEMP="$TEMP" \ |
|
283 |
- "$@" |
|
284 |
-} |
|
285 |
- |
|
286 | 227 |
# a helper to provide ".exe" when it's appropriate |
287 | 228 |
binary_extension() { |
288 | 229 |
if [ "$(go env GOOS)" = 'windows' ]; then |
289 | 230 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,68 @@ |
0 |
+#!/bin/bash |
|
1 |
+ |
|
2 |
+: ${TEST_REPEAT:=0} |
|
3 |
+ |
|
4 |
+bundle_test_integration_cli() { |
|
5 |
+ TESTFLAGS="$TESTFLAGS -check.v -check.timeout=${TIMEOUT} -test.timeout=360m" |
|
6 |
+ go_test_dir ./integration-cli |
|
7 |
+} |
|
8 |
+ |
|
9 |
+# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. |
|
10 |
+# You can use this to select certain tests to run, eg. |
|
11 |
+# |
|
12 |
+# TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit |
|
13 |
+# |
|
14 |
+# For integration-cli test, we use [gocheck](https://labix.org/gocheck), if you want |
|
15 |
+# to run certain tests on your local host, you should run with command: |
|
16 |
+# |
|
17 |
+# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration-cli |
|
18 |
+# |
|
19 |
+go_test_dir() { |
|
20 |
+ dir=$1 |
|
21 |
+ coverpkg=$2 |
|
22 |
+ testcover=() |
|
23 |
+ testcoverprofile=() |
|
24 |
+ testbinary="$DEST/test.main" |
|
25 |
+ if [ "$HAVE_GO_TEST_COVER" ]; then |
|
26 |
+ # if our current go install has -cover, we want to use it :) |
|
27 |
+ mkdir -p "$DEST/coverprofiles" |
|
28 |
+ coverprofile="docker${dir#.}" |
|
29 |
+ coverprofile="$ABS_DEST/coverprofiles/${coverprofile//\//-}" |
|
30 |
+ testcover=( -test.cover ) |
|
31 |
+ testcoverprofile=( -test.coverprofile "$coverprofile" $coverpkg ) |
|
32 |
+ fi |
|
33 |
+ ( |
|
34 |
+ echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}" |
|
35 |
+ cd "$dir" |
|
36 |
+ export DEST="$ABS_DEST" # in a subshell this is safe -- our integration-cli tests need DEST, and "cd" screws it up |
|
37 |
+ go test -c -o "$testbinary" ${testcover[@]} -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" |
|
38 |
+ i=0 |
|
39 |
+ while ((++i)); do |
|
40 |
+ test_env "$testbinary" ${testcoverprofile[@]} $TESTFLAGS |
|
41 |
+ if [ $i -gt "$TEST_REPEAT" ]; then |
|
42 |
+ break |
|
43 |
+ fi |
|
44 |
+ echo "Repeating test ($i)" |
|
45 |
+ done |
|
46 |
+ ) |
|
47 |
+} |
|
48 |
+ |
|
49 |
+test_env() { |
|
50 |
+ # use "env -i" to tightly control the environment variables that bleed into the tests |
|
51 |
+ env -i \ |
|
52 |
+ DEST="$DEST" \ |
|
53 |
+ DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ |
|
54 |
+ DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \ |
|
55 |
+ DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \ |
|
56 |
+ DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \ |
|
57 |
+ DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \ |
|
58 |
+ DOCKER_HOST="$DOCKER_HOST" \ |
|
59 |
+ DOCKER_REMAP_ROOT="$DOCKER_REMAP_ROOT" \ |
|
60 |
+ DOCKER_REMOTE_DAEMON="$DOCKER_REMOTE_DAEMON" \ |
|
61 |
+ GOPATH="$GOPATH" \ |
|
62 |
+ GOTRACEBACK=all \ |
|
63 |
+ HOME="$ABS_DEST/fake-HOME" \ |
|
64 |
+ PATH="$PATH" \ |
|
65 |
+ TEMP="$TEMP" \ |
|
66 |
+ "$@" |
|
67 |
+} |
... | ... |
@@ -1,10 +1,7 @@ |
1 | 1 |
#!/bin/bash |
2 | 2 |
set -e |
3 | 3 |
|
4 |
-bundle_test_integration_cli() { |
|
5 |
- TESTFLAGS="$TESTFLAGS -check.v -check.timeout=${TIMEOUT} -test.timeout=360m" |
|
6 |
- go_test_dir ./integration-cli |
|
7 |
-} |
|
4 |
+source hack/make/.integration-test-helpers |
|
8 | 5 |
|
9 | 6 |
# subshell so that we can export PATH without breaking other things |
10 | 7 |
( |