Skip to content

Test EDOT collector onboarding reference configurations can be used to start a collector successfully #10826

@cmacknz

Description

@cmacknz

There are per OS getting started configuration files for the EDOT collector in this repository that apparently are not tested here, allowing simple things like typos and configuration name changes from dependency updates to break them.

The simplest tests that could happen would be unit tests to ensure the collector starts if given these as the starting configuration. The reference for testing this can be taken from

func TestStartCollector(t *testing.T) {
testCases := []struct {
configFile string
expectedErrorMessage string
}{
{
configFile: "all-components.yml",
expectedErrorMessage: "", // empty string means no error is expected
},
{
configFile: "nonexistent-component.yml",
expectedErrorMessage: `'extensions' unknown type: "zpages"`,
},
}
for _, tc := range testCases {
t.Run(tc.configFile, func(t *testing.T) {
configFiles := getConfigFiles(tc.configFile)
settings := NewSettings("test", configFiles)
collector, err := otelcol.NewCollector(*settings)
require.NoError(t, err)
require.NotNil(t, collector)
wg := startCollector(context.Background(), t, collector, tc.expectedErrorMessage)
if tc.expectedErrorMessage == "" {
assert.Eventually(t, func() bool {
return otelcol.StateRunning == collector.GetState()
}, 10*time.Second, 200*time.Millisecond)
}
collector.Shutdown()
wg.Wait()
assert.Equal(t, otelcol.StateClosed, collector.GetState())
})
}
}
where the modification would be to conditionally use the configuration based on the current GOOS. Our unit tests run on each of Linux, Windows, and Darwin already.

Further validation could be done using an integration test to make sure they ship the expected data, but this only supports Linux and Windows right now.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions