diff --git a/service/internal/pipelines/pipelines_test.go b/service/internal/pipelines/pipelines_test.go index fd6ac871d00..acaec1cf3eb 100644 --- a/service/internal/pipelines/pipelines_test.go +++ b/service/internal/pipelines/pipelines_test.go @@ -210,54 +210,305 @@ func TestBuildErrors(t *testing.T) { badExporterFactory := newBadExporterFactory() tests := []struct { - configFile string + name string + settings Settings }{ - {configFile: "not_supported_exporter_logs.yaml"}, - {configFile: "not_supported_exporter_metrics.yaml"}, - {configFile: "not_supported_exporter_traces.yaml"}, - {configFile: "not_supported_processor_logs.yaml"}, - {configFile: "not_supported_processor_metrics.yaml"}, - {configFile: "not_supported_processor_traces.yaml"}, - {configFile: "not_supported_receiver_traces.yaml"}, - {configFile: "not_supported_receiver_metrics.yaml"}, - {configFile: "not_supported_receiver_traces.yaml"}, - {configFile: "unknown_exporter_config.yaml"}, - {configFile: "unknown_exporter_factory.yaml"}, - {configFile: "unknown_processor_config.yaml"}, - {configFile: "unknown_processor_factory.yaml"}, - {configFile: "unknown_receiver_config.yaml"}, - {configFile: "unknown_receiver_factory.yaml"}, + { + name: "not_supported_exporter_logs", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("bf"): badExporterFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("logs"): { + Receivers: []component.ID{component.NewID("nop")}, + Exporters: []component.ID{component.NewID("bf")}, + }, + }, + }, + }, + { + name: "not_supported_exporter_metrics", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("bf"): badExporterFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("metrics"): { + Receivers: []component.ID{component.NewID("nop")}, + Exporters: []component.ID{component.NewID("bf")}, + }, + }, + }, + }, + { + name: "not_supported_exporter_traces", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("bf"): badExporterFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("traces"): { + Receivers: []component.ID{component.NewID("nop")}, + Exporters: []component.ID{component.NewID("bf")}, + }, + }, + }, + }, + { + name: "not_supported_processor_logs", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ProcessorConfigs: map[component.ID]component.Config{ + component.NewID("bf"): badProcessorFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("logs"): { + Receivers: []component.ID{component.NewID("nop")}, + Processors: []component.ID{component.NewID("bf")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, + { + name: "not_supported_processor_metrics", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ProcessorConfigs: map[component.ID]component.Config{ + component.NewID("bf"): badProcessorFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("metrics"): { + Receivers: []component.ID{component.NewID("nop")}, + Processors: []component.ID{component.NewID("bf")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, + { + name: "not_supported_processor_traces", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ProcessorConfigs: map[component.ID]component.Config{ + component.NewID("bf"): badProcessorFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("traces"): { + Receivers: []component.ID{component.NewID("nop")}, + Processors: []component.ID{component.NewID("bf")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, + { + name: "not_supported_receiver_logs", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("bf"): badReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("logs"): { + Receivers: []component.ID{component.NewID("bf")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, + { + name: "not_supported_receiver_metrics", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("bf"): badReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("metrics"): { + Receivers: []component.ID{component.NewID("bf")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, + { + name: "not_supported_receiver_traces", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("bf"): badReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("traces"): { + Receivers: []component.ID{component.NewID("bf")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, + { + name: "unknown_exporter_config", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("traces"): { + Receivers: []component.ID{component.NewID("nop")}, + Exporters: []component.ID{component.NewID("nop"), component.NewID("nop/1")}, + }, + }, + }, + }, + { + name: "unknown_exporter_factory", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("unknown"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("traces"): { + Receivers: []component.ID{component.NewID("nop")}, + Exporters: []component.ID{component.NewID("unknown")}, + }, + }, + }, + }, + { + name: "unknown_processor_config", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ProcessorConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("metrics"): { + Receivers: []component.ID{component.NewID("nop")}, + Processors: []component.ID{component.NewID("nop"), component.NewID("nop/1")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, + { + name: "unknown_processor_factory", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ProcessorConfigs: map[component.ID]component.Config{ + component.NewID("unknown"): nopProcessorFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("metrics"): { + Receivers: []component.ID{component.NewID("nop")}, + Processors: []component.ID{component.NewID("unknown")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, + { + name: "unknown_receiver_config", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("logs"): { + Receivers: []component.ID{component.NewID("nop"), component.NewID("nop/1")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, + { + name: "unknown_receiver_factory", + settings: Settings{ + ReceiverConfigs: map[component.ID]component.Config{ + component.NewID("unknown"): nopReceiverFactory.CreateDefaultConfig(), + }, + ExporterConfigs: map[component.ID]component.Config{ + component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(), + }, + PipelineConfigs: map[component.ID]*config.Pipeline{ + component.NewID("logs"): { + Receivers: []component.ID{component.NewID("unknown")}, + Exporters: []component.ID{component.NewID("nop")}, + }, + }, + }, + }, } for _, test := range tests { - t.Run(test.configFile, func(t *testing.T) { - factories := component.Factories{ - Receivers: map[component.Type]component.ReceiverFactory{ - nopReceiverFactory.Type(): nopReceiverFactory, - "unknown": nopReceiverFactory, - badReceiverFactory.Type(): badReceiverFactory, - }, - Processors: map[component.Type]component.ProcessorFactory{ - nopProcessorFactory.Type(): nopProcessorFactory, - "unknown": nopProcessorFactory, - badProcessorFactory.Type(): badProcessorFactory, - }, - Exporters: map[component.Type]component.ExporterFactory{ - nopExporterFactory.Type(): nopExporterFactory, - "unknown": nopExporterFactory, - badExporterFactory.Type(): badExporterFactory, - }, + t.Run(test.name, func(t *testing.T) { + set := test.settings + set.BuildInfo = component.NewDefaultBuildInfo() + set.Telemetry = componenttest.NewNopTelemetrySettings() + set.ReceiverFactories = map[component.Type]component.ReceiverFactory{ + nopReceiverFactory.Type(): nopReceiverFactory, + badReceiverFactory.Type(): badReceiverFactory, + } + set.ProcessorFactories = map[component.Type]component.ProcessorFactory{ + nopProcessorFactory.Type(): nopProcessorFactory, + badProcessorFactory.Type(): badProcessorFactory, + } + set.ExporterFactories = map[component.Type]component.ExporterFactory{ + nopExporterFactory.Type(): nopExporterFactory, + badExporterFactory.Type(): badExporterFactory, } - // Need the unknown factories to do unmarshalling. - cfg := loadConfig(t, filepath.Join("testdata", test.configFile), factories) - - // Remove the unknown factories, so they are NOT available during building. - delete(factories.Exporters, "unknown") - delete(factories.Processors, "unknown") - delete(factories.Receivers, "unknown") - - _, err := Build(context.Background(), toSettings(factories, cfg)) + _, err := Build(context.Background(), set) assert.Error(t, err) }) } diff --git a/service/internal/pipelines/testdata/not_supported_exporter_logs.yaml b/service/internal/pipelines/testdata/not_supported_exporter_logs.yaml deleted file mode 100644 index 2907aabeb5f..00000000000 --- a/service/internal/pipelines/testdata/not_supported_exporter_logs.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - nop: -exporters: - bf: - -service: - pipelines: - logs: - receivers: [nop] - exporters: [bf] diff --git a/service/internal/pipelines/testdata/not_supported_exporter_metrics.yaml b/service/internal/pipelines/testdata/not_supported_exporter_metrics.yaml deleted file mode 100644 index 962aad9ef81..00000000000 --- a/service/internal/pipelines/testdata/not_supported_exporter_metrics.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - nop: -exporters: - bf: - -service: - pipelines: - metrics: - receivers: [nop] - exporters: [bf] diff --git a/service/internal/pipelines/testdata/not_supported_exporter_traces.yaml b/service/internal/pipelines/testdata/not_supported_exporter_traces.yaml deleted file mode 100644 index 88aaba0a214..00000000000 --- a/service/internal/pipelines/testdata/not_supported_exporter_traces.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - nop: -exporters: - bf: - -service: - pipelines: - traces: - receivers: [nop] - exporters: [bf] diff --git a/service/internal/pipelines/testdata/not_supported_processor_logs.yaml b/service/internal/pipelines/testdata/not_supported_processor_logs.yaml deleted file mode 100644 index 49636decb7b..00000000000 --- a/service/internal/pipelines/testdata/not_supported_processor_logs.yaml +++ /dev/null @@ -1,13 +0,0 @@ -receivers: - nop: -processors: - bf: -exporters: - nop: - -service: - pipelines: - logs: - receivers: [nop] - processors: [bf] - exporters: [nop] diff --git a/service/internal/pipelines/testdata/not_supported_processor_metrics.yaml b/service/internal/pipelines/testdata/not_supported_processor_metrics.yaml deleted file mode 100644 index bb62de57e18..00000000000 --- a/service/internal/pipelines/testdata/not_supported_processor_metrics.yaml +++ /dev/null @@ -1,13 +0,0 @@ -receivers: - nop: -processors: - bf: -exporters: - nop: - -service: - pipelines: - metrics: - receivers: [nop] - processors: [bf] - exporters: [nop] diff --git a/service/internal/pipelines/testdata/not_supported_processor_traces.yaml b/service/internal/pipelines/testdata/not_supported_processor_traces.yaml deleted file mode 100644 index 79baed24a29..00000000000 --- a/service/internal/pipelines/testdata/not_supported_processor_traces.yaml +++ /dev/null @@ -1,13 +0,0 @@ -receivers: - nop: -processors: - bf: -exporters: - nop: - -service: - pipelines: - traces: - receivers: [nop] - processors: [bf] - exporters: [nop] diff --git a/service/internal/pipelines/testdata/not_supported_receiver_logs.yaml b/service/internal/pipelines/testdata/not_supported_receiver_logs.yaml deleted file mode 100644 index f59d862f0ae..00000000000 --- a/service/internal/pipelines/testdata/not_supported_receiver_logs.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - bf: # this is the bad receiver factory -exporters: - nop: - -service: - pipelines: - logs: - receivers: [bf] - exporters: [nop] diff --git a/service/internal/pipelines/testdata/not_supported_receiver_metrics.yaml b/service/internal/pipelines/testdata/not_supported_receiver_metrics.yaml deleted file mode 100644 index 20edc1d388c..00000000000 --- a/service/internal/pipelines/testdata/not_supported_receiver_metrics.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - bf: # this is the bad receiver factory -exporters: - nop: - -service: - pipelines: - metrics: - receivers: [bf] - exporters: [nop] diff --git a/service/internal/pipelines/testdata/not_supported_receiver_traces.yaml b/service/internal/pipelines/testdata/not_supported_receiver_traces.yaml deleted file mode 100644 index ec29c48b204..00000000000 --- a/service/internal/pipelines/testdata/not_supported_receiver_traces.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - bf: # this is the bad receiver factory -exporters: - nop: - -service: - pipelines: - traces: - receivers: [bf] - exporters: [nop] diff --git a/service/internal/pipelines/testdata/unknown_exporter_config.yaml b/service/internal/pipelines/testdata/unknown_exporter_config.yaml deleted file mode 100644 index a205cbfa016..00000000000 --- a/service/internal/pipelines/testdata/unknown_exporter_config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - nop: -exporters: - nop: - -service: - pipelines: - logs: - receivers: [nop] - exporters: [nop/1] \ No newline at end of file diff --git a/service/internal/pipelines/testdata/unknown_exporter_factory.yaml b/service/internal/pipelines/testdata/unknown_exporter_factory.yaml deleted file mode 100644 index 51e20dba800..00000000000 --- a/service/internal/pipelines/testdata/unknown_exporter_factory.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - nop: -exporters: - unknown: - -service: - pipelines: - logs: - receivers: [nop] - exporters: [unknown] diff --git a/service/internal/pipelines/testdata/unknown_processor_config.yaml b/service/internal/pipelines/testdata/unknown_processor_config.yaml deleted file mode 100644 index f7df08fb164..00000000000 --- a/service/internal/pipelines/testdata/unknown_processor_config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -receivers: - nop: -processors: - nop: -exporters: - nop: - -service: - pipelines: - metrics: - receivers: [nop] - processors: [nop/1] - exporters: [nop] \ No newline at end of file diff --git a/service/internal/pipelines/testdata/unknown_processor_factory.yaml b/service/internal/pipelines/testdata/unknown_processor_factory.yaml deleted file mode 100644 index 315b40c0020..00000000000 --- a/service/internal/pipelines/testdata/unknown_processor_factory.yaml +++ /dev/null @@ -1,13 +0,0 @@ -receivers: - nop: -processors: - unknown: -exporters: - nop: - -service: - pipelines: - metrics: - receivers: [nop] - processors: [unknown] - exporters: [nop] \ No newline at end of file diff --git a/service/internal/pipelines/testdata/unknown_receiver_config.yaml b/service/internal/pipelines/testdata/unknown_receiver_config.yaml deleted file mode 100644 index ad1558070ed..00000000000 --- a/service/internal/pipelines/testdata/unknown_receiver_config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - nop: -exporters: - nop: - -service: - pipelines: - traces: - receivers: [nop/1] - exporters: [nop] diff --git a/service/internal/pipelines/testdata/unknown_receiver_factory.yaml b/service/internal/pipelines/testdata/unknown_receiver_factory.yaml deleted file mode 100644 index 8e0eb5952dd..00000000000 --- a/service/internal/pipelines/testdata/unknown_receiver_factory.yaml +++ /dev/null @@ -1,10 +0,0 @@ -receivers: - unknown: -exporters: - nop: - -service: - pipelines: - traces: - receivers: [unknown] - exporters: [nop]