Skip to content

Commit dc4252f

Browse files
committed
add more tests for resdet
1 parent cf178a4 commit dc4252f

File tree

4 files changed

+244
-32
lines changed

4 files changed

+244
-32
lines changed

functional_tests/functional/testdata/expected_gce_values/expected_resource_attributes_agent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resourceMetrics:
99
stringValue: abcd
1010
- key: cloud.platform
1111
value:
12-
stringValue: abcd
12+
stringValue: gcp_compute_engine
1313
- key: cloud.provider
1414
value:
1515
stringValue: abcd

functional_tests/functional/testdata/expected_gce_values/expected_resource_attributes_cluster_receiver.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resourceMetrics:
99
stringValue: abcd
1010
- key: cloud.platform
1111
value:
12-
stringValue: abcd
12+
stringValue: gcp_compute_engine
1313
- key: cloud.provider
1414
value:
1515
stringValue: abcd

unittests/resource_detection_fargate_test.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

unittests/resource_detection_test.yaml

Lines changed: 242 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,103 +6,334 @@ release:
66
namespace: test-ns
77
templates:
88
- configmap-agent.yaml
9+
- configmap-cluster-receiver.yaml
10+
- configmap-gateway.yaml
911

1012
tests:
11-
- it: "vanilla K8s on AWS: detectors = [env, ec2, system]"
13+
# ---------------------------------------------------------------
14+
# Detector configuration: verified across agent, cluster receiver,
15+
# and gateway configmaps (no template: key = all three checked).
16+
# ---------------------------------------------------------------
17+
18+
# Vanilla K8s (distribution="") on each cloud provider
19+
- it: "vanilla K8s on AWS — all modes have [env, ec2, system]"
1220
set:
1321
distribution: ""
1422
cloudProvider: aws
23+
gateway.enabled: true
1524
asserts:
1625
- matchRegex:
1726
path: data["relay"]
1827
pattern: "detectors:\\n\\s+- env\\n\\s+- ec2\\n\\s+- system\\n\\s+[a-z]"
1928

20-
- it: "vanilla K8s on GCP: detectors = [env, gcp, system]"
29+
- it: "vanilla K8s on GCP — all modes have [env, gcp, system]"
2130
set:
2231
distribution: ""
2332
cloudProvider: gcp
33+
gateway.enabled: true
2434
asserts:
2535
- matchRegex:
2636
path: data["relay"]
2737
pattern: "detectors:\\n\\s+- env\\n\\s+- gcp\\n\\s+- system\\n\\s+[a-z]"
2838

29-
- it: "vanilla K8s on Azure: detectors = [env, azure, system]"
39+
- it: "vanilla K8s on Azure — all modes have [env, azure, system]"
3040
set:
3141
distribution: ""
3242
cloudProvider: azure
43+
gateway.enabled: true
3344
asserts:
3445
- matchRegex:
3546
path: data["relay"]
3647
pattern: "detectors:\\n\\s+- env\\n\\s+- azure\\n\\s+- system\\n\\s+[a-z]"
3748

38-
- it: "OpenShift on AWS: detectors = [env, openshift, ec2, system]"
49+
# OpenShift on each cloud provider
50+
- it: "OpenShift on AWS — all modes have [env, openshift, ec2, system]"
3951
set:
4052
distribution: openshift
4153
cloudProvider: aws
54+
gateway.enabled: true
4255
asserts:
4356
- matchRegex:
4457
path: data["relay"]
4558
pattern: "detectors:\\n\\s+- env\\n\\s+- openshift\\n\\s+- ec2\\n\\s+- system\\n\\s+[a-z]"
4659

47-
- it: "OpenShift on GCP: detectors = [env, openshift, gcp, system]"
60+
- it: "OpenShift on GCP — all modes have [env, openshift, gcp, system]"
4861
set:
4962
distribution: openshift
5063
cloudProvider: gcp
64+
gateway.enabled: true
5165
asserts:
5266
- matchRegex:
5367
path: data["relay"]
5468
pattern: "detectors:\\n\\s+- env\\n\\s+- openshift\\n\\s+- gcp\\n\\s+- system\\n\\s+[a-z]"
5569

56-
- it: "OpenShift on Azure: detectors = [env, openshift, azure, system]"
70+
- it: "OpenShift on Azure — all modes have [env, openshift, azure, system]"
5771
set:
5872
distribution: openshift
5973
cloudProvider: azure
74+
gateway.enabled: true
6075
asserts:
6176
- matchRegex:
6277
path: data["relay"]
6378
pattern: "detectors:\\n\\s+- env\\n\\s+- openshift\\n\\s+- azure\\n\\s+- system\\n\\s+[a-z]"
6479

65-
- it: "EKS on AWS: detectors = [env, eks, system]"
80+
# Managed distributions
81+
- it: "EKS on AWS — all modes have [env, eks, system]"
6682
set:
6783
distribution: eks
6884
cloudProvider: aws
85+
gateway.enabled: true
6986
asserts:
7087
- matchRegex:
7188
path: data["relay"]
7289
pattern: "detectors:\\n\\s+- env\\n\\s+- eks\\n\\s+- system\\n\\s+[a-z]"
7390

74-
- it: "EKS/auto-mode on AWS: detectors = [env, eks, system]"
91+
- it: "EKS/auto-mode on AWS — all modes have [env, eks, system]"
7592
set:
7693
distribution: eks/auto-mode
7794
cloudProvider: aws
95+
gateway.enabled: true
7896
asserts:
7997
- matchRegex:
8098
path: data["relay"]
8199
pattern: "detectors:\\n\\s+- env\\n\\s+- eks\\n\\s+- system\\n\\s+[a-z]"
82100

83-
- it: "GKE on GCP: detectors = [env, gcp, system]"
101+
- it: "EKS/Fargate on AWS — cluster receiver has [env, system] (no cloud detector, Fargate lacks IMDS)"
102+
set:
103+
distribution: eks/fargate
104+
cloudProvider: aws
105+
clusterName: fargate-test
106+
template: configmap-cluster-receiver.yaml
107+
asserts:
108+
- matchRegex:
109+
path: data["relay"]
110+
pattern: "detectors:\\n\\s+- env\\n\\s+- system\\n\\s+[a-z]"
111+
112+
- it: "GKE on GCP — all modes have [env, gcp, system]"
84113
set:
85114
distribution: gke
86115
cloudProvider: gcp
116+
gateway.enabled: true
87117
asserts:
88118
- matchRegex:
89119
path: data["relay"]
90120
pattern: "detectors:\\n\\s+- env\\n\\s+- gcp\\n\\s+- system\\n\\s+[a-z]"
91121

92-
- it: "GKE/Autopilot on GCP: detectors = [env, gcp, system]"
122+
- it: "GKE/Autopilot on GCP — all modes have [env, gcp, system]"
93123
set:
94124
distribution: gke/autopilot
95125
cloudProvider: gcp
126+
gateway.enabled: true
96127
asserts:
97128
- matchRegex:
98129
path: data["relay"]
99130
pattern: "detectors:\\n\\s+- env\\n\\s+- gcp\\n\\s+- system\\n\\s+[a-z]"
100131

101-
- it: "AKS on Azure: detectors = [env, aks, azure, system]"
132+
- it: "AKS on Azure — all modes have [env, aks, azure, system]"
102133
set:
103134
distribution: aks
104135
cloudProvider: azure
136+
gateway.enabled: true
105137
asserts:
106138
- matchRegex:
107139
path: data["relay"]
108140
pattern: "detectors:\\n\\s+- env\\n\\s+- aks\\n\\s+- azure\\n\\s+- system\\n\\s+[a-z]"
141+
142+
# ---------------------------------------------------------------
143+
# Pipeline wiring: verify resourcedetection processor appears in
144+
# the correct signal pipelines for each deployment mode.
145+
#
146+
# Rendered YAML orders pipeline keys alphabetically:
147+
# exporters -> processors -> receivers
148+
# Positive tests: match exporters(1+) -> processors containing resourcedetection -> receivers.
149+
# Negative tests: match exact processor list to prove no resourcedetection.
150+
# ---------------------------------------------------------------
151+
152+
# Agent: resourcedetection in all signal pipelines
153+
- it: "agent — metrics pipeline includes resourcedetection"
154+
set:
155+
distribution: openshift
156+
cloudProvider: aws
157+
template: configmap-agent.yaml
158+
asserts:
159+
- matchRegex:
160+
path: data["relay"]
161+
pattern: "metrics:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
162+
163+
- it: "agent — traces pipeline includes resourcedetection"
164+
set:
165+
distribution: openshift
166+
cloudProvider: aws
167+
template: configmap-agent.yaml
168+
asserts:
169+
- matchRegex:
170+
path: data["relay"]
171+
pattern: "traces:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
172+
173+
- it: "agent — logs (+ profiling) pipeline includes resourcedetection"
174+
set:
175+
distribution: openshift
176+
cloudProvider: aws
177+
splunkPlatform:
178+
endpoint: https://localhost
179+
token: test-token
180+
logsEnabled: true
181+
template: configmap-agent.yaml
182+
asserts:
183+
- matchRegex:
184+
path: data["relay"]
185+
pattern: "logs:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
186+
187+
- it: "agent — logs/entities pipeline includes resourcedetection"
188+
set:
189+
distribution: openshift
190+
cloudProvider: aws
191+
template: configmap-agent.yaml
192+
asserts:
193+
- matchRegex:
194+
path: data["relay"]
195+
pattern: "logs/entities:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
196+
197+
- it: "agent — metrics/agent pipeline includes resourcedetection"
198+
set:
199+
distribution: openshift
200+
cloudProvider: aws
201+
template: configmap-agent.yaml
202+
asserts:
203+
- matchRegex:
204+
path: data["relay"]
205+
pattern: "metrics/agent:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
206+
207+
# Cluster receiver: resourcedetection only in self-metrics, events, and objects pipelines.
208+
# The main metrics pipeline (k8s_cluster receiver) is cluster-level, not host-level.
209+
- it: "cluster receiver — metrics pipeline has no resourcedetection"
210+
set:
211+
distribution: openshift
212+
cloudProvider: aws
213+
template: configmap-cluster-receiver.yaml
214+
asserts:
215+
- notMatchRegex:
216+
path: data["relay"]
217+
pattern: "metrics:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
218+
219+
- it: "cluster receiver — metrics/collector pipeline includes resourcedetection"
220+
set:
221+
distribution: openshift
222+
cloudProvider: aws
223+
template: configmap-cluster-receiver.yaml
224+
asserts:
225+
- matchRegex:
226+
path: data["relay"]
227+
pattern: "metrics/collector:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
228+
229+
- it: "cluster receiver — logs/objects pipeline includes resourcedetection"
230+
set:
231+
distribution: openshift
232+
cloudProvider: aws
233+
splunkPlatform:
234+
endpoint: https://localhost
235+
token: test-token
236+
logsEnabled: true
237+
clusterReceiver:
238+
k8sObjects:
239+
- name: pods
240+
mode: pull
241+
interval: 60s
242+
template: configmap-cluster-receiver.yaml
243+
asserts:
244+
- matchRegex:
245+
path: data["relay"]
246+
pattern: "logs/objects:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
247+
248+
- it: "cluster receiver — logs (k8s_events) pipeline includes resourcedetection"
249+
set:
250+
distribution: openshift
251+
cloudProvider: aws
252+
splunkPlatform:
253+
endpoint: https://localhost
254+
token: test-token
255+
logsEnabled: true
256+
clusterReceiver:
257+
eventsEnabled: true
258+
template: configmap-cluster-receiver.yaml
259+
asserts:
260+
- matchRegex:
261+
path: data["relay"]
262+
pattern: "logs:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
263+
264+
- it: "cluster receiver — logs/events (smartagent) pipeline includes resourcedetection"
265+
set:
266+
distribution: openshift
267+
cloudProvider: aws
268+
splunkObservability:
269+
infrastructureMonitoringEventsEnabled: true
270+
template: configmap-cluster-receiver.yaml
271+
asserts:
272+
- matchRegex:
273+
path: data["relay"]
274+
pattern: "logs/events:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
275+
276+
# Gateway: resourcedetection only in self-metrics pipeline, NOT in forwarding pipelines.
277+
# The agent already stamps telemetry before forwarding to the gateway.
278+
- it: "gateway — metrics/collector pipeline includes resourcedetection"
279+
set:
280+
distribution: openshift
281+
cloudProvider: aws
282+
gateway.enabled: true
283+
template: configmap-gateway.yaml
284+
asserts:
285+
- matchRegex:
286+
path: data["relay"]
287+
pattern: "metrics/collector:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
288+
289+
# Forwarding pipelines: assert resourcedetection is NOT in the processor list.
290+
# Pattern is the same structure as positive tests but with notMatchRegex.
291+
# Safe because (?:\s+- .+\n) only matches list items and cannot cross
292+
# the receivers: boundary into another pipeline block.
293+
- it: "gateway — forwarding traces pipeline has no resourcedetection"
294+
set:
295+
distribution: openshift
296+
cloudProvider: aws
297+
gateway.enabled: true
298+
template: configmap-gateway.yaml
299+
asserts:
300+
- notMatchRegex:
301+
path: data["relay"]
302+
pattern: "traces:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
303+
304+
- it: "gateway — forwarding metrics pipeline has no resourcedetection"
305+
set:
306+
distribution: openshift
307+
cloudProvider: aws
308+
gateway.enabled: true
309+
template: configmap-gateway.yaml
310+
asserts:
311+
- notMatchRegex:
312+
path: data["relay"]
313+
pattern: "metrics:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
314+
315+
- it: "gateway — forwarding logs pipeline has no resourcedetection"
316+
set:
317+
distribution: openshift
318+
cloudProvider: aws
319+
gateway.enabled: true
320+
splunkPlatform:
321+
endpoint: https://localhost
322+
token: test-token
323+
logsEnabled: true
324+
template: configmap-gateway.yaml
325+
asserts:
326+
- notMatchRegex:
327+
path: data["relay"]
328+
pattern: "logs:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"
329+
330+
- it: "gateway — forwarding logs/entities pipeline has no resourcedetection"
331+
set:
332+
distribution: openshift
333+
cloudProvider: aws
334+
gateway.enabled: true
335+
template: configmap-gateway.yaml
336+
asserts:
337+
- notMatchRegex:
338+
path: data["relay"]
339+
pattern: "logs/entities:\\n\\s+exporters:\\n(?:\\s+- .+\\n)+\\s+processors:\\n(?:\\s+- .+\\n)*\\s+- resourcedetection\\n(?:\\s+- .+\\n)*\\s+receivers:"

0 commit comments

Comments
 (0)