Skip to content

Commit 4e48801

Browse files
fix: invoke serverless dedicated integration tests scripts
1 parent 646486a commit 4e48801

File tree

3 files changed

+71
-12
lines changed

3 files changed

+71
-12
lines changed

.buildkite/integration.pipeline.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ steps:
179179
depends_on:
180180
- packaging-windows
181181
command: |
182-
#right now, run a single test in serverless mode as a sort of smoke test, instead of re-running the entire suite
183182
buildkite-agent artifact download build/distributions/** . --step 'packaging-windows'
184-
.buildkite/scripts/integration-tests.ps1 fleet true TestLogIngestionFleetManaged
183+
.buildkite/scripts/steps/serverless-integration-tests.ps1
185184
artifact_paths:
186185
- build/**
187186
- build/diagnostics/**
@@ -200,9 +199,8 @@ steps:
200199
depends_on:
201200
- packaging-windows
202201
command: |
203-
#right now, run a single test in serverless mode as a sort of smoke test, instead of re-running the entire suite
204202
buildkite-agent artifact download build/distributions/** . --step 'packaging-windows'
205-
.buildkite/scripts/integration-tests.ps1 fleet true TestLogIngestionFleetManaged
203+
.buildkite/scripts/steps/serverless-integration-tests.ps1
206204
artifact_paths:
207205
- build/**
208206
- build/diagnostics/**
@@ -220,9 +218,8 @@ steps:
220218
- label: "Ubuntu:2404:amd64:sudo"
221219
depends_on: packaging-ubuntu-x86-64
222220
command: |
223-
#right now, run a single test in serverless mode as a sort of smoke test, instead of re-running the entire suite
224221
buildkite-agent artifact download build/distributions/** . --step 'packaging-ubuntu-x86-64'
225-
.buildkite/scripts/steps/integration_tests_tf.sh fleet true TestLogIngestionFleetManaged
222+
.buildkite/scripts/steps/serverless-integration-tests.sh
226223
artifact_paths:
227224
- build/**
228225
- build/diagnostics/**
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
}

.buildkite/scripts/steps/serverless-integration-tests.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22
# This script runs the serverless integration tests
33
set -eo pipefail
44

5-
BUILDKITE=${BUILDKITE:-}
5+
source .buildkite/scripts/common2.sh
66

7-
if [ -n "$BUILDKITE" ]; then
8-
buildkite-agent artifact download "build/distributions/**" . "$BUILDKITE_BUILD_ID"
9-
fi
7+
# Make sure that all tools are installed
8+
asdf install
9+
10+
echo "~~~ Building test binaries"
11+
mage build:testBinaries
12+
13+
# TODO: move to common.sh when it's refactored
14+
# BK analytics
15+
echo "--- Prepare BK test analytics token :vault:"
16+
BUILDKITE_ANALYTICS_TOKEN=$(vault kv get -field token kv/ci-shared/platform-ingest/buildkite_analytics_token)
17+
export BUILDKITE_ANALYTICS_TOKEN
18+
19+
# Run integration tests
20+
echo "~~~ Running serverless integration tests"
21+
sudo -E .buildkite/scripts/buildkite-integration-tests.sh fleet true TestLogIngestionFleetManaged
1022

11-
echo "+++ Run integration-tests"
12-
# TBC

0 commit comments

Comments
 (0)