Skip to content

Commit 7ad4370

Browse files
committed
Merge branch 'main' into rayz/v3-datadog-only-default
2 parents 72a1f64 + f86c193 commit 7ad4370

465 files changed

Lines changed: 14836 additions & 3297 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
name: run-windows-e2e
3+
description: Run Windows E2E tests (MSI install tests or Fleet Automation/installer tests) locally against AWS-provisioned VMs
4+
allowed-tools: Bash, Read, Glob, Grep, AskUserQuestion
5+
argument-hint: "[suite] [TestFunctionName] [--build release|pipeline|local] [--pipeline-id <id>] [--version <version>]"
6+
---
7+
8+
Run Windows E2E tests from `test/new-e2e/tests/windows/` or `test/new-e2e/tests/installer/windows/`.
9+
10+
Detailed reference material lives in `references/` next to this file — read the
11+
relevant one when a step calls for it rather than duplicating it here:
12+
13+
- [`references/setup.md`](references/setup.md) — prerequisites, `~/.test_infra_config.yaml`, dev mode
14+
- [`references/running.md`](references/running.md)`setup-env`, local builds, `go test` flags
15+
- [`references/vm-access.md`](references/vm-access.md) — connecting to a dev-mode VM (RDP/SSH)
16+
- [`references/troubleshooting.md`](references/troubleshooting.md) — test outputs, Pulumi locks, AWS profile
17+
18+
## Instructions
19+
20+
### Step 1 — Parse `$ARGUMENTS`
21+
22+
Determine:
23+
- **Suite**: which test suite to run (e.g. `install-test`, `service-test`, `agent-package`, `install-script`). If not provided, ask the user.
24+
- **Test function**: specific `TestXxx` function. Most suites expect exactly one test per run — ask the user which one if not specified.
25+
- **Artifact source**: `--build pipeline` (default), `--build local`, or `--build release`; pass `--pipeline-id <id>` through if given.
26+
- **Stable/previous version** (upgrade tests only): if the user specifies a version to upgrade *from*, plan a second `setup-env` run with `--prefix STABLE_AGENT` in Step 3 (see [`references/running.md`](references/running.md) "Upgrade tests").
27+
- **Branch**: if the user mentions a branch ("from main"), pass `--branch <name>` to `setup-env`. The default is the current git branch, which may have no pipelines if it's a local feature branch.
28+
29+
Map suite names to Go package paths:
30+
31+
| Suite | Package path |
32+
|-------|-------------|
33+
| `install-test` | `./test/new-e2e/tests/windows/install-test` |
34+
| `service-test` | `./test/new-e2e/tests/windows/service-test` |
35+
| `fips-test` | `./test/new-e2e/tests/windows/fips-test` |
36+
| `domain-test` | `./test/new-e2e/tests/windows/domain-test` |
37+
| installer / Fleet Automation (agent-package, install-script, install-exe, ddot, apm-inject, …) | `./test/new-e2e/tests/installer/windows` |
38+
39+
The installer / Fleet Automation tests are all one flat package (the
40+
`suites/<package>/` subdirectories were flattened in #47161) — pick the area by
41+
test function with `-run` (e.g. `TestAgentUpgrades`, `TestInstallScript`,
42+
`TestDDOTExtensionViaMSI`, `TestAPMInjectInstalls`).
43+
44+
If the user gives a partial name or test function, search with Glob/Grep under `test/new-e2e/tests/windows/` and `test/new-e2e/tests/installer/windows/` to resolve it.
45+
46+
### Step 2 — Check prerequisites
47+
48+
```bash
49+
test -f ~/.test_infra_config.yaml && echo "EXISTS" || echo "MISSING"
50+
pulumi version 2>/dev/null || echo "MISSING"
51+
```
52+
53+
If either is missing, offer to run `dda inv e2e.setup` and wait for the user to
54+
complete its interactive prompts. If prerequisites exist but `devMode` is not
55+
set, mention that `devMode: true` reuses VMs across runs (much faster for
56+
iterative development). Full detail in [`references/setup.md`](references/setup.md).
57+
58+
### Step 3 — Resolve artifact environment variables
59+
60+
Run `setup-env` with `--fmt json` to capture the required env vars (no shell
61+
`eval` needed — prepend the parsed pairs inline to `go test` in Step 5).
62+
63+
```bash
64+
# From a pipeline (most common)
65+
dda inv new-e2e-tests.setup-env --build pipeline --fmt json [--branch <branch>] [--pipeline-id <id>]
66+
67+
# From a local build (run `dda inv msi.build` first, + `msi.package-oci` for installer/OCI tests)
68+
dda inv new-e2e-tests.setup-env --build local --fmt json
69+
```
70+
71+
For upgrade tests, run a second time with `--prefix STABLE_AGENT` and merge the
72+
vars in. GitLab token handling, local-build details, and the `STABLE_AGENT`
73+
flow are in [`references/running.md`](references/running.md).
74+
75+
### Step 4 — Check for stale state (dev mode only)
76+
77+
If `devMode: true` and the user is rerunning, the previous VM may still have the
78+
agent installed. Ask whether they've cleaned up (MSI tests: uninstall the agent;
79+
installer tests: `datadog-installer.exe purge`). See
80+
[`references/running.md`](references/running.md) "Clean state between runs".
81+
82+
### Step 5 — Build and confirm the `go test` command
83+
84+
```bash
85+
go test -v -timeout 30m -tags test <package-path> -run <TestFunction>$
86+
```
87+
88+
Two rules to apply (rationale in [`references/running.md`](references/running.md)):
89+
anchor the `-run` regex with `$` at both suite and subtest level, and use the
90+
exact package path with **no trailing `/...`** (or output won't stream).
91+
92+
Show the full command to the user and confirm before running.
93+
94+
### Step 6 — Run the test
95+
96+
Warn the user that AWS SSO auth may open a browser window when the test starts
97+
(the test pauses until login completes), and that a non-sandbox `AWS_PROFILE`
98+
will cause auth errors — advise `unset AWS_PROFILE`.
99+
100+
Run with `run_in_background: true` since tests provision real AWS VMs.
101+
Provisioning takes a few minutes; once the VM is up, SSH becomes available
102+
within ~60s (Linux) / ~180s (Windows). If SSH is not available within those
103+
windows, troubleshoot before assuming the test is still running normally
104+
(see [`references/vm-access.md`](references/vm-access.md)).
105+
106+
### Step 7 — Report results
107+
108+
When the test completes:
109+
- Report pass/fail.
110+
- On failure, point the user to `~/e2e-output/latest/` (crash dumps, agent/installer logs, event logs). If `devMode` is on, the VM is still up — offer to help RDP/SSH in via [`references/vm-access.md`](references/vm-access.md).
111+
- For Pulumi lock errors or AWS auth errors, see [`references/troubleshooting.md`](references/troubleshooting.md).
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Artifacts & running — Windows E2E Tests
2+
3+
How to resolve which MSI/OCI package the tests use, and how to invoke
4+
`go test`. See [setup.md](setup.md) for one-time environment setup.
5+
6+
## Setting up artifact environment variables
7+
8+
Windows tests need to know which MSI and/or OCI package to use. The `setup-env`
9+
helper configures the required environment variables. Use `--fmt json` when
10+
driving it programmatically (parse the `"VAR": "value"` map and prepend the
11+
pairs inline to `go test`); use `--fmt powershell | Invoke-Expression` or
12+
`eval "$(...)"` for an interactive shell.
13+
14+
### From a pipeline (most common)
15+
16+
Auto-detects the most recent successful pipeline on the current branch. Add
17+
`--branch main` to target `main` instead — useful when the current branch is a
18+
local feature branch with no pipelines. Add `--pipeline-id <id>` to pin a
19+
specific pipeline.
20+
21+
```bash
22+
# Programmatic (skill default): parse the "VAR": "value" map, prepend inline to `go test`
23+
dda inv new-e2e-tests.setup-env --build pipeline --fmt json [--branch <branch>] [--pipeline-id <id>]
24+
25+
# Interactive shell — PowerShell
26+
dda inv new-e2e-tests.setup-env --build pipeline --fmt powershell | Invoke-Expression
27+
28+
# Interactive shell — Bash/WSL
29+
eval "$(dda inv new-e2e-tests.setup-env --build pipeline)"
30+
```
31+
32+
The task auto-resolves a GitLab token via `ddtool` if configured. If that fails
33+
it asks for `GITLAB_TOKEN`; retry with `GITLAB_TOKEN=<token> dda inv new-e2e-tests.setup-env ...`.
34+
35+
### From a local build
36+
37+
Build the MSI first (add `msi.package-oci` only for installer/OCI tests):
38+
39+
```bash
40+
dda inv msi.build # -> omnibus/pkg/datadog-agent-<version>-x86_64.msi
41+
dda inv msi.package-oci # -> omnibus/pkg/datadog-agent-<version>-windows-amd64.oci.tar
42+
dda inv new-e2e-tests.setup-env --build local --fmt json
43+
```
44+
45+
### Upgrade tests (stable / previous version)
46+
47+
Upgrade tests need a second package resolved under the `STABLE_AGENT_` prefix.
48+
Run `setup-env` again with `--prefix STABLE_AGENT --build <mode>` (same modes:
49+
`pipeline`, `local`, `release`) plus any relevant `--version` / `--pipeline-id`
50+
flags, and merge those vars in, overriding the first run's defaults.
51+
52+
The variables themselves are documented per suite — see
53+
`test/new-e2e/tests/windows/AGENTS.md` ("Package resolution") and
54+
`test/new-e2e/tests/installer/windows/AGENTS.md` ("Package resolution").
55+
56+
## Running a specific suite
57+
58+
```bash
59+
go test -v -timeout 30m -tags test <package-path> -run <TestFunction>$
60+
```
61+
62+
Two rules that are easy to get wrong:
63+
64+
- **Anchor the `-run` regex with `$`**, at both the suite and subtest level. The
65+
flag is a Go regex; without the anchor `TestInstall` also matches
66+
`TestInstallOpts`/`TestInstallFail`, and `TestUpgradeAgentPackage` also
67+
matches `TestUpgradeAgentPackageOCIBootstrap`.
68+
- **Use the exact package path, no trailing `/...`.** With `/...` Go buffers all
69+
output per-package and prints it only when the package finishes, making the
70+
test look silent. Without it, output streams live.
71+
72+
Examples:
73+
74+
```bash
75+
# MSI install test
76+
go test -v -timeout 30m -tags test ./test/new-e2e/tests/windows/install-test -run TestInstall$
77+
78+
# Service lifecycle test
79+
go test -v -timeout 30m -tags test ./test/new-e2e/tests/windows/service-test -run TestServiceBehaviorPowerShell$
80+
81+
# Fleet Automation — agent package, specific subtest
82+
go test -v -timeout 30m -tags test ./test/new-e2e/tests/installer/windows -run "TestAgentUpgrades$/TestUpgradeAgentPackage$"
83+
```
84+
85+
See each suite's `AGENTS.md` for the full list of test functions and the CI job
86+
names that map to them.
87+
88+
AWS SSO authentication may open a browser window when the test starts; the test
89+
pauses until login completes. This is expected. If `AWS_PROFILE` is set to a
90+
non-sandbox profile it causes auth errors — see [troubleshooting.md](troubleshooting.md).
91+
92+
## Clean state between runs
93+
94+
Most tests install the agent as part of the test and expect a clean starting
95+
state, so run them one at a time. In dev mode (reused VM), clean up between runs
96+
so state does not leak:
97+
98+
- **MSI install tests** (`install-test/`, `domain-test/`, `fips-test/`):
99+
uninstall via Add/Remove Programs or `MsiExec.exe /x {product-code}` on the VM.
100+
- **Installer / Fleet Automation tests** (`installer/windows/`): run
101+
`datadog-installer.exe purge` on the VM.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Setup — Windows E2E Tests
2+
3+
One-time environment setup for running Windows E2E tests locally. Applies to
4+
both MSI install tests (`test/new-e2e/tests/windows/`) and Fleet Automation /
5+
installer tests (`test/new-e2e/tests/installer/windows/`).
6+
7+
## Prerequisites
8+
9+
Follow the general E2E setup guide first:
10+
[docs/public/how-to/test/e2e.md](../../../../docs/public/how-to/test/e2e.md).
11+
It covers AWS `agent-sandbox` account access, `aws-vault` setup, the
12+
`PULUMI_CONFIG_PASSPHRASE` requirement, and required tooling (Go, Python,
13+
`dda`).
14+
15+
The Windows tests provision real AWS EC2 Windows instances and require the same
16+
AWS access as all other E2E tests. Without valid AWS credentials and
17+
`PULUMI_CONFIG_PASSPHRASE` set, the run fails before any test code executes.
18+
19+
`dda inv e2e.setup` (defined in `tasks/e2e_framework/setup/`) walks through this
20+
interactively: it validates CLI tools, installs Pulumi if missing, prompts for
21+
AWS keypair paths, Datadog API key, and Pulumi passphrase, then writes
22+
`~/.test_infra_config.yaml`.
23+
24+
## Persistent configuration
25+
26+
Most run parameters are easier to set once in `~/.test_infra_config.yaml` than
27+
as environment variables each session. Relevant fields:
28+
29+
- AWS keypair paths (`privateKeyPath` is also the SSH key — see
30+
[vm-access.md](vm-access.md))
31+
- Datadog API key — **required**; the agent MSI install needs a valid key
32+
- Pulumi passphrase — alternative to the `PULUMI_CONFIG_PASSPHRASE` env var
33+
- `devMode` — see below
34+
35+
## Dev mode
36+
37+
By default each run provisions a fresh VM and destroys it afterwards, which
38+
makes local test-fix-rerun loops slow. Set `devMode: true` in
39+
`~/.test_infra_config.yaml` to reuse the same VM across runs. The VM is
40+
identified by the Pulumi stack name, derived from the test package and suite
41+
name.
42+
43+
Per-run alternative:
44+
45+
```bash
46+
E2E_DEV_MODE=true go test -v -timeout 30m -tags test ./test/new-e2e/tests/windows/install-test -run TestInstall$
47+
```
48+
49+
Or in VSCode:
50+
51+
```json
52+
"go.testEnvVars": { "E2E_DEV_MODE": "true" }
53+
```
54+
55+
When reusing a VM, clean up the agent between runs so state does not leak — see
56+
[running.md](running.md) ("Clean state between runs").
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Troubleshooting — Windows E2E Tests
2+
3+
## Test outputs
4+
5+
Test output files (logs, crash dumps, event logs, agent logs) are written via
6+
`runner.GetProfile().CreateOutputSubDir()` to:
7+
8+
```
9+
~/e2e-output/<suite-name>/<timestamp>/
10+
~/e2e-output/latest/ ← symlink to the most recent run
11+
```
12+
13+
When a test fails, the suite's `AfterTest` hook automatically collects
14+
diagnostics into the output directory — WER crash dumps, Windows event logs
15+
(`.evtx`), agent logs, and installer logs depending on the suite. Check
16+
`~/e2e-output/latest/` first when investigating a failure. If `devMode` is on,
17+
the VM is still up — connect to it via [vm-access.md](vm-access.md).
18+
19+
In CI, outputs are stored as GitLab job artifacts, accessible from the job's
20+
artifact browser in the pipeline UI.
21+
22+
## Pulumi lock errors
23+
24+
If you see `error: the stack is currently locked by 1 lock(s)`:
25+
26+
```bash
27+
dda inv new-e2e-tests.clean # remove local Pulumi locks
28+
dda inv new-e2e-tests.clean -s # also clean local stack state
29+
dda inv new-e2e-tests.clean --output # clear local test output
30+
```
31+
32+
If cleanup reports "Cleanup supported for local state only":
33+
34+
```bash
35+
pulumi login --local
36+
```
37+
38+
## AWS account / profile
39+
40+
Local runs must use the `agent-sandbox` AWS account (CI uses `agent-qa`). The
41+
e2e framework automatically uses the `sso-agent-sandbox-account-admin` profile,
42+
so no explicit `aws-vault` invocation is needed.
43+
44+
However, if `AWS_PROFILE` is already set to a different profile it overrides the
45+
automatic selection and causes auth errors. Unset it before running:
46+
47+
```bash
48+
unset AWS_PROFILE
49+
```
50+
51+
A common symptom of the wrong account:
52+
`User: arn:aws:sts::... is not authorized to perform: ecr:BatchGetImage`.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Accessing the test VM — Windows E2E Tests
2+
3+
When `devMode` is enabled (see [setup.md](setup.md)) the VM persists after the
4+
test, so you can RDP or SSH in to investigate.
5+
6+
## Find the stack name
7+
8+
Two ways:
9+
10+
- From test output: look for `Creating workspace for stack: user-e2e-<suitename>-<hash>`
11+
- From the CLI: `pulumi stack ls --all` — find the entry matching the suite name
12+
13+
Format: `user-e2e-<suitename-lowercase>-<hash>`.
14+
15+
## Get connection details
16+
17+
```bash
18+
pulumi stack --stack organization/e2elocal/<stack-name> output --json --show-secrets
19+
```
20+
21+
The output includes `address` (private IP), `username` (`Administrator`),
22+
`password`, and an `osFamily` integer. The OS family/flavor enum values are in
23+
`test/e2e-framework/components/os/const.go` (`WindowsFamily = 2`,
24+
`WindowsServer = 509`, `WindowsClient = 510`).
25+
26+
## RDP
27+
28+
```bash
29+
# Opens RDP, prints IP + password, copies password to clipboard
30+
dda inv aws.rdp-vm --stack-name <stack-name>
31+
```
32+
33+
`dda inv aws.show-vm` does **not** work for e2e test stacks — it is only for VMs
34+
created with `dda inv aws.create-vm` (it prepends the username twice and looks
35+
for the wrong output key, `"aws-vm"` instead of `"dd-Host-aws-vm"`).
36+
37+
## SSH
38+
39+
The SSH key is the `privateKeyPath` from `~/.test_infra_config.yaml`.
40+
41+
```bash
42+
ssh -i <privateKeyPath> -o StrictHostKeyChecking=no <username>@<ip> "<commands>"
43+
```
44+
45+
Pick the command separator from `osFamily` in the stack output:
46+
47+
- `osFamily: 1` = Linux → `&&` or `;` (bash)
48+
- `osFamily: 2` = Windows → `;` only (PowerShell over SSH; `&&` is invalid)
49+
50+
### SSH availability
51+
52+
SSH should be reachable within ~60s for Linux VMs and ~180s for Windows VMs
53+
after the VM is provisioned. If it takes longer:
54+
55+
- Make sure the key is loaded in your SSH agent (`ssh-add -l`) or pass `-i`
56+
explicitly.
57+
- Verify the keypair name in `~/.test_infra_config.yaml` matches the AWS key
58+
pair used to provision the VM — a mismatch means the wrong public key was
59+
injected and authentication will always fail.

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
/.claude/skills/review-pr-comments/ @DataDog/agent-devx
4040
/.claude/skills/run-e2e/ @DataDog/agent-devx
4141
/.claude/skills/run-jira/ @DataDog/agent-devx
42+
/.claude/skills/run-windows-e2e/ @DataDog/windows-products
4243
/.claude/skills/update-3rd-party-libs @DataDog/agent-build
4344
/.claude/skills/update-otel-deps/ @DataDog/opentelemetry-agent
4445
/.claude/skills/write-e2e/ @DataDog/agent-devx
@@ -456,6 +457,7 @@
456457
# Per-team ownership of individual event platform pipeline descriptor files.
457458
# Each file holds the passthroughPipelineDesc entries for one owning team so
458459
# that teams can merge pipeline config changes without Logs team review.
460+
/comp/forwarder/eventplatform/impl/pipelines_agentdiscovery.go @DataDog/agent-discovery
459461
/comp/forwarder/eventplatform/impl/pipelines_dbm.go @DataDog/database-monitoring
460462
/comp/forwarder/eventplatform/impl/pipelines_ndm_core.go @DataDog/network-device-monitoring-core
461463
/comp/forwarder/eventplatform/impl/pipelines_ndm_integrations.go @DataDog/ndm-integrations

0 commit comments

Comments
 (0)