Skip to content

Commit

Permalink
better error lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
chouetz committed Nov 20, 2024
1 parent e7b60a9 commit ba6f8f4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/new-e2e/tests/agent-subcommands/health/health_win_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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)
}

0 comments on commit ba6f8f4

Please sign in to comment.