Skip to content

Commit

Permalink
Start running integration tests in CI (#1064)
Browse files Browse the repository at this point in the history
* Start running integration tests in CI
* Add gcp helper funcs
* Split integration test cleanup into separate phase

Signed-off-by: Kevin Lingerfelt <kl@buoyant.io>
  • Loading branch information
klingerf committed Jun 15, 2018
1 parent 0ed4028 commit a68ca73
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 15 deletions.
63 changes: 49 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ stages:
- name: test
- name: docker-deploy
if: branch = master AND type != pull_request
- name: integration-test
if: branch = master AND type != pull_request

jobs:
include:
Expand Down Expand Up @@ -91,23 +93,12 @@ jobs:
- |
# Install gcloud and kubectl.
dir="${CLOUDSDK_INSTALL_DIR:-${HOME}}/google-cloud-sdk"
export CLOUDSDK_CORE_DISABLE_PROMPTS=1
if [ -d "$dir/bin" ]; then
. "$dir/path.bash.inc"
gcloud components update
else
rm -rf "$dir"
curl https://sdk.cloud.google.com | bash
. "$dir/path.bash.inc"
fi
gcloud components install kubectl
(. bin/_gcp.sh ; install_gcloud_kubectl "$dir")
. "$dir/path.bash.inc"
- |
# Configure gcloud with a service account.
openssl aes-256-cbc -K $encrypted_6af64675f81c_key -iv $encrypted_6af64675f81c_iv -in .gcp.json.enc -out .gcp.json -d
gcloud auth activate-service-account --key-file .gcp.json
gcloud config set core/project "$GCP_PROJECT"
gcloud config set compute/zone "$GCP_ZONE"
gcloud config set container/cluster "$GKE_CLUSTER"
(. bin/_gcp.sh ; set_gcloud_config "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER")
- |
# Get a kubernetes context.
(. bin/_gcp.sh ; get_k8s_ctx "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER")
Expand Down Expand Up @@ -142,6 +133,50 @@ jobs:
- target/cli/linux/conduit install --conduit-version=$CONDUIT_TAG |tee conduit.yml
- kubectl -n conduit apply -f conduit.yml --prune --selector='conduit.io/control-plane-component'

# Run integration tests after container images have been published.
- stage: integration-test

language: go
go: "1.10.2"
go_import_path: github.com/runconduit/conduit

cache:
directories:
- vendor
- "$HOME/google-cloud-sdk/"
- "$HOME/.cache"

install:
- ./bin/dep ensure -vendor-only -v
- ./bin/dep status -v

- |
# Install gcloud and kubectl.
dir="${CLOUDSDK_INSTALL_DIR:-${HOME}}/google-cloud-sdk"
(. bin/_gcp.sh ; install_gcloud_kubectl "$dir")
. "$dir/path.bash.inc"
- |
# Configure gcloud with a service account.
openssl aes-256-cbc -K $encrypted_6af64675f81c_key -iv $encrypted_6af64675f81c_iv -in .gcp.json.enc -out .gcp.json -d
(. bin/_gcp.sh ; set_gcloud_config "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER")
- |
# Get a kubernetes context.
(. bin/_gcp.sh ; get_k8s_ctx "$GCP_PROJECT" "$GCP_ZONE" "$GKE_CLUSTER")
- gcloud version
- kubectl version --short

script:
- |
# Run integration tests.
version=$(./bin/go-run cli version --client --short)
namespace=conduit-$(echo $version | tr -cd '[:alnum:]-')
./bin/test-run $(pwd)/.gorun $namespace
after_script:
- |
# Cleanup after integration test run.
./bin/test-cleanup "conduit-$(./bin/root-tag | tr -cd '[:alnum:]-')"
# If we want to start building everything against bleeding-edge Rust nightly, we'll have
# to enable:
#
Expand Down
26 changes: 26 additions & 0 deletions bin/_gcp.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
set -eu

install_gcloud_kubectl() {
dir="$1"

export CLOUDSDK_CORE_DISABLE_PROMPTS=1
if [ -d "$dir/bin" ]; then
. "$dir/path.bash.inc"
gcloud components update
else
rm -rf "$dir"
curl https://sdk.cloud.google.com | bash
. "$dir/path.bash.inc"
fi
gcloud components install kubectl
}

set_gcloud_config() {
project="$1"
zone="$2"
cluster="$3"

gcloud auth activate-service-account --key-file .gcp.json
gcloud config set core/project "$project"
gcloud config set compute/zone "$zone"
gcloud config set container/cluster "$cluster"
}

get_k8s_ctx() {
project="$1"
zone="$2"
Expand Down
2 changes: 1 addition & 1 deletion bin/test-run
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ printf "Testing Conduit version [%s] namespace [%s]\\n" "$conduit_version" "$con

exit_code=0
run_test "$test_directory/install_test.go" || exit_code=$?
for test in $(find "$test_directory" -name '*_test.go' -mindepth 2); do
for test in $(find "$test_directory" -mindepth 2 -name '*_test.go'); do
run_test "$test" || exit_code=$?
done
exit $exit_code

0 comments on commit a68ca73

Please sign in to comment.