Files
cozystack/hack/e2e-apps/external-dns.bats
Myasnikov Daniil a3a7a6d516 test(e2e): add HR existence backstop for external-dns ${name}-system
The two external-dns bats tests already poll for the user-facing ${name}
HelmRelease before calling kubectl wait, but they immediately wait on the
${name}-system HR without the same backstop. The system HR is materialised
asynchronously by the controller, so kubectl wait can race and exit non-zero
when the object does not exist yet. Apply the same existence poll pattern
to both occurrences.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-05-28 21:25:25 +05:00

57 lines
2.3 KiB
Bash

#!/usr/bin/env bats
teardown() {
kubectl -n tenant-test delete externaldns.apps.cozystack.io --all --ignore-not-found 2>/dev/null || true
}
@test "Create and Verify ExternalDNS with inmemory provider" {
name='test'
kubectl apply -f - <<EOF
apiVersion: apps.cozystack.io/v1alpha1
kind: ExternalDNS
metadata:
name: ${name}
namespace: tenant-test
spec:
provider: inmemory
domainFilters:
- example.com
EOF
# Wait for the operator to materialise the HelmRelease before kubectl wait
# kicks in (kubectl wait errors immediately if the object does not exist yet).
timeout 60 sh -ec "until kubectl -n tenant-test get hr ${name} >/dev/null 2>&1; do sleep 2; done"
kubectl -n tenant-test wait hr ${name} --timeout=5m --for=condition=ready
timeout 60 sh -ec "until kubectl -n tenant-test get hr ${name}-system >/dev/null 2>&1; do sleep 2; done"
kubectl -n tenant-test wait hr ${name}-system --timeout=5m --for=condition=ready
timeout 60 sh -ec "until kubectl -n tenant-test get deploy -l app.kubernetes.io/instance=${name}-system -o jsonpath='{.items[0].status.readyReplicas}' | grep -q '1'; do sleep 5; done"
kubectl -n tenant-test delete externaldns.apps.cozystack.io ${name}
}
@test "Create and Verify ExternalDNS with custom annotationPrefix" {
name='test-prefix'
kubectl apply -f - <<EOF
apiVersion: apps.cozystack.io/v1alpha1
kind: ExternalDNS
metadata:
name: ${name}
namespace: tenant-test
spec:
provider: inmemory
annotationPrefix: custom-dns/
domainFilters:
- example.org
EOF
# Wait for the operator to materialise the HelmRelease before kubectl wait
# kicks in (kubectl wait errors immediately if the object does not exist yet).
timeout 60 sh -ec "until kubectl -n tenant-test get hr ${name} >/dev/null 2>&1; do sleep 2; done"
kubectl -n tenant-test wait hr ${name} --timeout=5m --for=condition=ready
timeout 60 sh -ec "until kubectl -n tenant-test get hr ${name}-system >/dev/null 2>&1; do sleep 2; done"
kubectl -n tenant-test wait hr ${name}-system --timeout=5m --for=condition=ready
timeout 60 sh -ec "until kubectl -n tenant-test get deploy -l app.kubernetes.io/instance=${name}-system -o jsonpath='{.items[0].status.readyReplicas}' | grep -q '1'; do sleep 5; done"
kubectl -n tenant-test delete externaldns.apps.cozystack.io ${name}
}