- 
                Notifications
    
You must be signed in to change notification settings  - Fork 198
 
Open
Labels
Team:Elastic-Agent-Control-PlaneLabel for the Agent Control Plane teamLabel for the Agent Control Plane team
Description
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
elastic-agent/internal/pkg/otel/run_nofips_test.go
Lines 19 to 55 in d6c6064
| 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()) | |
| }) | |
| } | |
| } | 
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
Labels
Team:Elastic-Agent-Control-PlaneLabel for the Agent Control Plane teamLabel for the Agent Control Plane team