-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
169 lines (147 loc) · 4.99 KB
/
Taskfile.yml
File metadata and controls
169 lines (147 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
version: '3'
includes:
# Remote include from test-infra
# Can be overridden with TASKFILE_TESTINFRA_PATH environment variable
test-infra:
taskfile: '{{default "https://raw.githubusercontent.com/datum-cloud/test-infra/main/Taskfile.yml" .TASKFILE_TESTINFRA_PATH}}'
internal: true # Hide test-infra tasks from `task --list`
vars:
CLUSTER_NAME: test-infra
KUBECONFIG: "{{.ROOT_DIR}}/.test-infra/kubeconfig"
IMAGE_NAME: datum-dns-webhook:e2e-test
env:
KUBECONFIG: "{{.KUBECONFIG}}"
tasks:
# High-level orchestration tasks
dev:setup:
desc: Create complete E2E environment for interactive development
cmds:
- task: test-infra:cluster-up
vars:
CLUSTER_NAME: '{{.CLUSTER_NAME}}'
- task: e2e:build
- task: e2e:deploy
- cmd: |
echo ""
echo "✓ E2E environment ready!"
echo ""
echo "Export KUBECONFIG:"
echo " export KUBECONFIG={{.KUBECONFIG}}"
echo ""
echo "Useful commands:"
echo " task test:e2e # Run E2E tests"
echo " task e2e:logs # View component logs"
echo " task e2e:diag # Collect diagnostics"
echo " task e2e:cleanup # Destroy environment"
silent: true
test:e2e:
desc: Run E2E tests (requires environment from dev:setup)
cmds:
- task: e2e:test:chainsaw
ci:e2e:
desc: Run full E2E suite in CI (setup + test + cleanup on failure)
cmds:
- task: dev:setup
- task: test:e2e
- defer: {task: e2e:diag:on-failure}
# Component-specific tasks (e2e namespace)
e2e:build:
desc: Build and load webhook image into KIND
dir: .
cmds:
- docker build -t {{.IMAGE_NAME}} .
- kind load docker-image {{.IMAGE_NAME}} --name {{.CLUSTER_NAME}}
e2e:deploy:
desc: Deploy DNS operator, fixtures, webhook, and test app
vars:
KUBECONFIG: '{{.KUBECONFIG}}'
cmds:
- cmd: echo "Deploying DNS operator (mock)..."
silent: true
- kubectl apply -k config/overlays/test/dns-operator/
- kubectl wait --for=condition=available --timeout=300s -n dns-operator-system deployment/mock-dns-operator
- cmd: echo "Deploying DNS fixtures..."
silent: true
- kubectl apply -k config/overlays/test/dns-fixtures/
- cmd: echo "Installing ExternalDNS DNSEndpoint CRD..."
silent: true
- kubectl apply --server-side -f https://raw.githubusercontent.com/kubernetes-sigs/external-dns/master/config/crd/standard/dnsendpoints.externaldns.k8s.io.yaml
- cmd: echo "Deploying ExternalDNS via Flux HelmRelease..."
silent: true
- kubectl apply -k config/dependencies/external-dns/
- flux reconcile helmrelease external-dns -n external-dns --timeout=5m
- kubectl wait --for=condition=available --timeout=300s -n external-dns deployment/external-dns
- cmd: echo "Deploying webhook + test application..."
silent: true
- kubectl apply -k config/overlays/test/
- kubectl wait --for=condition=available --timeout=300s -n external-dns deployment/datum-dns-webhook
- kubectl wait --for=condition=available --timeout=300s -n default deployment/whoami
e2e:test:chainsaw:
desc: Run Chainsaw E2E tests
vars:
KUBECONFIG: '{{.KUBECONFIG}}'
cmds:
- chainsaw test --test-dir e2e/chainsaw --config e2e/chainsaw/chainsaw-config.yaml
e2e:logs:
desc: Show logs from key components
vars:
KUBECONFIG: '{{.KUBECONFIG}}'
cmds:
- cmd: echo "=== Webhook Logs ===" && echo ""
silent: true
- kubectl logs -n external-dns -l app=datum-dns-webhook --tail=50
- cmd: echo "" && echo "=== ExternalDNS Logs ===" && echo ""
silent: true
- kubectl logs -n external-dns -l app=external-dns --tail=50
e2e:diag:
desc: Collect full diagnostics
vars:
KUBECONFIG: '{{.KUBECONFIG}}'
dir: e2e
cmds:
- bash scripts/diagnostics.sh
e2e:diag:on-failure:
desc: Collect diagnostics only if previous task failed
vars:
KUBECONFIG: '{{.KUBECONFIG}}'
dir: e2e
cmds:
- cmd: |
if [ "{{.TASK_EXIT_CODE}}" != "0" ]; then
echo "Test failed, collecting diagnostics..."
bash scripts/diagnostics.sh
fi
ignore_error: true
e2e:cleanup:
desc: Delete KIND cluster and kubeconfig
cmds:
- kind delete cluster --name {{.CLUSTER_NAME}}
- rm -f {{.KUBECONFIG}}
# Existing build/test tasks (preserved)
build:
desc: Build datum-dns-webhook binary
cmds:
- mkdir -p bin
- go build -o bin/datum-dns-webhook .
sources:
- '**/*.go'
- go.mod
- go.sum
generates:
- bin/datum-dns-webhook
test:
desc: Run unit tests with race detection
cmds:
- go test -v -race ./...
lint:
desc: Run golangci-lint
cmds:
- golangci-lint run
docker:
desc: Build Docker image
cmds:
- docker build -t datum-dns-webhook:latest .
clean:
desc: Clean build artifacts
cmds:
- rm -rf bin/