Skip to content

Commit

Permalink
fix: do not check return value in case of error (#24019)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgimalac authored Mar 22, 2024
1 parent 92f92e3 commit 5136441
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

type baseConfigCheckSuite struct {
Expand Down Expand Up @@ -80,23 +81,27 @@ Config for instance ID: cpu:e331d61ed1323219
~
===`

result, err := MatchCheckToTemplate("uptime", sampleCheck)
assert.NoError(t, err)

assert.Contains(t, result.CheckName, "uptime")
assert.Contains(t, result.Filepath, "file:/etc/datadog-agent/conf.d/uptime.d/conf.yaml.default")
assert.Contains(t, result.InstanceID, "uptime:c72f390abdefdf1a")
assert.Contains(t, result.Settings, "key: value")
assert.Contains(t, result.Settings, "path: http://example.com/foo")
assert.NotContains(t, result.Settings, "{}")

result, err = MatchCheckToTemplate("cpu", sampleCheck)
assert.NoError(t, err)

assert.Contains(t, result.CheckName, "cpu")
assert.Contains(t, result.Filepath, "file:/etc/datadog-agent/conf.d/cpu.d/conf.yaml.default")
assert.Contains(t, result.InstanceID, "cpu:e331d61ed1323219")
assert.Contains(t, result.Settings, "{}")
t.Run("uptime", func(t *testing.T) {
result, err := MatchCheckToTemplate("uptime", sampleCheck)
require.NoError(t, err)

assert.Contains(t, result.CheckName, "uptime")
assert.Contains(t, result.Filepath, "file:/etc/datadog-agent/conf.d/uptime.d/conf.yaml.default")
assert.Contains(t, result.InstanceID, "uptime:c72f390abdefdf1a")
assert.Contains(t, result.Settings, "key: value")
assert.Contains(t, result.Settings, "path: http://example.com/foo")
assert.NotContains(t, result.Settings, "{}")
})

t.Run("cpu", func(t *testing.T) {
result, err := MatchCheckToTemplate("cpu", sampleCheck)
require.NoError(t, err)

assert.Contains(t, result.CheckName, "cpu")
assert.Contains(t, result.Filepath, "file:/etc/datadog-agent/conf.d/cpu.d/conf.yaml.default")
assert.Contains(t, result.InstanceID, "cpu:e331d61ed1323219")
assert.Contains(t, result.Settings, "{}")
})
}

func VerifyDefaultInstalledCheck(t *testing.T, output string, testChecks []CheckConfigOutput) {
Expand All @@ -105,7 +110,7 @@ func VerifyDefaultInstalledCheck(t *testing.T, output string, testChecks []Check
for _, testCheck := range testChecks {
t.Run(fmt.Sprintf("default - %s test", testCheck.CheckName), func(t *testing.T) {
result, err := MatchCheckToTemplate(testCheck.CheckName, output)
assert.NoError(t, err)
require.NoError(t, err)
assert.Contains(t, result.Filepath, testCheck.Filepath)
assert.Contains(t, result.InstanceID, testCheck.InstanceID)
assert.Contains(t, result.Settings, testCheck.Settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ package configcheck
import (
"testing"

"github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e"
awshost "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments/aws/host"
"github.com/DataDog/test-infra-definitions/components/datadog/agentparams"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e"
awshost "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments/aws/host"
)

type linuxConfigCheckSuite struct {
Expand Down Expand Up @@ -109,7 +111,7 @@ func (v *linuxConfigCheckSuite) TestWithAddedIntegrationsCheck() {
output := v.Env().Agent.Client.ConfigCheck()

result, err := MatchCheckToTemplate("http_check", output)
assert.NoError(v.T(), err)
require.NoError(v.T(), err)
assert.Contains(v.T(), result.Filepath, "file:/etc/datadog-agent/conf.d/http_check.d/conf.yaml")
assert.Contains(v.T(), result.InstanceID, "http_check:")
assert.Contains(v.T(), result.Settings, "name: My First Service")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ package configcheck
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e"
awshost "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments/aws/host"
"github.com/stretchr/testify/assert"

"github.com/DataDog/test-infra-definitions/components/datadog/agentparams"
"github.com/DataDog/test-infra-definitions/components/os"
Expand Down Expand Up @@ -112,7 +114,7 @@ func (v *windowsConfigCheckSuite) TestWithAddedIntegrationsCheck() {
output := v.Env().Agent.Client.ConfigCheck()

result, err := MatchCheckToTemplate("http_check", output)
assert.NoError(v.T(), err)
require.NoError(v.T(), err)
assert.Contains(v.T(), result.Filepath, "file:C:\\ProgramData\\Datadog\\conf.d\\http_check.d\\conf.yaml")
assert.Contains(v.T(), result.InstanceID, "http_check:")
assert.Contains(v.T(), result.Settings, "name: My First Service")
Expand Down

0 comments on commit 5136441

Please sign in to comment.