From 5a6a67f632141cd5f6589f127ec17712496cc18d Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Wed, 13 May 2015 13:57:27 +0100 Subject: [PATCH] Add integration test for the proxy, using docker-py client --- test/600_proxy_docker_py_test.sh | 16 ++++++++++++++++ test/610_proxy_wait_for_weave_test.sh | 15 +++++++++++++++ test/config.sh | 7 +++++++ 3 files changed, 38 insertions(+) create mode 100755 test/600_proxy_docker_py_test.sh create mode 100755 test/610_proxy_wait_for_weave_test.sh diff --git a/test/600_proxy_docker_py_test.sh b/test/600_proxy_docker_py_test.sh new file mode 100755 index 00000000..dc5e3282 --- /dev/null +++ b/test/600_proxy_docker_py_test.sh @@ -0,0 +1,16 @@ +#! /bin/bash + +. ./config.sh + +start_suite "Run docker-py test suite against the proxy" + +weave_on $HOST1 launch-proxy +assert_raises "docker_on $HOST1 ps | grep weaveproxy" +assert_raises "docker_on $HOST1 run \ + -e NOT_ON_HOST=true \ + -e DOCKER_HOST=tcp://172.17.42.1:12375 \ + -v /tmp:/tmp \ + -v /var/run/docker.sock:/var/run/docker.sock \ + joffrey/docker-py python tests/integration_test.py" + +end_suite diff --git a/test/610_proxy_wait_for_weave_test.sh b/test/610_proxy_wait_for_weave_test.sh new file mode 100755 index 00000000..c1cb054c --- /dev/null +++ b/test/610_proxy_wait_for_weave_test.sh @@ -0,0 +1,15 @@ +#! /bin/bash + +. ./config.sh + +start_suite "Proxy waits for weave to be ready before running container commands" +weave_on $HOST1 launch-proxy +BASE_IMAGE=ubuntu +# Ensure the base image does not exist, so that it will be pulled +if (docker_on $HOST1 images $BASE_IMAGE | grep $BASE_IMAGE); then + docker_on $HOST1 rmi $BASE_IMAGE +fi + +assert_raises "docker_proxy_on $HOST1 run -e 'WEAVE_CIDR=10.2.1.1/24' $BASE_IMAGE ip link show ethwe | grep 'state UP'" + +end_suite diff --git a/test/config.sh b/test/config.sh index 3983c826..48de3afb 100644 --- a/test/config.sh +++ b/test/config.sh @@ -76,6 +76,13 @@ docker_on() { docker -H tcp://$host:2375 "$@" } +docker_proxy_on() { + host=$1 + shift 1 + greyly echo "Docker (with proxy) on $host: $@" >&2 + docker -H tcp://$host:12375 "$@" +} + weave_on() { host=$1 shift 1