From 77e6fad02b7ceeeea6bba888949cf7d7437610ba Mon Sep 17 00:00:00 2001 From: Kevin Fairise <132568982+KevinFairise2@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:42:06 +0200 Subject: [PATCH] Mark windows security agent test as flaky and log output (#29029) --- .../security_agent_test.go | 9 ++++++--- test/new-e2e/tests/windows/remoteexecutable.go | 17 +++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/test/new-e2e/tests/security-agent-functional/security_agent_test.go b/test/new-e2e/tests/security-agent-functional/security_agent_test.go index 283e622f4c913a..6606c33a6d6002 100644 --- a/test/new-e2e/tests/security-agent-functional/security_agent_test.go +++ b/test/new-e2e/tests/security-agent-functional/security_agent_test.go @@ -12,15 +12,17 @@ import ( "testing" "time" + componentsos "github.com/DataDog/test-infra-definitions/components/os" + "github.com/DataDog/test-infra-definitions/scenarios/aws/ec2" + "github.com/stretchr/testify/require" + + "github.com/DataDog/datadog-agent/pkg/util/testutil/flake" "github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e" "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments" awshost "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments/aws/host" "github.com/DataDog/datadog-agent/test/new-e2e/tests/windows" windowsCommon "github.com/DataDog/datadog-agent/test/new-e2e/tests/windows/common" windowsAgent "github.com/DataDog/datadog-agent/test/new-e2e/tests/windows/common/agent" - componentsos "github.com/DataDog/test-infra-definitions/components/os" - "github.com/DataDog/test-infra-definitions/scenarios/aws/ec2" - "github.com/stretchr/testify/require" ) type vmSuite struct { @@ -34,6 +36,7 @@ var ( ) func TestVMSuite(t *testing.T) { + flake.Mark(t) suiteParams := []e2e.SuiteOption{e2e.WithProvisioner(awshost.ProvisionerNoAgentNoFakeIntake(awshost.WithEC2InstanceOptions(ec2.WithOS(componentsos.WindowsDefault))))} if *devMode { suiteParams = append(suiteParams, e2e.WithDevMode()) diff --git a/test/new-e2e/tests/windows/remoteexecutable.go b/test/new-e2e/tests/windows/remoteexecutable.go index 680dea998e3cb1..e9895b04fb3568 100644 --- a/test/new-e2e/tests/windows/remoteexecutable.go +++ b/test/new-e2e/tests/windows/remoteexecutable.go @@ -11,8 +11,10 @@ import ( "strings" "testing" - "github.com/DataDog/datadog-agent/test/new-e2e/pkg/components" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/DataDog/datadog-agent/test/new-e2e/pkg/components" ) // RemoteExecutable is a helper struct to run tests on a remote host @@ -138,15 +140,18 @@ func executeAndLogOutput(t *testing.T, vm *components.RemoteHost, command string outfilename := command + ".out" fullcommand := "cd " + cmdDir + ";" fullcommand += command + " " + strings.Join(args, " ") + " | Out-File -Encoding ASCII -FilePath " + outfilename - _, err := vm.Execute(fullcommand) - require.NoError(t, err) + _, testErr := vm.Execute(fullcommand) // get the output outbytes, err := vm.ReadFile(outfilename) - require.NoError(t, err) // log the output - for _, line := range strings.Split(string(outbytes[:]), "\n") { - t.Logf("TestSuite: %s", line) + if assert.NoError(t, err) { + for _, line := range strings.Split(string(outbytes[:]), "\n") { + t.Logf("TestSuite: %s", line) + } } + + require.NoError(t, testErr) + }