Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding all extensions to lifecycle tests #6934

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/components/exporters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func TestDefaultExporters(t *testing.T) {
},
}

assert.Equal(t, len(tests), len(expFactories), "All user configurable components must be added to the lifecycle test")
assert.Len(t, tests, len(expFactories), "All user configurable components must be added to the lifecycle test")
for _, tt := range tests {
t.Run(string(tt.exporter), func(t *testing.T) {
t.Parallel()
Expand All @@ -416,7 +416,7 @@ func TestDefaultExporters(t *testing.T) {
assert.Equal(t, config.NewComponentID(tt.exporter), factory.CreateDefaultConfig().ID())

if tt.skipLifecycle {
t.Log("Skipping lifecycle test", tt.exporter)
t.Skip("Skipping lifecycle test", tt.exporter)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this so that go test would should that the test was skipped instead of a log message.

return
}

Expand Down
73 changes: 68 additions & 5 deletions internal/components/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ import (

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/asapauthextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/fluentbitextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/httpforwarder"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/oauth2clientauthextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/ecstaskobserver"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/hostobserver"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testutil"
)

Expand All @@ -43,8 +48,9 @@ func TestDefaultExtensions(t *testing.T) {
endpoint := testutil.GetAvailableLocalAddress(t)

tests := []struct {
extension config.Type
getConfigFn getExtensionConfigFn
extension config.Type
getConfigFn getExtensionConfigFn
skipLifecycle bool
}{
{
extension: "health_check",
Expand Down Expand Up @@ -111,18 +117,75 @@ func TestDefaultExtensions(t *testing.T) {
return cfg
},
},
{
extension: "awsproxy",
skipLifecycle: true, // Requires EC2 metadata service to be running
},
{
extension: "fluentbit",
getConfigFn: func() config.Extension {
cfg := extFactories["fluentbit"].CreateDefaultConfig().(*fluentbitextension.Config)
cfg.TCPEndpoint = "http://" + endpoint
return cfg
},
},
{
extension: "http_forwarder",
getConfigFn: func() config.Extension {
cfg := extFactories["http_forwarder"].CreateDefaultConfig().(*httpforwarder.Config)
cfg.Egress.Endpoint = "http://" + endpoint
cfg.Ingress.Endpoint = testutil.GetAvailableLocalAddress(t)
return cfg
},
},
{
extension: "oauth2client",
getConfigFn: func() config.Extension {
cfg := extFactories["oauth2client"].CreateDefaultConfig().(*oauth2clientauthextension.Config)
cfg.ClientID = "otel-extension"
cfg.ClientSecret = "testsarehard"
cfg.TokenURL = "http://" + endpoint
return cfg
},
},
{
extension: "oidc",
skipLifecycle: true, // Requires a running OIDC server in order to complete life cycle testing
},
{
extension: "file_storage",
getConfigFn: func() config.Extension {
cfg := extFactories["file_storage"].CreateDefaultConfig().(*filestorage.Config)
cfg.Directory = testutil.NewTemporaryDirectory(t)
return cfg
},
},
{
extension: "host_observer",
getConfigFn: func() config.Extension {
cfg := extFactories["host_observer"].CreateDefaultConfig().(*hostobserver.Config)
return cfg
},
},
{
extension: "k8s_observer",
skipLifecycle: true, // Requires a K8s api to interfact with and validate
},
}

// * The OIDC Auth extension requires an OIDC server to get the config from, and we don't want to spawn one here for this test.
assert.Equal(t, len(tests)+8 /* not tested */, len(extFactories))

assert.Len(t, tests, len(extFactories), "All extensions must be added to the lifecycle tests")
for _, tt := range tests {
t.Run(string(tt.extension), func(t *testing.T) {
factory, ok := extFactories[tt.extension]
require.True(t, ok)
assert.Equal(t, tt.extension, factory.Type())
assert.Equal(t, config.NewComponentID(tt.extension), factory.CreateDefaultConfig().ID())

if tt.skipLifecycle {
t.Skip("Skipping lifecycle test for ", tt.extension)
return
}

verifyExtensionLifecycle(t, factory, tt.getConfigFn)
})
}
Expand Down