Skip to content

Commit 8ee2446

Browse files
committed
add unit tests for custom annotations
1 parent 17ef7c2 commit 8ee2446

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
suite: Custom Annotations
3+
templates:
4+
# primary template files
5+
- deployments.yaml
6+
- ingress.yaml
7+
- jobs.yaml
8+
- service-account.yaml
9+
- services.yaml
10+
11+
# included templates must also be listed
12+
- configmaps_packs.yaml
13+
- configmaps_rbac.yaml
14+
- configmaps_st2-conf.yaml
15+
- configmaps_st2-urls.yaml
16+
- configmaps_st2web.yaml
17+
- secrets_datastore_crypto_key.yaml
18+
- secrets_ssh.yaml
19+
- secrets_st2apikeys.yaml
20+
- secrets_st2auth.yaml
21+
- secrets_st2chatops.yaml
22+
23+
tests:
24+
- it: ServiceAccount accepts custom annotations
25+
template: service-account.yaml
26+
set:
27+
serviceAccount:
28+
create: true
29+
serviceAccountAnnotations: &annotations
30+
foo: bar
31+
answer: "42"
32+
asserts: &annotations_asserts
33+
- isNotNull:
34+
path: metadata.annotations
35+
- equal:
36+
path: metadata.annotations.foo
37+
value: bar
38+
- equal:
39+
path: metadata.annotations.answer
40+
value: "42"
41+
42+
- it: st2web Ingress accepts custom annotations
43+
template: ingress.yaml
44+
set:
45+
st2web:
46+
service:
47+
hostname: some-host-name
48+
ingress:
49+
enabled: true
50+
annotations: *annotations
51+
asserts: *annotations_asserts
52+
53+
# st2auth, st2api, st2stream services do not accept custom annotations
54+
55+
- it: st2web Service accepts custom annotations
56+
template: services.yaml
57+
documentIndex: 3
58+
set:
59+
st2web:
60+
service:
61+
hostname: some-host-name
62+
annotations: *annotations
63+
asserts: *annotations_asserts
64+
65+
# st2chatops service does not accept custom annotations
66+
67+
- it: Deployments+Pods accept custom annotations
68+
template: deployments.yaml
69+
set:
70+
st2auth:
71+
annotations: &deployment_annotations
72+
foo: bar
73+
answer: "42"
74+
st2api:
75+
annotations: *deployment_annotations
76+
st2stream:
77+
annotations: *deployment_annotations
78+
st2web:
79+
annotations: *deployment_annotations
80+
st2rulesengine:
81+
annotations: *deployment_annotations
82+
st2timersengine:
83+
annotations: *deployment_annotations
84+
st2workflowengine:
85+
annotations: *deployment_annotations
86+
st2scheduler:
87+
annotations: *deployment_annotations
88+
st2notifier:
89+
annotations: *deployment_annotations
90+
st2sensorcontainer:
91+
annotations: *deployment_annotations
92+
st2: { packs: { sensors: [] } } # ensure only 1 sensor
93+
st2actionrunner:
94+
annotations: *deployment_annotations
95+
st2garbagecollector:
96+
annotations: *deployment_annotations
97+
st2client:
98+
annotations: *deployment_annotations
99+
st2chatops:
100+
enabled: true
101+
annotations: *deployment_annotations
102+
asserts:
103+
- hasDocuments:
104+
count: 14
105+
# st2auth, st2api,
106+
# st2stream, st2web,
107+
# st2rulesengine, st2timersengine,
108+
# st2workflowengine, st2scheduler,
109+
# st2notifier, (1) st2sensorcontainer,
110+
# st2actionrunner, st2garbagecollector,
111+
# st2client, st2chatops
112+
113+
# deployment annotations
114+
- isNotNull:
115+
path: metadata.annotations
116+
- equal:
117+
path: metadata.annotations.foo
118+
value: bar
119+
- equal:
120+
path: metadata.annotations.answer
121+
value: "42"
122+
123+
# pod annotations
124+
- isNotNull:
125+
path: spec.template.metadata.annotations
126+
- equal:
127+
path: spec.template.metadata.annotations.foo
128+
value: bar
129+
- equal:
130+
path: spec.template.metadata.annotations.answer
131+
value: "42"
132+
133+
- it: Jobs+Pods accept custom annotations
134+
template: jobs.yaml
135+
set:
136+
st2:
137+
rbac:
138+
enabled: true # enable rbac job
139+
jobs:
140+
annotations:
141+
foo: bar
142+
answer: "42"
143+
asserts:
144+
- hasDocuments:
145+
count: 4
146+
# job-st2-apply-rbac-defintions
147+
# job-st2-apikey-load
148+
# job-st2-key-load
149+
# job-st2-register-content
150+
151+
# job annotations
152+
- isNotNull:
153+
path: metadata.annotations
154+
- equal:
155+
path: metadata.annotations.foo
156+
value: bar
157+
- equal:
158+
path: metadata.annotations.answer
159+
value: "42"
160+
161+
# pod annotations
162+
- isNotNull:
163+
path: spec.template.metadata.annotations
164+
- equal:
165+
path: spec.template.metadata.annotations.foo
166+
value: bar
167+
- equal:
168+
path: spec.template.metadata.annotations.answer
169+
value: "42"

0 commit comments

Comments
 (0)