Skip to content

Commit 2997164

Browse files
committed
add label unit tests for ConfigMaps and Secrets
1 parent 1d37654 commit 2997164

File tree

1 file changed

+171
-2
lines changed

1 file changed

+171
-2
lines changed

tests/unit/labels_test.yaml

Lines changed: 171 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ templates:
66
- services.yaml
77

88
- configmaps_packs.yaml
9-
- configmaps_post-start-scripts.yaml
9+
- configmaps_post-start-script.yaml
1010
- configmaps_rbac.yaml
1111
- configmaps_st2-conf.yaml
1212
- configmaps_st2-urls.yaml
1313
- configmaps_st2web.yaml
1414

1515
- secrets_datastore_crypto_key.yaml
16-
- secrets_rabbit.yaml
16+
- secrets_rabbitmq.yaml
1717
- secrets_ssh.yaml
1818
- secrets_st2apikeys.yaml
1919
- secrets_st2auth.yaml
@@ -242,3 +242,172 @@ tests:
242242
- equal:
243243
path: metadata.labels.heritage
244244
value: Helm
245+
246+
- it: ConfigMaps and Secrets have required labels
247+
templates:
248+
- configmaps_packs.yaml
249+
- configmaps_st2-conf.yaml
250+
- configmaps_st2-urls.yaml
251+
252+
- secrets_datastore_crypto_key.yaml
253+
- secrets_rabbitmq.yaml
254+
- secrets_ssh.yaml
255+
- secrets_st2apikeys.yaml
256+
- secrets_st2auth.yaml
257+
- secrets_st2kv.yaml
258+
set:
259+
rabbitmq: # for secrets_rabbitmq.yaml
260+
enabled: true
261+
asserts:
262+
- hasDocuments:
263+
count: 1
264+
- equal:
265+
path: metadata.labels.app
266+
value: st2
267+
- equal:
268+
path: metadata.labels.release
269+
value: some-release-name
270+
- equal:
271+
path: metadata.labels.tier
272+
value: backend
273+
- equal:
274+
path: metadata.labels.vendor
275+
value: stackstorm
276+
- equal:
277+
path: metadata.labels.chart
278+
value: stackstorm-ha-1.0.999
279+
- equal:
280+
path: metadata.labels.heritage
281+
value: Helm
282+
283+
- it: RBAC ConfigMaps have required labels
284+
templates:
285+
- configmaps_rbac.yaml
286+
set:
287+
st2:
288+
rbac:
289+
enabled: true # enable rbac config maps
290+
asserts:
291+
- hasDocuments:
292+
count: 3
293+
- equal:
294+
path: metadata.labels.app
295+
value: st2
296+
- equal:
297+
path: metadata.labels.release
298+
value: some-release-name
299+
- equal:
300+
path: metadata.labels.tier
301+
value: backend
302+
- equal:
303+
path: metadata.labels.vendor
304+
value: stackstorm
305+
- equal:
306+
path: metadata.labels.chart
307+
value: stackstorm-ha-1.0.999
308+
- equal:
309+
path: metadata.labels.heritage
310+
value: Helm
311+
312+
- it: st2chatops Secret has required labels
313+
templates:
314+
- secrets_st2chatops.yaml
315+
set:
316+
st2chatops:
317+
enabled: true
318+
asserts:
319+
- hasDocuments:
320+
count: 1
321+
- equal:
322+
path: metadata.labels.app
323+
value: st2chatops
324+
- equal:
325+
path: metadata.labels.release
326+
value: some-release-name
327+
- equal:
328+
path: metadata.labels.tier
329+
value: backend
330+
- equal:
331+
path: metadata.labels.vendor
332+
value: stackstorm
333+
- equal:
334+
path: metadata.labels.chart
335+
value: stackstorm-ha-1.0.999
336+
- equal:
337+
path: metadata.labels.heritage
338+
value: Helm
339+
340+
- it: st2web ConfigMap has required labels
341+
templates:
342+
#- configmaps_post-start-scripts.yaml # needs postStartScript for each service
343+
- configmaps_st2web.yaml
344+
set:
345+
st2web:
346+
config: |
347+
// see https://github.com/StackStorm/st2web/blob/master/config.js
348+
'use strict';
349+
/* global angular */
350+
angular.module('main').constant('st2Config', {});
351+
asserts:
352+
- hasDocuments:
353+
count: 1
354+
- equal:
355+
path: metadata.labels.app
356+
value: st2 # should this be st2web?
357+
- equal:
358+
path: metadata.labels.release
359+
value: some-release-name
360+
- equal:
361+
path: metadata.labels.tier
362+
value: backend # should this be frontend?
363+
- equal:
364+
path: metadata.labels.vendor
365+
value: stackstorm
366+
- equal:
367+
path: metadata.labels.chart
368+
value: stackstorm-ha-1.0.999
369+
- equal:
370+
path: metadata.labels.heritage
371+
value: Helm
372+
373+
- it: post-start-script ConfigMaps have required labels
374+
templates:
375+
- configmaps_post-start-script.yaml
376+
set:
377+
st2auth: &postStartScript
378+
postStartScript: |
379+
echo hello world
380+
st2api: *postStartScript
381+
st2stream: *postStartScript
382+
st2web: *postStartScript
383+
st2rulesengine: *postStartScript
384+
st2timersengine: *postStartScript
385+
st2workflowengine: *postStartScript
386+
st2scheduler: *postStartScript
387+
st2notifier: *postStartScript
388+
st2sensorcontainer: *postStartScript
389+
st2actionrunner: *postStartScript
390+
st2garbagecollector: *postStartScript
391+
st2client: *postStartScript
392+
st2chatops: *postStartScript
393+
asserts:
394+
- hasDocuments:
395+
count: 14
396+
- equal:
397+
path: metadata.labels.app
398+
value: st2
399+
- equal:
400+
path: metadata.labels.release
401+
value: some-release-name
402+
- equal:
403+
path: metadata.labels.tier
404+
value: backend
405+
- equal:
406+
path: metadata.labels.vendor
407+
value: stackstorm
408+
- equal:
409+
path: metadata.labels.chart
410+
value: stackstorm-ha-1.0.999
411+
- equal:
412+
path: metadata.labels.heritage
413+
value: Helm

0 commit comments

Comments
 (0)