2015-05-28 07:36:24 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2015-08-06 01:26:34 +02:00
|
|
|
set -x
|
|
|
|
|
2015-05-28 07:36:24 +02:00
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
2015-08-18 02:00:58 +02:00
|
|
|
source helpers.bash
|
2015-08-06 01:26:34 +02:00
|
|
|
|
2015-05-28 07:36:24 +02:00
|
|
|
# Root directory of Distribution
|
|
|
|
DISTRIBUTION_ROOT=$(cd ../..; pwd -P)
|
|
|
|
|
2015-05-29 00:28:50 +02:00
|
|
|
volumeMount=""
|
|
|
|
if [ "$DOCKER_VOLUME" != "" ]; then
|
|
|
|
volumeMount="-v ${DOCKER_VOLUME}:/var/lib/docker"
|
|
|
|
fi
|
|
|
|
|
2015-06-03 19:18:02 +02:00
|
|
|
dockerMount=""
|
|
|
|
if [ "$DOCKER_BINARY" != "" ]; then
|
|
|
|
dockerMount="-v ${DOCKER_BINARY}:/usr/local/bin/docker"
|
2015-08-06 01:26:34 +02:00
|
|
|
else
|
|
|
|
DOCKER_BINARY=docker
|
2015-06-03 19:18:02 +02:00
|
|
|
fi
|
|
|
|
|
2015-05-28 07:36:24 +02:00
|
|
|
# Image containing the integration tests environment.
|
|
|
|
INTEGRATION_IMAGE=${INTEGRATION_IMAGE:-distribution/docker-integration}
|
|
|
|
|
2015-08-06 01:26:34 +02:00
|
|
|
if [ "$1" == "-d" ]; then
|
|
|
|
start_daemon
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
TESTS=${@:-.}
|
|
|
|
|
2015-05-28 07:36:24 +02:00
|
|
|
# Make sure we upgrade the integration environment.
|
2015-05-29 00:55:04 +02:00
|
|
|
docker pull $INTEGRATION_IMAGE
|
2015-05-28 07:36:24 +02:00
|
|
|
|
2015-08-06 01:26:34 +02:00
|
|
|
# Start a Docker engine inside a docker container
|
2015-08-18 02:00:58 +02:00
|
|
|
ID=$(docker run -d -it --privileged $volumeMount $dockerMount \
|
2015-05-28 07:36:24 +02:00
|
|
|
-v ${DISTRIBUTION_ROOT}:/go/src/github.com/docker/distribution \
|
2015-08-06 01:26:34 +02:00
|
|
|
-e "DOCKER_GRAPHDRIVER=$DOCKER_GRAPHDRIVER" \
|
2015-05-28 07:36:24 +02:00
|
|
|
-e "EXEC_DRIVER=$EXEC_DRIVER" \
|
|
|
|
${INTEGRATION_IMAGE} \
|
2015-08-06 01:26:34 +02:00
|
|
|
./run_engine.sh)
|
|
|
|
|
2015-08-18 02:00:58 +02:00
|
|
|
# Stop container on exit
|
|
|
|
trap "docker rm -f -v $ID" EXIT
|
|
|
|
|
2015-08-06 01:26:34 +02:00
|
|
|
# Wait for it to become reachable.
|
|
|
|
tries=10
|
2015-08-18 02:00:58 +02:00
|
|
|
until docker exec "$ID" docker version &> /dev/null; do
|
2015-08-06 01:26:34 +02:00
|
|
|
(( tries-- ))
|
|
|
|
if [ $tries -le 0 ]; then
|
|
|
|
echo >&2 "error: daemon failed to start"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2015-08-18 02:00:58 +02:00
|
|
|
# If no volume is specified, transfer images into the container from
|
|
|
|
# the outer docker instance
|
|
|
|
if [ "$DOCKER_VOLUME" == "" ]; then
|
|
|
|
# Make sure we have images outside the container, to transfer to the container.
|
|
|
|
# Not much will happen here if the images are already present.
|
|
|
|
docker-compose pull
|
|
|
|
docker-compose build
|
|
|
|
|
|
|
|
# Transfer images to the inner container.
|
|
|
|
for image in "$INTEGRATION_IMAGE" registry:0.9.1 dockerintegration_nginx dockerintegration_registryv2; do
|
|
|
|
docker save "$image" | docker exec -i "$ID" docker load
|
|
|
|
done
|
|
|
|
fi
|
2015-08-06 01:26:34 +02:00
|
|
|
|
|
|
|
# Run the tests.
|
2015-08-18 02:00:58 +02:00
|
|
|
docker exec -it "$ID" sh -c "./test_runner.sh $TESTS"
|
2015-08-06 01:26:34 +02:00
|
|
|
|