1+ suite : Test OTEL Collector ConfigMap
2+ templates :
3+ - configmaps/otel-collector-configmap.yaml
4+ tests :
5+ - it : should not render when otel is disabled
6+ set :
7+ otel :
8+ enabled : false
9+ customConfig : |
10+ receivers:
11+ otlp:
12+ protocols:
13+ grpc:
14+ endpoint: 0.0.0.0:4317
15+ asserts :
16+ - hasDocuments :
17+ count : 0
18+
19+ - it : should not render when customConfig is not provided
20+ set :
21+ otel :
22+ enabled : true
23+ asserts :
24+ - hasDocuments :
25+ count : 0
26+
27+ - it : should render when both enabled and customConfig are set
28+ set :
29+ otel :
30+ enabled : true
31+ customConfig : |
32+ receivers:
33+ otlp:
34+ protocols:
35+ grpc:
36+ endpoint: 0.0.0.0:4317
37+ http:
38+ endpoint: 0.0.0.0:4318
39+ release :
40+ name : my-release
41+ asserts :
42+ - hasDocuments :
43+ count : 1
44+ - isKind :
45+ of : ConfigMap
46+ - equal :
47+ path : metadata.name
48+ value : my-release-hdx-oss-v2-otel-custom-config
49+ - matchRegex :
50+ path : data["custom.config.yaml"]
51+ pattern : " receivers:"
52+ - matchRegex :
53+ path : data["custom.config.yaml"]
54+ pattern : " endpoint: 0.0.0.0:4317"
55+ - matchRegex :
56+ path : data["custom.config.yaml"]
57+ pattern : " endpoint: 0.0.0.0:4318"
58+
59+ - it : should include proper labels
60+ set :
61+ otel :
62+ enabled : true
63+ customConfig : |
64+ test: config
65+ release :
66+ name : test-release
67+ chart :
68+ version : 1.0.0
69+ asserts :
70+ - equal :
71+ path : metadata.labels.app
72+ value : otel-collector
73+ - matchRegex :
74+ path : metadata.labels["helm.sh/chart"]
75+ pattern : " hdx-oss-v2-"
76+ - equal :
77+ path : metadata.labels["app.kubernetes.io/name"]
78+ value : hdx-oss-v2
79+ - equal :
80+ path : metadata.labels["app.kubernetes.io/instance"]
81+ value : test-release
82+
83+ - it : should handle multi-line config with proper indentation
84+ set :
85+ otel :
86+ enabled : true
87+ customConfig : |
88+ receivers:
89+ otlp:
90+ protocols:
91+ grpc:
92+ endpoint: 0.0.0.0:4317
93+ keepalive:
94+ server_parameters:
95+ max_connection_idle: 30s
96+ max_connection_age: 60s
97+ processors:
98+ batch:
99+ timeout: 10s
100+ send_batch_size: 1024
101+ memory_limiter:
102+ limit_mib: 512
103+ exporters:
104+ logging:
105+ loglevel: debug
106+ service:
107+ pipelines:
108+ traces:
109+ receivers: [otlp]
110+ processors: [memory_limiter, batch]
111+ exporters: [logging]
112+ asserts :
113+ - matchRegex :
114+ path : data["custom.config.yaml"]
115+ pattern : " keepalive:"
116+ - matchRegex :
117+ path : data["custom.config.yaml"]
118+ pattern : " server_parameters:"
119+ - matchRegex :
120+ path : data["custom.config.yaml"]
121+ pattern : " max_connection_idle: 30s"
122+ - matchRegex :
123+ path : data["custom.config.yaml"]
124+ pattern : " memory_limiter:"
125+ - matchRegex :
126+ path : data["custom.config.yaml"]
127+ pattern : " limit_mib: 512"
128+ - matchRegex :
129+ path : data["custom.config.yaml"]
130+ pattern : " pipelines:"
131+ - matchRegex :
132+ path : data["custom.config.yaml"]
133+ pattern : " processors: \\ [memory_limiter, batch\\ ]"
134+
135+ - it : should preserve environment variable references
136+ set :
137+ otel :
138+ enabled : true
139+ customConfig : |
140+ receivers:
141+ otlp:
142+ protocols:
143+ grpc:
144+ endpoint: ${OTEL_GRPC_ENDPOINT:-0.0.0.0:4317}
145+ exporters:
146+ clickhouse:
147+ endpoint: ${CLICKHOUSE_ENDPOINT}
148+ database: ${HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE}
149+ username: ${CLICKHOUSE_USER}
150+ password: ${CLICKHOUSE_PASSWORD}
151+ asserts :
152+ - matchRegex :
153+ path : data["custom.config.yaml"]
154+ pattern : " \\ $\\ {OTEL_GRPC_ENDPOINT:-0.0.0.0:4317\\ }"
155+ - matchRegex :
156+ path : data["custom.config.yaml"]
157+ pattern : " \\ $\\ {CLICKHOUSE_ENDPOINT\\ }"
158+ - matchRegex :
159+ path : data["custom.config.yaml"]
160+ pattern : " \\ $\\ {HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE\\ }"
161+ - matchRegex :
162+ path : data["custom.config.yaml"]
163+ pattern : " \\ $\\ {CLICKHOUSE_USER\\ }"
164+ - matchRegex :
165+ path : data["custom.config.yaml"]
166+ pattern : " \\ $\\ {CLICKHOUSE_PASSWORD\\ }"
167+
168+ - it : should handle empty customConfig string
169+ set :
170+ otel :
171+ enabled : true
172+ customConfig : " "
173+ asserts :
174+ - hasDocuments :
175+ count : 0
176+
177+ - it : should render with minimal config
178+ set :
179+ otel :
180+ enabled : true
181+ customConfig : |
182+ test: minimal
183+ release :
184+ name : minimal-test
185+ asserts :
186+ - hasDocuments :
187+ count : 1
188+ - equal :
189+ path : metadata.name
190+ value : minimal-test-hdx-oss-v2-otel-custom-config
191+ - matchRegex :
192+ path : data["custom.config.yaml"]
193+ pattern : " test: minimal"
194+
195+ - it : should handle config with special characters
196+ set :
197+ otel :
198+ enabled : true
199+ customConfig : |
200+ receivers:
201+ prometheus:
202+ config:
203+ scrape_configs:
204+ - job_name: 'otel-collector'
205+ metrics_path: /metrics
206+ static_configs:
207+ - targets: ['localhost:8888']
208+ labels:
209+ env: "prod-us-west-2"
210+ cluster: "k8s-cluster-1"
211+ asserts :
212+ - matchRegex :
213+ path : data["custom.config.yaml"]
214+ pattern : " job_name: 'otel-collector'"
215+ - matchRegex :
216+ path : data["custom.config.yaml"]
217+ pattern : " metrics_path: /metrics"
218+ - matchRegex :
219+ path : data["custom.config.yaml"]
220+ pattern : " targets: \\ ['localhost:8888'\\ ]"
221+ - matchRegex :
222+ path : data["custom.config.yaml"]
223+ pattern : " env: \" prod-us-west-2\" "
224+ - matchRegex :
225+ path : data["custom.config.yaml"]
226+ pattern : " cluster: \" k8s-cluster-1\" "
227+
228+ - it : should handle config with yaml anchors and references
229+ set :
230+ otel :
231+ enabled : true
232+ customConfig : |
233+ extensions:
234+ health_check:
235+ endpoint: 0.0.0.0:13133
236+
237+ receivers:
238+ otlp: &otlp-receiver
239+ protocols:
240+ grpc:
241+ endpoint: 0.0.0.0:4317
242+ http:
243+ endpoint: 0.0.0.0:4318
244+
245+ otlp/secondary:
246+ <<: *otlp-receiver
247+ protocols:
248+ grpc:
249+ endpoint: 0.0.0.0:14317
250+ asserts :
251+ - matchRegex :
252+ path : data["custom.config.yaml"]
253+ pattern : " otlp: &otlp-receiver"
254+ - matchRegex :
255+ path : data["custom.config.yaml"]
256+ pattern : " <<: \\ *otlp-receiver"
257+ - matchRegex :
258+ path : data["custom.config.yaml"]
259+ pattern : " endpoint: 0.0.0.0:14317"
0 commit comments