Add Windows Azure VM integration test - #764
Merged
Merged
Conversation
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
force-pushed
the
hsookim/azure-vm-windows-integ-test
branch
from
September 18, 2026 20:08
aff3ed0 to
28f3426
Compare
jefchien
reviewed
Sep 18, 2026
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.
jefchien
approved these changes
Sep 21, 2026
| 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 |
Contributor
There was a problem hiding this comment.
nit: Consider adding PassThru (https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-5.1#-passthru) to check if the install failed.
|
|
||
| # 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 |
Contributor
There was a problem hiding this comment.
nit: Seems like we use a mix of curl.exe and Invoke-WebRequest. Any reason not to standardize on one?
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the issue
The existing Azure VM integration test is Linux-only (
azurerm_linux_virtual_machine,.debinstalled over SSH). Windows-specific regressions in the MSI (e.g. a staleamazon-cloudwatch-agent-ctl.ps1) or Windows Azure-m autodetection (aws/amazon-cloudwatch-agent#2289) are therefore not caught by CI.Description of changes
terraform/azure/vmintovm/linux(existing module, moved),vm/win(new), andvm/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 asagent_msi_url,msiexecinstall, thenamazon-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, andgo test -tags integration -computeType=AZUREVM -instancePlatform=windows.test/azure/vm/azurevm_test.gousescommon.AgentLogFilefor the per-OS agent log path.ReadAgentLogfilemoved to a single untaggedutil/common/agent_util.go.!windowsbuild tag fromtest/status/test_result.go,test/status/test_status.go, andtest/otel_collect/otlpvalidation/validate.goso they build for windows.Testing
terraform validate/fmt -checkclean invm/linux,vm/win,vm/iam.GOOS=windowsandGOOS=linuxgo test -tags integration -c ./test/azure/vmbuild.AzureVM-default-otel-WindowsandAzureVM-default-otel-Linuxboth pass (TestAzureVMMetrics/Logs/Traces), resources destroyed cleanly.Worth noting
terraform/ec2/mac) rather than thego.mod1.20 directive:util/otelmetricsimportslog/slog(Go 1.21+), so 1.20 fails to compile the suite.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.