Skip to content

Commit

Permalink
Fix config used in Otel manager test (#6966)
Browse files Browse the repository at this point in the history
Otel collector exposes metrics on port 8888 by default, which can cause
conflicts with other applications in tests. Disable this.

Use the nopexporter and debugpreceiver in the test instead of the
otlpexporter and otlpreceiver. This is faster and doesn't require
binding to any ports as well.
  • Loading branch information
swiatekm authored Feb 24, 2025
1 parent e50f7bf commit d68ade9
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions internal/pkg/otel/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,36 @@ import (
var (
testConfig = map[string]interface{}{
"receivers": map[string]interface{}{
"otlp": map[string]interface{}{
"protocols": map[string]interface{}{
"grpc": map[string]interface{}{
"endpoint": "0.0.0.0:4317",
},
},
},
"nop": map[string]interface{}{},
},
"processors": map[string]interface{}{
"batch": map[string]interface{}{},
},
"exporters": map[string]interface{}{
"otlp": map[string]interface{}{
"endpoint": "otelcol:4317",
},
"debug": map[string]interface{}{},
},
"service": map[string]interface{}{
"telemetry": map[string]interface{}{
"metrics": map[string]interface{}{
"level": "none",
"readers": []any{},
},
},
"pipelines": map[string]interface{}{
"traces": map[string]interface{}{
"receivers": []string{"otlp"},
"receivers": []string{"nop"},
"processors": []string{"batch"},
"exporters": []string{"otlp"},
"exporters": []string{"debug"},
},
"metrics": map[string]interface{}{
"receivers": []string{"otlp"},
"receivers": []string{"nop"},
"processors": []string{"batch"},
"exporters": []string{"otlp"},
"exporters": []string{"debug"},
},
"logs": map[string]interface{}{
"receivers": []string{"otlp"},
"receivers": []string{"nop"},
"processors": []string{"batch"},
"exporters": []string{"otlp"},
"exporters": []string{"debug"},
},
},
},
Expand Down Expand Up @@ -191,7 +189,7 @@ func TestOTelManager_ConfigError(t *testing.T) {

go func() {
err := m.Run(ctx)
require.ErrorIs(t, err, context.Canceled, "otel manager should be cancelled")
assert.ErrorIs(t, err, context.Canceled, "otel manager should be cancelled")
}()

// watch is synchronous, so we need to read from it to avoid blocking the manager
Expand Down

0 comments on commit d68ade9

Please sign in to comment.