Add dind test runner
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
f6716e73c9
commit
06de74a4e9
3 changed files with 138 additions and 0 deletions
55
contrib/docker-integration/Dockerfile
Normal file
55
contrib/docker-integration/Dockerfile
Normal file
|
@ -0,0 +1,55 @@
|
|||
FROM debian:jessie
|
||||
|
||||
# compile and runtime deps
|
||||
# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
# For DIND
|
||||
ca-certificates \
|
||||
curl \
|
||||
iptables \
|
||||
procps \
|
||||
e2fsprogs \
|
||||
xz-utils \
|
||||
# For build
|
||||
build-essential \
|
||||
file \
|
||||
git \
|
||||
net-tools \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Docker
|
||||
ENV VERSION 1.7.0-rc1
|
||||
RUN curl -L -o /usr/local/bin/docker https://test.docker.com/builds/Linux/x86_64/docker-${VERSION} \
|
||||
&& chmod +x /usr/local/bin/docker
|
||||
|
||||
# Install DIND
|
||||
RUN curl -L -o /dind https://raw.githubusercontent.com/docker/docker/master/hack/dind \
|
||||
&& chmod +x /dind
|
||||
|
||||
# Install golang
|
||||
ENV GO_VERSION 1.4.2
|
||||
RUN curl -sSL https://golang.org/dl/go${GO_VERSION}.src.tar.gz | tar -v -C /usr/local -xz \
|
||||
&& mkdir -p /go/bin
|
||||
ENV PATH /go/bin:/usr/local/go/bin:$PATH
|
||||
ENV GOPATH /go
|
||||
RUN cd /usr/local/go/src && ./make.bash --no-clean 2>&1
|
||||
|
||||
# Go dependencies
|
||||
RUN go get github.com/tools/godep
|
||||
|
||||
# Install bats
|
||||
RUN cd /usr/local/src/ \
|
||||
&& git clone https://github.com/sstephenson/bats.git \
|
||||
&& cd bats \
|
||||
&& ./install.sh /usr/local
|
||||
|
||||
# Install docker-compose
|
||||
RUN curl -L https://github.com/docker/compose/releases/download/1.2.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose \
|
||||
&& chmod +x /usr/local/bin/docker-compose
|
||||
|
||||
RUN mkdir -p /go/src/github.com/docker/distribution
|
||||
WORKDIR /go/src/github.com/docker/distribution/contrib/docker-integration
|
||||
|
||||
VOLUME /var/lib/docker
|
||||
|
||||
ENTRYPOINT ["/dind"]
|
29
contrib/docker-integration/run.sh
Executable file
29
contrib/docker-integration/run.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
||||
|
||||
# Root directory of Distribution
|
||||
DISTRIBUTION_ROOT=$(cd ../..; pwd -P)
|
||||
|
||||
# Image containing the integration tests environment.
|
||||
INTEGRATION_IMAGE=${INTEGRATION_IMAGE:-distribution/docker-integration}
|
||||
|
||||
# Make sure we upgrade the integration environment.
|
||||
# Not yet on hub, run `docker build -t distribution/docker-integration .`
|
||||
#docker pull $INTEGRATION_IMAGE
|
||||
|
||||
# Start the integration tests in a Docker container.
|
||||
ID=$(docker run -d -t --privileged \
|
||||
-v ${DISTRIBUTION_ROOT}:/go/src/github.com/docker/distribution \
|
||||
-e "DOCKER_IMAGE=$DOCKER_IMAGE" \
|
||||
-e "DOCKER_VERSION=$DOCKER_VERSION" \
|
||||
-e "STORAGE_DRIVER=$STORAGE_DRIVER" \
|
||||
-e "EXEC_DRIVER=$EXEC_DRIVER" \
|
||||
${INTEGRATION_IMAGE} \
|
||||
./test_runner.sh "$@")
|
||||
|
||||
# Clean it up when we exit.
|
||||
trap "docker rm -f -v $ID > /dev/null" EXIT
|
||||
|
||||
docker logs -f $ID
|
54
contrib/docker-integration/test_runner.sh
Executable file
54
contrib/docker-integration/test_runner.sh
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
||||
|
||||
# Load the helpers.
|
||||
#. helpers.bash
|
||||
|
||||
TESTS=${@:-.}
|
||||
|
||||
# Drivers to use for Docker engines the tests are going to create.
|
||||
STORAGE_DRIVER=${STORAGE_DRIVER:-overlay}
|
||||
EXEC_DRIVER=${EXEC_DRIVER:-native}
|
||||
|
||||
|
||||
function execute() {
|
||||
>&2 echo "++ $@"
|
||||
eval "$@"
|
||||
}
|
||||
|
||||
# Set IP address in /etc/hosts for localregistry
|
||||
IP=$(ifconfig eth0|grep "inet addr:"| cut -d: -f2 | awk '{ print $1}')
|
||||
execute echo "$IP localregistry" >> /etc/hosts
|
||||
|
||||
# Setup certificates
|
||||
execute sh install_certs.sh localregistry
|
||||
|
||||
# Start the docker engine.
|
||||
execute docker --daemon --log-level=panic \
|
||||
--storage-driver="$STORAGE_DRIVER" --exec-driver="$EXEC_DRIVER" &
|
||||
DOCKER_PID=$!
|
||||
|
||||
# Wait for it to become reachable.
|
||||
tries=10
|
||||
until docker version &> /dev/null; do
|
||||
(( tries-- ))
|
||||
if [ $tries -le 0 ]; then
|
||||
echo >&2 "error: daemon failed to start"
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
execute time docker-compose build
|
||||
|
||||
execute docker-compose up -d
|
||||
|
||||
# Run the tests.
|
||||
execute time bats -p $TESTS
|
||||
|
||||
|
||||
# Run test script
|
||||
execute sh test_docker.sh localregistry
|
||||
|
Loading…
Reference in a new issue