diff --git a/e2e/provider/coredns.yaml b/e2e/provider/coredns.yaml index 14d02737fb..95d4d25fb3 100644 --- a/e2e/provider/coredns.yaml +++ b/e2e/provider/coredns.yaml @@ -36,7 +36,7 @@ spec: app: coredns spec: hostNetwork: true - dnsPolicy: Default + dnsPolicy: ClusterFirstWithHostNet containers: - name: coredns image: coredns/coredns:1.13.1 @@ -52,23 +52,15 @@ spec: name: dns-tcp protocol: TCP livenessProbe: - httpGet: - path: /health - port: 8080 - scheme: HTTP - initialDelaySeconds: 60 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 5 - readinessProbe: - httpGet: - path: /ready - port: 8181 - scheme: HTTP + tcpSocket: + port: 5353 initialDelaySeconds: 10 - timeoutSeconds: 5 - successThreshold: 1 - failureThreshold: 5 + periodSeconds: 10 + readinessProbe: + tcpSocket: + port: 5353 + initialDelaySeconds: 5 + periodSeconds: 5 volumes: - name: config-volume configMap: diff --git a/scripts/e2e-test.sh b/scripts/e2e-test.sh index 3cac31731b..64bebedecf 100755 --- a/scripts/e2e-test.sh +++ b/scripts/e2e-test.sh @@ -15,10 +15,20 @@ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-linux-amd64 chmod +x ./kind sudo mv ./kind /usr/local/bin/kind +# Cleanup function +cleanup() { + echo "Cleaning up..." + kind delete cluster 2>/dev/null || true +} + # Create kind cluster echo "Creating kind cluster..." +kind delete cluster 2>/dev/null || true kind create cluster +# Set trap to cleanup on script exit +trap cleanup EXIT + # Install kubectl echo "Installing kubectl..." curl -LO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" @@ -48,6 +58,18 @@ echo "Using image reference: $EXTERNAL_DNS_IMAGE" echo "Applying etcd" kubectl apply -f e2e/provider/etcd.yaml +# wait for etcd to be ready +echo "Waiting for etcd to be ready..." +kubectl wait --for=condition=ready --timeout=120s pod -l app=etcd + +# apply coredns deployment +echo "Applying CoreDNS" +kubectl apply -f e2e/provider/coredns.yaml + +# wait for coredns to be ready +echo "Waiting for CoreDNS to be ready..." +kubectl wait --for=condition=available --timeout=120s deployment/coredns + # Build a DNS testing image with dig echo "Building DNS test image with dig..." docker build -t dns-test:v1 -f - . </dev/null) + if echo "\$RESULT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then + echo "DNS query successful: \$RESULT" + exit 0 + fi + echo "DNS query returned empty result, retrying in 10s..." + sleep 10 + ATTEMPT=\$((ATTEMPT + 1)) + done + echo "DNS query failed after \$MAX_ATTEMPTS attempts" + exit 1 - echo "=== Testing DNS server with dig ===" - echo "Querying: externaldns-e2e.external.dns A record" - if dig @$NODE_IP -p 5353 externaldns-e2e.external.dns A +short +timeout=5; then - echo "DNS query successful" - exit 0 - else - echo "DNS query failed" - exit 1 - fi - - echo "DNS server tests completed" - exit 0 EOF # Wait for the job to complete echo "Waiting for DNS server test job to complete..." -kubectl wait --for=condition=complete --timeout=90s job/dns-server-test-job || true +kubectl wait --for=condition=complete --timeout=240s job/dns-server-test-job || true # Check job status and get results echo "DNS server test job results:" @@ -211,17 +234,6 @@ kubectl delete job dns-server-test-job echo "End-to-end test completed!" -# Cleanup function -cleanup() { - echo "Cleaning up..." - if [ ! -z "$EXTERNAL_DNS_PID" ]; then - kill $EXTERNAL_DNS_PID 2>/dev/null || true - fi - if [ ! -z "$LOCAL_PROVIDER_PID" ]; then - kill $LOCAL_PROVIDER_PID 2>/dev/null || true - fi - kind delete cluster 2>/dev/null || true -} - -# Set trap to cleanup on script exit -trap cleanup EXIT +if [ "$TEST_PASSED" != "true" ]; then + exit 1 +fi