blob: 170eaf3c96285392bacbcc3730fc319c6579ff73 [file] [log] [blame]
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +01001---
2suite: test job behavior
3templates:
4 - job.yaml
5tests:
6 - it: "should render with default value (global)"
7 asserts:
8 - isKind:
9 of: Job
10 - matchRegex:
11 path: metadata.name
12 pattern: -mariadb-init-config-job$
13 - equal:
14 path: metadata.namespace
15 value: NAMESPACE
16 - matchRegex:
17 path: metadata.labels.app
18 pattern: mariadb-init
19 - matchRegex:
20 path: spec.template.metadata.labels.app
21 pattern: mariadb-init
22 - matchRegex:
23 path: spec.template.metadata.name
24 pattern: mariadb-init
25 - isNull:
26 path: spec.template.spec.nodeSelector
27 - isNull:
28 path: spec.template.spec.affinity
29 - it: "should render with default value (init container)"
30 asserts:
31 - matchRegex:
32 path: spec.template.spec.initContainers[0].name
33 pattern: mariadb-init-readiness
34 - contains:
35 path: spec.template.spec.initContainers[0].args
36 content: mariadb-galera
37 - equal:
38 path: spec.template.spec.initContainers[0].image
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020039 value: nexus3.onap.org:10001/onap/oom/readiness:3.0.1
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010040 - equal:
41 path: spec.template.spec.initContainers[0].imagePullPolicy
42 value: IfNotPresent
43 - it: "should render with default value (container)"
44 asserts:
45 - matchRegex:
46 path: spec.template.spec.containers[0].name
47 pattern: mariadb-init
48 - equal:
49 path: spec.template.spec.containers[0].image
50 value: nexus3.onap.org:10001/mariadb:10.1.38
51 - equal:
52 path: spec.template.spec.containers[0].imagePullPolicy
53 value: IfNotPresent
54 - contains:
55 path: spec.template.spec.containers[0].env
56 content:
57 name: DB_HOST
58 value: mariadb-galera
59 - contains:
60 path: spec.template.spec.containers[0].env
61 content:
62 name: DB_PORT
63 value: "3306"
64 - contains:
65 path: spec.template.spec.containers[0].env
66 content:
67 name: MYSQL_ROOT_PASSWORD
68 valueFrom:
69 secretKeyRef:
70 name: RELEASE-NAME-mariadb-galera-mariadb-galera
71 key: db-root-password
72 - contains:
73 path: spec.template.spec.containers[0].env
74 content:
75 name: MYSQL_PASSWORD
76 valueFrom:
77 secretKeyRef:
78 name: RELEASE-NAME-mariadb-init-secret
79 key: db-user-password
80 - contains:
81 path: spec.template.spec.containers[0].volumeMounts
82 content:
83 name: mariadb-conf
84 mountPath: /db_init/
85 readOnly: true
86 - equal:
87 path: spec.template.spec.containers[0].resources.limits.cpu
88 value: 100m
89 - equal:
90 path: spec.template.spec.containers[0].resources.limits.memory
91 value: 500Mbi
92 - equal:
93 path: spec.template.spec.containers[0].resources.requests.cpu
94 value: 10m
95 - equal:
96 path: spec.template.spec.containers[0].resources.requests.memory
97 value: 10Mbi
98 - it: "should render with default value (volumes)"
99 asserts:
100 - contains:
101 path: spec.template.spec.volumes
102 content:
103 name: mariadb-conf
104 configMap:
105 name: RELEASE-NAME-mariadb-init
106
107 - it: "should render with nameOverride set"
108 set:
109 nameOverride: myJob
110 asserts:
111 - matchRegex:
112 path: metadata.name
113 pattern: -myJob-config-job$
114 - matchRegex:
115 path: metadata.labels.app
116 pattern: myJob
117 - matchRegex:
118 path: spec.template.metadata.labels.app
119 pattern: myJob
120 - matchRegex:
121 path: spec.template.metadata.name
122 pattern: myJob
123 - matchRegex:
124 path: spec.template.spec.initContainers[0].name
125 pattern: myJob-readiness
126 - matchRegex:
127 path: spec.template.spec.containers[0].name
128 pattern: myJob
129 - contains:
130 path: spec.template.spec.containers[0].env
131 content:
132 name: MYSQL_PASSWORD
133 valueFrom:
134 secretKeyRef:
135 # replicating name from mariadb galera cluster, kind of hardcoded...
136 name: RELEASE-NAME-myJob-secret
137 key: db-user-password
138 - contains:
139 path: spec.template.spec.volumes
140 content:
141 name: mariadb-conf
142 configMap:
143 name: RELEASE-NAME-myJob
144
145 - it: "should render with configmap set"
146 set:
147 config:
148 config_map: myCM
149 asserts:
150 - contains:
151 path: spec.template.spec.volumes
152 content:
153 name: mariadb-conf
154 configMap:
155 name: RELEASE-NAME-myCM
156
157 - it: "should render with mariadbGalera changes"
158 set:
159 global:
160 mariadbGalera:
161 nameOverride: myMaria
162 servicePort: 545
163 asserts:
164 - contains:
165 path: spec.template.spec.initContainers[0].args
166 content: myMaria
167 - contains:
168 path: spec.template.spec.containers[0].env
169 content:
170 name: DB_HOST
171 value: myMaria
172 - contains:
173 path: spec.template.spec.containers[0].env
174 content:
175 name: DB_PORT
176 value: "545"
177 - contains:
178 path: spec.template.spec.containers[0].env
179 content:
180 name: MYSQL_ROOT_PASSWORD
181 valueFrom:
182 secretKeyRef:
183 name: RELEASE-NAME-mariadb-galera-myMaria
184 key: db-root-password
185
186 - it: "should render with full mariadbGalera changes"
187 set:
188 global:
189 mariadbGalera:
190 nameOverride: myMaria
191 servicePort: 545
192 userRootSecret: galera-secret
193 userRootSecretKey: root-password
194 asserts:
195 - contains:
196 path: spec.template.spec.initContainers[0].args
197 content: myMaria
198 - contains:
199 path: spec.template.spec.containers[0].env
200 content:
201 name: DB_HOST
202 value: myMaria
203 - contains:
204 path: spec.template.spec.containers[0].env
205 content:
206 name: DB_PORT
207 value: "545"
208 - contains:
209 path: spec.template.spec.containers[0].env
210 content:
211 name: MYSQL_ROOT_PASSWORD
212 valueFrom:
213 secretKeyRef:
214 name: galera-secret
215 key: root-password
216
217 - it: "should set the right nodeSelector"
218 set:
219 nodeSelector:
220 disktype: ssd
221 asserts:
222 - equal:
223 path: spec.template.spec.nodeSelector.disktype
224 value: ssd
225
226 - it: "should set the right affinity"
227 set:
228 affinity:
229 nodeAffinity:
230 requiredDuringSchedulingIgnoredDuringExecution:
231 nodeSelectorTerms:
232 - matchExpressions:
233 - key: kubernetes.io/e2e-az-name
234 operator: In
235 values:
236 - e2e-az1
237 - e2e-az2
238 asserts:
239 - equal:
240 path: spec.template.spec.affinity
241 value:
242 nodeAffinity:
243 requiredDuringSchedulingIgnoredDuringExecution:
244 nodeSelectorTerms:
245 - matchExpressions:
246 - key: kubernetes.io/e2e-az-name
247 operator: In
248 values:
249 - e2e-az1
250 - e2e-az2
251 - it: "should use large flavor"
252 set:
253 flavor: large
254 asserts:
255 - equal:
256 path: spec.template.spec.containers[0].resources.limits.cpu
257 value: 200m
258 - equal:
259 path: spec.template.spec.containers[0].resources.limits.memory
260 value: 500Mbi
261 - equal:
262 path: spec.template.spec.containers[0].resources.requests.cpu
263 value: 20m
264 - equal:
265 path: spec.template.spec.containers[0].resources.requests.memory
266 value: 20Mbi
267 - it: "should use unlimited flavor"
268 set:
269 flavor: unlimited
270 asserts:
271 - isEmpty:
272 path: spec.template.spec.containers[0].resources
273 - it: "shoud render with other databases"
274 set:
275 config:
276 mysqlAdditionalDatabases:
277 dbOne:
278 user: one
279 password: pwd1
280 dbTwo:
281 user: two
282 password: pwd2
283 asserts:
284 - contains:
285 path: spec.template.spec.containers[0].env
286 content:
287 name: MYSQL_PASSWORD
288 valueFrom:
289 secretKeyRef:
290 name: RELEASE-NAME-mariadb-init-secret
291 key: db-user-password
292 - contains:
293 path: spec.template.spec.containers[0].env
294 content:
295 name: MYSQL_PASSWORD_DBONE
296 valueFrom:
297 secretKeyRef:
298 name: RELEASE-NAME-mariadb-init-secret
299 key: db-dbOne-user-password
300 - contains:
301 path: spec.template.spec.containers[0].env
302 content:
303 name: MYSQL_PASSWORD_DBTWO
304 valueFrom:
305 secretKeyRef:
306 name: RELEASE-NAME-mariadb-init-secret
307 key: db-dbTwo-user-password