Skip to content

[ansible][windows] Add option to set service CLI args (#6371) #5304

[ansible][windows] Add option to set service CLI args (#6371)

[ansible][windows] Add option to set service CLI args (#6371) #5304

name: win-package-test
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/scripts/*.ps1'
- '.github/workflows/win-package-test.yml'
- 'cmd/otelcol/**'
- 'instrumentation/packaging/dotnet-agent-release.txt'
- 'internal/**'
- 'Makefile'
- 'Makefile.Common'
- 'packaging/msi/**'
- 'tests/zeroconfig/windows/**'
- '!**.md'
concurrency:
group: win-package-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GO_VERSION: 1.23.10
jobs:
cross-compile:
strategy:
matrix:
SYS_BINARIES: [ "binaries-windows_amd64" ]
uses: ./.github/workflows/compile.yml
with:
SYS_BINARY: ${{ matrix.SYS_BINARIES }}
agent-bundle-windows:
strategy:
matrix:
OS: [ "windows-2022", "windows-2025" ]
uses: ./.github/workflows/agent-bundle-windows.yml
with:
OS: ${{ matrix.OS }}
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
msi-custom-actions:
strategy:
matrix:
OS: [ "windows-2022" ]
uses: ./.github/workflows/msi-custom-actions.yml
with:
OS: ${{ matrix.OS }}
msi-build:
strategy:
matrix:
OS: [ "windows-2022", "windows-2025" ]
needs: [cross-compile, agent-bundle-windows, msi-custom-actions]
uses: ./.github/workflows/msi-build.yml
with:
OS: ${{ matrix.OS }}
dotnet-zeroconfig-e2e-test:
runs-on: ${{ matrix.OS }}
strategy:
matrix:
OS: [ "windows-2022", "windows-2025" ]
needs: [msi-build]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Setup NuGet
uses: nuget/[email protected]
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- uses: actions/[email protected]
with:
dotnet-version: |
6.0.407
- name: Download Splunk OTel Collector msi
uses: actions/download-artifact@v4
with:
name: msi-build-${{ matrix.OS }}
path: ./tests/zeroconfig/windows/testdata/docker-setup/
- name: Run the test script
working-directory: tests/zeroconfig/windows/
run: |
.\run-tests.ps1
msi-test:
strategy:
matrix:
OS: [ "windows-2022" ]
runs-on: otel-windows
needs: [msi-build]
timeout-minutes: 40
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Downloading msi build
uses: actions/download-artifact@v4
with:
name: msi-build-${{ matrix.OS }}
path: ./dist
- name: Set the MSI_COLLECTOR_PATH environment variable
run: |
$ErrorActionPreference = 'Stop'
$msi_path = Resolve-Path .\dist\splunk-otel-collector*.msi
Test-Path $msi_path
"MSI_COLLECTOR_PATH=$msi_path" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Run the MSI tests
run: |
go test -timeout 15m -v github.com/signalfx/splunk-otel-collector/tests/msi
windows-install-script-test:
runs-on: ${{ matrix.OS }}
needs: [msi-build]
strategy:
max-parallel: 2
matrix:
OS: [ "windows-2022", "windows-2025" ]
MODE: [ "agent", "gateway" ]
WITH_FLUENTD: [ "true", "false" ]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Downloading msi build
uses: actions/download-artifact@v4
with:
name: msi-build-${{ matrix.OS }}
path: ./dist
- name: Ensure required ports in the dynamic range are available
run: |
$ErrorActionPreference = 'Continue'
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1
- name: Installation test
env:
token: fake-token
realm: fake-realm
memory: "256"
run: |
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1
$msi_path = Resolve-Path .\dist\splunk-otel-collector*.msi
$env:VERIFY_ACCESS_TOKEN = "false"
.\packaging\installer\install.ps1 -access_token "${{ env.token }}" -realm "${{ env.realm }}" -msi_path "$msi_path" -mode "${{ matrix.MODE }}" -memory "${{ env.memory }}" -with_fluentd $${{ matrix.WITH_FLUENTD }}
Start-Sleep -s 30
& ${{ github.workspace }}\.github\workflows\scripts\win-test-services.ps1 -mode "${{ matrix.MODE }}" -access_token "${{ env.token }}" -realm "${{ env.realm }}" -memory "${{ env.memory }}" -with_fluentd "${{ matrix.WITH_FLUENTD }}"
& ${{ github.workspace }}\.github\workflows\scripts\win-test-support-bundle.ps1 -mode "${{ matrix.MODE }}" -with_fluentd "${{ matrix.WITH_FLUENTD }}"
Resolve-Path -Path "$env:ProgramFiles\Splunk\OpenTelemetry Collector\agent-bundle\python\python.exe"
Resolve-Path -Path "$env:ProgramFiles\Splunk\OpenTelemetry Collector\agent-bundle\collectd-python"
# The JMX file is installed under Disk:\opt, so we need to check each available disk to see if it's installed
$found_jmx = $false
(Get-PSDrive -PSProvider FileSystem).Root | ForEach-Object {
$found_jmx = $found_jmx -Or (Test-Path (Join-Path "$_" "opt\opentelemetry-java-contrib-jmx-metrics.jar"))
}
if (-not $found_jmx) { throw "Could not find expected jar file" }
- name: splunk-otel-collector logs
if: ${{ always() }}
run: Get-WinEvent -ProviderName splunk-otel-collector | Sort-Object -Property TimeCreated | Select-Object -Property Message | Format-List
- name: fluentd logs
if: ${{ always() && matrix.WITH_FLUENTD == 'true' }}
run: Get-Content -Path "${env:SYSTEMDRIVE}\opt\td-agent\td-agent.log"
windows-script-upgrade-test:
strategy:
matrix:
OS: [ "windows-2022", "windows-2025" ]
runs-on: otel-windows # Tests with uninstall require a more powerful runner
needs: [msi-test, windows-install-script-test]
timeout-minutes: 45
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Downloading msi build
uses: actions/download-artifact@v4
with:
name: msi-build-${{ matrix.OS }}
path: ./dist
- name: Ensure required ports in the dynamic range are available
run: |
$ErrorActionPreference = 'Continue'
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1
- name: Set the MSI_COLLECTOR_PATH and INSTALL_SCRIPT_PATH environment variable
run: |
$ErrorActionPreference = 'Stop'
$msi_path = Resolve-Path .\dist\splunk-otel-collector*.msi
Test-Path $msi_path
"MSI_COLLECTOR_PATH=$msi_path" | Out-File -FilePath $env:GITHUB_ENV -Append
$ps1_path = Resolve-Path .\packaging\installer\install.ps1
Test-Path $ps1_path
"INSTALL_SCRIPT_PATH=$ps1_path" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Run the script upgrade tests
shell: powershell # Use PowerShell to run the script since running the go test from pwsh.exe hides the Get-ExecutionPolicy cmdlet.
run: |
go test -v github.com/signalfx/splunk-otel-collector/tests/windows-install-script
choco-build:
runs-on: ${{ matrix.OS }}
strategy:
matrix:
OS: [ "windows-2022", "windows-2025" ]
needs: [msi-build]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Downloading msi build
uses: actions/download-artifact@v4
with:
name: msi-build-${{ matrix.OS }}
path: ./dist
- name: Build Chocolatey
run: |
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1
$msi_file_path = Resolve-Path .\dist\splunk-otel-collector*.msi
$msi_file_name = Resolve-Path .\dist\splunk-otel-collector*.msi | Split-Path -leaf
$msi_file_name -match '(\d+\.)(\d+\.)+(\d*)'
$version = $matches[0]
write-host "Building choco package..."
.\packaging\choco\make.ps1 build_choco -MSIFile $msi_file_path -Version $version | Tee-Object -file .\dist\build_logs.log
Test-Path -Path ".\dist\splunk-otel-collector.$version.nupkg"
- name: Test install without parameters
run: |
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1
choco install splunk-otel-collector -s=".\dist" -y
if ($LASTEXITCODE -ne 0) {
throw "choco install failed!"
}
# the collector service should not be running if installed without the SPLUNK_ACCESS_TOKEN parameter
if ((Get-CimInstance -ClassName win32_service -Filter "Name = 'splunk-otel-collector'" | Select Name, State).State -Eq "Running") {
throw "splunk-otel-collector is running"
}
- name: Uploading choco build artifacts
uses: actions/upload-artifact@v4
with:
name: choco-build-${{ matrix.OS }}
path: ./dist/*.nupkg
choco-test:
runs-on: ${{ matrix.OS }}
needs: [choco-build]
strategy:
max-parallel: 4
matrix:
OS: [ "windows-2022", "windows-2025" ]
MODE: [ "agent", "gateway" ]
WITH_FLUENTD: [ "true", "false" ]
SCENARIO: [ "install", "upgrade" ]
fail-fast: false
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Downloading choco build
uses: actions/download-artifact@v4
with:
name: choco-build-${{ matrix.OS }}
path: ./dist
- name: Ensure required ports in the dynamic range are available
run: |
$ErrorActionPreference = 'Continue'
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1
- name: Chocolatey ${{ matrix.SCENARIO }} test
env:
token: fake-token
realm: fake-realm
memory: "256"
run: |
$ErrorActionPreference = 'Stop'
Set-PSDebug -Trace 1
$choco_file_name = Resolve-Path .\dist\splunk-otel-collector*.nupkg
$params = "/SPLUNK_ACCESS_TOKEN=${{ env.token }} /SPLUNK_REALM=${{ env.realm }} /SPLUNK_MEMORY_TOTAL_MIB=${{ env.memory }} /MODE:${{ matrix.MODE }} /WITH_FLUENTD:${{ matrix.WITH_FLUENTD }}"
if ("${{ matrix.SCENARIO }}" -eq "install") {
write-host "Installing $choco_file_name ..."
choco install splunk-otel-collector -s=".\dist" --params="'$params'" -y
if ($LASTEXITCODE -ne 0) {
throw "choco install failed!"
}
} else {
write-host "Installing splunk-otel-collector ..."
choco feature enable -n=useRememberedArgumentsForUpgrades
choco install splunk-otel-collector --no-progress --params="'$params'" -y
if ($LASTEXITCODE -ne 0) {
throw "choco install failed!"
}
$env_vars = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment"
$test_env_vars = @(
"MY VAR WITH SPACES=my value",
"GOOD_ENV_VAR_NAME=good value",
"GOOD_KEY_NEEDS_ESCAPING=`" that breaks MSI call if not escaped properly due to double-quote"
)
$env_vars += $test_env_vars
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment" -Value $env_vars -type MultiString
Start-Sleep 30
write-host "Upgrading $choco_file_name ..."
choco upgrade splunk-otel-collector -s=".\dist" -y
if ($LASTEXITCODE -ne 0) {
throw "choco upgrade failed!"
}
$env_vars = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment"
foreach ($test_env_var in $test_env_vars) {
if (!($env_vars -contains $test_env_var)) {
$env_vars
throw "'$test_env_var' not found!"
}
}
}
Start-Sleep -s 30
& ${{ github.workspace }}\.github\workflows\scripts\win-test-services.ps1 -mode "${{ matrix.MODE }}" -access_token "${{ env.token }}" -realm "${{ env.realm }}" -memory "${{ env.memory }}" -with_fluentd "${{ matrix.WITH_FLUENTD }}"
& ${{ github.workspace }}\.github\workflows\scripts\win-test-support-bundle.ps1 -mode "${{ matrix.MODE }}" -with_fluentd "${{ matrix.WITH_FLUENTD }}"
- name: splunk-otel-collector logs
if: ${{ always() }}
run: Get-WinEvent -ProviderName splunk-otel-collector | Sort-Object -Property TimeCreated | Select-Object -Property Message | Format-List
- name: fluentd logs
if: ${{ always() && matrix.WITH_FLUENTD == 'true' }}
run: Get-Content -Path "${env:SYSTEMDRIVE}\opt\td-agent\td-agent.log"
- name: Uninstall test
run: |
choco uninstall splunk-otel-collector -y
if ($LASTEXITCODE -ne 0) {
throw "choco uninstall failed!"
}
Start-Sleep -s 30
if ((Get-CimInstance -ClassName win32_service -Filter "Name = 'splunk-otel-collector'" | Select Name, State).State -Eq "Running") {
throw "splunk-otel-collector service is still running"
}
docker-otelcol:
runs-on: ${{ matrix.OS }}
needs: [cross-compile, agent-bundle-windows]
strategy:
matrix:
OS: [ "windows-2022", "windows-2025" ]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Downloading binaries-windows_amd64
uses: actions/download-artifact@v4
with:
name: binaries-windows_amd64
path: ./bin
- uses: actions/download-artifact@v4
with:
name: agent-bundle-windows-${{ matrix.OS }}
path: ./dist
- name: Build docker image
run: |
$ErrorActionPreference = 'Stop'
Copy-Item .\bin\otelcol_windows_amd64.exe .\cmd\otelcol\otelcol.exe
Copy-Item .\dist\agent-bundle_windows_amd64.zip .\cmd\otelcol\agent-bundle_windows_amd64.zip
docker build -t otelcol-windows --build-arg BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022 --build-arg JMX_METRIC_GATHERER_RELEASE=$(Get-Content packaging\jmx-metric-gatherer-release.txt) -f .\cmd\otelcol\Dockerfile.windows .\cmd\otelcol\
Remove-Item .\cmd\otelcol\otelcol.exe
Remove-Item .\cmd\otelcol\agent-bundle_windows_amd64.zip
- name: Run docker image
run: |
$ErrorActionPreference = 'Stop'
docker run -d -e SPLUNK_ACCESS_TOKEN=abc123 -e SPLUNK_REALM=fake-realm --name otelcol otelcol-windows:latest
Start-Sleep 10
$DockerOutput=$(docker ps --filter=status=running --filter=name=otelcol -q)
if ( $DockerOutput -eq $null ) {
docker logs otelcol
echo "Failing job execution: fail to start otelcol docker container in 10 seconds."
exit 1
}
docker exec otelcol java -version
if ( $LASTEXITCODE -ne 0 ) {
docker logs otelcol
echo "Failing job execution: Failed to run java"
exit 1
}