Skip to content

Commit bd9b193

Browse files
committed
debezium/dbz#1452 Add unit test on helm
1 parent 41a2a9d commit bd9b193

File tree

3 files changed

+263
-1
lines changed

3 files changed

+263
-1
lines changed

.github/workflows/helm-workflow.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ jobs:
3131
3232
- name: Helm template and validate with kubeconform
3333
run: |
34-
helm template debezium-platform helm/ -f examples/example.yaml | kubeconform -strict -summary
34+
helm template debezium-platform helm/ -f examples/example.yaml | kubeconform -strict -summary
35+
36+
- name: Install helm-unittest plugin
37+
run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false
38+
39+
- name: Run helm unit tests
40+
run: helm unittest helm/

helm/tests/conductor_test.yaml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
suite: test conductor resources
2+
templates:
3+
- conductor-deployment.yaml
4+
- conductor-service.yaml
5+
- conductor-ingress.yaml
6+
- conductor-config-map.yaml
7+
- conductor-service-account.yaml
8+
- conductor-role.yaml
9+
- conductor-role-binding.yaml
10+
values:
11+
- ../../examples/example.yaml
12+
tests:
13+
- it: should create conductor deployment with correct configuration
14+
template: conductor-deployment.yaml
15+
asserts:
16+
- isKind:
17+
of: Deployment
18+
- equal:
19+
path: metadata.name
20+
value: conductor
21+
- equal:
22+
path: metadata.labels["app.kubernetes.io/name"]
23+
value: conductor
24+
- equal:
25+
path: metadata.labels["app.kubernetes.io/component"]
26+
value: backend
27+
- equal:
28+
path: metadata.labels["app.kubernetes.io/part-of"]
29+
value: debezium-platform
30+
- equal:
31+
path: spec.replicas
32+
value: 1
33+
- equal:
34+
path: spec.strategy.type
35+
value: Recreate
36+
- equal:
37+
path: spec.selector.matchLabels["app.kubernetes.io/name"]
38+
value: conductor
39+
- equal:
40+
path: spec.template.spec.serviceAccountName
41+
value: conductor-service-account
42+
- equal:
43+
path: spec.template.spec.containers[0].name
44+
value: conductor
45+
- equal:
46+
path: spec.template.spec.containers[0].ports[0].containerPort
47+
value: 8080
48+
- isNotEmpty:
49+
path: spec.template.spec.containers[0].image
50+
- isNotEmpty:
51+
path: spec.template.spec.containers[0].env
52+
- contains:
53+
path: spec.template.spec.containers[0].env
54+
content:
55+
name: CONDUCTOR_WATCHER_OFFSET_STORAGE_TYPE
56+
value: io.debezium.storage.configmap.ConfigMapOffsetStore
57+
- lengthEqual:
58+
path: spec.template.spec.containers[0].env
59+
count: 7
60+
61+
- it: should create conductor service with correct ports
62+
template: conductor-service.yaml
63+
asserts:
64+
- isKind:
65+
of: Service
66+
- equal:
67+
path: metadata.name
68+
value: conductor
69+
- equal:
70+
path: metadata.labels["app.kubernetes.io/name"]
71+
value: conductor
72+
- equal:
73+
path: metadata.labels["app.kubernetes.io/component"]
74+
value: backend
75+
- equal:
76+
path: spec.selector["app.kubernetes.io/name"]
77+
value: conductor
78+
- equal:
79+
path: spec.ports[0].name
80+
value: conductor-port
81+
- equal:
82+
path: spec.ports[0].port
83+
value: 8080
84+
- equal:
85+
path: spec.ports[0].targetPort
86+
value: 8080
87+
88+
- it: should create conductor ingress with correct routing
89+
template: conductor-ingress.yaml
90+
asserts:
91+
- isKind:
92+
of: Ingress
93+
- equal:
94+
path: metadata.name
95+
value: conductor-ingress
96+
- isNotEmpty:
97+
path: spec.rules[0].host
98+
- equal:
99+
path: spec.rules[0].http.paths[0].path
100+
value: /
101+
- equal:
102+
path: spec.rules[0].http.paths[0].pathType
103+
value: Prefix
104+
- equal:
105+
path: spec.rules[0].http.paths[0].backend.service.name
106+
value: stage
107+
- equal:
108+
path: spec.rules[0].http.paths[0].backend.service.port.number
109+
value: 3000
110+
- equal:
111+
path: spec.rules[0].http.paths[1].path
112+
value: /api
113+
- equal:
114+
path: spec.rules[0].http.paths[1].pathType
115+
value: Prefix
116+
- equal:
117+
path: spec.rules[0].http.paths[1].backend.service.name
118+
value: conductor
119+
- equal:
120+
path: spec.rules[0].http.paths[1].backend.service.port.number
121+
value: 8080
122+
123+
- it: should create conductor configmap
124+
template: conductor-config-map.yaml
125+
asserts:
126+
- isKind:
127+
of: ConfigMap
128+
- equal:
129+
path: metadata.name
130+
value: debezium-platform-offsets
131+
132+
- it: should create conductor service account
133+
template: conductor-service-account.yaml
134+
asserts:
135+
- isKind:
136+
of: ServiceAccount
137+
- equal:
138+
path: metadata.name
139+
value: conductor-service-account
140+
141+
- it: should create conductor role with correct permissions
142+
template: conductor-role.yaml
143+
asserts:
144+
- isKind:
145+
of: Role
146+
- equal:
147+
path: metadata.name
148+
value: conductor-debeziumservers-creator
149+
- contains:
150+
path: rules
151+
content:
152+
apiGroups: ["debezium.io"]
153+
resources: ["debeziumservers"]
154+
verbs: ["patch", "create", "delete", "list", "deletecollection"]
155+
count: 1
156+
- contains:
157+
path: rules
158+
content:
159+
apiGroups: ["apps"]
160+
resources: ["deployments", "replicasets"]
161+
verbs: ["get", "list"]
162+
count: 1
163+
- contains:
164+
path: rules
165+
content:
166+
apiGroups: [""]
167+
resources: ["pods", "pods/log", "services"]
168+
verbs: ["get", "list"]
169+
count: 1
170+
171+
- it: should create conductor role binding
172+
template: conductor-role-binding.yaml
173+
asserts:
174+
- isKind:
175+
of: RoleBinding
176+
- equal:
177+
path: metadata.name
178+
value: conductor-role-binding

