From e564231f58ce3a893b04e6ab3facbfaad54c2017 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Mon, 27 Jul 2015 18:08:04 -0700 Subject: [PATCH 1/2] Run integration tests with multiple Docker engine versions Add a run_multiversion.sh script that downloads a variety of Docker engines and runs the integration tests against each of them. Skip some of the tests when running with Docker 1.6.0. It has a bug that prevents these tests from completing successfully. Fixes #751 Signed-off-by: Aaron Lehmann --- .../docker-integration/run_multiversion.sh | 46 +++++++++++++++++++ contrib/docker-integration/tls.bats | 11 +++++ 2 files changed, 57 insertions(+) create mode 100755 contrib/docker-integration/run_multiversion.sh diff --git a/contrib/docker-integration/run_multiversion.sh b/contrib/docker-integration/run_multiversion.sh new file mode 100755 index 000000000..694dec4ed --- /dev/null +++ b/contrib/docker-integration/run_multiversion.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Run the integration tests with multiple versions of the Docker engine + +set -e + +# Don't use /tmp because this isn't available in boot2docker +tmpdir_template="`pwd`/docker-versions.XXXXX" +tmpdir=`mktemp -d "$tmpdir_template"` +trap "rm -rf $tmpdir" EXIT + +# If DOCKER_VOLUME is unset, create a temporary directory to cache containers +# between runs +# Only do this on Linux, because using /var/lib/docker from a host volume seems +# problematic with boot2docker. +if [ "$DOCKER_VOLUME" = "" -a `uname` = "Linux" ]; then + volumes_template="`pwd`/docker-versions.XXXXX" + volume=`mktemp -d "$volumes_template"` + trap "rm -rf $tmpdir $volume" EXIT +else + volume="$DOCKER_VOLUME" +fi + +# Released versions + +versions="1.6.0 1.7.0" + +for v in $versions; do + echo "Downloading Docker $v" + binpath="$tmpdir/docker-$v" + curl -L -o "$binpath" "https://test.docker.com/builds/Linux/x86_64/docker-$v" + chmod +x "$binpath" + echo "Running tests with Docker $v" + DOCKER_BINARY="$binpath" DOCKER_VOLUME="$volume" ./run.sh +done + +# Latest experimental version + +# Extract URI from https://experimental.docker.com/builds/ +experimental=`curl -sSL https://experimental.docker.com/builds/ | tr " " "\n" | grep 'https://experimental.docker.com/builds/Linux/'` +echo "Downloading Docker experimental" +binpath="$tmpdir/docker-experimental" +curl -L -o "$binpath" "$experimental" +chmod +x "$binpath" +echo "Running tests with Docker experimental" +DOCKER_BINARY="$binpath" DOCKER_VOLUME="$volume" ./run.sh diff --git a/contrib/docker-integration/tls.bats b/contrib/docker-integration/tls.bats index c0332283f..47ab6895c 100644 --- a/contrib/docker-integration/tls.bats +++ b/contrib/docker-integration/tls.bats @@ -13,6 +13,15 @@ function setup() { docker pull $image } +# skip basic auth tests with Docker 1.6, where they don't pass due to +# certificate issues +function basic_auth_version_check() { + run sh -c 'docker version | fgrep -q "Client version: 1.6.0"' + if [ "$status" -eq 0 ]; then + skip "Basic auth tests don't support 1.6.0" + fi +} + # has_digest enforces the last output line is "Digest: sha256:..." # the input is the name of the array containing the output lines function has_digest() { @@ -35,6 +44,7 @@ function login() { } @test "Test basic auth" { + basic_auth_version_check login $hostname:5441 docker tag -f $image $hostname:5441/$image run docker push $hostname:5441/$image @@ -56,6 +66,7 @@ function login() { } @test "Test basic auth with TLS client auth" { + basic_auth_version_check login $hostname:5444 docker tag -f $image $hostname:5444/$image run docker push $hostname:5444/$image From 1368e2ac53e9aa164d2d2a0e1bac1c2ffba01182 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Thu, 30 Jul 2015 15:38:33 -0700 Subject: [PATCH 2/2] Change run_multiversion.sh to get Docker engine versions from dind container This is much better than downloading the builds with curl, because Docker is intelligent about only pulling what it needs. We use tagged versions of dind for the released version, and dind-master for a master build. Signed-off-by: Aaron Lehmann --- .../docker-integration/run_multiversion.sh | 32 ++++++++++++------- contrib/docker-integration/tls.bats | 4 +-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/contrib/docker-integration/run_multiversion.sh b/contrib/docker-integration/run_multiversion.sh index 694dec4ed..e52a0e248 100755 --- a/contrib/docker-integration/run_multiversion.sh +++ b/contrib/docker-integration/run_multiversion.sh @@ -3,6 +3,7 @@ # Run the integration tests with multiple versions of the Docker engine set -e +set -x # Don't use /tmp because this isn't available in boot2docker tmpdir_template="`pwd`/docker-versions.XXXXX" @@ -23,24 +24,31 @@ fi # Released versions -versions="1.6.0 1.7.0" +versions="1.6.0 1.6.1 1.7.0 1.7.1" for v in $versions; do - echo "Downloading Docker $v" - binpath="$tmpdir/docker-$v" - curl -L -o "$binpath" "https://test.docker.com/builds/Linux/x86_64/docker-$v" - chmod +x "$binpath" + echo "Extracting Docker $v from dind image" + binpath="$tmpdir/docker-$v/docker" + ID=$(docker create dockerswarm/dind:$v) + docker cp "$ID:/usr/local/bin/docker" "$tmpdir/docker-$v" + echo "Running tests with Docker $v" DOCKER_BINARY="$binpath" DOCKER_VOLUME="$volume" ./run.sh + + # Cleanup. + docker rm -f "$ID" done # Latest experimental version -# Extract URI from https://experimental.docker.com/builds/ -experimental=`curl -sSL https://experimental.docker.com/builds/ | tr " " "\n" | grep 'https://experimental.docker.com/builds/Linux/'` -echo "Downloading Docker experimental" -binpath="$tmpdir/docker-experimental" -curl -L -o "$binpath" "$experimental" -chmod +x "$binpath" -echo "Running tests with Docker experimental" +echo "Extracting Docker master from dind image" +binpath="$tmpdir/docker-master/docker" +docker pull dockerswarm/dind-master +ID=$(docker create dockerswarm/dind-master) +docker cp "$ID:/usr/local/bin/docker" "$tmpdir/docker-master" + +echo "Running tests with Docker master" DOCKER_BINARY="$binpath" DOCKER_VOLUME="$volume" ./run.sh + +# Cleanup. +docker rm -f "$ID" diff --git a/contrib/docker-integration/tls.bats b/contrib/docker-integration/tls.bats index 47ab6895c..8b7ae2871 100644 --- a/contrib/docker-integration/tls.bats +++ b/contrib/docker-integration/tls.bats @@ -16,9 +16,9 @@ function setup() { # skip basic auth tests with Docker 1.6, where they don't pass due to # certificate issues function basic_auth_version_check() { - run sh -c 'docker version | fgrep -q "Client version: 1.6.0"' + run sh -c 'docker version | fgrep -q "Client version: 1.6."' if [ "$status" -eq 0 ]; then - skip "Basic auth tests don't support 1.6.0" + skip "Basic auth tests don't support 1.6.x" fi }