From 7d694f16d1225b86fe36f46740ffc6dc1a7ce747 Mon Sep 17 00:00:00 2001 From: Maciej Kwiek Date: Fri, 18 Aug 2017 15:02:09 +0200 Subject: [PATCH] Circleci e2e config Additional scripts, changes in Makefile and circleci config required to run dind cluster --- .circleci/config.yml | 14 +++++++++++++- Makefile | 14 +++++++++++++- e2e/e2e_test.go | 1 + e2e/helm_client.go | 4 ++++ scripts/ci.sh | 5 +++++ scripts/dind.sh | 22 ++++++++++++++++++++++ scripts/import-docker-image.sh | 27 +++++++++++++++++++++++++++ 7 files changed, 85 insertions(+), 2 deletions(-) create mode 100755 scripts/dind.sh create mode 100755 scripts/import-docker-image.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index c32c9f08d..49968308e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,12 +2,24 @@ version: 2 jobs: build: working_directory: /go/src/k8s.io/helm - parallelism: 3 + parallelism: 4 docker: - image: golang:1.8 environment: PROJECT_NAME: "kubernetes-helm" + DOCKER_VERSION: "17.03.0-ce" steps: + - setup_remote_docker + - run: + name: Install Docker client + command: | + set -x + curl -sSL -o "/tmp/docker-${DOCKER_VERSION}.tgz" "https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz" + tar -xz -C /tmp -f "/tmp/docker-${DOCKER_VERSION}.tgz" + mv /tmp/docker/* /usr/bin + - run: + name: Install socat + command: apt-get update && apt-get install -y socat - checkout - run: name: install dependencies diff --git a/Makefile b/Makefile index 2070fd4d0..d065841dd 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ APP = helm # go option GO ?= go -PKG := $(shell glide novendor) +PKG := ./pkg/... ./cmd/... TAGS := TESTS := . TESTFLAGS := @@ -117,6 +117,18 @@ clean: coverage: @scripts/coverage.sh +.PHONY: dind +dind: docker-build +dind: + @scripts/portforward.sh start + @scripts/dind.sh + @scripts/import-docker-image.sh + +.PHONY: e2e +e2e: dind +e2e: + go test -v ./e2e --cluster-url http://localhost:8080 --helm-bin ../bin/helm + HAS_GLIDE := $(shell command -v glide;) HAS_GOX := $(shell command -v gox;) HAS_GIT := $(shell command -v git;) diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 0893ec288..8bbd0b219 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -46,6 +46,7 @@ var _ = Describe("Basic Suite", func() { Clientset: clientset, HelmBin: helmBinPath, TillerHost: tillerHost, + UseCanary: true, } if !localTiller { Expect(helm.InstallTiller()).NotTo(HaveOccurred()) diff --git a/e2e/helm_client.go b/e2e/helm_client.go index 3789c2f86..d86087cc0 100644 --- a/e2e/helm_client.go +++ b/e2e/helm_client.go @@ -63,12 +63,16 @@ type BinaryHelmManager struct { Namespace string HelmBin string TillerHost string + UseCanary bool } func (m *BinaryHelmManager) InstallTiller() error { arg := make([]string, 0, 5) var err error arg = append(arg, "init", "--tiller-namespace", m.Namespace) + if m.UseCanary { + arg = append(arg, "--canary-image") + } _, err = m.executeUsingHelm(arg...) if err != nil { return err diff --git a/scripts/ci.sh b/scripts/ci.sh index e0faf9c18..c4f0bba66 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -42,6 +42,10 @@ run_docs_check() { make verify-docs } +run_e2e_test() { + make e2e +} + # Build to ensure packages are compiled echo "Running 'make build'" make build @@ -50,4 +54,5 @@ case "${CIRCLE_NODE_INDEX-0}" in 0) run_unit_test ;; 1) run_style_check ;; 2) run_docs_check ;; + 3) run_e2e_test ;; esac diff --git a/scripts/dind.sh b/scripts/dind.sh new file mode 100755 index 000000000..ca447e80f --- /dev/null +++ b/scripts/dind.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Copyright 2017 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +scripts/portforward.sh 8080& + +wget https://cdn.rawgit.com/Mirantis/kubeadm-dind-cluster/master/fixed/dind-cluster-v1.7.sh +chmod +x dind-cluster-v1.7.sh +RUN_ON_BTRFS_ANYWAY=trololo bash -x ./dind-cluster-v1.7.sh up +export PATH="$HOME/.kubeadm-dind-cluster:$PATH" diff --git a/scripts/import-docker-image.sh b/scripts/import-docker-image.sh new file mode 100755 index 000000000..701da6d1e --- /dev/null +++ b/scripts/import-docker-image.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail +set -o xtrace + +IMAGE_REPO=${IMAGE_REPO:-gcr.io/kubernetes-helm/tiller} +IMAGE_TAG=${IMAGE_TAG:-canary} +TMP_IMAGE_PATH=${TMP_IMAGE_PATH:-/tmp/image.tar} +NODE_PATTERN=${NODE_PATTERN:-"kube-node-"} + + +function import-image { + docker save ${IMAGE_REPO}:${IMAGE_TAG} -o "${TMP_IMAGE_PATH}" + + for node in `docker ps --format "{{.Names}}" | grep ${NODE_PATTERN}`; + do + docker cp "${TMP_IMAGE_PATH}" $node:/image.tar + docker exec -ti "$node" docker load -i /image.tar + done + + set +o xtrace + echo "Finished copying docker image to dind nodes" +} + +import-image