Skip to content

Commit ce4a481

Browse files
authored
Move MSI tests to golang (#5106)
* Add the initial golang test * Add GH workflow for golang MSI test * gofmt * tidy * Add path to download action * Add remaining tests * Give more time to msi golang tests * Try separate run for each test * Do not run golang tests in parallel * Comment GH msi tests * Go test verbose to try to get insight into the failures * Use larger runner * Try a single large instance to run all tests * Check service configuration on golang test * Remove GH msi-without-wrappers-test workflow * Better names for GH jobs * Add a MSI reconfiguration test * Skip starting the service after reinstall * Remove MSI reinstall test in GH action
1 parent 1f21620 commit ce4a481

File tree

3 files changed

+294
-177
lines changed

3 files changed

+294
-177
lines changed

.github/workflows/win-package-test.yml

Lines changed: 8 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -209,108 +209,10 @@ jobs:
209209
run: |
210210
.\run-tests.ps1
211211
212-
msi-without-wrappers-test:
213-
runs-on: ${{ matrix.OS }}
214-
needs: [msi-build]
215-
timeout-minutes: 15
216-
strategy:
217-
max-parallel: 1
218-
matrix:
219-
OS: [ "windows-2022" ]
220-
install-properties:
221-
222-
- test: "default"
223-
install: "SPLUNK_ACCESS_TOKEN=fakeToken"
224-
expected: "-mode agent -access_token fakeToken -realm us0 -memory $null -with_fluentd false"
225-
226-
- test: "gateway"
227-
install: "SPLUNK_SETUP_COLLECTOR_MODE=gateway SPLUNK_ACCESS_TOKEN=testing123"
228-
expected: "-mode gateway -access_token testing123 -realm us0 -memory $null -with_fluentd false"
229-
230-
- test: "realm"
231-
install: "SPLUNK_REALM=myrealm SPLUNK_ACCESS_TOKEN=testing"
232-
expected: "-mode agent -access_token testing -realm myrealm -memory $null -with_fluentd false"
233-
234-
- test: "ingest-url"
235-
install: "SPLUNK_INGEST_URL=https://fake.ingest.url SPLUNK_ACCESS_TOKEN=testing"
236-
expected: "-mode agent -realm us0 -access_token testing -ingest_url \"https://fake.ingest.url\" -memory $null -with_fluentd false"
237-
238-
- test: "optional-params"
239-
install: "SPLUNK_ACCESS_TOKEN=fakeToken SPLUNK_MEMORY_TOTAL_MIB=256"
240-
expected: "-mode agent -access_token fakeToken -realm us0 -memory 256 -with_fluentd false"
241-
242-
steps:
243-
- name: Check out the codebase.
244-
uses: actions/checkout@v4
245-
246-
- name: Downloading msi build
247-
uses: actions/download-artifact@v4
248-
with:
249-
name: msi-build
250-
path: ./dist
251-
252-
- name: Ensure required ports in the dynamic range are available
253-
run: |
254-
$ErrorActionPreference = 'Continue'
255-
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1
256-
257-
- name: Install the collector
258-
run: |
259-
$ErrorActionPreference = 'Stop'
260-
$msi_path = Resolve-Path .\dist\splunk-otel-collector*.msi
261-
Test-Path $msi_path
262-
Write-Host "Installing $msi_path ..."
263-
$process = Start-Process -Wait -PassThru msiexec "/i `"$msi_path`" /qn /l*v msi-install.log ${{ matrix.install-properties.install }}"
264-
if ($process.ExitCode -ne 0) {
265-
throw "MSI installation failed with exit code $($process.ExitCode)"
266-
}
267-
268-
- name: "In case of failure: display the install logs"
269-
if: ${{ failure() }}
270-
run: Get-Content msi-install.log
271-
272-
- name: Start the collector service
273-
run: |
274-
$sc = Start-Service splunk-otel-collector -PassThru
275-
$sc.WaitForStatus('Running', '00:00:30')
276-
277-
- name: Check registry expectations
278-
run: |
279-
$ErrorActionPreference = 'Stop'
280-
& ${{ github.workspace }}\.github\workflows\scripts\win-test-services.ps1 ${{ matrix.install-properties.expected }}
281-
282-
- name: Stop the collector service
283-
run: |
284-
$sc = Stop-Service splunk-otel-collector -PassThru
285-
$sc.WaitForStatus('Stopped', '00:00:30')
286-
287-
- name: "In case of failure: collect splunk-otel-collector events"
288-
if: ${{ failure() }}
289-
run: Get-WinEvent -ProviderName splunk-otel-collector | Sort-Object -Property TimeCreated | Select-Object -Property Message | Format-List
290-
291-
- name: Uninstall the collector
292-
run: |
293-
$ErrorActionPreference = 'Stop'
294-
$uninstall_info = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\uninstall\* | Where { $_.DisplayName -eq "Splunk OpenTelemetry Collector" }
295-
Write-Host "Uninstalling $($uninstall_info.PSChildName) ..."
296-
$process = Start-Process -Wait -PassThru msiexec "/x $($uninstall_info.PSChildName) /qn /norestart"
297-
if ($process.ExitCode -ne 0) {
298-
throw "MSI installation failed with exit code $($process.ExitCode)"
299-
}
300-
301-
- name: Check no leftover on the registry
302-
run: |
303-
$ErrorActionPreference = 'Stop'
304-
$uninstall_info = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\uninstall\* | Where { $_.DisplayName -eq "Splunk OpenTelemetry Collector" }
305-
if ($uninstall_info -ne $null) {
306-
throw "MSI uninstall failed"
307-
}
308-
309-
msi-reinstall-test:
310-
runs-on: windows-2022
212+
msi-test:
213+
runs-on: otel-windows
311214
needs: [msi-build]
312-
timeout-minutes: 15
313-
215+
timeout-minutes: 40
314216
steps:
315217
- name: Check out the codebase.
316218
uses: actions/checkout@v4
@@ -321,88 +223,18 @@ jobs:
321223
name: msi-build
322224
path: ./dist
323225

324-
- name: Ensure required ports in the dynamic range are available
325-
run: |
326-
$ErrorActionPreference = 'Continue'
327-
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1
328-
329-
- name: Install the collector
226+
- name: Set the MSI_COLLECTOR_PATH environment variable
330227
run: |
331228
$ErrorActionPreference = 'Stop'
332229
$msi_path = Resolve-Path .\dist\splunk-otel-collector*.msi
333230
Test-Path $msi_path
334-
Write-Host "Installing $msi_path ..."
335-
$process = Start-Process -Wait -PassThru msiexec "/i `"$msi_path`" /qn /l*v msi-install.log SPLUNK_ACCESS_TOKEN=1stInstall SPLUNK_REALM=1st"
336-
if ($process.ExitCode -ne 0) {
337-
throw "MSI installation failed with exit code $($process.ExitCode)"
338-
}
339-
340-
- name: "In case of failure: display the install logs"
341-
if: ${{ failure() }}
342-
run: Get-Content msi-install.log
231+
"MSI_COLLECTOR_PATH=$msi_path" | Out-File -FilePath $env:GITHUB_ENV -Append
343232
344-
- name: Start the collector service
233+
- name: Run the MSI tests
345234
run: |
346-
$sc = Start-Service splunk-otel-collector -PassThru
347-
$sc.WaitForStatus('Running', '00:00:30')
235+
go test -timeout 15m -v github.com/signalfx/splunk-otel-collector/tests/msi
348236
349-
- name: "In case of failure: collect splunk-otel-collector events"
350-
if: ${{ failure() }}
351-
run: Get-WinEvent -ProviderName splunk-otel-collector | Sort-Object -Property TimeCreated | Select-Object -Property Message | Format-List
352-
353-
- name: Check registry expectations
354-
run: |
355-
$ErrorActionPreference = 'Stop'
356-
& ${{ github.workspace }}\.github\workflows\scripts\win-test-services.ps1 -mode agent -realm 1st -access_token 1stInstall -memory $null -with_fluentd false
357-
358-
- name: Reinstall the collector
359-
run: |
360-
$ErrorActionPreference = 'Stop'
361-
$msi_path = Resolve-Path .\dist\splunk-otel-collector*.msi
362-
Test-Path $msi_path
363-
Write-Host "Reinstalling $msi_path ..."
364-
$process = Start-Process -Wait -PassThru msiexec "/i `"$msi_path`" /qn /l*v msi-reinstall.log SPLUNK_ACCESS_TOKEN=2ndInstall SPLUNK_REALM=2nd SPLUNK_MEMORY_TOTAL_MIB=256 REINSTALL=SplunkCollectorConfiguration"
365-
if ($process.ExitCode -ne 0) {
366-
throw "MSI installation failed with exit code $($process.ExitCode)"
367-
}
368-
369-
- name: "In case of failure: display the reinstall logs"
370-
if: ${{ failure() }}
371-
run: Get-Content msi-reinstall.log
372-
373-
- name: Start the collector service after reinstall
374-
run: |
375-
$sc = Start-Service splunk-otel-collector -PassThru
376-
$sc.WaitForStatus('Running', '00:00:30')
377-
378-
- name: Check registry expectations
379-
run: |
380-
$ErrorActionPreference = 'Stop'
381-
& ${{ github.workspace }}\.github\workflows\scripts\win-test-services.ps1 -mode agent -realm 2nd -access_token 2ndInstall -memory 256 -with_fluentd false
382-
383-
- name: "In case of failure: collect splunk-otel-collector events"
384-
if: ${{ failure() }}
385-
run: Get-WinEvent -ProviderName splunk-otel-collector | Sort-Object -Property TimeCreated | Select-Object -Property Message | Format-List
386-
387-
- name: Uninstall the collector
388-
run: |
389-
$ErrorActionPreference = 'Stop'
390-
$uninstall_info = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\uninstall\* | Where { $_.DisplayName -eq "Splunk OpenTelemetry Collector" }
391-
Write-Host "Uninstalling $($uninstall_info.PSChildName) ..."
392-
$process = Start-Process -Wait -PassThru msiexec "/x $($uninstall_info.PSChildName) /qn /norestart"
393-
if ($process.ExitCode -ne 0) {
394-
throw "MSI installation failed with exit code $($process.ExitCode)"
395-
}
396-
397-
- name: Check no leftover on the registry
398-
run: |
399-
$ErrorActionPreference = 'Stop'
400-
$uninstall_info = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\uninstall\* | Where { $_.DisplayName -eq "Splunk OpenTelemetry Collector" }
401-
if ($uninstall_info -ne $null) {
402-
throw "MSI uninstall failed"
403-
}
404-
405-
msi-test:
237+
windows-install-script-test:
406238
runs-on: ${{ matrix.OS }}
407239
needs: [msi-build]
408240
strategy:

tests/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ require (
2929
go.uber.org/atomic v1.11.0
3030
go.uber.org/zap v1.27.0
3131
golang.org/x/exp v0.0.0-20230711023510-fffb14384f22
32+
golang.org/x/sys v0.21.0
3233
gopkg.in/yaml.v2 v2.4.0
3334
gopkg.in/yaml.v3 v3.0.1
3435
)
@@ -111,7 +112,6 @@ require (
111112
golang.org/x/mod v0.17.0 // indirect
112113
golang.org/x/net v0.26.0 // indirect
113114
golang.org/x/sync v0.7.0 // indirect
114-
golang.org/x/sys v0.21.0 // indirect
115115
golang.org/x/text v0.16.0 // indirect
116116
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
117117
google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 // indirect

0 commit comments

Comments
 (0)