#!/usr/bin/env bash # This script runs e2e tests for A/B traffic shifting, Canary analysis and promotion # Prerequisites: Kubernetes Kind and Contour with GatewayAPI set -o errexit REPO_ROOT=$(git rev-parse --show-toplevel) source ${REPO_ROOT}/test/gatewayapi/test-utils.sh create_latency_metric_template create_error_rate_metric_template echo '>>> Deploy podinfo in ab-test namespace' kubectl create ns ab-test kubectl apply -f ${REPO_ROOT}/test/workloads/secret.yaml -n ab-test kubectl apply -f ${REPO_ROOT}/test/workloads/deployment.yaml -n ab-test cat <>> Triggering A/B testing' kubectl -n ab-test set image deployment/podinfo podinfod=stefanprodan/podinfo:6.0.1 echo '>>> Waiting for A/B testing promotion' retries=50 count=0 ok=false until ${ok}; do kubectl -n ab-test describe deployment/podinfo-primary | grep '6.0.1' && 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 ab-test describe deployment/podinfo kubectl -n ab-test describe deployment/podinfo-primary kubectl -n flagger-system logs deployment/flagger echo "No more retries left" exit 1 fi done display_httproute "ab-test" echo '>>> Waiting for A/B finalization' retries=50 count=0 ok=false until ${ok}; do kubectl -n ab-test get canary/podinfo | grep 'Succeeded' && 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 '✔ A/B testing promotion test passed' kubectl delete -n ab-test canary podinfo