diff --git a/internal/pkg/agent/application/coordinator/coordinator_unit_test.go b/internal/pkg/agent/application/coordinator/coordinator_unit_test.go index 5dae078653b..5c56ccc6d48 100644 --- a/internal/pkg/agent/application/coordinator/coordinator_unit_test.go +++ b/internal/pkg/agent/application/coordinator/coordinator_unit_test.go @@ -942,6 +942,7 @@ service: configChan <- cfgChange coord.runLoopIteration(ctx) assert.True(t, cfgChange.acked, "empty policy should be acknowledged") + assert.NoError(t, cfgChange.err, "config processing shouldn't report an error") assert.True(t, updated, "empty policy should cause runtime manager update") assert.Empty(t, components, "empty policy should produce empty component model") assert.True(t, otelUpdated, "empty policy should cause otel manager update") @@ -1052,11 +1053,20 @@ service: - nop `) +<<<<<<< HEAD // Send the policy change and make sure it was acknowledged. cfgChange := &configChange{cfg: cfg} configChan <- cfgChange coord.runLoopIteration(ctx) assert.True(t, cfgChange.acked, "Coordinator should ACK a successful policy change") +======= + // Send the policy change and make sure it was acknowledged. + cfgChange := &configChange{cfg: cfg} + configChan <- cfgChange + coord.runLoopIteration(ctx) + assert.True(t, cfgChange.acked, "Coordinator should ACK a successful policy change") + assert.NoError(t, cfgChange.err, "config processing shouldn't report an error") +>>>>>>> 0ba2ea683 (Check for config processing errors in coordinator unit tests (#10203)) // Make sure the runtime manager received the expected component update. // An assert.Equal on the full component model doesn't play nice with @@ -1073,12 +1083,75 @@ service: assert.Equal(t, "input not supported", runtimeComponent.Err.Error(), "Input with no spec should report 'input not supported'") require.Equal(t, 2, len(runtimeComponent.Units)) +<<<<<<< HEAD units := runtimeComponent.Units // Verify the input unit assert.Equal(t, "system/metrics-default-test-other-input", units[0].ID) assert.Equal(t, client.UnitTypeInput, units[0].Type) assert.Equal(t, "test-other-input", units[0].Config.Id) assert.Equal(t, "system/metrics", units[0].Config.Type) +======= + units := runtimeComponent.Units + // Verify the input unit + assert.Equal(t, "system/metrics-default-test-other-input", units[0].ID) + assert.Equal(t, client.UnitTypeInput, units[0].Type) + assert.Equal(t, "test-other-input", units[0].Config.Id) + assert.Equal(t, "system/metrics", units[0].Config.Type) + + // Verify the output unit + assert.Equal(t, "system/metrics-default", units[1].ID) + assert.Equal(t, client.UnitTypeOutput, units[1].Type) + assert.Equal(t, "elasticsearch", units[1].Config.Type) + }) + + t.Run("unsupported otel output option", func(t *testing.T) { + // Create a policy with one input and one output (no otel configuration) + cfg := config.MustNewConfigFrom(` +outputs: + default: + type: elasticsearch + hosts: + - localhost:9200 + indices: [] # not supported by the elasticsearch exporter +inputs: + - id: test-input + type: filestream + use_output: default + _runtime_experimental: otel + - id: test-other-input + type: system/metrics + use_output: default +receivers: + nop: +exporters: + nop: +service: + pipelines: + traces: + receivers: + - nop + exporters: + - nop +`) + + // Send the policy change and make sure it was acknowledged. + cfgChange := &configChange{cfg: cfg} + configChan <- cfgChange + coord.runLoopIteration(ctx) + assert.True(t, cfgChange.acked, "Coordinator should ACK a successful policy change") + assert.NoError(t, cfgChange.err, "config processing shouldn't report an error") + + // Make sure the runtime manager received the expected component update. + // An assert.Equal on the full component model doesn't play nice with + // the embedded proto structs, so instead we verify the important fields + // manually (sorry). + assert.True(t, updated, "Runtime manager should be updated after a policy change") + assert.True(t, otelUpdated, "OTel manager should be updated after a policy change") + require.NotNil(t, otelConfig, "OTel manager should have config") + + assert.Len(t, components, 2, "both components should be assigned to the runtime manager") + }) +>>>>>>> 0ba2ea683 (Check for config processing errors in coordinator unit tests (#10203)) // Verify the output unit assert.Equal(t, "system/metrics-default", units[1].ID)