2015-05-28 05:36:24 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2015-08-05 23:26:34 +00:00
|
|
|
set -x
|
|
|
|
|
|
|
|
source helpers.bash
|
2015-05-28 05:36:24 +00:00
|
|
|
|
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
2015-08-05 23:26:34 +00:00
|
|
|
# Port used by engine under test
|
|
|
|
ENGINE_PORT=5216
|
|
|
|
|
2015-05-28 05:36:24 +00:00
|
|
|
# Root directory of Distribution
|
|
|
|
DISTRIBUTION_ROOT=$(cd ../..; pwd -P)
|
|
|
|
|
2015-08-05 23:26:34 +00:00
|
|
|
DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-overlay}
|
|
|
|
EXEC_DRIVER=${EXEC_DRIVER:-native}
|
|
|
|
|
2015-05-28 22:28:50 +00:00
|
|
|
volumeMount=""
|
|
|
|
if [ "$DOCKER_VOLUME" != "" ]; then
|
|
|
|
volumeMount="-v ${DOCKER_VOLUME}:/var/lib/docker"
|
|
|
|
fi
|
|
|
|
|
2015-06-03 17:18:02 +00:00
|
|
|
dockerMount=""
|
|
|
|
if [ "$DOCKER_BINARY" != "" ]; then
|
|
|
|
dockerMount="-v ${DOCKER_BINARY}:/usr/local/bin/docker"
|
2015-08-05 23:26:34 +00:00
|
|
|
else
|
|
|
|
DOCKER_BINARY=docker
|
2015-06-03 17:18:02 +00:00
|
|
|
fi
|
|
|
|
|
2015-05-28 05:36:24 +00:00
|
|
|
# Image containing the integration tests environment.
|
|
|
|
INTEGRATION_IMAGE=${INTEGRATION_IMAGE:-distribution/docker-integration}
|
|
|
|
|
2015-08-05 23:26:34 +00:00
|
|
|
if [ "$1" == "-d" ]; then
|
|
|
|
start_daemon
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
TESTS=${@:-.}
|
|
|
|
|
2015-05-28 05:36:24 +00:00
|
|
|
# Make sure we upgrade the integration environment.
|
2015-05-28 22:55:04 +00:00
|
|
|
docker pull $INTEGRATION_IMAGE
|
2015-05-28 05:36:24 +00:00
|
|
|
|
2015-08-05 23:26:34 +00:00
|
|
|
# Start a Docker engine inside a docker container
|
|
|
|
ID=$(docker run -d -it -p $ENGINE_PORT:$ENGINE_PORT --privileged $volumeMount $dockerMount \
|
2015-05-28 05:36:24 +00:00
|
|
|
-v ${DISTRIBUTION_ROOT}:/go/src/github.com/docker/distribution \
|
2015-08-05 23:26:34 +00:00
|
|
|
-e "ENGINE_PORT=$ENGINE_PORT" \
|
|
|
|
-e "DOCKER_GRAPHDRIVER=$DOCKER_GRAPHDRIVER" \
|
2015-05-28 05:36:24 +00:00
|
|
|
-e "EXEC_DRIVER=$EXEC_DRIVER" \
|
|
|
|
${INTEGRATION_IMAGE} \
|
2015-08-05 23:26:34 +00:00
|
|
|
./run_engine.sh)
|
|
|
|
|
|
|
|
# Wait for it to become reachable.
|
|
|
|
tries=10
|
|
|
|
until "$DOCKER_BINARY" -H "127.0.0.1:$ENGINE_PORT" version &> /dev/null; do
|
|
|
|
(( tries-- ))
|
|
|
|
if [ $tries -le 0 ]; then
|
|
|
|
echo >&2 "error: daemon failed to start"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
# 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_BINARY" -H "127.0.0.1:$ENGINE_PORT" load
|
|
|
|
done
|
|
|
|
|
|
|
|
#DOCKER_HOST="tcp://127.0.0.1:$ENGINE_PORT" docker-compose pull
|
|
|
|
#DOCKER_HOST="tcp://127.0.0.1:$ENGINE_PORT" docker-compose build
|
|
|
|
|
|
|
|
# Run the tests.
|
|
|
|
docker exec -it "$ID" sh -c "DOCKER_HOST=tcp://127.0.0.1:$ENGINE_PORT ./test_runner.sh $TESTS"
|
|
|
|
|
|
|
|
# Stop container
|
|
|
|
docker rm -f -v "$ID"
|