helm/tests/stage_test.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
suite: test stage resources
2+
templates:
3+
- stage-deployment.yaml
4+
- stage-service.yaml
5+
values:
6+
- ../../examples/example.yaml
7+
tests:
8+
- it: should create stage deployment with correct configuration
9+
template: stage-deployment.yaml
10+
asserts:
11+
- isKind:
12+
of: Deployment
13+
- equal:
14+
path: metadata.name
15+
value: stage
16+
- equal:
17+
path: metadata.labels["app.kubernetes.io/name"]
18+
value: stage
19+
- equal:
20+
path: metadata.labels["app.kubernetes.io/component"]
21+
value: frontend
22+
- equal:
23+
path: metadata.labels["app.kubernetes.io/part-of"]
24+
value: debezium-platform
25+
- equal:
26+
path: spec.replicas
27+
value: 1
28+
- equal:
29+
path: spec.selector.matchLabels["app.kubernetes.io/name"]
30+
value: stage
31+
- equal:
32+
path: spec.template.spec.containers[0].name
33+
value: stage
34+
- equal:
35+
path: spec.template.spec.containers[0].ports[0].containerPort
36+
value: 3000
37+
- equal:
38+
path: spec.template.spec.containers[0].ports[0].protocol
39+
value: TCP
40+
- isNotEmpty:
41+
path: spec.template.spec.containers[0].image
42+
- isNotEmpty:
43+
path: spec.template.spec.containers[0].env
44+
- equal:
45+
path: spec.template.spec.containers[0].env[0].name
46+
value: CONDUCTOR_URL
47+
- isNotEmpty:
48+
path: spec.template.spec.containers[0].env[0].value
49+
- equal:
50+
path: spec.template.spec.restartPolicy
51+
value: Always
52+
53+
- it: should create stage service with correct ports
54+
template: stage-service.yaml
55+
asserts:
56+
- isKind:
57+
of: Service
58+
- equal:
59+
path: metadata.name
60+
value: stage
61+
- equal:
62+
path: metadata.labels["app.kubernetes.io/name"]
63+
value: stage
64+
- equal:
65+
path: metadata.labels["app.kubernetes.io/component"]
66+
value: frontend
67+
- equal:
68+
path: spec.selector["app.kubernetes.io/name"]
69+
value: stage
70+
- equal:
71+
path: spec.ports[0].name
72+
value: stage-port
73+
- equal:
74+
path: spec.ports[0].port
75+
value: 3000
76+
- equal:
77+
path: spec.ports[0].targetPort
78+
value: 3000

0 commit comments

Comments
 (0)