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
- persist_to_workspace:
root: /go/src/github.com/roboll/helmfile
paths:
- .
test:
docker:
- image: circleci/golang:1.7
working_directory: /go/src/github.com/roboll/helmfile
steps:
- checkout
- run: make check
- run: make pristine
- run: make test
# thanks to https://raw.githubusercontent.com/weaveworks/launcher/master/.circleci/config.yml
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: | command: |
export GODIST="go1.7.linux-amd64.tar.gz" # Install kubectl
export GOPATH="$HOME/go" 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/
export PATH="$PATH:$GOPATH/bin" # Install minikube
export WORK="$GOPATH/src/github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/" curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
mkdir -p download # Install yq
test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST 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/
sudo rm -rf /usr/local/go # Install helm
sudo tar -C /usr/local -xzf download/$GODIST HELM_VERSION=v2.8.2
HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz"
dependencies: curl -Lo ${HELM_FILENAME} "https://kubernetes-helm.storage.googleapis.com/${HELM_FILENAME}"
override: tar zxf ${HELM_FILENAME} linux-amd64/helm
- mkdir -p "$WORK" chmod +x linux-amd64/helm
- rsync -az --delete ./ "$WORK" sudo mv linux-amd64/helm /usr/local/bin/
- &start_minikube
test: run:
pre: name: Start minikube
- cd "$WORK" && make check command: |
- cd "$WORK" && make pristine sudo minikube start --vm-driver=none
sudo chown -R $USER.$USER ~/.minikube
override: sudo chown -R $USER.$USER ~/.kube
- cd "$WORK" && make test 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----------------------------------------------------------------------------------------------------------