Skip to content

Commit

Permalink
Fix some pipeline tests and validate error messages (#6685)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski committed Dec 8, 2022
1 parent a470d8a commit 9a763f9
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions service/pipelines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ func TestBuildErrors(t *testing.T) {
tests := []struct {
name string
settings pipelinesSettings
expected string
}{
{
name: "not_supported_exporter_logs",
Expand All @@ -318,6 +319,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "failed to create \"bf\" exporter, in pipeline \"logs\": telemetry type is not supported",
},
{
name: "not_supported_exporter_metrics",
Expand All @@ -335,6 +337,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "failed to create \"bf\" exporter, in pipeline \"metrics\": telemetry type is not supported",
},
{
name: "not_supported_exporter_traces",
Expand All @@ -352,6 +355,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "failed to create \"bf\" exporter, in pipeline \"traces\": telemetry type is not supported",
},
{
name: "not_supported_processor_logs",
Expand All @@ -363,7 +367,7 @@ func TestBuildErrors(t *testing.T) {
component.NewID("bf"): badProcessorFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("logs"): {
Expand All @@ -373,6 +377,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "failed to create \"bf\" processor, in pipeline \"logs\": telemetry type is not supported",
},
{
name: "not_supported_processor_metrics",
Expand All @@ -384,7 +389,7 @@ func TestBuildErrors(t *testing.T) {
component.NewID("bf"): badProcessorFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("metrics"): {
Expand All @@ -394,6 +399,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "failed to create \"bf\" processor, in pipeline \"metrics\": telemetry type is not supported",
},
{
name: "not_supported_processor_traces",
Expand All @@ -405,7 +411,7 @@ func TestBuildErrors(t *testing.T) {
component.NewID("bf"): badProcessorFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("traces"): {
Expand All @@ -415,6 +421,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "failed to create \"bf\" processor, in pipeline \"traces\": telemetry type is not supported",
},
{
name: "not_supported_receiver_logs",
Expand All @@ -423,7 +430,7 @@ func TestBuildErrors(t *testing.T) {
component.NewID("bf"): badReceiverFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("logs"): {
Expand All @@ -432,6 +439,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "failed to create \"bf\" receiver, in pipeline \"logs\": telemetry type is not supported",
},
{
name: "not_supported_receiver_metrics",
Expand All @@ -440,7 +448,7 @@ func TestBuildErrors(t *testing.T) {
component.NewID("bf"): badReceiverFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("metrics"): {
Expand All @@ -449,6 +457,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "failed to create \"bf\" receiver, in pipeline \"metrics\": telemetry type is not supported",
},
{
name: "not_supported_receiver_traces",
Expand All @@ -457,7 +466,7 @@ func TestBuildErrors(t *testing.T) {
component.NewID("bf"): badReceiverFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("traces"): {
Expand All @@ -466,6 +475,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "failed to create \"bf\" receiver, in pipeline \"traces\": telemetry type is not supported",
},
{
name: "unknown_exporter_config",
Expand All @@ -474,15 +484,16 @@ func TestBuildErrors(t *testing.T) {
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("traces"): {
Receivers: []component.ID{component.NewID("nop")},
Exporters: []component.ID{component.NewID("nop"), component.NewID("nop/1")},
Exporters: []component.ID{component.NewID("nop"), component.NewIDWithName("nop", "1")},
},
},
},
expected: "exporter \"nop/1\" is not configured",
},
{
name: "unknown_exporter_factory",
Expand All @@ -491,7 +502,7 @@ func TestBuildErrors(t *testing.T) {
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("unknown"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("unknown"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("traces"): {
Expand All @@ -500,6 +511,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "exporter factory not available for: \"unknown\"",
},
{
name: "unknown_processor_config",
Expand All @@ -511,16 +523,17 @@ func TestBuildErrors(t *testing.T) {
component.NewID("nop"): nopProcessorFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("metrics"): {
Receivers: []component.ID{component.NewID("nop")},
Processors: []component.ID{component.NewID("nop"), component.NewID("nop/1")},
Processors: []component.ID{component.NewID("nop"), component.NewIDWithName("nop", "1")},
Exporters: []component.ID{component.NewID("nop")},
},
},
},
expected: "processor \"nop/1\" is not configured",
},
{
name: "unknown_processor_factory",
Expand All @@ -532,7 +545,7 @@ func TestBuildErrors(t *testing.T) {
component.NewID("unknown"): nopProcessorFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("metrics"): {
Expand All @@ -542,6 +555,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "processor factory not available for: \"unknown\"",
},
{
name: "unknown_receiver_config",
Expand All @@ -550,15 +564,16 @@ func TestBuildErrors(t *testing.T) {
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("logs"): {
Receivers: []component.ID{component.NewID("nop"), component.NewID("nop/1")},
Receivers: []component.ID{component.NewID("nop"), component.NewIDWithName("nop", "1")},
Exporters: []component.ID{component.NewID("nop")},
},
},
},
expected: "receiver \"nop/1\" is not configured",
},
{
name: "unknown_receiver_factory",
Expand All @@ -567,7 +582,7 @@ func TestBuildErrors(t *testing.T) {
component.NewID("unknown"): nopReceiverFactory.CreateDefaultConfig(),
},
ExporterConfigs: map[component.ID]component.Config{
component.NewID("nop"): nopReceiverFactory.CreateDefaultConfig(),
component.NewID("nop"): nopExporterFactory.CreateDefaultConfig(),
},
PipelineConfigs: map[component.ID]*ConfigServicePipeline{
component.NewID("logs"): {
Expand All @@ -576,6 +591,7 @@ func TestBuildErrors(t *testing.T) {
},
},
},
expected: "receiver factory not available for: \"unknown\"",
},
}

Expand All @@ -598,7 +614,7 @@ func TestBuildErrors(t *testing.T) {
}

_, err := buildPipelines(context.Background(), set)
assert.Error(t, err)
assert.EqualError(t, err, test.expected)
})
}
}
Expand Down

0 comments on commit 9a763f9

Please sign in to comment.