-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[windows][e2e] Port security agent functional tests to e2e (#27611)
- Loading branch information
1 parent
1296242
commit bec830a
Showing
4 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
test/new-e2e/tests/security-agent-functional/security_agent_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
package secagentfunctional | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"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 { | ||
e2e.BaseSuite[environments.Host] | ||
|
||
testspath string | ||
} | ||
|
||
var ( | ||
devMode = flag.Bool("devmode", false, "run tests in dev mode") | ||
) | ||
|
||
func TestVMSuite(t *testing.T) { | ||
suiteParams := []e2e.SuiteOption{e2e.WithProvisioner(awshost.ProvisionerNoAgentNoFakeIntake(awshost.WithEC2InstanceOptions(ec2.WithOS(componentsos.WindowsDefault))))} | ||
if *devMode { | ||
suiteParams = append(suiteParams, e2e.WithDevMode()) | ||
} | ||
|
||
e2e.Run(t, &vmSuite{}, suiteParams...) | ||
} | ||
|
||
func (v *vmSuite) SetupSuite() { | ||
t := v.T() | ||
|
||
// Get the absolute path to the test assets directory | ||
currDir, err := os.Getwd() | ||
require.NoError(t, err) | ||
|
||
reporoot, _ := filepath.Abs(filepath.Join(currDir, "..", "..", "..", "..")) | ||
kitchenDir := filepath.Join(reporoot, "test", "kitchen", "site-cookbooks") | ||
v.testspath = filepath.Join(kitchenDir, "dd-security-agent-check", "files", "tests") | ||
} | ||
|
||
func (v *vmSuite) TestSystemProbeCWSSuite() { | ||
v.BaseSuite.SetupSuite() | ||
t := v.T() | ||
// get the remote host | ||
vm := v.Env().RemoteHost | ||
|
||
rs := windows.NewRemoteExecutable(vm, t, "testsuite.exe", v.testspath) | ||
err := rs.FindTestPrograms() | ||
require.NoError(t, err) | ||
|
||
err = rs.CreateRemotePaths() | ||
require.NoError(t, err) | ||
|
||
err = rs.CopyFiles() | ||
require.NoError(t, err) | ||
|
||
// install the agent (just so we can get the driver(s) installed) | ||
agentPackage, err := windowsAgent.GetPackageFromEnv() | ||
require.NoError(t, err) | ||
remoteMSIPath, err := windowsCommon.GetTemporaryFile(vm) | ||
require.NoError(t, err) | ||
t.Logf("Getting install package %s...", agentPackage.URL) | ||
err = windowsCommon.PutOrDownloadFile(vm, agentPackage.URL, remoteMSIPath) | ||
require.NoError(t, err) | ||
|
||
err = windowsCommon.InstallMSI(vm, remoteMSIPath, "", "") | ||
t.Log("Install complete") | ||
require.NoError(t, err) | ||
|
||
time.Sleep(30 * time.Second) | ||
// disable the agent, and enable the drivers for testing | ||
_, err = vm.Execute("stop-service -force datadogagent") | ||
require.NoError(t, err) | ||
_, err = vm.Execute("sc.exe config datadogagent start= disabled") | ||
require.NoError(t, err) | ||
_, err = vm.Execute("sc.exe config ddnpm start= demand") | ||
require.NoError(t, err) | ||
_, err = vm.Execute("start-service ddnpm") | ||
require.NoError(t, err) | ||
|
||
rs.RunTests("5m") // security agent tests can take a while waiting for ETW to start. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters