Debian Codegraph @

service/internal/graph/graph_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package graph
5
6 import (
7 "context"
8 "fmt"
9 "strings"
10 "testing"
11
12 "github.com/stretchr/testify/assert"
13 "github.com/stretchr/testify/require"
14
15 "go.opentelemetry.io/collector/component"
16 "go.opentelemetry.io/collector/component/componentstatus"
17 "go.opentelemetry.io/collector/component/componenttest"
18 "go.opentelemetry.io/collector/connector"
19 "go.opentelemetry.io/collector/connector/connectortest"
20 "go.opentelemetry.io/collector/consumer"
21 "go.opentelemetry.io/collector/consumer/xconsumer"
22 "go.opentelemetry.io/collector/exporter"
23 "go.opentelemetry.io/collector/exporter/exportertest"
24 "go.opentelemetry.io/collector/pdata/testdata"
25 "go.opentelemetry.io/collector/pdata/xpdata/pref"
26 "go.opentelemetry.io/collector/pipeline"
27 "go.opentelemetry.io/collector/pipeline/xpipeline"
28 "go.opentelemetry.io/collector/processor"
29 "go.opentelemetry.io/collector/processor/processortest"
30 "go.opentelemetry.io/collector/receiver"
31 "go.opentelemetry.io/collector/receiver/receivertest"
32 "go.opentelemetry.io/collector/service/internal/builders"
33 "go.opentelemetry.io/collector/service/internal/status"
34 "go.opentelemetry.io/collector/service/internal/testcomponents"
35 "go.opentelemetry.io/collector/service/pipelines"
36 )
37
38 func TestConnectorPipelinesGraph(t *testing.T) {
39 t.Run("with_internal_telemetry", func(t *testing.T) {
40 setObsConsumerGateForTest(t, true)
41 testConnectorPipelinesGraph(t)
42 })
43 t.Run("without_internal_telemetry", func(t *testing.T) {
44 setObsConsumerGateForTest(t, false)
45 testConnectorPipelinesGraph(t)
46 })
47 }
48
49 func testConnectorPipelinesGraph(t *testing.T) {
50 tests := []struct {
51 name string
52 pipelineConfigs pipelines.Config
53 expectedPerExporter int // requires symmetry in Pipelines
54 }{
55 {
56 name: "pipelines_simple.yaml",
57 pipelineConfigs: pipelines.Config{
58 pipeline.NewID(pipeline.SignalTraces): {
59 Receivers: []component.ID{component.MustNewID("examplereceiver")},
60 Processors: []component.ID{component.MustNewID("exampleprocessor")},
61 Exporters: []component.ID{component.MustNewID("exampleexporter")},
62 },
63 pipeline.NewID(pipeline.SignalMetrics): {
64 Receivers: []component.ID{component.MustNewID("examplereceiver")},
65 Processors: []component.ID{component.MustNewID("exampleprocessor")},
66 Exporters: []component.ID{component.MustNewID("exampleexporter")},
67 },
68 pipeline.NewID(pipeline.SignalLogs): {
69 Receivers: []component.ID{component.MustNewID("examplereceiver")},
70 Processors: []component.ID{component.MustNewID("exampleprocessor")},
71 Exporters: []component.ID{component.MustNewID("exampleexporter")},
72 },
73 pipeline.NewID(xpipeline.SignalProfiles): {
74 Receivers: []component.ID{component.MustNewID("examplereceiver")},
75 Processors: []component.ID{component.MustNewID("exampleprocessor")},
76 Exporters: []component.ID{component.MustNewID("exampleexporter")},
77 },
78 },
79 expectedPerExporter: 1,
80 },
81 {
82 name: "pipelines_simple_mutate.yaml",
83 pipelineConfigs: pipelines.Config{
84 pipeline.NewID(pipeline.SignalTraces): {
85 Receivers: []component.ID{component.MustNewID("examplereceiver")},
86 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
87 Exporters: []component.ID{component.MustNewID("exampleexporter")},
88 },
89 pipeline.NewID(pipeline.SignalMetrics): {
90 Receivers: []component.ID{component.MustNewID("examplereceiver")},
91 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
92 Exporters: []component.ID{component.MustNewID("exampleexporter")},
93 },
94 pipeline.NewID(pipeline.SignalLogs): {
95 Receivers: []component.ID{component.MustNewID("examplereceiver")},
96 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
97 Exporters: []component.ID{component.MustNewID("exampleexporter")},
98 },
99 pipeline.NewID(xpipeline.SignalProfiles): {
100 Receivers: []component.ID{component.MustNewID("examplereceiver")},
101 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
102 Exporters: []component.ID{component.MustNewID("exampleexporter")},
103 },
104 },
105 expectedPerExporter: 1,
106 },
107 {
108 name: "pipelines_simple_multi_proc.yaml",
109 pipelineConfigs: pipelines.Config{
110 pipeline.NewID(pipeline.SignalTraces): {
111 Receivers: []component.ID{component.MustNewID("examplereceiver")},
112 Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")},
113 Exporters: []component.ID{component.MustNewID("exampleexporter")},
114 },
115 pipeline.NewID(pipeline.SignalMetrics): {
116 Receivers: []component.ID{component.MustNewID("examplereceiver")},
117 Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")},
118 Exporters: []component.ID{component.MustNewID("exampleexporter")},
119 },
120 pipeline.NewID(pipeline.SignalLogs): {
121 Receivers: []component.ID{component.MustNewID("examplereceiver")},
122 Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")},
123 Exporters: []component.ID{component.MustNewID("exampleexporter")},
124 },
125 pipeline.NewID(xpipeline.SignalProfiles): {
126 Receivers: []component.ID{component.MustNewID("examplereceiver")},
127 Processors: []component.ID{component.MustNewID("exampleprocessor"), component.MustNewIDWithName("exampleprocessor", "mutate")},
128 Exporters: []component.ID{component.MustNewID("exampleexporter")},
129 },
130 },
131 expectedPerExporter: 1,
132 },
133 {
134 name: "pipelines_simple_no_proc.yaml",
135 pipelineConfigs: pipelines.Config{
136 pipeline.NewID(pipeline.SignalTraces): {
137 Receivers: []component.ID{component.MustNewID("examplereceiver")},
138 Exporters: []component.ID{component.MustNewID("exampleexporter")},
139 },
140 pipeline.NewID(pipeline.SignalMetrics): {
141 Receivers: []component.ID{component.MustNewID("examplereceiver")},
142 Exporters: []component.ID{component.MustNewID("exampleexporter")},
143 },
144 pipeline.NewID(pipeline.SignalLogs): {
145 Receivers: []component.ID{component.MustNewID("examplereceiver")},
146 Exporters: []component.ID{component.MustNewID("exampleexporter")},
147 },
148 pipeline.NewID(xpipeline.SignalProfiles): {
149 Receivers: []component.ID{component.MustNewID("examplereceiver")},
150 Exporters: []component.ID{component.MustNewID("exampleexporter")},
151 },
152 },
153 expectedPerExporter: 1,
154 },
155 {
156 name: "pipelines_multi.yaml",
157 pipelineConfigs: pipelines.Config{
158 pipeline.NewID(pipeline.SignalTraces): {
159 Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")},
160 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")},
161 Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")},
162 },
163 pipeline.NewID(pipeline.SignalMetrics): {
164 Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")},
165 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")},
166 Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")},
167 },
168 pipeline.NewID(pipeline.SignalLogs): {
169 Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")},
170 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")},
171 Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")},
172 },
173 pipeline.NewID(xpipeline.SignalProfiles): {
174 Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")},
175 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate"), component.MustNewID("exampleprocessor")},
176 Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")},
177 },
178 },
179 expectedPerExporter: 2,
180 },
181 {
182 name: "pipelines_multi_no_proc.yaml",
183 pipelineConfigs: pipelines.Config{
184 pipeline.NewID(pipeline.SignalTraces): {
185 Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")},
186 Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")},
187 },
188 pipeline.NewID(pipeline.SignalMetrics): {
189 Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")},
190 Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")},
191 },
192 pipeline.NewID(pipeline.SignalLogs): {
193 Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")},
194 Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")},
195 },
196 pipeline.NewID(xpipeline.SignalProfiles): {
197 Receivers: []component.ID{component.MustNewID("examplereceiver"), component.MustNewIDWithName("examplereceiver", "1")},
198 Exporters: []component.ID{component.MustNewID("exampleexporter"), component.MustNewIDWithName("exampleexporter", "1")},
199 },
200 },
201 expectedPerExporter: 2,
202 },
203 {
204 name: "multi_pipeline_receivers_and_exporters.yaml",
205 pipelineConfigs: pipelines.Config{
206 pipeline.NewID(pipeline.SignalTraces): {
207 Receivers: []component.ID{component.MustNewID("examplereceiver")},
208 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
209 Exporters: []component.ID{component.MustNewID("exampleexporter")},
210 },
211 pipeline.NewIDWithName(pipeline.SignalTraces, "1"): {
212 Receivers: []component.ID{component.MustNewID("examplereceiver")},
213 Exporters: []component.ID{component.MustNewID("exampleexporter")},
214 },
215 pipeline.NewID(pipeline.SignalMetrics): {
216 Receivers: []component.ID{component.MustNewID("examplereceiver")},
217 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
218 Exporters: []component.ID{component.MustNewID("exampleexporter")},
219 },
220 pipeline.NewIDWithName(pipeline.SignalMetrics, "1"): {
221 Receivers: []component.ID{component.MustNewID("examplereceiver")},
222 Exporters: []component.ID{component.MustNewID("exampleexporter")},
223 },
224 pipeline.NewID(pipeline.SignalLogs): {
225 Receivers: []component.ID{component.MustNewID("examplereceiver")},
226 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
227 Exporters: []component.ID{component.MustNewID("exampleexporter")},
228 },
229 pipeline.NewIDWithName(pipeline.SignalLogs, "1"): {
230 Receivers: []component.ID{component.MustNewID("examplereceiver")},
231 Exporters: []component.ID{component.MustNewID("exampleexporter")},
232 },
233 pipeline.NewID(xpipeline.SignalProfiles): {
234 Receivers: []component.ID{component.MustNewID("examplereceiver")},
235 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
236 Exporters: []component.ID{component.MustNewID("exampleexporter")},
237 },
238 pipeline.NewIDWithName(xpipeline.SignalProfiles, "1"): {
239 Receivers: []component.ID{component.MustNewID("examplereceiver")},
240 Exporters: []component.ID{component.MustNewID("exampleexporter")},
241 },
242 },
243 expectedPerExporter: 2,
244 },
245 {
246 name: "pipelines_conn_simple_traces.yaml",
247 pipelineConfigs: pipelines.Config{
248 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
249 Receivers: []component.ID{component.MustNewID("examplereceiver")},
250 Processors: []component.ID{component.MustNewID("exampleprocessor")},
251 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
252 },
253 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
254 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
255 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
256 Exporters: []component.ID{component.MustNewID("exampleexporter")},
257 },
258 },
259 expectedPerExporter: 1,
260 },
261 {
262 name: "pipelines_conn_simple_metrics.yaml",
263 pipelineConfigs: pipelines.Config{
264 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
265 Receivers: []component.ID{component.MustNewID("examplereceiver")},
266 Processors: []component.ID{component.MustNewID("exampleprocessor")},
267 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
268 },
269 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
270 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
271 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
272 Exporters: []component.ID{component.MustNewID("exampleexporter")},
273 },
274 },
275 expectedPerExporter: 1,
276 },
277 {
278 name: "pipelines_conn_simple_logs.yaml",
279 pipelineConfigs: pipelines.Config{
280 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
281 Receivers: []component.ID{component.MustNewID("examplereceiver")},
282 Processors: []component.ID{component.MustNewID("exampleprocessor")},
283 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
284 },
285 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
286 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
287 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
288 Exporters: []component.ID{component.MustNewID("exampleexporter")},
289 },
290 },
291 expectedPerExporter: 1,
292 },
293 {
294 name: "pipelines_conn_simple_profiles.yaml",
295 pipelineConfigs: pipelines.Config{
296 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
297 Receivers: []component.ID{component.MustNewID("examplereceiver")},
298 Processors: []component.ID{component.MustNewID("exampleprocessor")},
299 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
300 },
301 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
302 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
303 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
304 Exporters: []component.ID{component.MustNewID("exampleexporter")},
305 },
306 },
307 expectedPerExporter: 1,
308 },
309 {
310 name: "pipelines_conn_fork_merge_traces.yaml",
311 pipelineConfigs: pipelines.Config{
312 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
313 Receivers: []component.ID{component.MustNewID("examplereceiver")},
314 Processors: []component.ID{component.MustNewID("exampleprocessor")},
315 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
316 },
317 pipeline.NewIDWithName(pipeline.SignalTraces, "type0"): {
318 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
319 Processors: []component.ID{component.MustNewID("exampleprocessor")},
320 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
321 },
322 pipeline.NewIDWithName(pipeline.SignalTraces, "type1"): {
323 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
324 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
325 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
326 },
327 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
328 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
329 Processors: []component.ID{component.MustNewID("exampleprocessor")},
330 Exporters: []component.ID{component.MustNewID("exampleexporter")},
331 },
332 },
333 expectedPerExporter: 2,
334 },
335 {
336 name: "pipelines_conn_fork_merge_metrics.yaml",
337 pipelineConfigs: pipelines.Config{
338 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
339 Receivers: []component.ID{component.MustNewID("examplereceiver")},
340 Processors: []component.ID{component.MustNewID("exampleprocessor")},
341 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
342 },
343 pipeline.NewIDWithName(pipeline.SignalMetrics, "type0"): {
344 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
345 Processors: []component.ID{component.MustNewID("exampleprocessor")},
346 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
347 },
348 pipeline.NewIDWithName(pipeline.SignalMetrics, "type1"): {
349 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
350 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
351 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
352 },
353 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
354 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
355 Processors: []component.ID{component.MustNewID("exampleprocessor")},
356 Exporters: []component.ID{component.MustNewID("exampleexporter")},
357 },
358 },
359 expectedPerExporter: 2,
360 },
361 {
362 name: "pipelines_conn_fork_merge_logs.yaml",
363 pipelineConfigs: pipelines.Config{
364 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
365 Receivers: []component.ID{component.MustNewID("examplereceiver")},
366 Processors: []component.ID{component.MustNewID("exampleprocessor")},
367 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
368 },
369 pipeline.NewIDWithName(pipeline.SignalLogs, "type0"): {
370 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
371 Processors: []component.ID{component.MustNewID("exampleprocessor")},
372 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
373 },
374 pipeline.NewIDWithName(pipeline.SignalLogs, "type1"): {
375 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
376 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
377 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
378 },
379 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
380 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
381 Processors: []component.ID{component.MustNewID("exampleprocessor")},
382 Exporters: []component.ID{component.MustNewID("exampleexporter")},
383 },
384 },
385 expectedPerExporter: 2,
386 },
387 {
388 name: "pipelines_conn_fork_merge_profiles.yaml",
389 pipelineConfigs: pipelines.Config{
390 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
391 Receivers: []component.ID{component.MustNewID("examplereceiver")},
392 Processors: []component.ID{component.MustNewID("exampleprocessor")},
393 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
394 },
395 pipeline.NewIDWithName(xpipeline.SignalProfiles, "type0"): {
396 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
397 Processors: []component.ID{component.MustNewID("exampleprocessor")},
398 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
399 },
400 pipeline.NewIDWithName(xpipeline.SignalProfiles, "type1"): {
401 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
402 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
403 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
404 },
405 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
406 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "merge")},
407 Processors: []component.ID{component.MustNewID("exampleprocessor")},
408 Exporters: []component.ID{component.MustNewID("exampleexporter")},
409 },
410 },
411 expectedPerExporter: 2,
412 },
413 {
414 name: "pipelines_conn_translate_from_traces.yaml",
415 pipelineConfigs: pipelines.Config{
416 pipeline.NewID(pipeline.SignalTraces): {
417 Receivers: []component.ID{component.MustNewID("examplereceiver")},
418 Processors: []component.ID{component.MustNewID("exampleprocessor")},
419 Exporters: []component.ID{component.MustNewID("exampleconnector")},
420 },
421 pipeline.NewID(pipeline.SignalMetrics): {
422 Receivers: []component.ID{component.MustNewID("exampleconnector")},
423 Processors: []component.ID{component.MustNewID("exampleprocessor")},
424 Exporters: []component.ID{component.MustNewID("exampleexporter")},
425 },
426 pipeline.NewID(pipeline.SignalLogs): {
427 Receivers: []component.ID{component.MustNewID("exampleconnector")},
428 Processors: []component.ID{component.MustNewID("exampleprocessor")},
429 Exporters: []component.ID{component.MustNewID("exampleexporter")},
430 },
431 pipeline.NewID(xpipeline.SignalProfiles): {
432 Receivers: []component.ID{component.MustNewID("exampleconnector")},
433 Processors: []component.ID{component.MustNewID("exampleprocessor")},
434 Exporters: []component.ID{component.MustNewID("exampleexporter")},
435 },
436 },
437 expectedPerExporter: 1,
438 },
439 {
440 name: "pipelines_conn_translate_from_metrics.yaml",
441 pipelineConfigs: pipelines.Config{
442 pipeline.NewID(pipeline.SignalMetrics): {
443 Receivers: []component.ID{component.MustNewID("examplereceiver")},
444 Processors: []component.ID{component.MustNewID("exampleprocessor")},
445 Exporters: []component.ID{component.MustNewID("exampleconnector")},
446 },
447 pipeline.NewID(pipeline.SignalTraces): {
448 Receivers: []component.ID{component.MustNewID("exampleconnector")},
449 Processors: []component.ID{component.MustNewID("exampleprocessor")},
450 Exporters: []component.ID{component.MustNewID("exampleexporter")},
451 },
452 pipeline.NewID(pipeline.SignalLogs): {
453 Receivers: []component.ID{component.MustNewID("exampleconnector")},
454 Processors: []component.ID{component.MustNewID("exampleprocessor")},
455 Exporters: []component.ID{component.MustNewID("exampleexporter")},
456 },
457 pipeline.NewID(xpipeline.SignalProfiles): {
458 Receivers: []component.ID{component.MustNewID("exampleconnector")},
459 Processors: []component.ID{component.MustNewID("exampleprocessor")},
460 Exporters: []component.ID{component.MustNewID("exampleexporter")},
461 },
462 },
463 expectedPerExporter: 1,
464 },
465 {
466 name: "pipelines_conn_translate_from_logs.yaml",
467 pipelineConfigs: pipelines.Config{
468 pipeline.NewID(pipeline.SignalLogs): {
469 Receivers: []component.ID{component.MustNewID("examplereceiver")},
470 Processors: []component.ID{component.MustNewID("exampleprocessor")},
471 Exporters: []component.ID{component.MustNewID("exampleconnector")},
472 },
473 pipeline.NewID(pipeline.SignalTraces): {
474 Receivers: []component.ID{component.MustNewID("exampleconnector")},
475 Processors: []component.ID{component.MustNewID("exampleprocessor")},
476 Exporters: []component.ID{component.MustNewID("exampleexporter")},
477 },
478 pipeline.NewID(pipeline.SignalMetrics): {
479 Receivers: []component.ID{component.MustNewID("exampleconnector")},
480 Processors: []component.ID{component.MustNewID("exampleprocessor")},
481 Exporters: []component.ID{component.MustNewID("exampleexporter")},
482 },
483 pipeline.NewID(xpipeline.SignalProfiles): {
484 Receivers: []component.ID{component.MustNewID("exampleconnector")},
485 Processors: []component.ID{component.MustNewID("exampleprocessor")},
486 Exporters: []component.ID{component.MustNewID("exampleexporter")},
487 },
488 },
489 expectedPerExporter: 1,
490 },
491 {
492 name: "pipelines_conn_translate_from_profiles.yaml",
493 pipelineConfigs: pipelines.Config{
494 pipeline.NewID(pipeline.SignalTraces): {
495 Receivers: []component.ID{component.MustNewID("examplereceiver")},
496 Processors: []component.ID{component.MustNewID("exampleprocessor")},
497 Exporters: []component.ID{component.MustNewID("exampleconnector")},
498 },
499 pipeline.NewID(pipeline.SignalMetrics): {
500 Receivers: []component.ID{component.MustNewID("exampleconnector")},
501 Processors: []component.ID{component.MustNewID("exampleprocessor")},
502 Exporters: []component.ID{component.MustNewID("exampleexporter")},
503 },
504 pipeline.NewID(pipeline.SignalLogs): {
505 Receivers: []component.ID{component.MustNewID("exampleconnector")},
506 Processors: []component.ID{component.MustNewID("exampleprocessor")},
507 Exporters: []component.ID{component.MustNewID("exampleexporter")},
508 },
509 pipeline.NewID(xpipeline.SignalProfiles): {
510 Receivers: []component.ID{component.MustNewID("exampleconnector")},
511 Processors: []component.ID{component.MustNewID("exampleprocessor")},
512 Exporters: []component.ID{component.MustNewID("exampleexporter")},
513 },
514 },
515 expectedPerExporter: 1,
516 },
517 {
518 name: "pipelines_conn_matrix_immutable.yaml",
519 pipelineConfigs: pipelines.Config{
520 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
521 Receivers: []component.ID{component.MustNewID("examplereceiver")},
522 Processors: []component.ID{component.MustNewID("exampleprocessor")},
523 Exporters: []component.ID{component.MustNewID("exampleconnector")},
524 },
525 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
526 Receivers: []component.ID{component.MustNewID("examplereceiver")},
527 Processors: []component.ID{component.MustNewID("exampleprocessor")},
528 Exporters: []component.ID{component.MustNewID("exampleconnector")},
529 },
530 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
531 Receivers: []component.ID{component.MustNewID("examplereceiver")},
532 Processors: []component.ID{component.MustNewID("exampleprocessor")},
533 Exporters: []component.ID{component.MustNewID("exampleconnector")},
534 },
535 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
536 Receivers: []component.ID{component.MustNewID("examplereceiver")},
537 Processors: []component.ID{component.MustNewID("exampleprocessor")},
538 Exporters: []component.ID{component.MustNewID("exampleconnector")},
539 },
540 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
541 Receivers: []component.ID{component.MustNewID("exampleconnector")},
542 Processors: []component.ID{component.MustNewID("exampleprocessor")},
543 Exporters: []component.ID{component.MustNewID("exampleexporter")},
544 },
545 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
546 Receivers: []component.ID{component.MustNewID("exampleconnector")},
547 Processors: []component.ID{component.MustNewID("exampleprocessor")},
548 Exporters: []component.ID{component.MustNewID("exampleexporter")},
549 },
550 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
551 Receivers: []component.ID{component.MustNewID("exampleconnector")},
552 Processors: []component.ID{component.MustNewID("exampleprocessor")},
553 Exporters: []component.ID{component.MustNewID("exampleexporter")},
554 },
555 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
556 Receivers: []component.ID{component.MustNewID("exampleconnector")},
557 Processors: []component.ID{component.MustNewID("exampleprocessor")},
558 Exporters: []component.ID{component.MustNewID("exampleexporter")},
559 },
560 },
561 expectedPerExporter: 4,
562 },
563 {
564 name: "pipelines_conn_matrix_mutable.yaml",
565 pipelineConfigs: pipelines.Config{
566 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
567 Receivers: []component.ID{component.MustNewID("examplereceiver")},
568 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
569 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
570 },
571 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
572 Receivers: []component.ID{component.MustNewID("examplereceiver")},
573 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
574 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
575 },
576 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
577 Receivers: []component.ID{component.MustNewID("examplereceiver")},
578 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
579 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
580 },
581 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
582 Receivers: []component.ID{component.MustNewID("examplereceiver")},
583 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")},
584 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
585 },
586 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
587 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
588 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
589 Exporters: []component.ID{component.MustNewID("exampleexporter")},
590 },
591 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
592 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
593 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
594 Exporters: []component.ID{component.MustNewID("exampleexporter")},
595 },
596 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
597 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
598 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
599 Exporters: []component.ID{component.MustNewID("exampleexporter")},
600 },
601 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
602 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
603 Processors: []component.ID{component.MustNewIDWithName("exampleprocessor", "mutate")}, // mutate propagates upstream to connector
604 Exporters: []component.ID{component.MustNewID("exampleexporter")},
605 },
606 },
607 expectedPerExporter: 4,
608 },
609 {
610 name: "pipelines_conn_lanes.yaml",
611 pipelineConfigs: pipelines.Config{
612 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
613 Receivers: []component.ID{component.MustNewID("examplereceiver")},
614 Exporters: []component.ID{component.MustNewID("mockforward")},
615 },
616 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
617 Receivers: []component.ID{component.MustNewID("mockforward")},
618 Exporters: []component.ID{component.MustNewID("exampleexporter")},
619 },
620 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
621 Receivers: []component.ID{component.MustNewID("examplereceiver")},
622 Exporters: []component.ID{component.MustNewID("mockforward")},
623 },
624 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
625 Receivers: []component.ID{component.MustNewID("mockforward")},
626 Exporters: []component.ID{component.MustNewID("exampleexporter")},
627 },
628 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
629 Receivers: []component.ID{component.MustNewID("examplereceiver")},
630 Exporters: []component.ID{component.MustNewID("mockforward")},
631 },
632 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
633 Receivers: []component.ID{component.MustNewID("mockforward")},
634 Exporters: []component.ID{component.MustNewID("exampleexporter")},
635 },
636 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
637 Receivers: []component.ID{component.MustNewID("examplereceiver")},
638 Exporters: []component.ID{component.MustNewID("mockforward")},
639 },
640 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
641 Receivers: []component.ID{component.MustNewID("mockforward")},
642 Exporters: []component.ID{component.MustNewID("exampleexporter")},
643 },
644 },
645 expectedPerExporter: 1,
646 },
647 {
648 name: "pipelines_conn_mutate_traces.yaml",
649 pipelineConfigs: pipelines.Config{
650 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
651 Receivers: []component.ID{component.MustNewID("examplereceiver")},
652 Processors: []component.ID{component.MustNewID("exampleprocessor")},
653 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
654 },
655 pipeline.NewIDWithName(pipeline.SignalTraces, "out0"): {
656 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
657 Processors: []component.ID{component.MustNewID("exampleprocessor")},
658 Exporters: []component.ID{component.MustNewID("exampleexporter")},
659 },
660 pipeline.NewIDWithName(pipeline.SignalTraces, "middle"): {
661 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
662 Processors: []component.ID{component.MustNewID("exampleprocessor")},
663 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")},
664 },
665 pipeline.NewIDWithName(pipeline.SignalTraces, "out1"): {
666 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")},
667 Processors: []component.ID{component.MustNewID("exampleprocessor")},
668 Exporters: []component.ID{component.MustNewID("exampleexporter")},
669 },
670 },
671 expectedPerExporter: 2,
672 },
673 {
674 name: "pipelines_conn_mutate_metrics.yaml",
675 pipelineConfigs: pipelines.Config{
676 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
677 Receivers: []component.ID{component.MustNewID("examplereceiver")},
678 Processors: []component.ID{component.MustNewID("exampleprocessor")},
679 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
680 },
681 pipeline.NewIDWithName(pipeline.SignalMetrics, "out0"): {
682 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
683 Processors: []component.ID{component.MustNewID("exampleprocessor")},
684 Exporters: []component.ID{component.MustNewID("exampleexporter")},
685 },
686 pipeline.NewIDWithName(pipeline.SignalMetrics, "middle"): {
687 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
688 Processors: []component.ID{component.MustNewID("exampleprocessor")},
689 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")},
690 },
691 pipeline.NewIDWithName(pipeline.SignalMetrics, "out1"): {
692 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")},
693 Processors: []component.ID{component.MustNewID("exampleprocessor")},
694 Exporters: []component.ID{component.MustNewID("exampleexporter")},
695 },
696 },
697 expectedPerExporter: 2,
698 },
699 {
700 name: "pipelines_conn_mutate_logs.yaml",
701 pipelineConfigs: pipelines.Config{
702 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
703 Receivers: []component.ID{component.MustNewID("examplereceiver")},
704 Processors: []component.ID{component.MustNewID("exampleprocessor")},
705 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
706 },
707 pipeline.NewIDWithName(pipeline.SignalLogs, "out0"): {
708 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
709 Processors: []component.ID{component.MustNewID("exampleprocessor")},
710 Exporters: []component.ID{component.MustNewID("exampleexporter")},
711 },
712 pipeline.NewIDWithName(pipeline.SignalLogs, "middle"): {
713 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
714 Processors: []component.ID{component.MustNewID("exampleprocessor")},
715 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")},
716 },
717 pipeline.NewIDWithName(pipeline.SignalLogs, "out1"): {
718 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")},
719 Processors: []component.ID{component.MustNewID("exampleprocessor")},
720 Exporters: []component.ID{component.MustNewID("exampleexporter")},
721 },
722 },
723 expectedPerExporter: 2,
724 },
725 {
726 name: "pipelines_conn_mutate_profiles.yaml",
727 pipelineConfigs: pipelines.Config{
728 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
729 Receivers: []component.ID{component.MustNewID("examplereceiver")},
730 Processors: []component.ID{component.MustNewID("exampleprocessor")},
731 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
732 },
733 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out0"): {
734 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
735 Processors: []component.ID{component.MustNewID("exampleprocessor")},
736 Exporters: []component.ID{component.MustNewID("exampleexporter")},
737 },
738 pipeline.NewIDWithName(xpipeline.SignalProfiles, "middle"): {
739 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "inherit_mutate")},
740 Processors: []component.ID{component.MustNewID("exampleprocessor")},
741 Exporters: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")},
742 },
743 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out1"): {
744 Receivers: []component.ID{component.MustNewIDWithName("exampleconnector", "mutate")},
745 Processors: []component.ID{component.MustNewID("exampleprocessor")},
746 Exporters: []component.ID{component.MustNewID("exampleexporter")},
747 },
748 },
749 expectedPerExporter: 2,
750 },
751 }
752
753 for _, tt := range tests {
754 t.Run(tt.name, func(t *testing.T) {
755 // Build the pipeline
756 set := Settings{
757 Telemetry: componenttest.NewNopTelemetrySettings(),
758 BuildInfo: component.NewDefaultBuildInfo(),
759 ReceiverBuilder: builders.NewReceiver(
760 map[component.ID]component.Config{
761 component.MustNewID("examplereceiver"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(),
762 component.MustNewIDWithName("examplereceiver", "1"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(),
763 },
764 map[component.Type]receiver.Factory{
765 testcomponents.ExampleReceiverFactory.Type(): testcomponents.ExampleReceiverFactory,
766 },
767 ),
768 ProcessorBuilder: builders.NewProcessor(
769 map[component.ID]component.Config{
770 component.MustNewID("exampleprocessor"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(),
771 component.MustNewIDWithName("exampleprocessor", "mutate"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(),
772 },
773 map[component.Type]processor.Factory{
774 testcomponents.ExampleProcessorFactory.Type(): testcomponents.ExampleProcessorFactory,
775 },
776 ),
777 ExporterBuilder: builders.NewExporter(
778 map[component.ID]component.Config{
779 component.MustNewID("exampleexporter"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(),
780 component.MustNewIDWithName("exampleexporter", "1"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(),
781 },
782 map[component.Type]exporter.Factory{
783 testcomponents.ExampleExporterFactory.Type(): testcomponents.ExampleExporterFactory,
784 },
785 ),
786 ConnectorBuilder: builders.NewConnector(
787 map[component.ID]component.Config{
788 component.MustNewID("exampleconnector"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(),
789 component.MustNewIDWithName("exampleconnector", "merge"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(),
790 component.MustNewIDWithName("exampleconnector", "mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(),
791 component.MustNewIDWithName("exampleconnector", "inherit_mutate"): testcomponents.ExampleConnectorFactory.CreateDefaultConfig(),
792 component.MustNewID("mockforward"): testcomponents.MockForwardConnectorFactory.CreateDefaultConfig(),
793 },
794 map[component.Type]connector.Factory{
795 testcomponents.ExampleConnectorFactory.Type(): testcomponents.ExampleConnectorFactory,
796 testcomponents.MockForwardConnectorFactory.Type(): testcomponents.MockForwardConnectorFactory,
797 },
798 ),
799 PipelineConfigs: tt.pipelineConfigs,
800 }
801
802 pg, err := Build(context.Background(), set)
803 require.NoError(t, err)
804
805 assert.Len(t, pg.pipelines, len(tt.pipelineConfigs))
806
807 require.NoError(t, pg.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})}))
808
809 mutatingPipelines := make(map[pipeline.ID]bool, len(tt.pipelineConfigs))
810
811 // Check each pipeline individually, ensuring that all components are started
812 // and that they have observed no signals yet.
813 for pipelineID, pipelineCfg := range tt.pipelineConfigs {
814 pl, ok := pg.pipelines[pipelineID]
815 require.True(t, ok, "expected to find pipeline: %s", pipelineID.String())
816
817 // Determine independently if the capabilities node should report MutateData as true
818 var expectMutatesData bool
819 for _, expr := range pipelineCfg.Exporters {
820 if strings.Contains(expr.Name(), "mutate") {
821 expectMutatesData = true
822 }
823 }
824 for _, proc := range pipelineCfg.Processors {
825 if proc.Name() == "mutate" {
826 expectMutatesData = true
827 }
828 }
829 assert.Equal(t, expectMutatesData, pl.capabilitiesNode.getConsumer().Capabilities().MutatesData)
830 mutatingPipelines[pipelineID] = expectMutatesData
831
832 expectedReceivers, expectedExporters := expectedInstances(tt.pipelineConfigs, pipelineID)
833 require.Len(t, pl.receivers, expectedReceivers)
834 require.Len(t, pl.processors, len(pipelineCfg.Processors))
835 require.Len(t, pl.exporters, expectedExporters)
836
837 for _, n := range pl.exporters {
838 switch c := n.(type) {
839 case *exporterNode:
840 e := c.Component.(*testcomponents.ExampleExporter)
841 require.True(t, e.Started())
842 require.Empty(t, e.Traces)
843 require.Empty(t, e.Metrics)
844 require.Empty(t, e.Logs)
845 require.Empty(t, e.Profiles)
846 case *connectorNode:
847 require.True(t, c.Component.(*testcomponents.ExampleConnector).Started())
848 default:
849 require.Fail(t, fmt.Sprintf("unexpected type %T", c))
850 }
851 }
852
853 for _, n := range pl.processors {
854 require.True(t, n.(*processorNode).Component.(*testcomponents.ExampleProcessor).Started())
855 }
856
857 for _, n := range pl.receivers {
858 switch c := n.(type) {
859 case *receiverNode:
860 require.True(t, c.Component.(*testcomponents.ExampleReceiver).Started())
861 case *connectorNode:
862 require.True(t, c.Component.(*testcomponents.ExampleConnector).Started())
863 default:
864 require.Fail(t, fmt.Sprintf("unexpected type %T", c))
865 }
866 }
867 }
868
869 // Check that Connectors are correctly inheriting mutability from downstream Pipelines
870 for expPipelineID, expPipeline := range pg.pipelines {
871 for _, exp := range expPipeline.exporters {
872 expConn, ok := exp.(*connectorNode)
873 if !ok {
874 continue
875 }
876 if expConn.getConsumer().Capabilities().MutatesData {
877 continue
878 }
879 // find all the Pipelines of the same type where this connector is a receiver
880 var inheritMutatesData bool
881 for recPipelineID, recPipeline := range pg.pipelines {
882 if recPipelineID == expPipelineID || recPipelineID.Signal() != expPipelineID.Signal() {
883 continue
884 }
885 for _, rec := range recPipeline.receivers {
886 recConn, ok := rec.(*connectorNode)
887 if !ok || recConn.ID() != expConn.ID() {
888 continue
889 }
890 inheritMutatesData = inheritMutatesData || mutatingPipelines[recPipelineID]
891 }
892 }
893 assert.Equal(t, inheritMutatesData, expConn.getConsumer().Capabilities().MutatesData)
894 }
895 }
896
897 // Push data into the Pipelines. The list of Receivers is retrieved directly from the overall
898 // component graph because we do not want to duplicate signal inputs to Receivers that are
899 // shared between Pipelines. The `allReceivers` function also excludes Connectors, which we do
900 // not want to directly inject with signals.
901 allReceivers := pg.getReceivers()
902 for _, c := range allReceivers[pipeline.SignalTraces] {
903 tracesReceiver := c.(*testcomponents.ExampleReceiver)
904 require.NoError(t, tracesReceiver.ConsumeTraces(context.Background(), testdata.GenerateTraces(1)))
905 }
906 for _, c := range allReceivers[pipeline.SignalMetrics] {
907 metricsReceiver := c.(*testcomponents.ExampleReceiver)
908 require.NoError(t, metricsReceiver.ConsumeMetrics(context.Background(), testdata.GenerateMetrics(1)))
909 }
910 for _, c := range allReceivers[pipeline.SignalLogs] {
911 logsReceiver := c.(*testcomponents.ExampleReceiver)
912 require.NoError(t, logsReceiver.ConsumeLogs(context.Background(), testdata.GenerateLogs(1)))
913 }
914 for _, c := range allReceivers[xpipeline.SignalProfiles] {
915 profilesReceiver := c.(*testcomponents.ExampleReceiver)
916 require.NoError(t, profilesReceiver.ConsumeProfiles(context.Background(), testdata.GenerateProfiles(1)))
917 }
918
919 // Shut down the entire component graph
920 require.NoError(t, pg.ShutdownAll(context.Background(), status.NewNopStatusReporter()))
921
922 // Check each pipeline individually, ensuring that all components are stopped.
923 for pipelineID := range tt.pipelineConfigs {
924 pl, ok := pg.pipelines[pipelineID]
925 require.True(t, ok, "expected to find pipeline: %s", pipelineID.String())
926
927 for _, n := range pl.receivers {
928 switch c := n.(type) {
929 case *receiverNode:
930 require.True(t, c.Component.(*testcomponents.ExampleReceiver).Stopped())
931 case *connectorNode:
932 require.True(t, c.Component.(*testcomponents.ExampleConnector).Stopped())
933 default:
934 require.Fail(t, fmt.Sprintf("unexpected type %T", c))
935 }
936 }
937
938 for _, n := range pl.processors {
939 require.True(t, n.(*processorNode).Component.(*testcomponents.ExampleProcessor).Stopped())
940 }
941
942 for _, n := range pl.exporters {
943 switch c := n.(type) {
944 case *exporterNode:
945 require.True(t, c.Component.(*testcomponents.ExampleExporter).Stopped())
946 case *connectorNode:
947 require.True(t, c.Component.(*testcomponents.ExampleConnector).Stopped())
948 default:
949 require.Fail(t, fmt.Sprintf("unexpected type %T", c))
950 }
951 }
952 }
953
954 // Get the list of Exporters directly from the overall component graph. Like Receivers,
955 // exclude Connectors and validate each exporter once regardless of sharing between Pipelines.
956 allExporters := pg.GetExporters()
957 for _, e := range allExporters[pipeline.SignalTraces] {
958 tracesExporter := e.(consumer.Traces).(*testcomponents.ExampleExporter)
959 assert.Len(t, tracesExporter.Traces, tt.expectedPerExporter)
960 expected := testdata.GenerateTraces(1)
961 for i := 0; i < tt.expectedPerExporter; i++ {
962 assert.True(t, pref.EqualTraces(expected, tracesExporter.Traces[i]))
963 }
964 }
965 for _, e := range allExporters[pipeline.SignalMetrics] {
966 metricsExporter := e.(consumer.Metrics).(*testcomponents.ExampleExporter)
967 assert.Len(t, metricsExporter.Metrics, tt.expectedPerExporter)
968 expected := testdata.GenerateMetrics(1)
969 for i := 0; i < tt.expectedPerExporter; i++ {
970 assert.True(t, pref.EqualMetrics(expected, metricsExporter.Metrics[i]))
971 }
972 }
973 for _, e := range allExporters[pipeline.SignalLogs] {
974 logsExporter := e.(consumer.Logs).(*testcomponents.ExampleExporter)
975 assert.Len(t, logsExporter.Logs, tt.expectedPerExporter)
976 expected := testdata.GenerateLogs(1)
977 for i := 0; i < tt.expectedPerExporter; i++ {
978 assert.True(t, pref.EqualLogs(expected, logsExporter.Logs[i]))
979 }
980 }
981 for _, e := range allExporters[xpipeline.SignalProfiles] {
982 profilesExporter := e.(xconsumer.Profiles).(*testcomponents.ExampleExporter)
983 assert.Len(t, profilesExporter.Profiles, tt.expectedPerExporter)
984 expected := testdata.GenerateProfiles(1)
985 for i := 0; i < tt.expectedPerExporter; i++ {
986 assert.True(t, pref.EqualProfiles(expected, profilesExporter.Profiles[i]))
987 }
988 }
989 })
990 }
991 }
992
993 func TestInstances(t *testing.T) {
994 t.Run("with_internal_telemetry", func(t *testing.T) {
995 setObsConsumerGateForTest(t, true)
996 testInstances(t)
997 })
998 t.Run("without_internal_telemetry", func(t *testing.T) {
999 setObsConsumerGateForTest(t, false)
1000 testInstances(t)
1001 })
1002 }
1003
1004 func testInstances(t *testing.T) {
1005 tests := []struct {
1006 name string
1007 pipelineConfigs pipelines.Config
1008 expectInstances map[component.ID]int
1009 }{
1010 {
1011 name: "one_pipeline_each_signal",
1012 pipelineConfigs: pipelines.Config{
1013 pipeline.NewID(pipeline.SignalTraces): {
1014 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1015 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1016 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1017 },
1018 pipeline.NewID(pipeline.SignalMetrics): {
1019 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1020 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1021 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1022 },
1023 pipeline.NewID(pipeline.SignalLogs): {
1024 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1025 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1026 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1027 },
1028 pipeline.NewID(xpipeline.SignalProfiles): {
1029 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1030 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1031 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1032 },
1033 },
1034 expectInstances: map[component.ID]int{
1035 component.MustNewID("examplereceiver"): 4, // one per signal
1036 component.MustNewID("exampleprocessor"): 4, // one per pipeline
1037 component.MustNewID("exampleexporter"): 4, // one per signal
1038 },
1039 },
1040 {
1041 name: "shared_by_signals",
1042 pipelineConfigs: pipelines.Config{
1043 pipeline.NewIDWithName(pipeline.SignalTraces, "1"): {
1044 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1045 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1046 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1047 },
1048 pipeline.NewIDWithName(pipeline.SignalTraces, "2"): {
1049 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1050 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1051 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1052 },
1053 pipeline.NewIDWithName(pipeline.SignalMetrics, "1"): {
1054 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1055 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1056 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1057 },
1058 pipeline.NewIDWithName(pipeline.SignalMetrics, "2"): {
1059 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1060 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1061 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1062 },
1063 pipeline.NewIDWithName(pipeline.SignalLogs, "1"): {
1064 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1065 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1066 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1067 },
1068 pipeline.NewIDWithName(pipeline.SignalLogs, "2"): {
1069 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1070 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1071 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1072 },
1073 pipeline.NewIDWithName(xpipeline.SignalProfiles, "1"): {
1074 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1075 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1076 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1077 },
1078 pipeline.NewIDWithName(xpipeline.SignalProfiles, "2"): {
1079 Receivers: []component.ID{component.MustNewID("examplereceiver")},
1080 Processors: []component.ID{component.MustNewID("exampleprocessor")},
1081 Exporters: []component.ID{component.MustNewID("exampleexporter")},
1082 },
1083 },
1084 expectInstances: map[component.ID]int{
1085 component.MustNewID("examplereceiver"): 4, // one per signal
1086 component.MustNewID("exampleprocessor"): 8, // one per pipeline
1087 component.MustNewID("exampleexporter"): 4, // one per signal
1088 },
1089 },
1090 }
1091
1092 for _, tt := range tests {
1093 t.Run(tt.name, func(t *testing.T) {
1094 set := Settings{
1095 Telemetry: componenttest.NewNopTelemetrySettings(),
1096 BuildInfo: component.NewDefaultBuildInfo(),
1097 ReceiverBuilder: builders.NewReceiver(
1098 map[component.ID]component.Config{
1099 component.MustNewID("examplereceiver"): testcomponents.ExampleReceiverFactory.CreateDefaultConfig(),
1100 },
1101 map[component.Type]receiver.Factory{
1102 testcomponents.ExampleReceiverFactory.Type(): testcomponents.ExampleReceiverFactory,
1103 },
1104 ),
1105 ProcessorBuilder: builders.NewProcessor(
1106 map[component.ID]component.Config{
1107 component.MustNewID("exampleprocessor"): testcomponents.ExampleProcessorFactory.CreateDefaultConfig(),
1108 },
1109 map[component.Type]processor.Factory{
1110 testcomponents.ExampleProcessorFactory.Type(): testcomponents.ExampleProcessorFactory,
1111 },
1112 ),
1113 ExporterBuilder: builders.NewExporter(
1114 map[component.ID]component.Config{
1115 component.MustNewID("exampleexporter"): testcomponents.ExampleExporterFactory.CreateDefaultConfig(),
1116 },
1117 map[component.Type]exporter.Factory{
1118 testcomponents.ExampleExporterFactory.Type(): testcomponents.ExampleExporterFactory,
1119 },
1120 ),
1121 ConnectorBuilder: builders.NewConnector(map[component.ID]component.Config{}, map[component.Type]connector.Factory{}),
1122 PipelineConfigs: tt.pipelineConfigs,
1123 }
1124
1125 pg, err := Build(context.Background(), set)
1126 require.NoError(t, err)
1127
1128 require.Len(t, pg.pipelines, len(set.PipelineConfigs))
1129
1130 // For each component id, build a map of the instances of that component.
1131 // Use graph.Node.ID() as the key to determine uniqueness of instances.
1132 componentInstances := map[component.ID]map[int64]struct{}{}
1133 for _, pipeline := range pg.pipelines {
1134 for _, n := range pipeline.receivers {
1135 r := n.(*receiverNode)
1136 if _, ok := componentInstances[r.componentID]; !ok {
1137 componentInstances[r.componentID] = map[int64]struct{}{}
1138 }
1139 componentInstances[r.componentID][n.ID()] = struct{}{}
1140 }
1141 for _, n := range pipeline.processors {
1142 p := n.(*processorNode)
1143 if _, ok := componentInstances[p.componentID]; !ok {
1144 componentInstances[p.componentID] = map[int64]struct{}{}
1145 }
1146 componentInstances[p.componentID][n.ID()] = struct{}{}
1147 }
1148 for _, n := range pipeline.exporters {
1149 e := n.(*exporterNode)
1150 if _, ok := componentInstances[e.componentID]; !ok {
1151 componentInstances[e.componentID] = map[int64]struct{}{}
1152 }
1153 componentInstances[e.componentID][n.ID()] = struct{}{}
1154 }
1155 }
1156
1157 var totalExpected int
1158 for id, instances := range componentInstances {
1159 totalExpected += tt.expectInstances[id]
1160 require.Len(t, instances, tt.expectInstances[id], id.String())
1161 }
1162 totalExpected += len(tt.pipelineConfigs) * 2 // one fanout & one capabilities node per pipeline
1163 require.Equal(t, totalExpected, pg.componentGraph.Nodes().Len())
1164 })
1165 }
1166 }
1167
1168 func TestConnectorRouter(t *testing.T) {
1169 t.Run("with_internal_telemetry", func(t *testing.T) {
1170 setObsConsumerGateForTest(t, true)
1171 testConnectorRouter(t)
1172 })
1173 t.Run("without_internal_telemetry", func(t *testing.T) {
1174 setObsConsumerGateForTest(t, false)
1175 testConnectorRouter(t)
1176 })
1177 }
1178
1179 func testConnectorRouter(t *testing.T) {
1180 rcvrID := component.MustNewID("examplereceiver")
1181 routeTracesID := component.MustNewIDWithName("examplerouter", "traces")
1182 routeMetricsID := component.MustNewIDWithName("examplerouter", "metrics")
1183 routeLogsID := component.MustNewIDWithName("examplerouter", "logs")
1184 routeProfilesID := component.MustNewIDWithName("examplerouter", "profiles")
1185 expRightID := component.MustNewIDWithName("exampleexporter", "right")
1186 expLeftID := component.MustNewIDWithName("exampleexporter", "left")
1187
1188 tracesInID := pipeline.NewIDWithName(pipeline.SignalTraces, "in")
1189 tracesRightID := pipeline.NewIDWithName(pipeline.SignalTraces, "right")
1190 tracesLeftID := pipeline.NewIDWithName(pipeline.SignalTraces, "left")
1191
1192 metricsInID := pipeline.NewIDWithName(pipeline.SignalMetrics, "in")
1193 metricsRightID := pipeline.NewIDWithName(pipeline.SignalMetrics, "right")
1194 metricsLeftID := pipeline.NewIDWithName(pipeline.SignalMetrics, "left")
1195
1196 logsInID := pipeline.NewIDWithName(pipeline.SignalLogs, "in")
1197 logsRightID := pipeline.NewIDWithName(pipeline.SignalLogs, "right")
1198 logsLeftID := pipeline.NewIDWithName(pipeline.SignalLogs, "left")
1199
1200 profilesInID := pipeline.NewIDWithName(xpipeline.SignalProfiles, "in")
1201 profilesRightID := pipeline.NewIDWithName(xpipeline.SignalProfiles, "right")
1202 profilesLeftID := pipeline.NewIDWithName(xpipeline.SignalProfiles, "left")
1203
1204 ctx := context.Background()
1205 set := Settings{
1206 Telemetry: componenttest.NewNopTelemetrySettings(),
1207 BuildInfo: component.NewDefaultBuildInfo(),
1208 ReceiverBuilder: builders.NewReceiver(
1209 map[component.ID]component.Config{
1210 rcvrID: testcomponents.ExampleReceiverFactory.CreateDefaultConfig(),
1211 },
1212 map[component.Type]receiver.Factory{
1213 testcomponents.ExampleReceiverFactory.Type(): testcomponents.ExampleReceiverFactory,
1214 },
1215 ),
1216 ExporterBuilder: builders.NewExporter(
1217 map[component.ID]component.Config{
1218 expRightID: testcomponents.ExampleExporterFactory.CreateDefaultConfig(),
1219 expLeftID: testcomponents.ExampleExporterFactory.CreateDefaultConfig(),
1220 },
1221 map[component.Type]exporter.Factory{
1222 testcomponents.ExampleExporterFactory.Type(): testcomponents.ExampleExporterFactory,
1223 },
1224 ),
1225 ConnectorBuilder: builders.NewConnector(
1226 map[component.ID]component.Config{
1227 routeTracesID: testcomponents.ExampleRouterConfig{
1228 Traces: &testcomponents.LeftRightConfig{
1229 Right: tracesRightID,
1230 Left: tracesLeftID,
1231 },
1232 },
1233 routeMetricsID: testcomponents.ExampleRouterConfig{
1234 Metrics: &testcomponents.LeftRightConfig{
1235 Right: metricsRightID,
1236 Left: metricsLeftID,
1237 },
1238 },
1239 routeLogsID: testcomponents.ExampleRouterConfig{
1240 Logs: &testcomponents.LeftRightConfig{
1241 Right: logsRightID,
1242 Left: logsLeftID,
1243 },
1244 },
1245 routeProfilesID: testcomponents.ExampleRouterConfig{
1246 Profiles: &testcomponents.LeftRightConfig{
1247 Right: profilesRightID,
1248 Left: profilesLeftID,
1249 },
1250 },
1251 },
1252 map[component.Type]connector.Factory{
1253 testcomponents.ExampleRouterFactory.Type(): testcomponents.ExampleRouterFactory,
1254 },
1255 ),
1256 PipelineConfigs: pipelines.Config{
1257 tracesInID: {
1258 Receivers: []component.ID{rcvrID},
1259 Exporters: []component.ID{routeTracesID},
1260 },
1261 tracesRightID: {
1262 Receivers: []component.ID{routeTracesID},
1263 Exporters: []component.ID{expRightID},
1264 },
1265 tracesLeftID: {
1266 Receivers: []component.ID{routeTracesID},
1267 Exporters: []component.ID{expLeftID},
1268 },
1269 metricsInID: {
1270 Receivers: []component.ID{rcvrID},
1271 Exporters: []component.ID{routeMetricsID},
1272 },
1273 metricsRightID: {
1274 Receivers: []component.ID{routeMetricsID},
1275 Exporters: []component.ID{expRightID},
1276 },
1277 metricsLeftID: {
1278 Receivers: []component.ID{routeMetricsID},
1279 Exporters: []component.ID{expLeftID},
1280 },
1281 logsInID: {
1282 Receivers: []component.ID{rcvrID},
1283 Exporters: []component.ID{routeLogsID},
1284 },
1285 logsRightID: {
1286 Receivers: []component.ID{routeLogsID},
1287 Exporters: []component.ID{expRightID},
1288 },
1289 logsLeftID: {
1290 Receivers: []component.ID{routeLogsID},
1291 Exporters: []component.ID{expLeftID},
1292 },
1293 profilesInID: {
1294 Receivers: []component.ID{rcvrID},
1295 Exporters: []component.ID{routeProfilesID},
1296 },
1297 profilesRightID: {
1298 Receivers: []component.ID{routeProfilesID},
1299 Exporters: []component.ID{expRightID},
1300 },
1301 profilesLeftID: {
1302 Receivers: []component.ID{routeProfilesID},
1303 Exporters: []component.ID{expLeftID},
1304 },
1305 },
1306 }
1307
1308 pg, err := Build(ctx, set)
1309 require.NoError(t, err)
1310
1311 allReceivers := pg.getReceivers()
1312 allExporters := pg.GetExporters()
1313
1314 assert.Len(t, pg.pipelines, len(set.PipelineConfigs))
1315
1316 // Get a handle for the traces receiver and both Exporters
1317 tracesReceiver := allReceivers[pipeline.SignalTraces][rcvrID].(*testcomponents.ExampleReceiver)
1318 tracesRight := allExporters[pipeline.SignalTraces][expRightID].(*testcomponents.ExampleExporter)
1319 tracesLeft := allExporters[pipeline.SignalTraces][expLeftID].(*testcomponents.ExampleExporter)
1320
1321 // Consume 1, validate it went right
1322 require.NoError(t, tracesReceiver.ConsumeTraces(ctx, testdata.GenerateTraces(1)))
1323 assert.Len(t, tracesRight.Traces, 1)
1324 assert.Empty(t, tracesLeft.Traces)
1325
1326 // Consume 1, validate it went left
1327 require.NoError(t, tracesReceiver.ConsumeTraces(ctx, testdata.GenerateTraces(1)))
1328 assert.Len(t, tracesRight.Traces, 1)
1329 assert.Len(t, tracesLeft.Traces, 1)
1330
1331 // Consume 3, validate 2 went right, 1 went left
1332 assert.NoError(t, tracesReceiver.ConsumeTraces(ctx, testdata.GenerateTraces(1)))
1333 assert.NoError(t, tracesReceiver.ConsumeTraces(ctx, testdata.GenerateTraces(1)))
1334 assert.NoError(t, tracesReceiver.ConsumeTraces(ctx, testdata.GenerateTraces(1)))
1335 assert.Len(t, tracesRight.Traces, 3)
1336 assert.Len(t, tracesLeft.Traces, 2)
1337
1338 // Get a handle for the metrics receiver and both Exporters
1339 metricsReceiver := allReceivers[pipeline.SignalMetrics][rcvrID].(*testcomponents.ExampleReceiver)
1340 metricsRight := allExporters[pipeline.SignalMetrics][expRightID].(*testcomponents.ExampleExporter)
1341 metricsLeft := allExporters[pipeline.SignalMetrics][expLeftID].(*testcomponents.ExampleExporter)
1342
1343 // Consume 1, validate it went right
1344 require.NoError(t, metricsReceiver.ConsumeMetrics(ctx, testdata.GenerateMetrics(1)))
1345 assert.Len(t, metricsRight.Metrics, 1)
1346 assert.Empty(t, metricsLeft.Metrics)
1347
1348 // Consume 1, validate it went left
1349 require.NoError(t, metricsReceiver.ConsumeMetrics(ctx, testdata.GenerateMetrics(1)))
1350 assert.Len(t, metricsRight.Metrics, 1)
1351 assert.Len(t, metricsLeft.Metrics, 1)
1352
1353 // Consume 3, validate 2 went right, 1 went left
1354 assert.NoError(t, metricsReceiver.ConsumeMetrics(ctx, testdata.GenerateMetrics(1)))
1355 assert.NoError(t, metricsReceiver.ConsumeMetrics(ctx, testdata.GenerateMetrics(1)))
1356 assert.NoError(t, metricsReceiver.ConsumeMetrics(ctx, testdata.GenerateMetrics(1)))
1357 assert.Len(t, metricsRight.Metrics, 3)
1358 assert.Len(t, metricsLeft.Metrics, 2)
1359
1360 // Get a handle for the logs receiver and both Exporters
1361 logsReceiver := allReceivers[pipeline.SignalLogs][rcvrID].(*testcomponents.ExampleReceiver)
1362 logsRight := allExporters[pipeline.SignalLogs][expRightID].(*testcomponents.ExampleExporter)
1363 logsLeft := allExporters[pipeline.SignalLogs][expLeftID].(*testcomponents.ExampleExporter)
1364
1365 // Consume 1, validate it went right
1366 require.NoError(t, logsReceiver.ConsumeLogs(ctx, testdata.GenerateLogs(1)))
1367 assert.Len(t, logsRight.Logs, 1)
1368 assert.Empty(t, logsLeft.Logs)
1369
1370 // Consume 1, validate it went left
1371 require.NoError(t, logsReceiver.ConsumeLogs(ctx, testdata.GenerateLogs(1)))
1372 assert.Len(t, logsRight.Logs, 1)
1373 assert.Len(t, logsLeft.Logs, 1)
1374
1375 // Consume 3, validate 2 went right, 1 went left
1376 assert.NoError(t, logsReceiver.ConsumeLogs(ctx, testdata.GenerateLogs(1)))
1377 assert.NoError(t, logsReceiver.ConsumeLogs(ctx, testdata.GenerateLogs(1)))
1378 assert.NoError(t, logsReceiver.ConsumeLogs(ctx, testdata.GenerateLogs(1)))
1379 assert.Len(t, logsRight.Logs, 3)
1380 assert.Len(t, logsLeft.Logs, 2)
1381
1382 // Get a handle for the profiles receiver and both Exporters
1383 profilesReceiver := allReceivers[xpipeline.SignalProfiles][rcvrID].(*testcomponents.ExampleReceiver)
1384 profilesRight := allExporters[xpipeline.SignalProfiles][expRightID].(*testcomponents.ExampleExporter)
1385 profilesLeft := allExporters[xpipeline.SignalProfiles][expLeftID].(*testcomponents.ExampleExporter)
1386
1387 // Consume 1, validate it went right
1388 require.NoError(t, profilesReceiver.ConsumeProfiles(ctx, testdata.GenerateProfiles(1)))
1389 assert.Len(t, profilesRight.Profiles, 1)
1390 assert.Empty(t, profilesLeft.Profiles)
1391
1392 // Consume 1, validate it went left
1393 require.NoError(t, profilesReceiver.ConsumeProfiles(ctx, testdata.GenerateProfiles(1)))
1394 assert.Len(t, profilesRight.Profiles, 1)
1395 assert.Len(t, profilesLeft.Profiles, 1)
1396
1397 // Consume 3, validate 2 went right, 1 went left
1398 assert.NoError(t, profilesReceiver.ConsumeProfiles(ctx, testdata.GenerateProfiles(1)))
1399 assert.NoError(t, profilesReceiver.ConsumeProfiles(ctx, testdata.GenerateProfiles(1)))
1400 assert.NoError(t, profilesReceiver.ConsumeProfiles(ctx, testdata.GenerateProfiles(1)))
1401 assert.Len(t, profilesRight.Profiles, 3)
1402 assert.Len(t, profilesLeft.Profiles, 2)
1403 }
1404
1405 func TestGraphBuildErrors(t *testing.T) {
1406 t.Run("with_internal_telemetry", func(t *testing.T) {
1407 setObsConsumerGateForTest(t, true)
1408 testGraphBuildErrors(t)
1409 })
1410 t.Run("without_internal_telemetry", func(t *testing.T) {
1411 setObsConsumerGateForTest(t, false)
1412 testGraphBuildErrors(t)
1413 })
1414 }
1415
1416 func testGraphBuildErrors(t *testing.T) {
1417 nopReceiverFactory := receivertest.NewNopFactory()
1418 nopProcessorFactory := processortest.NewNopFactory()
1419 nopExporterFactory := exportertest.NewNopFactory()
1420 nopConnectorFactory := connectortest.NewNopFactory()
1421 mfConnectorFactory := testcomponents.MockForwardConnectorFactory
1422 badReceiverFactory := newBadReceiverFactory()
1423 badProcessorFactory := newBadProcessorFactory()
1424 badExporterFactory := newBadExporterFactory()
1425 badConnectorFactory := newBadConnectorFactory()
1426
1427 tests := []struct {
1428 name string
1429 receiverCfgs map[component.ID]component.Config
1430 processorCfgs map[component.ID]component.Config
1431 exporterCfgs map[component.ID]component.Config
1432 connectorCfgs map[component.ID]component.Config
1433 pipelineCfgs pipelines.Config
1434 expected string
1435 }{
1436 {
1437 name: "not_supported_exporter_logs",
1438 receiverCfgs: map[component.ID]component.Config{
1439 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1440 },
1441 exporterCfgs: map[component.ID]component.Config{
1442 component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(),
1443 },
1444 pipelineCfgs: pipelines.Config{
1445 pipeline.NewID(pipeline.SignalLogs): {
1446 Receivers: []component.ID{component.MustNewID("nop")},
1447 Exporters: []component.ID{component.MustNewID("bf")},
1448 },
1449 },
1450 expected: "failed to create \"bf\" exporter for data type \"logs\": telemetry type is not supported",
1451 },
1452 {
1453 name: "not_supported_exporter_metrics",
1454 receiverCfgs: map[component.ID]component.Config{
1455 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1456 },
1457 exporterCfgs: map[component.ID]component.Config{
1458 component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(),
1459 },
1460 pipelineCfgs: pipelines.Config{
1461 pipeline.NewID(pipeline.SignalMetrics): {
1462 Receivers: []component.ID{component.MustNewID("nop")},
1463 Exporters: []component.ID{component.MustNewID("bf")},
1464 },
1465 },
1466 expected: "failed to create \"bf\" exporter for data type \"metrics\": telemetry type is not supported",
1467 },
1468 {
1469 name: "not_supported_exporter_traces",
1470 receiverCfgs: map[component.ID]component.Config{
1471 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1472 },
1473 exporterCfgs: map[component.ID]component.Config{
1474 component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(),
1475 },
1476 pipelineCfgs: pipelines.Config{
1477 pipeline.NewID(pipeline.SignalTraces): {
1478 Receivers: []component.ID{component.MustNewID("nop")},
1479 Exporters: []component.ID{component.MustNewID("bf")},
1480 },
1481 },
1482 expected: "failed to create \"bf\" exporter for data type \"traces\": telemetry type is not supported",
1483 },
1484 {
1485 name: "not_supported_exporter_profiles",
1486 receiverCfgs: map[component.ID]component.Config{
1487 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1488 },
1489 exporterCfgs: map[component.ID]component.Config{
1490 component.MustNewID("bf"): badExporterFactory.CreateDefaultConfig(),
1491 },
1492 pipelineCfgs: pipelines.Config{
1493 pipeline.NewID(xpipeline.SignalProfiles): {
1494 Receivers: []component.ID{component.MustNewID("nop")},
1495 Exporters: []component.ID{component.MustNewID("bf")},
1496 },
1497 },
1498 expected: "failed to create \"bf\" exporter for data type \"profiles\": telemetry type is not supported",
1499 },
1500 {
1501 name: "not_supported_processor_logs",
1502 receiverCfgs: map[component.ID]component.Config{
1503 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1504 },
1505 processorCfgs: map[component.ID]component.Config{
1506 component.MustNewID("bf"): badProcessorFactory.CreateDefaultConfig(),
1507 },
1508 exporterCfgs: map[component.ID]component.Config{
1509 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1510 },
1511 pipelineCfgs: pipelines.Config{
1512 pipeline.NewID(pipeline.SignalLogs): {
1513 Receivers: []component.ID{component.MustNewID("nop")},
1514 Processors: []component.ID{component.MustNewID("bf")},
1515 Exporters: []component.ID{component.MustNewID("nop")},
1516 },
1517 },
1518 expected: "failed to create \"bf\" processor, in pipeline \"logs\": telemetry type is not supported",
1519 },
1520 {
1521 name: "not_supported_processor_metrics",
1522 receiverCfgs: map[component.ID]component.Config{
1523 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1524 },
1525 processorCfgs: map[component.ID]component.Config{
1526 component.MustNewID("bf"): badProcessorFactory.CreateDefaultConfig(),
1527 },
1528 exporterCfgs: map[component.ID]component.Config{
1529 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1530 },
1531 pipelineCfgs: pipelines.Config{
1532 pipeline.NewID(pipeline.SignalMetrics): {
1533 Receivers: []component.ID{component.MustNewID("nop")},
1534 Processors: []component.ID{component.MustNewID("bf")},
1535 Exporters: []component.ID{component.MustNewID("nop")},
1536 },
1537 },
1538 expected: "failed to create \"bf\" processor, in pipeline \"metrics\": telemetry type is not supported",
1539 },
1540 {
1541 name: "not_supported_processor_traces",
1542 receiverCfgs: map[component.ID]component.Config{
1543 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1544 },
1545 processorCfgs: map[component.ID]component.Config{
1546 component.MustNewID("bf"): badProcessorFactory.CreateDefaultConfig(),
1547 },
1548 exporterCfgs: map[component.ID]component.Config{
1549 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1550 },
1551 pipelineCfgs: pipelines.Config{
1552 pipeline.NewID(pipeline.SignalTraces): {
1553 Receivers: []component.ID{component.MustNewID("nop")},
1554 Processors: []component.ID{component.MustNewID("bf")},
1555 Exporters: []component.ID{component.MustNewID("nop")},
1556 },
1557 },
1558 expected: "failed to create \"bf\" processor, in pipeline \"traces\": telemetry type is not supported",
1559 },
1560 {
1561 name: "not_supported_processor_profiles",
1562 receiverCfgs: map[component.ID]component.Config{
1563 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1564 },
1565 processorCfgs: map[component.ID]component.Config{
1566 component.MustNewID("bf"): badProcessorFactory.CreateDefaultConfig(),
1567 },
1568 exporterCfgs: map[component.ID]component.Config{
1569 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1570 },
1571 pipelineCfgs: pipelines.Config{
1572 pipeline.NewID(xpipeline.SignalProfiles): {
1573 Receivers: []component.ID{component.MustNewID("nop")},
1574 Processors: []component.ID{component.MustNewID("bf")},
1575 Exporters: []component.ID{component.MustNewID("nop")},
1576 },
1577 },
1578 expected: "failed to create \"bf\" processor, in pipeline \"profiles\": telemetry type is not supported",
1579 },
1580 {
1581 name: "not_supported_receiver_logs",
1582 receiverCfgs: map[component.ID]component.Config{
1583 component.MustNewID("bf"): badReceiverFactory.CreateDefaultConfig(),
1584 },
1585 exporterCfgs: map[component.ID]component.Config{
1586 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1587 },
1588 pipelineCfgs: pipelines.Config{
1589 pipeline.NewID(pipeline.SignalLogs): {
1590 Receivers: []component.ID{component.MustNewID("bf")},
1591 Exporters: []component.ID{component.MustNewID("nop")},
1592 },
1593 },
1594 expected: "failed to create \"bf\" receiver for data type \"logs\": telemetry type is not supported",
1595 },
1596 {
1597 name: "not_supported_receiver_metrics",
1598 receiverCfgs: map[component.ID]component.Config{
1599 component.MustNewID("bf"): badReceiverFactory.CreateDefaultConfig(),
1600 },
1601 exporterCfgs: map[component.ID]component.Config{
1602 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1603 },
1604 pipelineCfgs: pipelines.Config{
1605 pipeline.NewID(pipeline.SignalMetrics): {
1606 Receivers: []component.ID{component.MustNewID("bf")},
1607 Exporters: []component.ID{component.MustNewID("nop")},
1608 },
1609 },
1610 expected: "failed to create \"bf\" receiver for data type \"metrics\": telemetry type is not supported",
1611 },
1612 {
1613 name: "not_supported_receiver_traces",
1614 receiverCfgs: map[component.ID]component.Config{
1615 component.MustNewID("bf"): badReceiverFactory.CreateDefaultConfig(),
1616 },
1617 exporterCfgs: map[component.ID]component.Config{
1618 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1619 },
1620 pipelineCfgs: pipelines.Config{
1621 pipeline.NewID(pipeline.SignalTraces): {
1622 Receivers: []component.ID{component.MustNewID("bf")},
1623 Exporters: []component.ID{component.MustNewID("nop")},
1624 },
1625 },
1626 expected: "failed to create \"bf\" receiver for data type \"traces\": telemetry type is not supported",
1627 },
1628 {
1629 name: "not_supported_receiver_profiles",
1630 receiverCfgs: map[component.ID]component.Config{
1631 component.MustNewID("bf"): badReceiverFactory.CreateDefaultConfig(),
1632 },
1633 exporterCfgs: map[component.ID]component.Config{
1634 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1635 },
1636 pipelineCfgs: pipelines.Config{
1637 pipeline.NewID(xpipeline.SignalProfiles): {
1638 Receivers: []component.ID{component.MustNewID("bf")},
1639 Exporters: []component.ID{component.MustNewID("nop")},
1640 },
1641 },
1642 expected: "failed to create \"bf\" receiver for data type \"profiles\": telemetry type is not supported",
1643 },
1644 {
1645 name: "not_supported_connector_traces_traces.yaml",
1646 receiverCfgs: map[component.ID]component.Config{
1647 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1648 },
1649 exporterCfgs: map[component.ID]component.Config{
1650 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1651 },
1652 connectorCfgs: map[component.ID]component.Config{
1653 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1654 },
1655 pipelineCfgs: pipelines.Config{
1656 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
1657 Receivers: []component.ID{component.MustNewID("nop")},
1658 Exporters: []component.ID{component.MustNewID("bf")},
1659 },
1660 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
1661 Receivers: []component.ID{component.MustNewID("bf")},
1662 Exporters: []component.ID{component.MustNewID("nop")},
1663 },
1664 },
1665 expected: "connector \"bf\" used as exporter in [traces/in] pipeline but not used in any supported receiver pipeline",
1666 },
1667 {
1668 name: "not_supported_connector_traces_metrics.yaml",
1669 receiverCfgs: map[component.ID]component.Config{
1670 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1671 },
1672 exporterCfgs: map[component.ID]component.Config{
1673 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1674 },
1675 connectorCfgs: map[component.ID]component.Config{
1676 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1677 },
1678 pipelineCfgs: pipelines.Config{
1679 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
1680 Receivers: []component.ID{component.MustNewID("nop")},
1681 Exporters: []component.ID{component.MustNewID("bf")},
1682 },
1683 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
1684 Receivers: []component.ID{component.MustNewID("bf")},
1685 Exporters: []component.ID{component.MustNewID("nop")},
1686 },
1687 },
1688 expected: "connector \"bf\" used as exporter in [traces/in] pipeline but not used in any supported receiver pipeline",
1689 },
1690 {
1691 name: "not_supported_connector_traces_logs.yaml",
1692 receiverCfgs: map[component.ID]component.Config{
1693 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1694 },
1695 exporterCfgs: map[component.ID]component.Config{
1696 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1697 },
1698 connectorCfgs: map[component.ID]component.Config{
1699 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1700 },
1701 pipelineCfgs: pipelines.Config{
1702 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
1703 Receivers: []component.ID{component.MustNewID("nop")},
1704 Exporters: []component.ID{component.MustNewID("bf")},
1705 },
1706 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
1707 Receivers: []component.ID{component.MustNewID("bf")},
1708 Exporters: []component.ID{component.MustNewID("nop")},
1709 },
1710 },
1711 expected: "connector \"bf\" used as exporter in [traces/in] pipeline but not used in any supported receiver pipeline",
1712 },
1713 {
1714 name: "not_supported_connector_traces_profiles.yaml",
1715 receiverCfgs: map[component.ID]component.Config{
1716 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1717 },
1718 exporterCfgs: map[component.ID]component.Config{
1719 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1720 },
1721 connectorCfgs: map[component.ID]component.Config{
1722 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1723 },
1724 pipelineCfgs: pipelines.Config{
1725 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
1726 Receivers: []component.ID{component.MustNewID("nop")},
1727 Exporters: []component.ID{component.MustNewID("bf")},
1728 },
1729 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
1730 Receivers: []component.ID{component.MustNewID("bf")},
1731 Exporters: []component.ID{component.MustNewID("nop")},
1732 },
1733 },
1734 expected: "connector \"bf\" used as exporter in [traces/in] pipeline but not used in any supported receiver pipeline",
1735 },
1736 {
1737 name: "not_supported_connector_metrics_traces.yaml",
1738 receiverCfgs: map[component.ID]component.Config{
1739 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1740 },
1741 exporterCfgs: map[component.ID]component.Config{
1742 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1743 },
1744 connectorCfgs: map[component.ID]component.Config{
1745 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1746 },
1747 pipelineCfgs: pipelines.Config{
1748 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
1749 Receivers: []component.ID{component.MustNewID("nop")},
1750 Exporters: []component.ID{component.MustNewID("bf")},
1751 },
1752 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
1753 Receivers: []component.ID{component.MustNewID("bf")},
1754 Exporters: []component.ID{component.MustNewID("nop")},
1755 },
1756 },
1757 expected: "connector \"bf\" used as exporter in [metrics/in] pipeline but not used in any supported receiver pipeline",
1758 },
1759 {
1760 name: "not_supported_connector_metrics_metrics.yaml",
1761 receiverCfgs: map[component.ID]component.Config{
1762 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1763 },
1764 exporterCfgs: map[component.ID]component.Config{
1765 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1766 },
1767 connectorCfgs: map[component.ID]component.Config{
1768 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1769 },
1770 pipelineCfgs: pipelines.Config{
1771 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
1772 Receivers: []component.ID{component.MustNewID("nop")},
1773 Exporters: []component.ID{component.MustNewID("bf")},
1774 },
1775 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
1776 Receivers: []component.ID{component.MustNewID("bf")},
1777 Exporters: []component.ID{component.MustNewID("nop")},
1778 },
1779 },
1780 expected: "connector \"bf\" used as exporter in [metrics/in] pipeline but not used in any supported receiver pipeline",
1781 },
1782 {
1783 name: "not_supported_connector_metrics_logs.yaml",
1784 receiverCfgs: map[component.ID]component.Config{
1785 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1786 },
1787 exporterCfgs: map[component.ID]component.Config{
1788 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1789 },
1790 connectorCfgs: map[component.ID]component.Config{
1791 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1792 },
1793 pipelineCfgs: pipelines.Config{
1794 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
1795 Receivers: []component.ID{component.MustNewID("nop")},
1796 Exporters: []component.ID{component.MustNewID("bf")},
1797 },
1798 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
1799 Receivers: []component.ID{component.MustNewID("bf")},
1800 Exporters: []component.ID{component.MustNewID("nop")},
1801 },
1802 },
1803 expected: "connector \"bf\" used as exporter in [metrics/in] pipeline but not used in any supported receiver pipeline",
1804 },
1805 {
1806 name: "not_supported_connector_metrics_profiles.yaml",
1807 receiverCfgs: map[component.ID]component.Config{
1808 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1809 },
1810 exporterCfgs: map[component.ID]component.Config{
1811 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1812 },
1813 connectorCfgs: map[component.ID]component.Config{
1814 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1815 },
1816 pipelineCfgs: pipelines.Config{
1817 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
1818 Receivers: []component.ID{component.MustNewID("nop")},
1819 Exporters: []component.ID{component.MustNewID("bf")},
1820 },
1821 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
1822 Receivers: []component.ID{component.MustNewID("bf")},
1823 Exporters: []component.ID{component.MustNewID("nop")},
1824 },
1825 },
1826 expected: "connector \"bf\" used as exporter in [metrics/in] pipeline but not used in any supported receiver pipeline",
1827 },
1828 {
1829 name: "not_supported_connector_logs_traces.yaml",
1830 receiverCfgs: map[component.ID]component.Config{
1831 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1832 },
1833 exporterCfgs: map[component.ID]component.Config{
1834 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1835 },
1836 connectorCfgs: map[component.ID]component.Config{
1837 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1838 },
1839 pipelineCfgs: pipelines.Config{
1840 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
1841 Receivers: []component.ID{component.MustNewID("nop")},
1842 Exporters: []component.ID{component.MustNewID("bf")},
1843 },
1844 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
1845 Receivers: []component.ID{component.MustNewID("bf")},
1846 Exporters: []component.ID{component.MustNewID("nop")},
1847 },
1848 },
1849 expected: "connector \"bf\" used as exporter in [logs/in] pipeline but not used in any supported receiver pipeline",
1850 },
1851 {
1852 name: "not_supported_connector_logs_metrics.yaml",
1853 receiverCfgs: map[component.ID]component.Config{
1854 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1855 },
1856 exporterCfgs: map[component.ID]component.Config{
1857 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1858 },
1859 connectorCfgs: map[component.ID]component.Config{
1860 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1861 },
1862 pipelineCfgs: pipelines.Config{
1863 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
1864 Receivers: []component.ID{component.MustNewID("nop")},
1865 Exporters: []component.ID{component.MustNewID("bf")},
1866 },
1867 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
1868 Receivers: []component.ID{component.MustNewID("bf")},
1869 Exporters: []component.ID{component.MustNewID("nop")},
1870 },
1871 },
1872 expected: "connector \"bf\" used as exporter in [logs/in] pipeline but not used in any supported receiver pipeline",
1873 },
1874 {
1875 name: "not_supported_connector_logs_logs.yaml",
1876 receiverCfgs: map[component.ID]component.Config{
1877 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1878 },
1879 exporterCfgs: map[component.ID]component.Config{
1880 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1881 },
1882 connectorCfgs: map[component.ID]component.Config{
1883 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1884 },
1885 pipelineCfgs: pipelines.Config{
1886 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
1887 Receivers: []component.ID{component.MustNewID("nop")},
1888 Exporters: []component.ID{component.MustNewID("bf")},
1889 },
1890 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
1891 Receivers: []component.ID{component.MustNewID("bf")},
1892 Exporters: []component.ID{component.MustNewID("nop")},
1893 },
1894 },
1895 expected: "connector \"bf\" used as exporter in [logs/in] pipeline but not used in any supported receiver pipeline",
1896 },
1897 {
1898 name: "not_supported_connector_logs_profiles.yaml",
1899 receiverCfgs: map[component.ID]component.Config{
1900 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1901 },
1902 exporterCfgs: map[component.ID]component.Config{
1903 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1904 },
1905 connectorCfgs: map[component.ID]component.Config{
1906 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1907 },
1908 pipelineCfgs: pipelines.Config{
1909 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
1910 Receivers: []component.ID{component.MustNewID("nop")},
1911 Exporters: []component.ID{component.MustNewID("bf")},
1912 },
1913 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
1914 Receivers: []component.ID{component.MustNewID("bf")},
1915 Exporters: []component.ID{component.MustNewID("nop")},
1916 },
1917 },
1918 expected: "connector \"bf\" used as exporter in [logs/in] pipeline but not used in any supported receiver pipeline",
1919 },
1920 {
1921 name: "not_supported_connector_profiles_traces.yaml",
1922 receiverCfgs: map[component.ID]component.Config{
1923 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1924 },
1925 exporterCfgs: map[component.ID]component.Config{
1926 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1927 },
1928 connectorCfgs: map[component.ID]component.Config{
1929 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1930 },
1931 pipelineCfgs: pipelines.Config{
1932 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
1933 Receivers: []component.ID{component.MustNewID("nop")},
1934 Exporters: []component.ID{component.MustNewID("bf")},
1935 },
1936 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
1937 Receivers: []component.ID{component.MustNewID("bf")},
1938 Exporters: []component.ID{component.MustNewID("nop")},
1939 },
1940 },
1941 expected: "connector \"bf\" used as exporter in [profiles/in] pipeline but not used in any supported receiver pipeline",
1942 },
1943 {
1944 name: "not_supported_connector_profiles_metrics.yaml",
1945 receiverCfgs: map[component.ID]component.Config{
1946 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1947 },
1948 exporterCfgs: map[component.ID]component.Config{
1949 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1950 },
1951 connectorCfgs: map[component.ID]component.Config{
1952 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1953 },
1954 pipelineCfgs: pipelines.Config{
1955 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
1956 Receivers: []component.ID{component.MustNewID("nop")},
1957 Exporters: []component.ID{component.MustNewID("bf")},
1958 },
1959 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
1960 Receivers: []component.ID{component.MustNewID("bf")},
1961 Exporters: []component.ID{component.MustNewID("nop")},
1962 },
1963 },
1964 expected: "connector \"bf\" used as exporter in [profiles/in] pipeline but not used in any supported receiver pipeline",
1965 },
1966 {
1967 name: "not_supported_connector_profiles_logs.yaml",
1968 receiverCfgs: map[component.ID]component.Config{
1969 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1970 },
1971 exporterCfgs: map[component.ID]component.Config{
1972 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1973 },
1974 connectorCfgs: map[component.ID]component.Config{
1975 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1976 },
1977 pipelineCfgs: pipelines.Config{
1978 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
1979 Receivers: []component.ID{component.MustNewID("nop")},
1980 Exporters: []component.ID{component.MustNewID("bf")},
1981 },
1982 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
1983 Receivers: []component.ID{component.MustNewID("bf")},
1984 Exporters: []component.ID{component.MustNewID("nop")},
1985 },
1986 },
1987 expected: "connector \"bf\" used as exporter in [profiles/in] pipeline but not used in any supported receiver pipeline",
1988 },
1989 {
1990 name: "not_supported_connector_profiles_profiles.yaml",
1991 receiverCfgs: map[component.ID]component.Config{
1992 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
1993 },
1994 exporterCfgs: map[component.ID]component.Config{
1995 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
1996 },
1997 connectorCfgs: map[component.ID]component.Config{
1998 component.MustNewID("bf"): nopConnectorFactory.CreateDefaultConfig(),
1999 },
2000 pipelineCfgs: pipelines.Config{
2001 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
2002 Receivers: []component.ID{component.MustNewID("nop")},
2003 Exporters: []component.ID{component.MustNewID("bf")},
2004 },
2005 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
2006 Receivers: []component.ID{component.MustNewID("bf")},
2007 Exporters: []component.ID{component.MustNewID("nop")},
2008 },
2009 },
2010 expected: "connector \"bf\" used as exporter in [profiles/in] pipeline but not used in any supported receiver pipeline",
2011 },
2012 {
2013 name: "orphaned-connector-use-as-exporter",
2014 receiverCfgs: map[component.ID]component.Config{
2015 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2016 },
2017 exporterCfgs: map[component.ID]component.Config{
2018 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2019 },
2020 connectorCfgs: map[component.ID]component.Config{
2021 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2022 },
2023 pipelineCfgs: pipelines.Config{
2024 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
2025 Receivers: []component.ID{component.MustNewID("nop")},
2026 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")},
2027 },
2028 },
2029 expected: `connector "nop/conn" used as exporter in [metrics/in] pipeline but not used in any supported receiver pipeline`,
2030 },
2031 {
2032 name: "orphaned-connector-use-as-receiver",
2033 receiverCfgs: map[component.ID]component.Config{
2034 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2035 },
2036 exporterCfgs: map[component.ID]component.Config{
2037 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2038 },
2039 connectorCfgs: map[component.ID]component.Config{
2040 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2041 },
2042 pipelineCfgs: pipelines.Config{
2043 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
2044 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")},
2045 Exporters: []component.ID{component.MustNewID("nop")},
2046 },
2047 },
2048 expected: `connector "nop/conn" used as receiver in [traces/out] pipeline but not used in any supported exporter pipeline`,
2049 },
2050 {
2051 name: "partially-orphaned-connector-use-as-exporter",
2052 receiverCfgs: map[component.ID]component.Config{
2053 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2054 },
2055 exporterCfgs: map[component.ID]component.Config{
2056 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2057 },
2058 connectorCfgs: map[component.ID]component.Config{
2059 component.MustNewID("mockforward"): mfConnectorFactory.CreateDefaultConfig(),
2060 },
2061 pipelineCfgs: pipelines.Config{
2062 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
2063 Receivers: []component.ID{component.MustNewID("nop")},
2064 Exporters: []component.ID{component.MustNewID("mockforward")},
2065 },
2066 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
2067 Receivers: []component.ID{component.MustNewID("mockforward")},
2068 Exporters: []component.ID{component.MustNewID("nop")},
2069 },
2070 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
2071 Receivers: []component.ID{component.MustNewID("nop")},
2072 Exporters: []component.ID{component.MustNewID("mockforward")},
2073 },
2074 },
2075 expected: `connector "mockforward" used as exporter in [metrics/in] pipeline but not used in any supported receiver pipeline`,
2076 },
2077 {
2078 name: "partially-orphaned-connector-use-as-receiver",
2079 receiverCfgs: map[component.ID]component.Config{
2080 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2081 },
2082 exporterCfgs: map[component.ID]component.Config{
2083 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2084 },
2085 connectorCfgs: map[component.ID]component.Config{
2086 component.MustNewID("mockforward"): mfConnectorFactory.CreateDefaultConfig(),
2087 },
2088 pipelineCfgs: pipelines.Config{
2089 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
2090 Receivers: []component.ID{component.MustNewID("nop")},
2091 Exporters: []component.ID{component.MustNewID("mockforward")},
2092 },
2093 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
2094 Receivers: []component.ID{component.MustNewID("mockforward")},
2095 Exporters: []component.ID{component.MustNewID("nop")},
2096 },
2097 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
2098 Receivers: []component.ID{component.MustNewID("mockforward")},
2099 Exporters: []component.ID{component.MustNewID("nop")},
2100 },
2101 },
2102 expected: `connector "mockforward" used as receiver in [traces/out] pipeline but not used in any supported exporter pipeline`,
2103 },
2104 {
2105 name: "not_allowed_simple_cycle_traces.yaml",
2106 receiverCfgs: map[component.ID]component.Config{
2107 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2108 },
2109 processorCfgs: map[component.ID]component.Config{
2110 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2111 },
2112 exporterCfgs: map[component.ID]component.Config{
2113 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2114 },
2115 connectorCfgs: map[component.ID]component.Config{
2116 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2117 },
2118 pipelineCfgs: pipelines.Config{
2119 pipeline.NewID(pipeline.SignalTraces): {
2120 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")},
2121 Processors: []component.ID{component.MustNewID("nop")},
2122 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")},
2123 },
2124 },
2125 expected: `cycle detected: ` +
2126 `connector "nop/conn" (traces to traces) -> ` +
2127 `processor "nop" in pipeline "traces" -> ` +
2128 `connector "nop/conn" (traces to traces)`,
2129 },
2130 {
2131 name: "not_allowed_simple_cycle_metrics.yaml",
2132 receiverCfgs: map[component.ID]component.Config{
2133 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2134 },
2135 processorCfgs: map[component.ID]component.Config{
2136 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2137 },
2138 exporterCfgs: map[component.ID]component.Config{
2139 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2140 },
2141 connectorCfgs: map[component.ID]component.Config{
2142 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2143 },
2144 pipelineCfgs: pipelines.Config{
2145 pipeline.NewID(pipeline.SignalMetrics): {
2146 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")},
2147 Processors: []component.ID{component.MustNewID("nop")},
2148 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")},
2149 },
2150 },
2151 expected: `cycle detected: ` +
2152 `connector "nop/conn" (metrics to metrics) -> ` +
2153 `processor "nop" in pipeline "metrics" -> ` +
2154 `connector "nop/conn" (metrics to metrics)`,
2155 },
2156 {
2157 name: "not_allowed_simple_cycle_logs.yaml",
2158 receiverCfgs: map[component.ID]component.Config{
2159 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2160 },
2161 processorCfgs: map[component.ID]component.Config{
2162 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2163 },
2164 exporterCfgs: map[component.ID]component.Config{
2165 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2166 },
2167 connectorCfgs: map[component.ID]component.Config{
2168 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2169 },
2170 pipelineCfgs: pipelines.Config{
2171 pipeline.NewID(pipeline.SignalLogs): {
2172 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")},
2173 Processors: []component.ID{component.MustNewID("nop")},
2174 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")},
2175 },
2176 },
2177 expected: `cycle detected: ` +
2178 `connector "nop/conn" (logs to logs) -> ` +
2179 `processor "nop" in pipeline "logs" -> ` +
2180 `connector "nop/conn" (logs to logs)`,
2181 },
2182 {
2183 name: "not_allowed_simple_cycle_profiles.yaml",
2184 receiverCfgs: map[component.ID]component.Config{
2185 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2186 },
2187 processorCfgs: map[component.ID]component.Config{
2188 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2189 },
2190 exporterCfgs: map[component.ID]component.Config{
2191 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2192 },
2193 connectorCfgs: map[component.ID]component.Config{
2194 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2195 },
2196 pipelineCfgs: pipelines.Config{
2197 pipeline.NewID(xpipeline.SignalProfiles): {
2198 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")},
2199 Processors: []component.ID{component.MustNewID("nop")},
2200 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")},
2201 },
2202 },
2203 expected: `cycle detected: ` +
2204 `connector "nop/conn" (profiles to profiles) -> ` +
2205 `processor "nop" in pipeline "profiles" -> ` +
2206 `connector "nop/conn" (profiles to profiles)`,
2207 },
2208 {
2209 name: "not_allowed_deep_cycle_traces.yaml",
2210 receiverCfgs: map[component.ID]component.Config{
2211 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2212 },
2213 processorCfgs: map[component.ID]component.Config{
2214 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2215 },
2216 exporterCfgs: map[component.ID]component.Config{
2217 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2218 },
2219 connectorCfgs: map[component.ID]component.Config{
2220 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2221 component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(),
2222 component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(),
2223 },
2224 pipelineCfgs: pipelines.Config{
2225 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
2226 Receivers: []component.ID{component.MustNewID("nop")},
2227 Processors: []component.ID{component.MustNewID("nop")},
2228 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")},
2229 },
2230 pipeline.NewIDWithName(pipeline.SignalTraces, "1"): {
2231 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")},
2232 Processors: []component.ID{component.MustNewID("nop")},
2233 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")},
2234 },
2235 pipeline.NewIDWithName(pipeline.SignalTraces, "2"): {
2236 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")},
2237 Processors: []component.ID{component.MustNewID("nop")},
2238 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")},
2239 },
2240 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
2241 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")},
2242 Processors: []component.ID{component.MustNewID("nop")},
2243 Exporters: []component.ID{component.MustNewID("nop")},
2244 },
2245 },
2246 expected: `cycle detected: ` +
2247 `connector "nop/conn1" (traces to traces) -> ` +
2248 `processor "nop" in pipeline "traces/2" -> ` +
2249 `connector "nop/conn" (traces to traces) -> ` +
2250 `processor "nop" in pipeline "traces/1" -> ` +
2251 `connector "nop/conn1" (traces to traces)`,
2252 },
2253 {
2254 name: "not_allowed_deep_cycle_metrics.yaml",
2255 receiverCfgs: map[component.ID]component.Config{
2256 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2257 },
2258 processorCfgs: map[component.ID]component.Config{
2259 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2260 },
2261 exporterCfgs: map[component.ID]component.Config{
2262 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2263 },
2264 connectorCfgs: map[component.ID]component.Config{
2265 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2266 component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(),
2267 component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(),
2268 },
2269 pipelineCfgs: pipelines.Config{
2270 pipeline.NewIDWithName(pipeline.SignalMetrics, "in"): {
2271 Receivers: []component.ID{component.MustNewID("nop")},
2272 Processors: []component.ID{component.MustNewID("nop")},
2273 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")},
2274 },
2275 pipeline.NewIDWithName(pipeline.SignalMetrics, "1"): {
2276 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")},
2277 Processors: []component.ID{component.MustNewID("nop")},
2278 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")},
2279 },
2280 pipeline.NewIDWithName(pipeline.SignalMetrics, "2"): {
2281 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")},
2282 Processors: []component.ID{component.MustNewID("nop")},
2283 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")},
2284 },
2285 pipeline.NewIDWithName(pipeline.SignalMetrics, "out"): {
2286 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")},
2287 Processors: []component.ID{component.MustNewID("nop")},
2288 Exporters: []component.ID{component.MustNewID("nop")},
2289 },
2290 },
2291 expected: `cycle detected: ` +
2292 `connector "nop/conn1" (metrics to metrics) -> ` +
2293 `processor "nop" in pipeline "metrics/2" -> ` +
2294 `connector "nop/conn" (metrics to metrics) -> ` +
2295 `processor "nop" in pipeline "metrics/1" -> ` +
2296 `connector "nop/conn1" (metrics to metrics)`,
2297 },
2298 {
2299 name: "not_allowed_deep_cycle_logs.yaml",
2300 receiverCfgs: map[component.ID]component.Config{
2301 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2302 },
2303 processorCfgs: map[component.ID]component.Config{
2304 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2305 },
2306 exporterCfgs: map[component.ID]component.Config{
2307 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2308 },
2309 connectorCfgs: map[component.ID]component.Config{
2310 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2311 component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(),
2312 component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(),
2313 },
2314 pipelineCfgs: pipelines.Config{
2315 pipeline.NewIDWithName(pipeline.SignalLogs, "in"): {
2316 Receivers: []component.ID{component.MustNewID("nop")},
2317 Processors: []component.ID{component.MustNewID("nop")},
2318 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")},
2319 },
2320 pipeline.NewIDWithName(pipeline.SignalLogs, "1"): {
2321 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")},
2322 Processors: []component.ID{component.MustNewID("nop")},
2323 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")},
2324 },
2325 pipeline.NewIDWithName(pipeline.SignalLogs, "2"): {
2326 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")},
2327 Processors: []component.ID{component.MustNewID("nop")},
2328 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")},
2329 },
2330 pipeline.NewIDWithName(pipeline.SignalLogs, "out"): {
2331 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")},
2332 Processors: []component.ID{component.MustNewID("nop")},
2333 Exporters: []component.ID{component.MustNewID("nop")},
2334 },
2335 },
2336 expected: `cycle detected: ` +
2337 `connector "nop/conn" (logs to logs) -> ` +
2338 `processor "nop" in pipeline "logs/1" -> ` +
2339 `connector "nop/conn1" (logs to logs) -> ` +
2340 `processor "nop" in pipeline "logs/2" -> ` +
2341 `connector "nop/conn" (logs to logs)`,
2342 },
2343 {
2344 name: "not_allowed_deep_cycle_profiles.yaml",
2345 receiverCfgs: map[component.ID]component.Config{
2346 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2347 },
2348 processorCfgs: map[component.ID]component.Config{
2349 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2350 },
2351 exporterCfgs: map[component.ID]component.Config{
2352 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2353 },
2354 connectorCfgs: map[component.ID]component.Config{
2355 component.MustNewIDWithName("nop", "conn"): nopConnectorFactory.CreateDefaultConfig(),
2356 component.MustNewIDWithName("nop", "conn1"): nopConnectorFactory.CreateDefaultConfig(),
2357 component.MustNewIDWithName("nop", "conn2"): nopConnectorFactory.CreateDefaultConfig(),
2358 },
2359 pipelineCfgs: pipelines.Config{
2360 pipeline.NewIDWithName(xpipeline.SignalProfiles, "in"): {
2361 Receivers: []component.ID{component.MustNewID("nop")},
2362 Processors: []component.ID{component.MustNewID("nop")},
2363 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn")},
2364 },
2365 pipeline.NewIDWithName(xpipeline.SignalProfiles, "1"): {
2366 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn")},
2367 Processors: []component.ID{component.MustNewID("nop")},
2368 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn1")},
2369 },
2370 pipeline.NewIDWithName(xpipeline.SignalProfiles, "2"): {
2371 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn1")},
2372 Processors: []component.ID{component.MustNewID("nop")},
2373 Exporters: []component.ID{component.MustNewIDWithName("nop", "conn2"), component.MustNewIDWithName("nop", "conn")},
2374 },
2375 pipeline.NewIDWithName(xpipeline.SignalProfiles, "out"): {
2376 Receivers: []component.ID{component.MustNewIDWithName("nop", "conn2")},
2377 Processors: []component.ID{component.MustNewID("nop")},
2378 Exporters: []component.ID{component.MustNewID("nop")},
2379 },
2380 },
2381 expected: `cycle detected: ` +
2382 `connector "nop/conn1" (profiles to profiles) -> ` +
2383 `processor "nop" in pipeline "profiles/2" -> ` +
2384 `connector "nop/conn" (profiles to profiles) -> ` +
2385 `processor "nop" in pipeline "profiles/1" -> ` +
2386 `connector "nop/conn1" (profiles to profiles)`,
2387 },
2388 {
2389 name: "not_allowed_deep_cycle_multi_signal.yaml",
2390 receiverCfgs: map[component.ID]component.Config{
2391 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2392 },
2393 processorCfgs: map[component.ID]component.Config{
2394 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2395 },
2396 exporterCfgs: map[component.ID]component.Config{
2397 component.MustNewID("nop"): nopExporterFactory.CreateDefaultConfig(),
2398 },
2399 connectorCfgs: map[component.ID]component.Config{
2400 component.MustNewIDWithName("nop", "fork"): nopConnectorFactory.CreateDefaultConfig(),
2401 component.MustNewIDWithName("nop", "count"): nopConnectorFactory.CreateDefaultConfig(),
2402 component.MustNewIDWithName("nop", "forkagain"): nopConnectorFactory.CreateDefaultConfig(),
2403 component.MustNewIDWithName("nop", "rawlog"): nopConnectorFactory.CreateDefaultConfig(),
2404 },
2405 pipelineCfgs: pipelines.Config{
2406 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
2407 Receivers: []component.ID{component.MustNewID("nop")},
2408 Processors: []component.ID{component.MustNewID("nop")},
2409 Exporters: []component.ID{component.MustNewIDWithName("nop", "fork")},
2410 },
2411 pipeline.NewIDWithName(pipeline.SignalTraces, "copy1"): {
2412 Receivers: []component.ID{component.MustNewIDWithName("nop", "fork")},
2413 Processors: []component.ID{component.MustNewID("nop")},
2414 Exporters: []component.ID{component.MustNewIDWithName("nop", "count")},
2415 },
2416 pipeline.NewIDWithName(pipeline.SignalTraces, "copy2"): {
2417 Receivers: []component.ID{component.MustNewIDWithName("nop", "fork")},
2418 Processors: []component.ID{component.MustNewID("nop")},
2419 Exporters: []component.ID{component.MustNewIDWithName("nop", "forkagain")},
2420 },
2421 pipeline.NewIDWithName(pipeline.SignalTraces, "copy2a"): {
2422 Receivers: []component.ID{component.MustNewIDWithName("nop", "forkagain")},
2423 Processors: []component.ID{component.MustNewID("nop")},
2424 Exporters: []component.ID{component.MustNewIDWithName("nop", "count")},
2425 },
2426 pipeline.NewIDWithName(pipeline.SignalTraces, "copy2b"): {
2427 Receivers: []component.ID{component.MustNewIDWithName("nop", "forkagain")},
2428 Processors: []component.ID{component.MustNewID("nop")},
2429 Exporters: []component.ID{component.MustNewIDWithName("nop", "rawlog")},
2430 },
2431 pipeline.NewIDWithName(pipeline.SignalMetrics, "count"): {
2432 Receivers: []component.ID{component.MustNewIDWithName("nop", "count")},
2433 Processors: []component.ID{component.MustNewID("nop")},
2434 Exporters: []component.ID{component.MustNewID("nop")},
2435 },
2436 pipeline.NewIDWithName(pipeline.SignalLogs, "raw"): {
2437 Receivers: []component.ID{component.MustNewIDWithName("nop", "rawlog")},
2438 Processors: []component.ID{component.MustNewID("nop")},
2439 Exporters: []component.ID{component.MustNewIDWithName("nop", "fork")}, // cannot loop back to "nop/fork"
2440 },
2441 },
2442 expected: `cycle detected: ` +
2443 `connector "nop/rawlog" (traces to logs) -> ` +
2444 `processor "nop" in pipeline "logs/raw" -> ` +
2445 `connector "nop/fork" (logs to traces) -> ` +
2446 `processor "nop" in pipeline "traces/copy2" -> ` +
2447 `connector "nop/forkagain" (traces to traces) -> ` +
2448 `processor "nop" in pipeline "traces/copy2b" -> ` +
2449 `connector "nop/rawlog" (traces to logs)`,
2450 },
2451 {
2452 name: "unknown_exporter_config",
2453 receiverCfgs: map[component.ID]component.Config{
2454 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2455 },
2456 exporterCfgs: map[component.ID]component.Config{
2457 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2458 },
2459 pipelineCfgs: pipelines.Config{
2460 pipeline.NewID(pipeline.SignalTraces): {
2461 Receivers: []component.ID{component.MustNewID("nop")},
2462 Exporters: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("nop", "1")},
2463 },
2464 },
2465 expected: "failed to create \"nop/1\" exporter for data type \"traces\": exporter \"nop/1\" is not configured",
2466 },
2467 {
2468 name: "unknown_exporter_factory",
2469 receiverCfgs: map[component.ID]component.Config{
2470 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2471 },
2472 exporterCfgs: map[component.ID]component.Config{
2473 component.MustNewID("unknown"): nopReceiverFactory.CreateDefaultConfig(),
2474 },
2475 pipelineCfgs: pipelines.Config{
2476 pipeline.NewID(pipeline.SignalTraces): {
2477 Receivers: []component.ID{component.MustNewID("nop")},
2478 Exporters: []component.ID{component.MustNewID("unknown")},
2479 },
2480 },
2481 expected: "failed to create \"unknown\" exporter for data type \"traces\": exporter factory not available for: \"unknown\"",
2482 },
2483 {
2484 name: "unknown_processor_config",
2485 receiverCfgs: map[component.ID]component.Config{
2486 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2487 },
2488 processorCfgs: map[component.ID]component.Config{
2489 component.MustNewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
2490 },
2491 exporterCfgs: map[component.ID]component.Config{
2492 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2493 },
2494 pipelineCfgs: pipelines.Config{
2495 pipeline.NewID(pipeline.SignalMetrics): {
2496 Receivers: []component.ID{component.MustNewID("nop")},
2497 Processors: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("nop", "1")},
2498 Exporters: []component.ID{component.MustNewID("nop")},
2499 },
2500 },
2501 expected: "failed to create \"nop/1\" processor, in pipeline \"metrics\": processor \"nop/1\" is not configured",
2502 },
2503 {
2504 name: "unknown_processor_factory",
2505 receiverCfgs: map[component.ID]component.Config{
2506 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2507 },
2508 processorCfgs: map[component.ID]component.Config{
2509 component.MustNewID("unknown"): nopProcessorFactory.CreateDefaultConfig(),
2510 },
2511 exporterCfgs: map[component.ID]component.Config{
2512 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2513 },
2514 pipelineCfgs: pipelines.Config{
2515 pipeline.NewID(pipeline.SignalMetrics): {
2516 Receivers: []component.ID{component.MustNewID("nop")},
2517 Processors: []component.ID{component.MustNewID("unknown")},
2518 Exporters: []component.ID{component.MustNewID("nop")},
2519 },
2520 },
2521 expected: "failed to create \"unknown\" processor, in pipeline \"metrics\": processor factory not available for: \"unknown\"",
2522 },
2523 {
2524 name: "unknown_receiver_config",
2525 receiverCfgs: map[component.ID]component.Config{
2526 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2527 },
2528 exporterCfgs: map[component.ID]component.Config{
2529 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2530 },
2531 pipelineCfgs: pipelines.Config{
2532 pipeline.NewID(pipeline.SignalLogs): {
2533 Receivers: []component.ID{component.MustNewID("nop"), component.MustNewIDWithName("nop", "1")},
2534 Exporters: []component.ID{component.MustNewID("nop")},
2535 },
2536 },
2537 expected: "failed to create \"nop/1\" receiver for data type \"logs\": receiver \"nop/1\" is not configured",
2538 },
2539 {
2540 name: "unknown_receiver_factory",
2541 receiverCfgs: map[component.ID]component.Config{
2542 component.MustNewID("unknown"): nopReceiverFactory.CreateDefaultConfig(),
2543 },
2544 exporterCfgs: map[component.ID]component.Config{
2545 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2546 },
2547 pipelineCfgs: pipelines.Config{
2548 pipeline.NewID(pipeline.SignalLogs): {
2549 Receivers: []component.ID{component.MustNewID("unknown")},
2550 Exporters: []component.ID{component.MustNewID("nop")},
2551 },
2552 },
2553 expected: "failed to create \"unknown\" receiver for data type \"logs\": receiver factory not available for: \"unknown\"",
2554 },
2555 {
2556 name: "unknown_connector_factory",
2557 receiverCfgs: map[component.ID]component.Config{
2558 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2559 },
2560 exporterCfgs: map[component.ID]component.Config{
2561 component.MustNewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
2562 },
2563 connectorCfgs: map[component.ID]component.Config{
2564 component.MustNewID("unknown"): nopConnectorFactory.CreateDefaultConfig(),
2565 },
2566 pipelineCfgs: pipelines.Config{
2567 pipeline.NewIDWithName(pipeline.SignalTraces, "in"): {
2568 Receivers: []component.ID{component.MustNewID("nop")},
2569 Exporters: []component.ID{component.MustNewID("unknown")},
2570 },
2571 pipeline.NewIDWithName(pipeline.SignalTraces, "out"): {
2572 Receivers: []component.ID{component.MustNewID("unknown")},
2573 Exporters: []component.ID{component.MustNewID("nop")},
2574 },
2575 },
2576 expected: "connector factory not available for: \"unknown\"",
2577 },
2578 }
2579
2580 for _, tt := range tests {
2581 t.Run(tt.name, func(t *testing.T) {
2582 set := Settings{
2583 BuildInfo: component.NewDefaultBuildInfo(),
2584 Telemetry: componenttest.NewNopTelemetrySettings(),
2585 ReceiverBuilder: builders.NewReceiver(
2586 tt.receiverCfgs,
2587 map[component.Type]receiver.Factory{
2588 nopReceiverFactory.Type(): nopReceiverFactory,
2589 badReceiverFactory.Type(): badReceiverFactory,
2590 }),
2591 ProcessorBuilder: builders.NewProcessor(
2592 tt.processorCfgs,
2593 map[component.Type]processor.Factory{
2594 nopProcessorFactory.Type(): nopProcessorFactory,
2595 badProcessorFactory.Type(): badProcessorFactory,
2596 }),
2597 ExporterBuilder: builders.NewExporter(
2598 tt.exporterCfgs,
2599 map[component.Type]exporter.Factory{
2600 nopExporterFactory.Type(): nopExporterFactory,
2601 badExporterFactory.Type(): badExporterFactory,
2602 }),
2603 ConnectorBuilder: builders.NewConnector(
2604 tt.connectorCfgs,
2605 map[component.Type]connector.Factory{
2606 nopConnectorFactory.Type(): nopConnectorFactory,
2607 badConnectorFactory.Type(): badConnectorFactory,
2608 mfConnectorFactory.Type(): mfConnectorFactory,
2609 }),
2610 PipelineConfigs: tt.pipelineCfgs,
2611 }
2612 _, err := Build(context.Background(), set)
2613 assert.EqualError(t, err, tt.expected)
2614 })
2615 }
2616 }