Skip to content

Commit 08a4cb2

Browse files
authored
Merge pull request #6 from cwilson21/testing
Using helper templates everywhere and adding if overrides for checksums also adding unit test to check mounts for mounts on st2client and register-content
2 parents 01f6f7f + adcf0fe commit 08a4cb2

File tree

4 files changed

+173
-11
lines changed

4 files changed

+173
-11
lines changed

templates/deployments.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,9 @@ spec:
17001700
checksum/auth: {{ include (print $.Template.BasePath "/secrets_st2auth.yaml") . | sha256sum }}
17011701
checksum/ssh: {{ include (print $.Template.BasePath "/secrets_ssh.yaml") . | sha256sum }}
17021702
checksum/datastore-key: {{ include (print $.Template.BasePath "/secrets_datastore_crypto_key.yaml") . | sha256sum }}
1703+
{{- if .Values.st2.overrides }}
17031704
checksum/overrides: {{ include (print $.Template.BasePath "/configmaps_overrides.yaml") . | sha256sum }}
1705+
{{- end }}
17041706
{{- if .Values.st2client.postStartScript }}
17051707
checksum/post-start-script: {{ .Values.st2client.postStartScript | sha256sum }}
17061708
{{- end }}
@@ -1774,10 +1776,7 @@ spec:
17741776
- name: st2-rbac-mappings-vol
17751777
mountPath: /opt/stackstorm/rbac/mappings/
17761778
{{- end }}
1777-
{{- if .Values.st2.overrides }}
1778-
- name: st2-overrides-vol
1779-
mountPath: /opt/stackstorm/overrides/
1780-
{{- end }}
1779+
{{- include "stackstorm-ha.override-config-mounts" . | nindent 8 }}
17811780
- name: st2client-config-vol
17821781
mountPath: /root/.st2/
17831782
- name: st2-ssh-key-vol
@@ -1829,11 +1828,7 @@ spec:
18291828
configMap:
18301829
name: {{ .Release.Name }}-st2-rbac-mappings
18311830
{{- end }}
1832-
{{- if .Values.st2.overrides }}
1833-
- name: st2-overrides-vol
1834-
configMap:
1835-
name: {{ .Release.Name }}-st2-override-configs
1836-
{{- end }}
1831+
{{- include "stackstorm-ha.override-configs" . | nindent 8 }}
18371832
- name: st2client-config-vol
18381833
emptyDir:
18391834
medium: Memory

templates/jobs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,9 @@ spec:
416416
# TODO: Investigate/propose running Helm hook only on condition when ConfigMap or Secret has changed
417417
checksum/config: {{ include (print $.Template.BasePath "/configmaps_st2-conf.yaml") . | sha256sum }}
418418
checksum/packs: {{ include (print $.Template.BasePath "/configmaps_packs.yaml") . | sha256sum }}
419+
{{- if .Values.st2.overrides }}
419420
checksum/overrides: {{ include (print $.Template.BasePath "/configmaps_overrides.yaml") . | sha256sum }}
421+
{{- end }}
420422
{{- if .Values.jobs.annotations }}
421423
{{- toYaml .Values.jobs.annotations | nindent 8 }}
422424
{{- end }}
@@ -543,6 +545,9 @@ spec:
543545
annotations:
544546
checksum/config: {{ include (print $.Template.BasePath "/configmaps_st2-conf.yaml") $ | sha256sum }}
545547
checksum/packs: {{ include (print $.Template.BasePath "/configmaps_packs.yaml") $ | sha256sum }}
548+
{{- if $.Values.st2.overrides }}
549+
checksum/overrides: {{ include (print $.Template.BasePath "/configmaps_overrides.yaml") $ | sha256sum }}
550+
{{- end }}
546551
{{- if $.Values.jobs.annotations }}
547552
{{- toYaml $.Values.jobs.annotations | nindent 8 }}
548553
{{- end }}
@@ -608,6 +613,7 @@ spec:
608613
volumeMounts:
609614
- name: st2client-config-vol
610615
mountPath: /root/.st2/
616+
{{- include "stackstorm-ha.override-config-mounts" $ | nindent 8 }}
611617
{{- include "stackstorm-ha.st2-config-volume-mounts" $ | nindent 8 }}
612618
{{- include "stackstorm-ha.packs-volume-mounts-for-register-job" $ | nindent 8 }}
613619
{{- include "stackstorm-ha.pack-configs-volume-mount" $ | nindent 8 }}
@@ -618,6 +624,7 @@ spec:
618624
- name: st2client-config-vol
619625
emptyDir:
620626
medium: Memory
627+
{{- include "stackstorm-ha.override-configs" $ | nindent 8 }}
621628
{{- include "stackstorm-ha.st2-config-volume" $ | nindent 8 }}
622629
{{- include "stackstorm-ha.packs-volumes" $ | nindent 8 }}
623630
{{- include "stackstorm-ha.pack-configs-volume" $ | nindent 8 }}

tests/unit/dns_test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tests:
2424
- deployments.yaml
2525
- jobs.yaml
2626
set:
27-
st2:
27+
st2:
2828
packs: { sensors: [] } # ensure only 1 sensor
2929
rbac: { enabled: true } # enable rbac job
3030
jobs:
@@ -55,7 +55,7 @@ tests:
5555
- name: ndots
5656
value: "2"
5757
- name: edns0
58-
st2:
58+
st2:
5959
packs: { sensors: [] } # ensure only 1 sensor
6060
rbac: { enabled: true } # enable rbac job
6161
jobs:

