Skip to content

Commit e8a5c2d

Browse files
committed
add Resources test
1 parent 4ce954f commit e8a5c2d

File tree

2 files changed

+129
-1
lines changed

2 files changed

+129
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Advanced Feature: Make securityContext (on Deployments/Jobs) and podSecurityContext (on Pods) configurable. This allows dropping all capabilities, for example. You can override the securityContext for `st2actionrunner`, `st2sensorcontainer`, and `st2client` if your actions or sensors need, for example, additional capabilites that the rest of StackStorm does not need. (#271) (by @cognifloyd)
55
* Prefix template helpers with chart name and format helper comments as template comments. (#272) (by @cognifloyd)
66
* New feature: Add `extra_volumes` to all python-based st2 deployments. This can facilitate changing log levels by loading logging conf file(s) from a custom ConfigMap. (#276) (by @cognifloyd)
7-
* Initialize basic unittest infrastructure using `helm-unittest`. Added tests for labels, custom annotations, SecurityContext, pullSecrets, and pullPolicy. (#284, #288)
7+
* Initialize basic unittest infrastructure using `helm-unittest`. Added tests for labels, custom annotations, SecurityContext, pullSecrets, pullPolicy, and Resources. (#284, #288)
88

99
## v0.80.0
1010
* Switch st2 to `v3.6` as a new default stable version (#274)

tests/unit/resources_test.yaml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
suite: Resources
3+
templates:
4+
# primary template files
5+
- deployments.yaml
6+
7+
# No jobs resources yet
8+
9+
# included templates must also be listed
10+
- configmaps_packs.yaml
11+
- configmaps_rbac.yaml
12+
- configmaps_st2-conf.yaml
13+
- configmaps_st2web.yaml
14+
- secrets_datastore_crypto_key.yaml
15+
- secrets_ssh.yaml
16+
- secrets_st2auth.yaml
17+
- secrets_st2chatops.yaml
18+
19+
tests:
20+
- it: Deployments have default resources
21+
template: deployments.yaml
22+
set:
23+
st2:
24+
packs: { sensors: [] } # ensure only 1 sensor
25+
st2chatops:
26+
enabled: true
27+
asserts:
28+
- hasDocuments:
29+
count: 14
30+
31+
# only st2web defines limits for now
32+
- isNotEmpty:
33+
path: spec.template.spec.containers[0].resources.limits.memory
34+
documentIndex: 3
35+
36+
- isNotEmpty:
37+
path: spec.template.spec.containers[0].resources.requests.memory
38+
- isNotEmpty:
39+
path: spec.template.spec.containers[0].resources.requests.cpu
40+
41+
- it: Deployments accept custom resources (except st2client)
42+
template: deployments.yaml
43+
set:
44+
st2:
45+
packs: { sensors: [] } # ensure only 1 sensor
46+
st2web:
47+
resources:
48+
# bogus numbers just for the test
49+
requests: &custom_resources_requests
50+
memory: "333Mi"
51+
cpu: "77m"
52+
limits:
53+
memory: "999Mi"
54+
st2auth:
55+
resources: &custom_resources
56+
requests: *custom_resources_requests
57+
st2api:
58+
resources: *custom_resources
59+
st2stream:
60+
resources: *custom_resources
61+
st2rulesengine:
62+
resources: *custom_resources
63+
st2timersengine:
64+
resources: *custom_resources
65+
st2workflowengine:
66+
resources: *custom_resources
67+
st2scheduler:
68+
resources: *custom_resources
69+
st2notifier:
70+
resources: *custom_resources
71+
st2actionrunner:
72+
resources: *custom_resources
73+
st2sensorcontainer:
74+
resources: *custom_resources
75+
st2garbagecollector:
76+
resources: *custom_resources
77+
st2chatops:
78+
enabled: true
79+
resources: *custom_resources
80+
asserts:
81+
- hasDocuments:
82+
count: 14
83+
84+
# only st2web defines limits for now
85+
- equal:
86+
path: spec.template.spec.containers[0].resources.limits.memory
87+
value: "999Mi"
88+
documentIndex: 3
89+
90+
# st2client hard codes resources.requests
91+
- equal:
92+
path: spec.template.spec.containers[0].resources.requests
93+
value:
94+
memory: "5Mi"
95+
cpu: "5m"
96+
documentIndex: 12
97+
98+
# all but st2client means documentIndexes 0-11,13
99+
- equal: &assert_custom_requests
100+
path: spec.template.spec.containers[0].resources.requests
101+
value: *custom_resources_requests
102+
documentIndex: 0
103+
- equal: *assert_custom_requests
104+
documentIndex: 1
105+
- equal: *assert_custom_requests
106+
documentIndex: 2
107+
- equal: *assert_custom_requests
108+
documentIndex: 3
109+
- equal: *assert_custom_requests
110+
documentIndex: 4
111+
- equal: *assert_custom_requests
112+
documentIndex: 5
113+
- equal: *assert_custom_requests
114+
documentIndex: 6
115+
- equal: *assert_custom_requests
116+
documentIndex: 7
117+
- equal: *assert_custom_requests
118+
documentIndex: 8
119+
- equal: *assert_custom_requests
120+
documentIndex: 9
121+
- equal: *assert_custom_requests
122+
documentIndex: 10
123+
- equal: *assert_custom_requests
124+
documentIndex: 11
125+
- equal: *assert_custom_requests
126+
documentIndex: 13
127+
128+
# Jobs do not have default resources defined yet.

0 commit comments

Comments
 (0)