|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -e # Exit immediately if a command exits with a non-zero status |
| 4 | + |
| 5 | +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) |
| 6 | +REPO_DIR=$(dirname $(dirname "$SCRIPT_DIR")) |
| 7 | + |
| 8 | +TAG=$1 |
| 9 | + |
| 10 | +if [[ -z $TAG ]]; then |
| 11 | + echo "Usage: $0 <TAG> [RELEASE_NAME] [NAMESPACE] [CLUSTER_NAME]" |
| 12 | + echo "Error: TAG is a required parameter. Example usage: $(make ipv6-test TAG=release-X.Y-rc)" |
| 13 | + exit 1 |
| 14 | +fi |
| 15 | + |
| 16 | +RELEASE_NAME=${2:-nginx-gateway} |
| 17 | +NAMESPACE=${3:-nginx-gateway} |
| 18 | +CLUSTER_NAME=${4:-ipv6-only-${TAG}} |
| 19 | +RELEASE_REPO=ghcr.io/nginx/nginx-gateway-fabric |
| 20 | + |
| 21 | +cleanup() { |
| 22 | + echo "Cleaning up resources..." |
| 23 | + kind delete cluster --name ${CLUSTER_NAME} || true |
| 24 | +} |
| 25 | + |
| 26 | +trap cleanup EXIT |
| 27 | + |
| 28 | +kind create cluster --name ${CLUSTER_NAME} --config ipv6/config/kind-ipv6-only.yaml |
| 29 | + |
| 30 | +echo "== Installing NGINX Gateway Fabric..." |
| 31 | +echo "== Using NGF from ${RELEASE_REPO}:${TAG}..." |
| 32 | +echo "== Using NGINX from ${RELEASE_REPO}/nginx:${TAG}..." |
| 33 | + |
| 34 | +HELM_PARAMETERS="--set nginx.config.ipFamily=ipv6" |
| 35 | +make helm-install-local HELM_PARAMETERS="${HELM_PARAMETERS}" \ |
| 36 | + PREFIX="${RELEASE_REPO}" \ |
| 37 | + TAG="${TAG}" \ |
| 38 | + SELF_DIR="${REPO_DIR}/" \ |
| 39 | + NGINX_SERVICE_TYPE="ClusterIP" \ |
| 40 | + PULL_POLICY="Always" |
| 41 | + |
| 42 | +echo "== Deploying Gateway..." |
| 43 | +kubectl apply -f ipv6/manifests/gateway.yaml |
| 44 | + |
| 45 | +kubectl wait --for=condition=accepted --timeout=300s gateway/gateway |
| 46 | +POD_NAME=$(kubectl get pods -l app.kubernetes.io/instance=${RELEASE_NAME} -o jsonpath='{.items[0].metadata.name}') |
| 47 | +kubectl wait --for=condition=ready --timeout=300s pod/${POD_NAME} |
| 48 | + |
| 49 | +echo "== Deploying IPv6 test application" |
| 50 | +kubectl apply -f ipv6/manifests/ipv6-test-app.yaml |
| 51 | + |
| 52 | +echo "== Waiting for test applications to be ready..." |
| 53 | +kubectl wait --for=condition=available --timeout=300s deployment/test-app-ipv6 |
| 54 | + |
| 55 | +echo "== Getting NGF service IPv6 address from gateway status" |
| 56 | +NGF_IPV6=$(kubectl get gateway -o jsonpath='{.items[0].status.addresses[0].value}') |
| 57 | +echo "NGF IPv6 Address: $NGF_IPV6" |
| 58 | + |
| 59 | +echo "=== Running IPv6-Only Tests ===" |
| 60 | + |
| 61 | +echo "== Starting IPv6 test client" |
| 62 | +kubectl apply -f ipv6/manifests/ipv6-test-client.yaml |
| 63 | +kubectl wait --for=condition=ready --timeout=300s pod/ipv6-test-client |
| 64 | + |
| 65 | +echo "== Test 1: Basic IPv6 connectivity ==" |
| 66 | +kubectl exec ipv6-test-client -- curl --version |
| 67 | +kubectl exec ipv6-test-client -- nslookup gateway-nginx.default.svc.cluster.local || echo "Test 1: Basic IPv6 connectivity failed" |
| 68 | +test1_status=$? |
| 69 | + |
| 70 | +if [[ $test1_status -eq 0 ]]; then |
| 71 | + echo "✅ Test 1: Basic IPv6 connectivity succeeded" |
| 72 | +fi |
| 73 | + |
| 74 | +echo "== Test 2: NGF Service IPv6 connectivity ==" |
| 75 | +kubectl exec ipv6-test-client -- curl -6 --connect-timeout 30 --max-time 60 -v \ |
| 76 | + -H "Host: ipv6-test.example.com" \ |
| 77 | + "http://[${NGF_IPV6}]:80/" || echo "Test 2: NGF Service IPv6 connectivity failed" |
| 78 | +test2_status=$? |
| 79 | + |
| 80 | +if [[ $test2_status -eq 0 ]]; then |
| 81 | + echo "✅ Test 2: NGF Service IPv6 connectivity succeeded" |
| 82 | +fi |
| 83 | + |
| 84 | +echo "== Test 3: Service DNS IPv6 connectivity ==" |
| 85 | +kubectl exec ipv6-test-client -- curl -6 --connect-timeout 30 --max-time 60 -v \ |
| 86 | + -H "Host: ipv6-test.example.com" \ |
| 87 | + "http://gateway-nginx.default.svc.cluster.local:80/" || echo "Test 3: Service DNS IPv6 connectivity failed" |
| 88 | +test3_status=$? |
| 89 | + |
| 90 | +if [[ $test3_status -eq 0 ]]; then |
| 91 | + echo "✅ Test 3: Service DNS IPv6 connectivity succeeded" |
| 92 | +fi |
| 93 | + |
| 94 | +echo "=== Displaying IPv6-Only Configuration ===" |
| 95 | +echo "NGF Pod IPv6 addresses:" |
| 96 | +kubectl get pods -n nginx-gateway -o wide || true |
| 97 | +echo "NGF Service configuration:" |
| 98 | +kubectl get service ${HELM_RELEASE_NAME}-nginx-gateway-fabric -n nginx-gateway -o yaml || true |
| 99 | + |
| 100 | +if [[ $test1_status -eq 0 && $test2_status -eq 0 && $test3_status -eq 0 ]]; then |
| 101 | + echo -e "✅ All tests passed!" |
| 102 | +else |
| 103 | + echo -e "❌ One or more tests failed. Check the output above to help debug any issues." |
| 104 | +fi |
0 commit comments