tests/unit/overrides_test.yaml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
suite: Override check
3+
templates:
4+
# primary template files
5+
- deployments.yaml
6+
- jobs.yaml
7+
- service-account.yaml
8+
9+
# included templates must also be listed
10+
- configmaps_overrides.yaml
11+
- configmaps_packs.yaml
12+
- configmaps_rbac.yaml
13+
- configmaps_st2-conf.yaml
14+
- configmaps_st2-urls.yaml
15+
- configmaps_st2web.yaml
16+
- secrets_datastore_crypto_key.yaml
17+
- secrets_ssh.yaml
18+
- secrets_st2apikeys.yaml
19+
- secrets_st2auth.yaml
20+
- secrets_st2chatops.yaml
21+
22+
tests:
23+
- it: Jobs with overrides mounted
24+
template: jobs.yaml
25+
set:
26+
st2:
27+
overrides: #Enabling the override mounts in register-content job.
28+
_global.yaml: |
29+
---
30+
rules:
31+
defaults:
32+
enabled: false
33+
rbac: { enabled: true } # enable rbac job
34+
packs: { sensors: [] } # ensure only 1 sensor
35+
jobs:
36+
extra_hooks: &extra_hooks_jobs
37+
- name: upgrade-warning
38+
hook: pre-upgrade, pre-rollback
39+
hook_weight: -5
40+
command: ["st2", "run", "--tail", "custom_pack.warn_about_upgrade"]
41+
release:
42+
name: st2ha
43+
asserts:
44+
- hasDocuments:
45+
count: 5
46+
47+
- contains: &override_volume
48+
path: spec.template.spec.volumes
49+
content:
50+
name: st2-overrides-vol
51+
configMap:
52+
name: st2ha-st2-override-configs
53+
documentIndex: 3 # register_content
54+
55+
56+
- contains: &override_mnt
57+
path: spec.template.spec.containers[0].volumeMounts
58+
content:
59+
name: st2-overrides-vol
60+
mountPath: /opt/stackstorm/overrides/
61+
documentIndex: 3 # register_content
62+
63+
- notContains: *override_volume
64+
documentIndex: 0
65+
- notContains: *override_mnt
66+
documentIndex: 0
67+
68+
- notContains: *override_volume
69+
documentIndex: 1
70+
- notContains: *override_mnt
71+
documentIndex: 1
72+
73+
- notContains: *override_volume
74+
documentIndex: 2
75+
- notContains: *override_mnt
76+
documentIndex: 2
77+
78+
- it: Deployments with overrides
79+
template: deployments.yaml
80+
set:
81+
st2:
82+
overrides: #Enabling the override mounts in register-content job.
83+
_global.yaml: |
84+
---
85+
rules:
86+
defaults:
87+
enabled: false
88+
packs:
89+
sensors: [] # ensure only 1 sensor
90+
images: [] # no extra packs to load
91+
volumes:
92+
enabled: false
93+
configs: {} # has one core.yaml config file by default (dicts get merged)
94+
st2chatops:
95+
enabled: true
96+
release:
97+
name: st2ha
98+
asserts:
99+
- hasDocuments:
100+
count: 14
101+
102+
103+
- contains: *override_volume # always included
104+
documentIndex: 12 # st2client
105+
- contains: *override_mnt # always included
106+
documentIndex: 12 # st2client
107+
108+
109+
- notContains: *override_volume
110+
documentIndex: 1
111+
- notContains: *override_mnt
112+
documentIndex: 1 # st2api
113+
- notContains: *override_volume # only contains if volumes.enabled
114+
documentIndex: 10 # st2actionrunner
115+
- notContains: *override_mnt # only contains if volumes.enabled
116+
documentIndex: 10 # st2actionrunner
117+
- notContains: *override_volume
118+
documentIndex: 0
119+
- notContains: *override_mnt
120+
documentIndex: 0
121+
- notContains: *override_volume
122+
documentIndex: 2
123+
- notContains: *override_mnt
124+
documentIndex: 2
125+
- notContains: *override_volume
126+
documentIndex: 3
127+
- notContains: *override_mnt
128+
documentIndex: 3
129+
- notContains: *override_volume
130+
documentIndex: 4
131+
- notContains: *override_mnt
132+
documentIndex: 4
133+
- notContains: *override_volume
134+
documentIndex: 5
135+
- notContains: *override_mnt
136+
documentIndex: 5
137+
- notContains: *override_volume
138+
documentIndex: 6
139+
- notContains: *override_mnt
140+
documentIndex: 6
141+
- notContains: *override_volume
142+
documentIndex: 7
143+
- notContains: *override_mnt
144+
documentIndex: 7
145+
- notContains: *override_volume
146+
documentIndex: 8
147+
- notContains: *override_mnt
148+
documentIndex: 8
149+
- notContains: *override_volume # never
150+
documentIndex: 9 # st2sensorcontainer
151+
- notContains: *override_mnt # never
152+
documentIndex: 9 # st2sensorcontainer
153+
- notContains: *override_volume
154+
documentIndex: 11
155+
- notContains: *override_mnt
156+
documentIndex: 11
157+
- notContains: *override_volume
158+
documentIndex: 13
159+
- notContains: *override_mnt
160+
documentIndex: 13

0 commit comments

Comments
 (0)