Skip to content

Commit 22ffdf5

Browse files
authored
[cmd/otelcontribcol] Simplify exporters lifecycle tests (#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
1 parent 1a03d9c commit 22ffdf5

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

cmd/otelcontribcol/exporters_test.go

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ func TestDefaultExporters(t *testing.T) {
7777
{
7878
exporter: "awscloudwatchlogs",
7979
getConfigFn: func() component.Config {
80-
return expFactories["awscloudwatchlogs"].CreateDefaultConfig()
80+
cfg := expFactories["awscloudwatchlogs"].CreateDefaultConfig().(*awscloudwatchlogsexporter.Config)
81+
cfg.Endpoint = "http://" + endpoint
82+
cfg.Region = "local"
83+
return cfg
8184
},
8285
skipLifecycle: true,
8386
},
@@ -210,15 +213,6 @@ func TestDefaultExporters(t *testing.T) {
210213
return cfg
211214
},
212215
},
213-
{
214-
exporter: "awscloudwatch",
215-
getConfigFn: func() component.Config {
216-
cfg := expFactories["awscloudwatch"].CreateDefaultConfig().(*awscloudwatchlogsexporter.Config)
217-
cfg.Endpoint = "http://" + endpoint
218-
cfg.Region = "local"
219-
return cfg
220-
},
221-
},
222216
{
223217
exporter: "awsemf",
224218
getConfigFn: func() component.Config {
@@ -454,20 +448,8 @@ func TestDefaultExporters(t *testing.T) {
454448
},
455449
}
456450

457-
exporterCount := 0
458-
expectedExporters := map[component.Type]struct{}{}
459-
for k := range expFactories {
460-
expectedExporters[k] = struct{}{}
461-
}
451+
assert.Equal(t, len(expFactories), len(tests), "All user configurable components must be added to the lifecycle test")
462452
for _, tt := range tests {
463-
_, ok := expFactories[tt.exporter]
464-
if !ok {
465-
// not part of the distro, skipping.
466-
continue
467-
}
468-
tt := tt
469-
exporterCount++
470-
delete(expectedExporters, tt.exporter)
471453
t.Run(string(tt.exporter), func(t *testing.T) {
472454
factory := expFactories[tt.exporter]
473455
assert.Equal(t, tt.exporter, factory.Type())
@@ -482,7 +464,6 @@ func TestDefaultExporters(t *testing.T) {
482464
})
483465
})
484466
}
485-
assert.Len(t, expFactories, exporterCount, "All user configurable components must be added to the lifecycle test", expectedExporters)
486467
}
487468

488469
// GetExporterConfigFn is used customize the configuration passed to the verification.

0 commit comments

Comments
 (0)