Skip to content

Commit e38251b

Browse files
mauri870mergify[bot]
authored andcommitted
fix(tests): use assert.CollectT in TestContainerCMDAgentMonitoringRuntimeExperimental (#11499)
Updates TestContainerCMDAgentMonitoringRuntimeExperimental to use the assert.CollectT instead of the testing.T inside require.EventuallyWithT. This prevents the code from failing on the first pass of require.EventuallyWithT. Now it retries transient assertion errors up to the timeout. (cherry picked from commit f32807c)
1 parent 8250d07 commit e38251b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

testing/integration/ess/container_cmd_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ func TestContainerCMDAgentMonitoringRuntimeExperimental(t *testing.T) {
531531
// Verify that components are using the expected runtime
532532
require.EventuallyWithTf(t, func(ct *assert.CollectT) {
533533
status, err := agentFixture.ExecStatus(ctx, atesting.WithCmdOptions(withEnv(env)))
534-
require.NoErrorf(t, err, "error getting agent status")
534+
require.NoErrorf(ct, err, "error getting agent status")
535535

536536
expectedComponentCount := 4 // process runtime
537537
if tc.expectedRuntimeName == string(monitoringCfg.OtelRuntimeManager) {
@@ -552,13 +552,13 @@ func TestContainerCMDAgentMonitoringRuntimeExperimental(t *testing.T) {
552552
switch comp.ID {
553553
case "beat/metrics-monitoring", "filestream-monitoring", "prometheus/metrics-monitoring":
554554
// Monitoring components should use the expected runtime
555-
assert.Equalf(t, tc.expectedRuntimeName, compRuntime, "expected correct runtime name for monitoring component %s with id %s", comp.Name, comp.ID)
555+
assert.Equalf(ct, tc.expectedRuntimeName, compRuntime, "expected correct runtime name for monitoring component %s with id %s", comp.Name, comp.ID)
556556
case "http/metrics-monitoring":
557557
// The comp.VersionInfo.Name for this component is empty at times.
558558
// See https://github.com/elastic/elastic-agent/issues/11162.
559559
default:
560560
// Non-monitoring components should use the default runtime
561-
assert.Equalf(t, string(component.DefaultRuntimeManager), compRuntime, "expected default runtime for non-monitoring component %s with id %s", comp.Name, comp.ID)
561+
assert.Equalf(ct, string(component.DefaultRuntimeManager), compRuntime, "expected default runtime for non-monitoring component %s with id %s", comp.Name, comp.ID)
562562
}
563563
}
564564
}, 1*time.Minute, 1*time.Second,
@@ -655,7 +655,7 @@ func TestContainerCMDAgentMonitoringRuntimeExperimentalPolicy(t *testing.T) {
655655
// Verify that components are using the expected runtime
656656
require.EventuallyWithTf(t, func(ct *assert.CollectT) {
657657
status, err := agentFixture.ExecStatus(ctx, atesting.WithCmdOptions(withEnv(env)))
658-
require.NoErrorf(t, err, "error getting agent status")
658+
require.NoErrorf(ct, err, "error getting agent status")
659659

660660
expectedComponentCount := 4 // process runtime
661661
if tc.expectedRuntimeName == string(monitoringCfg.OtelRuntimeManager) {
@@ -676,13 +676,13 @@ func TestContainerCMDAgentMonitoringRuntimeExperimentalPolicy(t *testing.T) {
676676
switch comp.ID {
677677
case "beat/metrics-monitoring", "filestream-monitoring", "prometheus/metrics-monitoring":
678678
// Monitoring components should use the expected runtime
679-
assert.Equalf(t, tc.expectedRuntimeName, compRuntime, "unexpected runtime name for monitoring component %s with id %s", comp.Name, comp.ID)
679+
assert.Equalf(ct, tc.expectedRuntimeName, compRuntime, "unexpected runtime name for monitoring component %s with id %s", comp.Name, comp.ID)
680680
case "http/metrics-monitoring":
681681
// The comp.VersionInfo.Name for this component is empty at times.
682682
// See https://github.com/elastic/elastic-agent/issues/11162.
683683
default:
684684
// Non-monitoring components should use the default runtime
685-
assert.Equalf(t, string(component.DefaultRuntimeManager), compRuntime, "expected default runtime for non-monitoring component %s with id %s", comp.Name, comp.ID)
685+
assert.Equalf(ct, string(component.DefaultRuntimeManager), compRuntime, "expected default runtime for non-monitoring component %s with id %s", comp.Name, comp.ID)
686686
}
687687
}
688688
}, 1*time.Minute, 1*time.Second,

0 commit comments

Comments
 (0)