Skip to content

Commit 433e146

Browse files
test(procmgr): restore PAR Windows E2E with LocalSystem procmgr
Re-add the test dropped from #54731. Agent-profile spawn for PAR requires dd-procmgr-service as LocalSystem (Wix change in this PR) to read the agent password from LSA.
1 parent 2bc4458 commit 433e146

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

test/new-e2e/tests/agent-runtimes/procmgr/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ load("//bazel/rules/go:dd_agent_go_test.bzl", "dd_agent_go_test")
33
dd_agent_go_test(
44
name = "procmgr_test",
55
srcs = [
6+
"par_procmgr_win_test.go",
67
"procmgr_common_test.go",
78
"procmgr_nix_test.go",
89
"procmgr_win_test.go",
@@ -16,6 +17,7 @@ dd_agent_go_test(
1617
"//test/e2e-framework/testing/environments",
1718
"//test/e2e-framework/testing/provisioners/aws/host",
1819
"//test/e2e-framework/testing/utils/e2e/client/agentclient",
20+
"//test/new-e2e/tests/privateactionrunner",
1921
"//test/new-e2e/tests/windows/common/agent",
2022
"@com_github_pulumi_pulumi_sdk_v3//go/pulumi",
2123
"@com_github_stretchr_testify//assert",
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed
2+
// under the Apache License Version 2.0.
3+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
// Copyright 2016-present Datadog, Inc.
5+
6+
package procmgr
7+
8+
import (
9+
"fmt"
10+
"path/filepath"
11+
"strings"
12+
"testing"
13+
"time"
14+
15+
"github.com/stretchr/testify/assert"
16+
"github.com/stretchr/testify/require"
17+
18+
"github.com/DataDog/datadog-agent/test/e2e-framework/components/datadog/agentparams"
19+
e2eos "github.com/DataDog/datadog-agent/test/e2e-framework/components/os"
20+
"github.com/DataDog/datadog-agent/test/e2e-framework/scenarios/aws/ec2"
21+
"github.com/DataDog/datadog-agent/test/e2e-framework/testing/e2e"
22+
"github.com/DataDog/datadog-agent/test/e2e-framework/testing/environments"
23+
awshost "github.com/DataDog/datadog-agent/test/e2e-framework/testing/provisioners/aws/host"
24+
paridentity "github.com/DataDog/datadog-agent/test/new-e2e/tests/privateactionrunner"
25+
windowsagent "github.com/DataDog/datadog-agent/test/new-e2e/tests/windows/common/agent"
26+
)
27+
28+
const (
29+
parProcessName = "datadog-agent-action"
30+
parLegacySCMServiceName = "datadog-agent-action"
31+
parProcmgrConfigFileName = "datadog-agent-action.yaml"
32+
)
33+
34+
type parProcmgrWindowsSuite struct {
35+
e2e.BaseSuite[environments.Host]
36+
}
37+
38+
func TestPARManagedByProcmgrWindows(t *testing.T) {
39+
t.Parallel()
40+
config := paridentity.GenerateTestPrivateActionRunnerConfig(t)
41+
e2e.Run(t, &parProcmgrWindowsSuite{}, e2e.WithProvisioner(
42+
awshost.ProvisionerNoFakeIntake(
43+
awshost.WithRunOptions(
44+
ec2.WithEC2InstanceOptions(ec2.WithOS(e2eos.WindowsServerDefault), ec2.WithInternetAccess()),
45+
ec2.WithAgentOptions(agentparams.WithAgentConfig(config)),
46+
),
47+
),
48+
))
49+
}
50+
51+
func (s *parProcmgrWindowsSuite) TestPARSupervisedByProcmgrAndLegacySCMStopped() {
52+
host := s.Env().RemoteHost
53+
installRoot, err := windowsagent.GetInstallPathFromRegistry(host)
54+
require.NoError(s.T(), err)
55+
56+
parBin := filepath.Join(installRoot, "bin", "agent", "privateactionrunner.exe")
57+
exists, err := host.FileExists(parBin)
58+
require.NoError(s.T(), err)
59+
if !exists {
60+
s.T().Skip("privateactionrunner.exe not installed; skipping PAR procmgr test")
61+
}
62+
63+
cfg := filepath.Join(installRoot, "processes.d", parProcmgrConfigFileName)
64+
exists, err = host.FileExists(cfg)
65+
require.NoError(s.T(), err)
66+
require.True(s.T(), exists, "fleet PAR processes.d config should exist at %s", cfg)
67+
68+
cli := filepath.Join(installRoot, "bin", "agent", "dd-procmgr.exe")
69+
require.EventuallyWithT(s.T(), func(ct *assert.CollectT) {
70+
out, err := host.Execute(fmt.Sprintf(`& "%s" describe %s`, cli, parProcessName))
71+
assert.NoError(ct, err)
72+
assert.Contains(ct, out, "State")
73+
assert.Contains(ct, out, "Running")
74+
}, 120*time.Second, 3*time.Second)
75+
76+
out, err := host.Execute(fmt.Sprintf(
77+
`$s = Get-Service -Name '%s' -ErrorAction SilentlyContinue; if ($null -eq $s) { 'Absent' } else { $s.Status }`,
78+
parLegacySCMServiceName,
79+
))
80+
require.NoError(s.T(), err)
81+
require.NotEqual(s.T(), "Running", strings.TrimSpace(out),
82+
"%s Windows service must not be Running when PAR is managed by dd-procmgr", parLegacySCMServiceName)
83+
}

0 commit comments

Comments
 (0)