mirror of https://github.com/docker/docs.git
Use a container to run the client integration tests
Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
parent
08c6669473
commit
8d18c33f5a
|
@ -1,39 +1,23 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function cleanup {
|
||||||
|
docker-compose -f development.yml stop
|
||||||
|
# if we're in CircleCI, we cannot remove any containers
|
||||||
|
if [[ -z "${CIRCLECI}" ]]; then
|
||||||
|
docker-compose -f development.yml rm -f
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -z "${CIRCLECI}" ]]; then
|
||||||
|
BUILDOPTS="--force-rm"
|
||||||
|
fi
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
function finish {
|
cleanup
|
||||||
docker-compose stop
|
|
||||||
if [[ -n "${COMPOSE_PID}" ]]; then
|
|
||||||
kill "${COMPOSE_PID}" || true
|
|
||||||
fi
|
|
||||||
if [[ -n "${TEST_PID}" ]]; then
|
|
||||||
kill "${TEST_PID}" || true
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
docker-compose stop
|
docker-compose -f development.yml build ${BUILDOPTS}
|
||||||
|
docker-compose -f development.yml up --abort-on-container-exit
|
||||||
|
|
||||||
# if we're in CircleCI, we cannot remove any containers
|
trap cleanup SIGINT SIGTERM EXIT
|
||||||
if [[ -z "${CIRCLECI}" ]]; then
|
|
||||||
docker-compose rm -f
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker-compose build
|
|
||||||
docker-compose up --abort-on-container-exit >> /dev/null &
|
|
||||||
COMPOSE_PID=$!
|
|
||||||
|
|
||||||
|
|
||||||
.build/testclient.sh &
|
|
||||||
TEST_PID=$!
|
|
||||||
|
|
||||||
set +x
|
|
||||||
|
|
||||||
wait ${TEST_PID}
|
|
||||||
|
|
||||||
(docker-compose logs &)
|
|
||||||
|
|
||||||
trap finish SIGINT SIGTERM EXIT
|
|
||||||
|
|
|
@ -2,21 +2,17 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
RANDOMSTRING="$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)"
|
make client
|
||||||
HOST="${REMOTE_SERVER_URL:-https://localhost:4443}"
|
|
||||||
|
|
||||||
OPTS="-c cmd/notary/config.json -d /tmp/${RANDOMSTRING}"
|
set +e
|
||||||
if [[ -n "${DOCKER_HOST}" ]]; then
|
|
||||||
if [[ "$(resolveip -s notary-server)" == *"${DOCKER_HOST}"* ]]; then
|
RANDOMSTRING="$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)"
|
||||||
echo "This test is going to fail since the client doesn't have a trusted CA root for ${HOST}"
|
HOST="${REMOTE_SERVER_URL:-https://notary-server:4443}"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
HOST="${REMOTE_SERVER_URL:-https://notary-server:4443}"
|
|
||||||
OPTS="$OPTS -s ${HOST}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
REPONAME="docker.com/notary/${RANDOMSTRING}"
|
REPONAME="docker.com/notary/${RANDOMSTRING}"
|
||||||
|
|
||||||
|
OPTS="-c cmd/notary/config.json -d /tmp/${RANDOMSTRING}"
|
||||||
|
|
||||||
export NOTARY_ROOT_PASSPHRASE=ponies
|
export NOTARY_ROOT_PASSPHRASE=ponies
|
||||||
export NOTARY_TARGETS_PASSPHRASE=ponies
|
export NOTARY_TARGETS_PASSPHRASE=ponies
|
||||||
export NOTARY_SNAPSHOT_PASSPHRASE=ponies
|
export NOTARY_SNAPSHOT_PASSPHRASE=ponies
|
||||||
|
@ -29,7 +25,7 @@ echo
|
||||||
rm -rf "/tmp/${RANDOMSTRING}"
|
rm -rf "/tmp/${RANDOMSTRING}"
|
||||||
|
|
||||||
iter=0
|
iter=0
|
||||||
until curl -k "${HOST}"
|
until (curl -s -S -k "${HOST}")
|
||||||
do
|
do
|
||||||
((iter++))
|
((iter++))
|
||||||
if (( iter > 30 )); then
|
if (( iter > 30 )); then
|
||||||
|
@ -40,10 +36,9 @@ do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
make client
|
|
||||||
|
|
||||||
bin/notary ${OPTS} init ${REPONAME}
|
bin/notary ${OPTS} init ${REPONAME}
|
||||||
bin/notary ${OPTS} delegation add ${REPONAME} targets/releases fixtures/secure.example.com.crt --all-paths
|
bin/notary ${OPTS} delegation add ${REPONAME} targets/releases fixtures/secure.example.com.crt --all-paths
|
||||||
bin/notary ${OPTS} add ${REPONAME} readmetarget README.md
|
bin/notary ${OPTS} add ${REPONAME} readmetarget README.md
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -170,6 +170,9 @@ covmerge:
|
||||||
clean-protos:
|
clean-protos:
|
||||||
@rm proto/*.pb.go
|
@rm proto/*.pb.go
|
||||||
|
|
||||||
|
client: ${PREFIX}/bin/notary
|
||||||
|
@echo "+ $@"
|
||||||
|
|
||||||
binaries: ${PREFIX}/bin/notary-server ${PREFIX}/bin/notary ${PREFIX}/bin/notary-signer
|
binaries: ${PREFIX}/bin/notary-server ${PREFIX}/bin/notary ${PREFIX}/bin/notary-signer
|
||||||
@echo "+ $@"
|
@echo "+ $@"
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,15 @@ machine:
|
||||||
pre:
|
pre:
|
||||||
# Install gvm
|
# Install gvm
|
||||||
- bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/1.0.22/binscripts/gvm-installer)
|
- bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/1.0.22/binscripts/gvm-installer)
|
||||||
|
# Upgrade docker
|
||||||
|
- sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci'
|
||||||
|
- sudo chmod 0755 /usr/bin/docker
|
||||||
|
|
||||||
post:
|
post:
|
||||||
# Install many go versions
|
# Install many go versions
|
||||||
- gvm install go1.6 -B --name=stable
|
- gvm install go1.6 -B --name=stable
|
||||||
|
# upgrade compose
|
||||||
|
- sudo pip install --upgrade docker-compose
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
@ -80,6 +85,6 @@ test:
|
||||||
|
|
||||||
post:
|
post:
|
||||||
# Report to codecov.io
|
# Report to codecov.io
|
||||||
- bash <(curl -s https://codecov.io/bash):
|
- case $CIRCLE_NODE_INDEX in 0) bash <(curl -s https://codecov.io/bash) ;; 1) bash <(curl -s https://codecov.io/bash) ;; esac:
|
||||||
parallel: true
|
parallel: true
|
||||||
pwd: $BASE_STABLE
|
pwd: $BASE_STABLE
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
server:
|
||||||
|
build: .
|
||||||
|
dockerfile: server.Dockerfile
|
||||||
|
links:
|
||||||
|
- mysql
|
||||||
|
- signer
|
||||||
|
- signer:notarysigner
|
||||||
|
environment:
|
||||||
|
- SERVICE_NAME=notary_server
|
||||||
|
entrypoint: /bin/bash
|
||||||
|
command: -c "./migrations/migrate.sh && notary-server -config=fixtures/server-config.json"
|
||||||
|
signer:
|
||||||
|
build: .
|
||||||
|
dockerfile: signer.Dockerfile
|
||||||
|
links:
|
||||||
|
- mysql
|
||||||
|
environment:
|
||||||
|
- SERVICE_NAME=notary_signer
|
||||||
|
entrypoint: /bin/bash
|
||||||
|
command: -c "./migrations/migrate.sh && notary-signer -config=fixtures/signer-config.json"
|
||||||
|
mysql:
|
||||||
|
volumes:
|
||||||
|
- ./notarymysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
|
||||||
|
image: mariadb:10.1.10
|
||||||
|
environment:
|
||||||
|
- TERM=dumb
|
||||||
|
- MYSQL_ALLOW_EMPTY_PASSWORD="true"
|
||||||
|
command: mysqld --innodb_file_per_table
|
||||||
|
client:
|
||||||
|
build: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
links:
|
||||||
|
- server:notary-server
|
||||||
|
command: .build/testclient.sh
|
Loading…
Reference in New Issue