distribution/contrib/docker-integration
Derek McGowan 1a6949134e Fix mismatched version error on integration tests
When running a different version of docker outside of the default in the integration image, then commands will fail with mismatched version unless the docker binary is specified to the correct version.

Add various cleanups to run script.
Run all commands interacting with docker inside the container in an exec.
Remove port binding to outside of container since all commands run inside.
Trap docker rm to exit in case of failure which prevents final command from running.
Do no copy images when $DOCKER_VOLUME is specified, this allows for faster runs when mounting a volume with a warm image cache.
Move exec and graph driver defaulting into run engine script.
Remove duplicated update of /etc/hosts.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2015-08-17 17:00:58 -07:00
..
nginx Add v1 only http endpoint 2015-05-27 22:37:49 -07:00
docker-compose.yml Add v1 only http endpoint 2015-05-27 22:37:49 -07:00
Dockerfile Two more Docker integration test fixes 2015-08-04 13:28:03 -07:00
helpers.bash Redesign integration testing to copy images to nested containers 2015-08-06 18:06:18 -07:00
install_certs.sh Fix mismatched version error on integration tests 2015-08-17 17:00:58 -07:00
README.md Add docker developer flow 2015-06-05 13:19:55 -07:00
run_engine.sh Fix mismatched version error on integration tests 2015-08-17 17:00:58 -07:00
run_multiversion.sh Redesign integration testing to copy images to nested containers 2015-08-06 18:06:18 -07:00
run.sh Fix mismatched version error on integration tests 2015-08-17 17:00:58 -07:00
test_runner.sh Redesign integration testing to copy images to nested containers 2015-08-06 18:06:18 -07:00
tls.bats Change run_multiversion.sh to get Docker engine versions from dind container 2015-07-30 15:39:19 -07:00

Docker Registry Integration Testing

These integration tests cover interactions between the Docker daemon and the registry server. All tests are run using the docker cli.

The compose configuration is intended to setup a testing environment for Docker using multiple registry configurations. These configurations include different combinations of a v1 and v2 registry as well as TLS configurations.

Running inside of Docker

Get integration container

The container image to run the integation tests will need to be pulled or built locally.

Building locally

$ docker build -t distribution/docker-integration .

Run script

Invoke the tests within Docker through the run.sh script.

$ ./run.sh

Run with aufs driver and tmp volume NOTE: Using a volume will prevent multiple runs from needing to re-pull images

$ 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

Install Docker Compose

Docker Compose Installation Guide

Start compose setup

docker-compose up

Install Certificates

The certificates must be installed in /etc/docker/cert.d in order to use TLS client auth and use the CA certificate.

sudo sh ./install_certs.sh

Test with Docker

Tag an image as with any other private registry. Attempt to push the image.

docker pull hello-world
docker tag hello-world localhost:5440/hello-world
docker push localhost:5440/hello-world

docker tag hello-world localhost:5441/hello-world
docker push localhost:5441/hello-world
# Perform login using user `testuser` and password `passpassword`

Set /etc/hosts entry

Find the non-localhost ip address of local machine

Run bats

Run the bats tests after updating /etc/hosts, installing the certificates, and running the docker-compose script.

bats -p .

Configurations

Port V2 V1 TLS Authentication
5000 yes yes no none
5001 no yes no none
5002 yes no no none
5011 no yes yes none
5440 yes yes yes none
5441 yes yes yes basic (testuser/passpassword)
5442 yes yes yes TLS client
5443 yes yes yes TLS client (no CA)
5444 yes yes yes TLS client + basic (testuser/passpassword)
5445 yes yes yes (no CA) none
5446 yes yes yes (no CA) basic (testuser/passpassword)
5447 yes yes yes (no CA) TLS client
5448 yes yes yes (SSLv3) none