Skip to content

Commit

Permalink
Make default extensions test more resilient (#2763)
Browse files Browse the repository at this point in the history
Fixes #2738 by selecting available endpoints and ports for the default extensions tests.
  • Loading branch information
pjanotti authored Mar 22, 2021
1 parent 705e996 commit 73dfd89
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions service/defaultcomponents/default_extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,47 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config/configmodels"
"go.opentelemetry.io/collector/extension/healthcheckextension"
"go.opentelemetry.io/collector/extension/pprofextension"
"go.opentelemetry.io/collector/extension/zpagesextension"
"go.opentelemetry.io/collector/testutil"
)

func TestDefaultExtensions(t *testing.T) {
allFactories, err := Components()
require.NoError(t, err)

extFactories := allFactories.Extensions
endpoint := testutil.GetAvailableLocalAddress(t)
port := testutil.GetAvailablePort(t)

tests := []struct {
extension configmodels.Type
getConfigFn getExtensionConfigFn
}{
{
extension: "health_check",
getConfigFn: func() configmodels.Extension {
cfg := extFactories["health_check"].CreateDefaultConfig().(*healthcheckextension.Config)
cfg.Port = port
return cfg
},
},
{
extension: "pprof",
getConfigFn: func() configmodels.Extension {
cfg := extFactories["pprof"].CreateDefaultConfig().(*pprofextension.Config)
cfg.Endpoint = endpoint
return cfg
},
},
{
extension: "zpages",
getConfigFn: func() configmodels.Extension {
cfg := extFactories["zpages"].CreateDefaultConfig().(*zpagesextension.Config)
cfg.Endpoint = endpoint
return cfg
},
},
{
extension: "fluentbit",
Expand Down

0 comments on commit 73dfd89

Please sign in to comment.