From 19ec4e2c7ae2bf59a65d52f48db1926bfa03c8ef Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Wed, 3 Jun 2015 10:18:02 -0700 Subject: [PATCH] Add docker developer flow Integrate flags better with the development flow a Docker developer. Add a shell function to make invocation of tests easy. Signed-off-by: Derek McGowan (github: dmcgowan) --- contrib/docker-integration/README.md | 48 +++++++++++++++++++++++++++- contrib/docker-integration/run.sh | 10 ++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/contrib/docker-integration/README.md b/contrib/docker-integration/README.md index 9b091d99..e12bec1a 100644 --- a/contrib/docker-integration/README.md +++ b/contrib/docker-integration/README.md @@ -29,7 +29,53 @@ Run with aufs driver and tmp volume **NOTE: Using a volume will prevent multiple runs from needing to re-pull images** ``` -$ STORAGE_DRIVER=aufs DOCKER_VOLUME=/tmp/volume ./run.sh +$ DOCKER_GRAPHDRIVER=aufs DOCKER_VOLUME=/tmp/volume ./run.sh +``` + +### Example developer flow + +These tests are useful for developing both as a registry and docker +core developer. The following setup may be used to do integration +testing between development versions + +Insert into your `.zshrc` or `.bashrc` + +``` +# /usr/lib/docker for Docker-in-Docker +# Set this directory to make each invocation run much faster, without +# the need to repull images. +export DOCKER_VOLUME=$HOME/.docker-test-volume + +# Use overlay for all Docker testing, try aufs if overlay not supported +export DOCKER_GRAPHDRIVER=overlay + +# Name this according to personal preference +function rdtest() { + if [ "$1" != "" ]; then + DOCKER_BINARY=$GOPATH/src/github.com/docker/docker/bundles/$1/binary/docker + if [ ! -f $DOCKER_BINARY ]; then + current_version=`cat $GOPATH/src/github.com/docker/docker/VERSION` + echo "$DOCKER_BINARY does not exist" + echo "Current checked out docker version: $current_version" + echo "Checkout desired version and run 'make binary' from $GOPATH/src/github.com/docker/docker" + return 1 + fi + fi + + $GOPATH/src/github.com/docker/distribution/contrib/docker-integration/run.sh +} +``` + +Run with Docker release version +``` +$ rdtest +``` + +Run using local development version of docker +``` +$ cd $GOPATH/src/github.com/docker/docker +$ make binary +$ rdtest `cat VERSION` ``` ## Running manually outside of Docker diff --git a/contrib/docker-integration/run.sh b/contrib/docker-integration/run.sh index e670db01..c36c5147 100755 --- a/contrib/docker-integration/run.sh +++ b/contrib/docker-integration/run.sh @@ -11,6 +11,11 @@ if [ "$DOCKER_VOLUME" != "" ]; then volumeMount="-v ${DOCKER_VOLUME}:/var/lib/docker" fi +dockerMount="" +if [ "$DOCKER_BINARY" != "" ]; then + dockerMount="-v ${DOCKER_BINARY}:/usr/local/bin/docker" +fi + # Image containing the integration tests environment. INTEGRATION_IMAGE=${INTEGRATION_IMAGE:-distribution/docker-integration} @@ -18,10 +23,9 @@ INTEGRATION_IMAGE=${INTEGRATION_IMAGE:-distribution/docker-integration} docker pull $INTEGRATION_IMAGE # Start the integration tests in a Docker container. -ID=$(docker run -d -t --privileged $volumeMount \ +ID=$(docker run -d -t --privileged $volumeMount $dockerMount \ -v ${DISTRIBUTION_ROOT}:/go/src/github.com/docker/distribution \ - -e "DOCKER_VERSION=$DOCKER_VERSION" \ - -e "STORAGE_DRIVER=$STORAGE_DRIVER" \ + -e "STORAGE_DRIVER=$DOCKER_GRAPHDRIVER" \ -e "EXEC_DRIVER=$EXEC_DRIVER" \ ${INTEGRATION_IMAGE} \ ./test_runner.sh "$@")