diff --git a/.circleci/config.yml b/.circleci/config.yml index 7e19e3325..a55ac5570 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -78,6 +78,17 @@ jobs: - run: test/e2e-istio.sh - run: test/e2e-tests.sh + e2e-kubernetes-testing: + machine: true + steps: + - checkout + - attach_workspace: + at: /tmp/bin + - run: test/container-build.sh + - run: test/e2e-kind.sh + - run: test/e2e-kubernetes.sh + - run: test/e2e-kubernetes-tests.sh + e2e-smi-istio-testing: machine: true steps: @@ -145,7 +156,7 @@ workflows: - e2e-istio-testing: requires: - build-binary - - e2e-smi-istio-testing: + - e2e-kubernetes-testing: requires: - build-binary # - e2e-supergloo-testing: @@ -164,7 +175,7 @@ workflows: requires: - build-binary - e2e-istio-testing - - e2e-smi-istio-testing + - e2e-kubernetes-testing #- e2e-supergloo-testing - e2e-gloo-testing - e2e-nginx-testing diff --git a/test/e2e-kubernetes-tests.sh b/test/e2e-kubernetes-tests.sh new file mode 100755 index 000000000..d8669f5c3 --- /dev/null +++ b/test/e2e-kubernetes-tests.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash + +# This script runs e2e tests for Blue/Green initialization, analysis and promotion +# Prerequisites: Kubernetes Kind, Kustomize + +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 + +echo '>>> Installing the load tester' +kubectl apply -k ${REPO_ROOT}/kustomize/tester +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 flagger-system 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.7.0 + +echo '>>> Waiting for canary promotion' +retries=50 +count=0 +ok=false +until ${ok}; do + kubectl -n test describe deployment/podinfo-primary | grep '1.7.0' && ok=true || ok=false + sleep 10 + kubectl -n flagger-system logs deployment/flagger --tail 1 + count=$(($count + 1)) + if [[ ${count} -eq ${retries} ]]; then + kubectl -n test describe deployment/podinfo + kubectl -n test describe deployment/podinfo-primary + kubectl -n flagger-system logs deployment/flagger + echo "No more retries left" + exit 1 + fi +done + +echo '✔ Canary promotion test passed' + +kubectl -n flagger-system logs deployment/flagger diff --git a/test/e2e-kubernetes.sh b/test/e2e-kubernetes.sh new file mode 100755 index 000000000..c85ea1ee6 --- /dev/null +++ b/test/e2e-kubernetes.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -o errexit + +REPO_ROOT=$(git rev-parse --show-toplevel) +export KUBECONFIG="$(kind get kubeconfig-path --name="kind")" + +echo '>>> Loading Flagger image' +kind load docker-image test/flagger:latest + +echo '>>> Installing Flagger' +kubectl apply -k ${REPO_ROOT}/kustomize/kubernetes + +kubectl -n flagger-system set image deployment/flagger flagger=test/flagger:latest + +kubectl -n flagger-system rollout status deployment/flagger +kubectl -n flagger-system rollout status deployment/flagger-prometheus \ No newline at end of file