run integration tests against minikube on circleci

This commit is contained in:
Cedric Meury 2018-04-05 02:37:39 +02:00
parent 3545c12ee4
commit 8912eef468
2 changed files with 85 additions and 30 deletions

View File

@ -1,34 +1,74 @@
version: 2 version: 2
jobs: jobs:
build: build:
machine: true docker:
services: [ docker ] - image: circleci/golang:1.7
working_directory: /go/src/github.com/roboll/helmfile
steps: steps:
- checkout - checkout
- run: - run: make build
command: | - persist_to_workspace:
export GODIST="go1.7.linux-amd64.tar.gz" root: /go/src/github.com/roboll/helmfile
export GOPATH="$HOME/go" paths:
export PATH="$PATH:$GOPATH/bin" - .
export WORK="$GOPATH/src/github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/"
mkdir -p download
test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf download/$GODIST
dependencies:
override:
- mkdir -p "$WORK"
- rsync -az --delete ./ "$WORK"
test: test:
pre: docker:
- cd "$WORK" && make check - image: circleci/golang:1.7
- cd "$WORK" && make pristine working_directory: /go/src/github.com/roboll/helmfile
steps:
- checkout
- run: make check
- run: make pristine
- run: make test
override: # thanks to https://raw.githubusercontent.com/weaveworks/launcher/master/.circleci/config.yml
- cd "$WORK" && make test integration_tests:
machine: true
environment:
CHANGE_MINIKUBE_NONE_USER: true
steps:
- checkout
- run: mkdir ~/build
- attach_workspace:
at: ~/build
- run: cp ~/build/helmfile ~/project/helmfile
- &integration_deps
run:
name: Install integration test dependencies
command: |
# Install kubectl
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.4/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Install minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Install yq
curl -Lo yq https://github.com/mikefarah/yq/releases/download/1.14.0/yq_linux_amd64 && chmod +x yq && sudo mv yq /usr/local/bin/
# Install helm
HELM_VERSION=v2.8.2
HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz"
curl -Lo ${HELM_FILENAME} "https://kubernetes-helm.storage.googleapis.com/${HELM_FILENAME}"
tar zxf ${HELM_FILENAME} linux-amd64/helm
chmod +x linux-amd64/helm
sudo mv linux-amd64/helm /usr/local/bin/
- &start_minikube
run:
name: Start minikube
command: |
sudo minikube start --vm-driver=none
sudo chown -R $USER.$USER ~/.minikube
sudo chown -R $USER.$USER ~/.kube
minikube update-context
- &wait_for_minikube
run:
name: Wait for nodes to become ready
command: JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
- run:
name: Execute integration tests
command: |
export TERM=xterm
make integration
# GITHUB_TOKEN env var must be setup in circleci console # GITHUB_TOKEN env var must be setup in circleci console
deployment: deployment:
@ -38,3 +78,19 @@ deployment:
- docker login -e="." -u="$DOCKER_USER" -p="$DOCKER_PASS" quay.io - docker login -e="." -u="$DOCKER_USER" -p="$DOCKER_PASS" quay.io
- cd "$WORK" && make tools - cd "$WORK" && make tools
- cd "$WORK" && BUILD_URL="$CIRCLE_BUILD_URL" make push release - cd "$WORK" && BUILD_URL="$CIRCLE_BUILD_URL" make push release
workflows:
version: 2
build_and_test:
jobs:
- build
- test
integration_tests:
jobs:
- build
- integration_tests:
requires:
- build
filters:
branches:
only: pull/81

View File

@ -27,17 +27,16 @@ function wait_deploy_ready() {
done done
} }
# RUN BUILD & SETUP -------------------------------------------------------------------------------------------------- # SETUP --------------------------------------------------------------------------------------------------------------
set -e set -e
$helm init 1> /dev/null info "Using namespace: ${test_ns}"
make build 1> /dev/null info "Using Helm version: $(helm version --short --client | grep -o v.*$)"
$helmfile -v 1> /dev/null $helm init --wait
$helmfile -v
$kubectl get namespace ${test_ns} &> /dev/null && warn "Namespace ${test_ns} exists, from a previous test run?" $kubectl get namespace ${test_ns} &> /dev/null && warn "Namespace ${test_ns} exists, from a previous test run?"
trap "{ $kubectl delete namespace ${test_ns}; }" EXIT # remove namespace whenever we exit this script trap "{ $kubectl delete namespace ${test_ns}; }" EXIT # remove namespace whenever we exit this script
info "Using namespace: ${test_ns}"
info "Using Helm version: $(helm version --short --client | grep -o v.*$)"
# TEST CASES---------------------------------------------------------------------------------------------------------- # TEST CASES----------------------------------------------------------------------------------------------------------