Skip to content

Commit 0fe421a

Browse files
feat: add node-selector unittest
1 parent 78c614a commit 0fe421a

File tree

2 files changed

+254
-0
lines changed

2 files changed

+254
-0
lines changed

.changeset/happy-states-matter.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"helm-charts": patch
3+
---
4+
5+
feat: support nodeSelector and toleration
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
suite: Test nodeSelector and tolerations
2+
templates:
3+
- hyperdx-deployment.yaml
4+
- clickhouse-deployment.yaml
5+
- otel-collector-deployment.yaml
6+
- mongodb-deployment.yaml
7+
tests:
8+
# Test default behavior - no nodeSelector or tolerations
9+
- it: should not include nodeSelector and tolerations when not configured
10+
templates:
11+
- hyperdx-deployment.yaml
12+
asserts:
13+
- isNull:
14+
path: spec.template.spec.nodeSelector
15+
- isNull:
16+
path: spec.template.spec.tolerations
17+
18+
# Test HyperDX component nodeSelector
19+
- it: should apply nodeSelector to HyperDX deployment when configured
20+
set:
21+
hyperdx:
22+
nodeSelector:
23+
disktype: ssd
24+
node-role: hyperdx-app
25+
templates:
26+
- hyperdx-deployment.yaml
27+
asserts:
28+
- equal:
29+
path: spec.template.spec.nodeSelector
30+
value:
31+
disktype: ssd
32+
node-role: hyperdx-app
33+
34+
# Test HyperDX component tolerations
35+
- it: should apply tolerations to HyperDX deployment when configured
36+
set:
37+
hyperdx:
38+
tolerations:
39+
- key: hyperdx-key
40+
operator: Equal
41+
value: hyperdx-value
42+
effect: NoSchedule
43+
- key: dedicated
44+
operator: Equal
45+
value: hyperdx
46+
effect: NoExecute
47+
templates:
48+
- hyperdx-deployment.yaml
49+
asserts:
50+
- equal:
51+
path: spec.template.spec.tolerations
52+
value:
53+
- key: hyperdx-key
54+
operator: Equal
55+
value: hyperdx-value
56+
effect: NoSchedule
57+
- key: dedicated
58+
operator: Equal
59+
value: hyperdx
60+
effect: NoExecute
61+
62+
# Test ClickHouse component nodeSelector and tolerations
63+
- it: should apply nodeSelector and tolerations to ClickHouse deployment
64+
set:
65+
clickhouse:
66+
nodeSelector:
67+
node-role: database
68+
storage: fast-ssd
69+
tolerations:
70+
- key: database-key
71+
operator: Equal
72+
value: clickhouse
73+
effect: NoSchedule
74+
- key: io-intensive
75+
operator: Exists
76+
effect: NoSchedule
77+
templates:
78+
- clickhouse-deployment.yaml
79+
asserts:
80+
- equal:
81+
path: spec.template.spec.nodeSelector
82+
value:
83+
node-role: database
84+
storage: fast-ssd
85+
- equal:
86+
path: spec.template.spec.tolerations
87+
value:
88+
- key: database-key
89+
operator: Equal
90+
value: clickhouse
91+
effect: NoSchedule
92+
- key: io-intensive
93+
operator: Exists
94+
effect: NoSchedule
95+
96+
# Test OTEL Collector component nodeSelector and tolerations
97+
- it: should apply nodeSelector and tolerations to OTEL Collector deployment
98+
set:
99+
otel:
100+
nodeSelector:
101+
node-role: monitoring
102+
tolerations:
103+
- key: monitoring-key
104+
operator: Equal
105+
value: otel
106+
effect: PreferNoSchedule
107+
templates:
108+
- otel-collector-deployment.yaml
109+
asserts:
110+
- equal:
111+
path: spec.template.spec.nodeSelector
112+
value:
113+
node-role: monitoring
114+
- equal:
115+
path: spec.template.spec.tolerations
116+
value:
117+
- key: monitoring-key
118+
operator: Equal
119+
value: otel
120+
effect: PreferNoSchedule
121+
122+
# Test MongoDB component nodeSelector and tolerations
123+
- it: should apply nodeSelector and tolerations to MongoDB deployment
124+
set:
125+
mongodb:
126+
nodeSelector:
127+
node-role: database
128+
tolerations:
129+
- key: database-key
130+
operator: Equal
131+
value: mongodb
132+
effect: NoSchedule
133+
templates:
134+
- mongodb-deployment.yaml
135+
asserts:
136+
- equal:
137+
path: spec.template.spec.nodeSelector
138+
value:
139+
node-role: database
140+
- equal:
141+
path: spec.template.spec.tolerations
142+
value:
143+
- key: database-key
144+
operator: Equal
145+
value: mongodb
146+
effect: NoSchedule
147+
148+
# Test multiple components with different configurations
149+
- it: should handle different nodeSelector and tolerations per component
150+
set:
151+
hyperdx:
152+
nodeSelector:
153+
component: api
154+
tolerations:
155+
- key: hyperdx
156+
operator: Equal
157+
value: api
158+
effect: NoSchedule
159+
clickhouse:
160+
nodeSelector:
161+
component: database
162+
storage: ssd
163+
tolerations:
164+
- key: database
165+
operator: Equal
166+
value: clickhouse
167+
effect: NoExecute
168+
mongodb:
169+
nodeSelector:
170+
component: database
171+
storage: standard
172+
templates:
173+
- hyperdx-deployment.yaml
174+
- clickhouse-deployment.yaml
175+
- mongodb-deployment.yaml
176+
asserts:
177+
# HyperDX deployment
178+
- documentIndex: 0
179+
equal:
180+
path: spec.template.spec.nodeSelector
181+
value:
182+
component: api
183+
- documentIndex: 0
184+
equal:
185+
path: spec.template.spec.tolerations
186+
value:
187+
- key: hyperdx
188+
operator: Equal
189+
value: api
190+
effect: NoSchedule
191+
# ClickHouse deployment
192+
- documentIndex: 1
193+
equal:
194+
path: spec.template.spec.nodeSelector
195+
value:
196+
component: database
197+
storage: ssd
198+
- documentIndex: 1
199+
equal:
200+
path: spec.template.spec.tolerations
201+
value:
202+
- key: database
203+
operator: Equal
204+
value: clickhouse
205+
effect: NoExecute
206+
# MongoDB deployment
207+
- documentIndex: 2
208+
equal:
209+
path: spec.template.spec.nodeSelector
210+
value:
211+
component: database
212+
storage: standard
213+
- documentIndex: 2
214+
isNull:
215+
path: spec.template.spec.tolerations
216+
217+
# Test that disabled components are not affected
218+
- it: should not render nodeSelector and tolerations for disabled components
219+
set:
220+
clickhouse:
221+
enabled: false
222+
nodeSelector:
223+
should-not: appear
224+
mongodb:
225+
enabled: false
226+
tolerations:
227+
- key: should-not
228+
operator: Equal
229+
value: appear
230+
effect: NoSchedule
231+
otel:
232+
enabled: false
233+
tasks:
234+
enabled: false
235+
hyperdx:
236+
nodeSelector:
237+
component: api
238+
templates:
239+
- hyperdx-deployment.yaml
240+
asserts:
241+
# Should only have HyperDX deployment
242+
- hasDocuments:
243+
count: 1
244+
- isKind:
245+
of: Deployment
246+
- equal:
247+
path: spec.template.spec.nodeSelector
248+
value:
249+
component: api

0 commit comments

Comments
 (0)