-
Notifications
You must be signed in to change notification settings - Fork 7
test: add integration tests running against STACKIT DNS API #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
48136b1
test: add integration tests - they run daily plus on PRs
ondbeh 7cc6ef5
fix: make script executable
ondbeh dc5cfd9
fix: make script executable once more
ondbeh 158259e
fix: add debugging
ondbeh b1fb631
fix: fix script
ondbeh 60ed2e8
fix: embed the scripts.
ondbeh 83d5376
fix: cleanup
ondbeh c542676
fix: bump action versions
ondbeh 73b0105
docu: add readme entry, remove unused script, fix cleanup
ondbeh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: E2E Integration Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: ["main", "release/**"] | ||
| schedule: | ||
| - cron: '0 2 * * *' # Runs daily at 2:00 AM UTC | ||
|
|
||
| jobs: | ||
| e2e-tests: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v7 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v6 | ||
|
ondbeh marked this conversation as resolved.
Dismissed
|
||
| with: | ||
| go-version-file: 'go.mod' | ||
|
|
||
| - name: Install Dependencies (Kind, Kuttl, Dig) | ||
| run: | | ||
| # Install dig | ||
| sudo apt-get update && sudo apt-get install -y dnsutils | ||
|
|
||
| # Install Kind | ||
| curl -sSLo ./kind https://kind.sigs.k8s.io/dl/v0.22.0/kind-linux-amd64 | ||
| chmod +x ./kind | ||
| sudo mv ./kind /usr/local/bin/kind | ||
|
|
||
| # Install Kuttl | ||
| curl -sSLo kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v0.15.0/kubectl-kuttl_0.15.0_linux_x86_64 | ||
| chmod +x kubectl-kuttl | ||
| sudo mv kubectl-kuttl /usr/local/bin/ | ||
|
|
||
| - name: Prepare STACKIT Service Account Key | ||
| run: | | ||
| # Write the secret from GitHub Actions into a temporary file so the Makefile can mount it | ||
| echo '${{ secrets.STACKIT_SERVICE_ACCOUNT_KEY }}' > /tmp/sa.json | ||
|
|
||
| - name: Run E2E Tests | ||
| env: | ||
| PROJECT_ID: ${{ secrets.STACKIT_PROJECT_ID }} | ||
| ZONE_NAME: ${{ secrets.STACKIT_ZONE_NAME }} | ||
| AUTH_KEY_PATH: /tmp/sa.json | ||
| run: | | ||
| make test-e2e-local | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: external-dns | ||
| namespace: default | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: external-dns | ||
| rules: | ||
| - apiGroups: [""] | ||
| resources: ["services","endpoints","pods","nodes"] | ||
| verbs: ["get","watch","list"] | ||
| - apiGroups: ["extensions","networking.k8s.io"] | ||
| resources: ["ingresses"] | ||
| verbs: ["get","watch","list"] | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: external-dns-viewer | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: external-dns | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: external-dns | ||
| namespace: default | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: external-dns | ||
| namespace: default | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: external-dns | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: external-dns | ||
| spec: | ||
| serviceAccountName: external-dns | ||
| volumes: | ||
| - name: stackit-sa-key | ||
| secret: | ||
| secretName: external-dns-stackit-webhook | ||
| items: | ||
| - key: sa.json | ||
| path: sa.json | ||
| containers: | ||
| - name: external-dns | ||
| image: registry.k8s.io/external-dns/external-dns:v0.14.0 | ||
| args: | ||
| - --log-level=info | ||
| - --interval=10s | ||
| - --source=service | ||
| - --policy=sync | ||
| - --provider=webhook | ||
| - --domain-filter=${ZONE_NAME} | ||
| - --txt-prefix=txt- | ||
| - name: webhook | ||
| image: stackitcloud/external-dns-stackit-webhook:e2e | ||
| imagePullPolicy: Never # Forces the use of our sideloaded local build | ||
| args: | ||
| - --project-id=${PROJECT_ID} | ||
| - --log-level=debug | ||
| ports: | ||
| - name: http | ||
| containerPort: 8888 | ||
| env: | ||
| - name: AUTH_KEY_PATH | ||
| value: /var/run/secrets/stackit/sa.json | ||
| volumeMounts: | ||
| - name: stackit-sa-key | ||
| mountPath: /var/run/secrets/stackit | ||
| readOnly: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestSuite | ||
| testDirs: | ||
| - test-suite | ||
| timeout: 120 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 120 | ||
| commands: | ||
| - script: | | ||
| check_record() { | ||
| RECORD_TYPE=$1 | ||
| RECORD_NAME=$2 | ||
| EXPECTED_RESULT=$3 | ||
| ZONE=$4 | ||
|
|
||
| AUTH_NS=$(dig +short NS "$ZONE" | head -n 1) | ||
| if [ -z "$AUTH_NS" ]; then | ||
| echo "ERROR: Could not determine authoritative nameserver for $ZONE" | ||
| return 1 | ||
| fi | ||
|
|
||
| RESULT=$(dig "@$AUTH_NS" -t "$RECORD_TYPE" +short "$RECORD_NAME") | ||
| echo "DEBUG: Dig Result for $RECORD_NAME: '$RESULT'" | ||
|
|
||
| if echo "$RESULT" | grep -q "$EXPECTED_RESULT"; then | ||
| echo "SUCCESS: $RECORD_TYPE record $RECORD_NAME verified!" | ||
| return 0 | ||
| fi | ||
|
|
||
| echo "FAILED: Condition not met for $RECORD_NAME." | ||
| return 1 | ||
| } | ||
|
|
||
| # Run all checks. If any fail, the chain short-circuits and we exit 1 to trigger a Kuttl retry. | ||
| check_record A "e2e-a.${ZONE_NAME}" "10.0.0.1" "${ZONE_NAME}" && \ | ||
| check_record AAAA "e2e-aaaa.${ZONE_NAME}" "2001:db8::1" "${ZONE_NAME}" && \ | ||
| check_record CNAME "e2e-cname.${ZONE_NAME}" "e2e-a.${ZONE_NAME}." "${ZONE_NAME}" | ||
|
|
||
| if [ $? -ne 0 ]; then | ||
| sleep 5 | ||
| exit 1 | ||
| fi | ||
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # 1. Triggers an A Record (IPv4) | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: test-service-a | ||
| annotations: | ||
| external-dns.alpha.kubernetes.io/hostname: "e2e-a.${ZONE_NAME}" | ||
| external-dns.alpha.kubernetes.io/target: "10.0.0.1" | ||
| spec: | ||
| type: LoadBalancer | ||
| ports: | ||
| - port: 80 | ||
| --- | ||
| # 2. Triggers an AAAA Record (IPv6) | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: test-service-aaaa | ||
| annotations: | ||
| external-dns.alpha.kubernetes.io/hostname: "e2e-aaaa.${ZONE_NAME}" | ||
| external-dns.alpha.kubernetes.io/target: "2001:db8::1" | ||
| spec: | ||
| type: LoadBalancer | ||
| ports: | ||
| - port: 80 | ||
| --- | ||
| # 3. Triggers a CNAME Record (Hostname) | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: test-service-cname | ||
| annotations: | ||
| external-dns.alpha.kubernetes.io/hostname: "e2e-cname.${ZONE_NAME}" | ||
| external-dns.alpha.kubernetes.io/target: "e2e-a.${ZONE_NAME}" | ||
| spec: | ||
| type: LoadBalancer | ||
| ports: | ||
| - port: 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 120 | ||
| commands: | ||
| - script: | | ||
| check_deleted() { | ||
| RECORD_TYPE=$1 | ||
| RECORD_NAME=$2 | ||
| ZONE=$3 | ||
|
|
||
| AUTH_NS=$(dig +short NS "$ZONE" | head -n 1) | ||
| if [ -z "$AUTH_NS" ]; then | ||
| echo "ERROR: Could not determine authoritative nameserver for $ZONE" | ||
| return 1 | ||
| fi | ||
|
|
||
| RESULT=$(dig "@$AUTH_NS" -t "$RECORD_TYPE" +short "$RECORD_NAME") | ||
| echo "DEBUG: Dig Result for $RECORD_NAME: '$RESULT'" | ||
|
|
||
| if [ -z "$RESULT" ]; then | ||
| echo "SUCCESS: $RECORD_TYPE record $RECORD_NAME successfully deleted!" | ||
| return 0 | ||
| fi | ||
|
|
||
| echo "FAILED: $RECORD_NAME still exists." | ||
| return 1 | ||
| } | ||
|
|
||
| check_deleted A "e2e-a.${ZONE_NAME}" "${ZONE_NAME}" && \ | ||
| check_deleted AAAA "e2e-aaaa.${ZONE_NAME}" "${ZONE_NAME}" && \ | ||
| check_deleted CNAME "e2e-cname.${ZONE_NAME}" "${ZONE_NAME}" | ||
|
|
||
| if [ $? -ne 0 ]; then | ||
| sleep 5 | ||
| exit 1 | ||
| fi | ||
| exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| delete: | ||
| - apiVersion: v1 | ||
| kind: Service | ||
| name: test-service-a | ||
| - apiVersion: v1 | ||
| kind: Service | ||
| name: test-service-aaaa | ||
| - apiVersion: v1 | ||
| kind: Service | ||
| name: test-service-cname |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.