Skip to content

Commit

Permalink
[CI] Fix throttled windows test failures (#6662)
Browse files Browse the repository at this point in the history
* CI: Fifx throttled windows test failures

* Use LASTEXITCODE to catch test failures

* Update .buildkite/scripts/integration-tests.ps1

Co-authored-by: Doug W <[email protected]>

* Added  check to buildTestBinaries

* Apply suggestions from code review

Co-authored-by: Doug W <[email protected]>

---------

Co-authored-by: Doug W <[email protected]>
Co-authored-by: Julien Lind <[email protected]>
(cherry picked from commit 87360e6)

# Conflicts:
#	.buildkite/scripts/integration-tests.ps1
  • Loading branch information
pazone authored and mergify[bot] committed Feb 3, 2025
1 parent c78777d commit 3d90fed
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .buildkite/scripts/integration-tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
param (
[string]$GROUP_NAME,
[string]$TEST_SUDO
)

echo "~~~ Preparing environment"

$PSVersionTable.PSVersion

. "$PWD\.buildkite\scripts\steps\ess.ps1"

go install gotest.tools/gotestsum
gotestsum --version

# Read package version from .package-version file
$PACKAGE_VERSION = Get-Content .package-version -ErrorAction SilentlyContinue
if ($PACKAGE_VERSION) {
$PACKAGE_VERSION = "${PACKAGE_VERSION}-SNAPSHOT"
}
$env:TEST_BINARY_NAME = "elastic-agent"
# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925
$AGENT_VERSION = (Get-Content version/version.go | Select-String -Pattern 'const defaultBeatVersion =' | ForEach-Object { $_ -replace '.*?"(.*?)".*', '$1' })
$env:AGENT_VERSION = $AGENT_VERSION + "-SNAPSHOT"
echo "~~~ Agent version: $env:AGENT_VERSION"
$env:SNAPSHOT = $true

echo "~~~ Building test binaries"
& mage build:testBinaries
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to build test binaries"
exit 1
}
$osInfo = (Get-CimInstance Win32_OperatingSystem).Caption + " " + (Get-CimInstance Win32_OperatingSystem).OSArchitecture -replace " ", "_"
$root_suffix=""
if ($TEST_SUDO -eq "true") {
$root_suffix="_sudo"
}
$fully_qualified_group_name="${GROUP_NAME}${root_suffix}_${osInfo}"
$outputXML = "build/${fully_qualified_group_name}.integration.xml"
$outputJSON = "build/${fully_qualified_group_name}.integration.out.json"
$TestsExitCode = 0
try {
Get-Ess-Stack -StackVersion $PACKAGE_VERSION
Write-Output "~~~ Running integration test group: $GROUP_NAME as user: $env:USERNAME"
& gotestsum --no-color -f standard-quiet --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- -tags=integration -shuffle=on -timeout=2h0m0s "github.com/elastic/elastic-agent/testing/integration" -v -args "-integration.groups=$GROUP_NAME" "-integration.sudo=$TEST_SUDO"
$TestsExitCode = $LASTEXITCODE
} finally {
ess_down

if (Test-Path $outputXML) {
# Install junit2html if not installed
go install github.com/alexec/junit2html@latest
Get-Content $outputXML | junit2html > "build/TEST-report.html"
} else {
Write-Output "Cannot generate HTML test report: $outputXML not found"
}
}

if ($TestsExitCode -ne 0) {
exit 1
}

0 comments on commit 3d90fed

Please sign in to comment.