Browse code

Add docker-py integration tests aginst the docker daemon

This clones and run the integration tests for docker-py master as part
of the integration tests created on master. docker-py hits the api
directly and should be a good way to identify regressions in the api.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Michael Crosby authored on 2014/12/16 04:44:15
Showing 3 changed files
... ...
@@ -42,6 +42,8 @@ RUN	apt-get update && apt-get install -y \
42 42
 	lxc=1.0* \
43 43
 	mercurial \
44 44
 	parallel \
45
+	python-mock \
46
+	python-pip \
45 47
 	reprepro \
46 48
 	ruby1.9.1 \
47 49
 	ruby1.9.1-dev \
... ...
@@ -56,7 +56,7 @@ docs-release: docs-build
56 56
 	$(DOCKER_RUN_DOCS) -e OPTIONS -e BUILD_ROOT "$(DOCKER_DOCS_IMAGE)" ./release.sh
57 57
 
58 58
 test: build
59
-	$(DOCKER_RUN_DOCKER) hack/make.sh binary cross test-unit test-integration test-integration-cli
59
+	$(DOCKER_RUN_DOCKER) hack/make.sh binary cross test-unit test-integration test-integration-cli test-docker-py
60 60
 
61 61
 test-unit: build
62 62
 	$(DOCKER_RUN_DOCKER) hack/make.sh test-unit
63 63
new file mode 100644
... ...
@@ -0,0 +1,43 @@
0
+#!/bin/bash
1
+set -e
2
+
3
+DEST=$1
4
+
5
+DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-vfs}
6
+DOCKER_EXECDRIVER=${DOCKER_EXECDRIVER:-native}
7
+
8
+# subshell so that we can export PATH without breaking other things
9
+exec > >(tee -a $DEST/test.log) 2>&1
10
+(
11
+	export PATH="$DEST/../binary:$DEST/../dynbinary:$PATH"
12
+
13
+	if ! command -v docker &> /dev/null; then
14
+		echo >&2 'error: binary or dynbinary must be run before test-docker-py'
15
+		false
16
+	fi
17
+
18
+	# intentionally open a couple bogus file descriptors to help test that they get scrubbed in containers
19
+	exec 41>&1 42>&2
20
+
21
+	( set -x; exec \
22
+		docker --daemon --debug \
23
+		--storage-driver "$DOCKER_GRAPHDRIVER" \
24
+		--exec-driver "$DOCKER_EXECDRIVER" \
25
+		--pidfile "$DEST/docker.pid" \
26
+			&> "$DEST/docker.log"
27
+	) &
28
+
29
+	mkdir -p /tmp/dockerpy-tests && cd /tmp/dockerpy-tests
30
+	git clone https://github.com/docker/docker-py.git
31
+	cd docker-py
32
+	git checkout 0.6.0-integration
33
+	python setup.py install
34
+	python tests/integration_test.py
35
+
36
+	for pid in $(find "$DEST" -name docker.pid); do
37
+		DOCKER_PID=$(set -x; cat "$pid")
38
+		( set -x; kill $DOCKER_PID )
39
+		wait $DOCKERD_PID || true
40
+	done
41
+)
42
+