Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Add docker-compose integration test #1201

Merged
merged 16 commits into from
Jul 19, 2019
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ dist: xenial

go_import_path: github.com/google/keytransparency

services:
- docker
cache:
directories:
- "$HOME/gcloud/"
Expand All @@ -31,6 +33,8 @@ before_install:

install:
- gcloud -q components install kubectl
- docker --version
- docker-compose --version
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.16.0
- if [ "$GO111MODULE" = "auto" ]; then go get -t -v ./... ; fi

Expand All @@ -39,13 +43,12 @@ script:
- golangci-lint run --deadline=5m
- go test ./... -coverprofile=coverage1.txt
- go test ./impl/integration/ -coverprofile=coverage2.txt -coverpkg=./...
- ./scripts/integration.sh

after_success:
- bash <(curl -s https://codecov.io/bash)

before_deploy:
- docker --version
- docker-compose --version
- openssl aes-256-cbc -K $encrypted_555d9b2948d2_key -iv $encrypted_555d9b2948d2_iv
-in client_secrets.json.enc -d | gcloud auth activate-service-account --key-file /dev/stdin
- go get github.com/google/trillian/server/trillian_log_server
Expand Down
25 changes: 11 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
depends_on:
- server
- sequencer
image: us.gcr.io/key-transparency/prometheus:${TRAVIS_COMMIT}
image: gcr.io/key-transparency/prometheus:${TRAVIS_COMMIT}
build:
context: .
dockerfile: deploy/prometheus/Dockerfile
Expand All @@ -30,10 +30,7 @@ services:
- 9090:9090

db:
image: us.gcr.io/key-transparency/db
build:
context: ../trillian
dockerfile: examples/deployment/docker/db_server/Dockerfile
image: gcr.io/trillian-opensource-ci/db_server:latest
restart: always
ports:
- "3306"
Expand All @@ -42,10 +39,10 @@ services:
MYSQL_USER: test
MYSQL_DATABASE: test

log-server:
log-server:
depends_on:
- db
image: us.gcr.io/trillian/log-server:latest
image: gcr.io/trillian-opensource-ci/log_server:latest
restart: always
command:
- --mysql_uri=test:zaphod@tcp(db:3306)/test
Expand All @@ -64,7 +61,7 @@ services:
log-signer:
depends_on:
- db
image: us.gcr.io/trillian/log-signer:latest
image: gcr.io/trillian-opensource-ci/log_signer:latest
restart: always
command:
- --mysql_uri=test:zaphod@tcp(db:3306)/test
Expand All @@ -86,7 +83,7 @@ services:
map-server:
depends_on:
- db
image: us.gcr.io/trillian/map-server:latest
image: gcr.io/trillian-opensource-ci/map_server:latest
restart: always
command:
- --mysql_uri=test:zaphod@tcp(db:3306)/test
Expand All @@ -107,7 +104,7 @@ services:
- db
- log-server
- map-server
image: us.gcr.io/key-transparency/keytransparency-server:${TRAVIS_COMMIT}
image: gcr.io/key-transparency/keytransparency-server:${TRAVIS_COMMIT}
build:
context: .
dockerfile: ./cmd/keytransparency-server/Dockerfile
Expand All @@ -124,7 +121,7 @@ services:
- --tls-cert=/kt/server.crt
- --auth-type=insecure-fake
- --alsologtostderr
- --v=5
- --v=1
labels:
kompose.service.type: LoadBalancer
healthcheck:
Expand All @@ -138,7 +135,7 @@ services:
- db
- log-server
- map-server
image: us.gcr.io/key-transparency/keytransparency-sequencer:${TRAVIS_COMMIT}
image: gcr.io/key-transparency/keytransparency-sequencer:${TRAVIS_COMMIT}
build:
context: .
dockerfile: ./cmd/keytransparency-sequencer/Dockerfile
Expand All @@ -163,7 +160,7 @@ services:
retries: 5

init:
image: us.gcr.io/key-transparency/init:latest
image: gcr.io/key-transparency/init:latest
restart: "on-failure"
deploy:
restart_policy:
Expand All @@ -179,7 +176,7 @@ services:
depends_on:
- server
- sequencer
image: us.gcr.io/key-transparency/keytransparency-monitor:${TRAVIS_COMMIT}
image: gcr.io/key-transparency/keytransparency-monitor:${TRAVIS_COMMIT}
build:
context: .
dockerfile: ./cmd/keytransparency-monitor/Dockerfile
Expand Down
25 changes: 25 additions & 0 deletions scripts/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -ex
set -o pipefail

if [ ! -f genfiles/server.key ]; then
./scripts/prepare_server.sh -f
fi

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
trap "docker-compose down" INT EXIT

set +e
wget -T 60 --spider --retry-connrefused localhost:443
gdbelvin marked this conversation as resolved.
Show resolved Hide resolved
wget -T 60 --spider --retry-on-http-error=404 --no-check-certificate https://localhost/v1/directories/default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you don't want to fail the script here if you can't get a 200 response? It seems it'd make it easier to tell what went wrong. Is it just because you've found it to be a bit unreliable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

set -e

PASSWORD="foobar"
go run ./cmd/keytransparency-client authorized-keys create-keyset --password=${PASSWORD}
go run ./cmd/keytransparency-client post [email protected] \
--insecure \
--data='dGVzdA==' \
--password=${PASSWORD} \
--kt-url=0.0.0.0:443 \
--verbose \
--logtostderr