Add integration tests that build the docker images and the client binary

Signed-off-by: Ying Li <ying.li@docker.com>
This commit is contained in:
Ying Li
2016-03-16 15:55:57 -07:00
parent 5617ee4720
commit 08c6669473
4 changed files with 98 additions and 1 deletions

39
.build/integrationtest.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -e
set -x
function finish {
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
# if we're in CircleCI, we cannot remove any containers
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

52
.build/testclient.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/env bash
set -e
RANDOMSTRING="$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)"
HOST="${REMOTE_SERVER_URL:-https://localhost:4443}"
OPTS="-c cmd/notary/config.json -d /tmp/${RANDOMSTRING}"
if [[ -n "${DOCKER_HOST}" ]]; then
if [[ "$(resolveip -s notary-server)" == *"${DOCKER_HOST}"* ]]; then
echo "This test is going to fail since the client doesn't have a trusted CA root for ${HOST}"
exit 1
fi
HOST="${REMOTE_SERVER_URL:-https://notary-server:4443}"
OPTS="$OPTS -s ${HOST}"
fi
REPONAME="docker.com/notary/${RANDOMSTRING}"
export NOTARY_ROOT_PASSPHRASE=ponies
export NOTARY_TARGETS_PASSPHRASE=ponies
export NOTARY_SNAPSHOT_PASSPHRASE=ponies
echo "Notary Host: ${HOST}"
echo "Repo Name: ${REPONAME}"
echo
rm -rf "/tmp/${RANDOMSTRING}"
iter=0
until curl -k "${HOST}"
do
((iter++))
if (( iter > 30 )); then
echo "notary service failed to come up within 30 seconds"
exit 1;
fi
echo "waiting for notary service to come up."
sleep 1
done
set -x
make client
bin/notary ${OPTS} init ${REPONAME}
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} publish ${REPONAME}
bin/notary ${OPTS} delegation list ${REPONAME} | grep targets/releases
cat README.md | bin/notary ${OPTS} verify $REPONAME readmetarget > /dev/null

View File

@@ -125,6 +125,9 @@ test-full: vet lint
@echo
go test -tags "${NOTARY_BUILDTAGS}" $(TESTOPTS) -v $(PKGS)
integration:
.build/integrationtest.sh
protos:
@protoc --go_out=plugins=grpc:. proto/*.proto

View File

@@ -8,6 +8,9 @@ machine:
# Install many go versions
- gvm install go1.6 -B --name=stable
services:
- docker
environment:
# Convenient shortcuts to "common" locations
CHECKOUT: /home/ubuntu/$CIRCLE_PROJECT_REPONAME
@@ -70,7 +73,7 @@ test:
override:
# Test stable, and report
# hacking this to be parallel
- case $CIRCLE_NODE_INDEX in 0) gvm use stable && NOTARY_BUILDTAGS=pkcs11 make ci ;; 1) gvm use stable && NOTARY_BUILDTAGS=none make ci ;; esac:
- case $CIRCLE_NODE_INDEX in 0) gvm use stable && NOTARY_BUILDTAGS=pkcs11 make ci ;; 1) gvm use stable && NOTARY_BUILDTAGS=none make ci ;; 2) gvm use stable && make integration ;; esac:
parallel: true
timeout: 600
pwd: $BASE_STABLE