Skip to content

Add Windows Azure VM integration test - #764

Merged
movence merged 5 commits into
mainfrom
hsookim/azure-vm-windows-integ-test
Sep 21, 2026
Merged

movence merged 5 commits into
mainfrom
hsookim/azure-vm-windows-integ-test

Conversation

@movence

@movence movence commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Description of the issue

The existing Azure VM integration test is Linux-only (azurerm_linux_virtual_machine, .deb installed over SSH). Windows-specific regressions in the MSI (e.g. a stale amazon-cloudwatch-agent-ctl.ps1) or Windows Azure -m auto detection (aws/amazon-cloudwatch-agent#2289) are therefore not caught by CI.

Description of changes

  • Restructure terraform/azure/vm into vm/linux (existing module, moved), vm/win (new), and vm/iam (shared child module for the IAM/OIDC setup both roots consume).
  • vm/win: Windows Server VM (azurerm_windows_virtual_machine), WinRM over 5986 restricted to the runner IP, MSI downloaded on the VM from a presigned S3 URL passed as agent_msi_url, msiexec install, then amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m auto -s -c default:otel (each ctl call fail-fast on non-zero exit), IMDS token minted in PowerShell, Go 1.22.9 installed, and go test -tags integration -computeType=AZUREVM -instancePlatform=windows.
  • test/azure/vm/azurevm_test.go uses common.AgentLogFile for the per-OS agent log path.
  • ReadAgentLogfile moved to a single untagged util/common/agent_util.go.
  • Removed the !windows build tag from test/status/test_result.go, test/status/test_status.go, and test/otel_collect/otlpvalidation/validate.go so they build for windows.

Testing

Worth noting

  • The MSI is downloaded on the VM via presigned URL rather than copied over WinRM: the WinRM file provisioner took >40 min for the ~70 MB MSI and hit the job timeout.
  • Go 1.22.9 (matching terraform/ec2/mac) rather than the go.mod 1.20 directive: util/otelmetrics imports log/slog (Go 1.21+), so 1.20 fails to compile the suite.
  • Must merge together with Add Windows Azure VM integration test job amazon-cloudwatch-agent#2296; the module move changes the Linux job's working-directory.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@movence
movence requested a review from a team as a code owner September 18, 2026 19:52
Add a new terraform/azure/vm-windows module that provisions a Windows
Server VM (azurerm_windows_virtual_machine), installs the agent MSI over
WinRM, and runs the real amazon-cloudwatch-agent-ctl.ps1 -a fetch-config
-m auto -s -c default:otel path. azurevm_test.go now selects the agent
log path per OS via common.AgentLogFile, and a Windows ReadAgentLogfile
implementation is added. Drop the !windows build tags from
test/status/{test_result,test_status}.go and otlpvalidation/validate.go
so those packages compile in the windows build.

The existing Azure VM test is Linux-only, so a stale ctl.ps1 in the MSI
or a Windows Azure -m auto detection bug is invisible to CI.
Calling amazon-cloudwatch-agent-ctl.ps1 with `& $ctl` invokes the script
in its own scope, so an `Exit 1` inside it returns control to the
bootstrap rather than terminating the WinRM session. A non-zero exit
from set-env or fetch-config was therefore ignored and the flow
continued straight into `go test`, where the real failure surfaced
later and far less clearly.

Check $LASTEXITCODE after each set-env and fetch-config call and throw
naming the failed action, so a ctl.ps1 error stops the bootstrap at its
source. This is fail-fast hardening, not a bug fix.
@movence
movence force-pushed the hsookim/azure-vm-windows-integ-test branch from aff3ed0 to 28f3426 Compare September 18, 2026 20:08
Comment thread test/azure/vm/azurevm_test.go Outdated
Comment thread util/common/agent_util_windows.go Outdated
Comment thread terraform/azure/vm/iam/main.tf
Inline common.AgentLogFile at its call sites and drop the package-level
agentLogFile var/comment in test/azure/vm.

Move ReadAgentLogfile into a new OS-agnostic util/common/agent_util.go
(it is a generic os.ReadFile) rather than duplicating it per build tag.

Restructure terraform/azure/vm into {linux,win} to mirror terraform/ec2,
extracting the shared IAM setup into an iam child module both roots consume.
movence added a commit to aws/amazon-cloudwatch-agent that referenced this pull request Sep 20, 2026
Point the two Azure VM jobs at the restructured directories:
terraform/azure/vm -> terraform/azure/vm/linux and
terraform/azure/vm-windows -> terraform/azure/vm/win.

aws/amazon-cloudwatch-agent-test#764
Streaming the large agent MSI to the VM over the Terraform WinRM
file provisioner took ~41 min in run 35537032697, blowing the
45-min apply timeout. Instead the VM downloads the MSI itself over
HTTPS from a presigned URL: the file provisioner now writes only the
tiny URL text file, and the bootstrap script curls the MSI before
msiexec, failing fast if it is missing or empty.

Replace agent_msi_path with a sensitive agent_msi_url variable.
The VM installed Go 1.20 to match go.mod, but util/otelmetrics/query_cache.go
imports log/slog (Go 1.21+), so go test failed with
"package log/slog is not in GOROOT" on the Azure Windows VM. Use 1.22.9,
the version already pinned by terraform/ec2/mac.
if (-not (Test-Path $msi) -or (Get-Item $msi).Length -eq 0) { throw "agent MSI download failed or empty: $msi" }
Write-Host "downloaded MSI bytes: $((Get-Item $msi).Length)"
Remove-Item -Force $urlFile -ErrorAction SilentlyContinue
Start-Process msiexec.exe -ArgumentList '/i', $msi, '/norestart', '/qn' -Wait

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# Install Go matching the test repo go.mod directive, into C:\go, on PATH for this session only.
$goZip = "$env:TEMP\go.zip"
Invoke-WebRequest -Uri "https://go.dev/dl/go${var.go_version}.windows-amd64.zip" -OutFile $goZip

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Seems like we use a mix of curl.exe and Invoke-WebRequest. Any reason not to standardize on one?

@movence
movence merged commit 6fe24ec into main Sep 21, 2026
6 checks passed
@movence
movence deleted the hsookim/azure-vm-windows-integ-test branch September 21, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants