Skip to content

Commit

Permalink
[cmd/otelcontribcol] Simplify exporters lifecycle tests (open-telemet…
Browse files Browse the repository at this point in the history
…ry#27816)

There is no need to skip tests for components that we don't have
factories for. We can just remove those tests. This helped to find a
wrong test for nonexistent awscloudwatch exporter
  • Loading branch information
dmitryax committed Oct 17, 2023
1 parent 1a03d9c commit 22ffdf5
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions cmd/otelcontribcol/exporters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ func TestDefaultExporters(t *testing.T) {
{
exporter: "awscloudwatchlogs",
getConfigFn: func() component.Config {
return expFactories["awscloudwatchlogs"].CreateDefaultConfig()
cfg := expFactories["awscloudwatchlogs"].CreateDefaultConfig().(*awscloudwatchlogsexporter.Config)
cfg.Endpoint = "http:https://" + endpoint
cfg.Region = "local"
return cfg
},
skipLifecycle: true,
},
Expand Down Expand Up @@ -210,15 +213,6 @@ func TestDefaultExporters(t *testing.T) {
return cfg
},
},
{
exporter: "awscloudwatch",
getConfigFn: func() component.Config {
cfg := expFactories["awscloudwatch"].CreateDefaultConfig().(*awscloudwatchlogsexporter.Config)
cfg.Endpoint = "http:https://" + endpoint
cfg.Region = "local"
return cfg
},
},
{
exporter: "awsemf",
getConfigFn: func() component.Config {
Expand Down Expand Up @@ -454,20 +448,8 @@ func TestDefaultExporters(t *testing.T) {
},
}

exporterCount := 0
expectedExporters := map[component.Type]struct{}{}
for k := range expFactories {
expectedExporters[k] = struct{}{}
}
assert.Equal(t, len(expFactories), len(tests), "All user configurable components must be added to the lifecycle test")
for _, tt := range tests {
_, ok := expFactories[tt.exporter]
if !ok {
// not part of the distro, skipping.
continue
}
tt := tt
exporterCount++
delete(expectedExporters, tt.exporter)
t.Run(string(tt.exporter), func(t *testing.T) {
factory := expFactories[tt.exporter]
assert.Equal(t, tt.exporter, factory.Type())
Expand All @@ -482,7 +464,6 @@ func TestDefaultExporters(t *testing.T) {
})
})
}
assert.Len(t, expFactories, exporterCount, "All user configurable components must be added to the lifecycle test", expectedExporters)
}

// GetExporterConfigFn is used customize the configuration passed to the verification.
Expand Down

0 comments on commit 22ffdf5

Please sign in to comment.