|
| 1 | +echo "~~~ Preparing environment" |
| 2 | + |
| 3 | +$PSVersionTable.PSVersion |
| 4 | + |
| 5 | +# TODO: make is not available on Windows yet |
| 6 | +# hence we cannot use make install-gotestsum |
| 7 | +go install gotest.tools/gotestsum |
| 8 | +gotestsum --version |
| 9 | + |
| 10 | +# Read package version from .package-version file |
| 11 | +$PACKAGE_VERSION = Get-Content .package-version -ErrorAction SilentlyContinue |
| 12 | +if ($PACKAGE_VERSION) { |
| 13 | + $PACKAGE_VERSION = "${PACKAGE_VERSION}-SNAPSHOT" |
| 14 | +} |
| 15 | +$env:TEST_BINARY_NAME = "elastic-agent" |
| 16 | +# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925 |
| 17 | +$AGENT_VERSION = (Get-Content version/version.go | Select-String -Pattern 'const defaultBeatVersion =' | ForEach-Object { $_ -replace '.*?"(.*?)".*', '$1' }) |
| 18 | +$env:AGENT_VERSION = $AGENT_VERSION + "-SNAPSHOT" |
| 19 | + |
| 20 | +echo "~~~ Agent version: $env:AGENT_VERSION" |
| 21 | +$env:SNAPSHOT = $true |
| 22 | + |
| 23 | +echo "~~~ Building test binaries" |
| 24 | +& mage build:testBinaries |
| 25 | +if ($LASTEXITCODE -ne 0) { |
| 26 | + Write-Error "Failed to build test binaries" |
| 27 | + exit 1 |
| 28 | +} |
| 29 | +$osInfo = (Get-CimInstance Win32_OperatingSystem).Caption + " " + (Get-CimInstance Win32_OperatingSystem).OSArchitecture -replace " ", "_" |
| 30 | +$fully_qualified_group_name="fleet_sudo_${osInfo}" |
| 31 | +$outputXML = "build/${fully_qualified_group_name}.integration.xml" |
| 32 | +$outputJSON = "build/${fully_qualified_group_name}.integration.out.json" |
| 33 | +$TestsExitCode = 0 |
| 34 | +try { |
| 35 | + Write-Output "~~~ Running serverless integration tests" |
| 36 | + $gotestArgs = @("-tags=integration", "-shuffle=on", "-timeout=2h0m0s", "-run=TestLogIngestionFleetManaged") |
| 37 | + $gotestArgs += @("github.com/elastic/elastic-agent/testing/integration", "-v", "-args", "-integration.groups=fleet", "-integration.sudo=true") |
| 38 | + & gotestsum --no-color -f standard-quiet --junitfile-hide-skipped-tests --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- @gotestArgs |
| 39 | + $TestsExitCode = $LASTEXITCODE |
| 40 | +} finally { |
| 41 | + if (Test-Path $outputXML) { |
| 42 | + # Install junit2html if not installed |
| 43 | + go install github.com/alexec/junit2html@latest |
| 44 | + Get-Content $outputXML | junit2html > "build/TEST-report.html" |
| 45 | + } else { |
| 46 | + Write-Output "Cannot generate HTML test report: $outputXML not found" |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +if ($TestsExitCode -ne 0) { |
| 51 | + exit 1 |
| 52 | +} |
0 commit comments