diff --git a/.circleci/config.yml b/.circleci/config.yml index 478988a2..0497333b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -122,6 +122,17 @@ jobs: - run: test/e2e-nginx.sh - run: test/e2e-nginx-tests.sh + e2e-linkerd-testing: + machine: true + steps: + - checkout + - attach_workspace: + at: /tmp/bin + - run: test/container-build.sh + - run: test/e2e-kind.sh + - run: test/e2e-linkerd.sh + - run: test/e2e-linkerd-tests.sh + workflows: version: 2 build-test-push: @@ -146,6 +157,9 @@ workflows: - e2e-nginx-testing: requires: - build-binary + - e2e-linkerd-testing: + requires: + - build-binary - push-container: requires: - build-binary @@ -154,6 +168,7 @@ workflows: - e2e-supergloo-testing - e2e-gloo-testing - e2e-nginx-testing + - e2e-linkerd-testing release: jobs: diff --git a/Makefile b/Makefile index 145a9896..89ea050e 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,10 @@ run-nop: GO111MODULE=on go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=none -namespace=bg \ -metrics-server=https://prometheus.istio.weavedx.com +run-linkerd: + GO111MODULE=on go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=smi:linkerd -namespace=demo \ + -metrics-server=https://linkerd-prometheus.istio.weavedx.com + build: GIT_COMMIT=$$(git rev-list -1 HEAD) && GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w -X github.com/weaveworks/flagger/pkg/version.REVISION=$${GIT_COMMIT}" -a -installsuffix cgo -o ./bin/flagger ./cmd/flagger/* docker build -t weaveworks/flagger:$(TAG) . -f Dockerfile diff --git a/test/e2e-linkerd-tests.sh b/test/e2e-linkerd-tests.sh new file mode 100755 index 00000000..53ad55fb --- /dev/null +++ b/test/e2e-linkerd-tests.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash + +# This script runs Linkerd e2e tests for Canary initialization, analysis and promotion + +set -o errexit + +REPO_ROOT=$(git rev-parse --show-toplevel) +export KUBECONFIG="$(kind get kubeconfig-path --name="kind")" + +echo '>>> Creating test namespace' +kubectl create namespace test +kubectl annotate namespace test linkerd.io/inject=enabled + +echo '>>> Installing the load tester' +kubectl -n test apply -f ${REPO_ROOT}/artifacts/loadtester/ +kubectl -n test rollout status deployment/flagger-loadtester + +echo '>>> Initialising canary' +kubectl apply -f ${REPO_ROOT}/test/e2e-workload.yaml + +cat <>> Waiting for primary to be ready' +retries=50 +count=0 +ok=false +until ${ok}; do + kubectl -n test get canary/podinfo | grep 'Initialized' && ok=true || ok=false + sleep 5 + count=$(($count + 1)) + if [[ ${count} -eq ${retries} ]]; then + kubectl -n linkerd logs deployment/flagger + echo "No more retries left" + exit 1 + fi +done + +echo '✔ Canary initialization test passed' + +echo '>>> Triggering canary deployment' +kubectl -n test set image deployment/podinfo podinfod=quay.io/stefanprodan/podinfo:1.4.1 + +echo '>>> Waiting for canary promotion' +retries=50 +count=0 +ok=false +until ${ok}; do + kubectl -n test describe deployment/podinfo-primary | grep '1.4.1' && ok=true || ok=false + sleep 10 + kubectl -n istio-system logs deployment/flagger --tail 1 + count=$(($count + 1)) + if [[ ${count} -eq ${retries} ]]; then + kubectl -n linkerd logs deployment/flagger + echo "No more retries left" + exit 1 + fi +done + +echo '✔ Canary promotion test passed' diff --git a/test/e2e-linkerd.sh b/test/e2e-linkerd.sh new file mode 100755 index 00000000..e7293e42 --- /dev/null +++ b/test/e2e-linkerd.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -o errexit + +LINKERD_VER="edge-19.6.4" +REPO_ROOT=$(git rev-parse --show-toplevel) +export KUBECONFIG="$(kind get kubeconfig-path --name="kind")" + +curl -LO https://github.com/linkerd/linkerd2/releases/download/${LINKERD_VER}/linkerd2-cli-${LINKERD_VER}-linux > ${REPO_ROOT}/bin/linkerd +chmod +x ${REPO_ROOT}/bin/linkerd + +echo ">>> Installing Linkerd ${LINKERD_VER}" +${REPO_ROOT}/bin/linkerd install | kubectl apply -f - +${REPO_ROOT}/bin/linkerd check + +kubectl -n linkerd rollout status deployment/linkerd-controller +kubectl -n linkerd rollout status deployment/linkerd-proxy-injector + +echo '>>> Load Flagger image in Kind' +kind load docker-image test/flagger:latest + +echo '>>> Installing Flagger' +helm upgrade -i flagger ${REPO_ROOT}/charts/flagger \ +--namespace linkerd \ +--set metricsServer=http://linkerd-prometheus:9090 \ +--set meshProvider=smi:linkerd + +kubectl -n istio-system set image deployment/flagger flagger=test/flagger:latest +kubectl -n istio-system rollout status deployment/flagger \ No newline at end of file