diff --git a/test/new-e2e/tests/agent-subcommands/health/health_win_test.go b/test/new-e2e/tests/agent-subcommands/health/health_win_test.go index 0bc152a9818c5..a288c25e5d160 100644 --- a/test/new-e2e/tests/agent-subcommands/health/health_win_test.go +++ b/test/new-e2e/tests/agent-subcommands/health/health_win_test.go @@ -7,6 +7,7 @@ package health import ( "testing" + "time" "github.com/DataDog/datadog-agent/test/fakeintake/api" "github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e" @@ -15,6 +16,7 @@ import ( "github.com/DataDog/test-infra-definitions/components/os" "github.com/DataDog/test-infra-definitions/scenarios/aws/ec2" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) type windowsHealthSuite struct { @@ -38,11 +40,10 @@ func (v *windowsHealthSuite) TestDefaultInstallUnhealthy() { v.UpdateEnv(awshost.Provisioner(awshost.WithEC2InstanceOptions(ec2.WithOS(os.WindowsDefault)), awshost.WithAgentOptions(agentparams.WithAgentConfig("log_level: info\n")))) - // agent should be unhealthy because the key is invalid - _, err := v.Env().Agent.Client.Health() - if err == nil { - assert.Fail(v.T(), "agent expected to be unhealthy, but no error found!") - return - } - assert.Contains(v.T(), err.Error(), "Agent health: FAIL") + require.EventuallyWithT(v.T(), func(collect *assert.CollectT) { + // forwarder should be unhealthy because the key is invalid + _, err := v.Env().Agent.Client.Health() + assert.ErrorContains(collect, err, "Agent health: FAIL") + assert.ErrorContains(collect, err, "=== 1 unhealthy components ===\nforwarder") + }, time.Second*30, time.Second) }