Skip to content

Commit

Permalink
Integration tests: Parse agent version from version.go (#6611)
Browse files Browse the repository at this point in the history
* Integration tests: use the mage target to get agent version

* Added snapshot to version

* Test run

* Test run Windows

* Removed -v flag

* Parse agent version

* Cleanup

(cherry picked from commit cab384c)
  • Loading branch information
pazone authored and mergify[bot] committed Jan 30, 2025
1 parent 4507d47 commit ab3ee92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
15 changes: 9 additions & 6 deletions .buildkite/scripts/buildkite-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ fi
asdf install

echo "~~~ Running integration tests as $USER"
echo "~~~ Integration tests: ${GROUP_NAME}"

go install gotest.tools/gotestsum
gotestsum --version

PACKAGE_VERSION="$(cat .package-version)"
if [[ -n "$PACKAGE_VERSION" ]]; then
PACKAGE_VERSION=${PACKAGE_VERSION}"-SNAPSHOT"
fi
# Parsing version.go. Will be simplified here: https://github.com/elastic/ingest-dev/issues/4925
AGENT_VERSION=$(grep "const defaultBeatVersion =" version/version.go | cut -d\" -f2)
AGENT_VERSION="${AGENT_VERSION}-SNAPSHOT"
export AGENT_VERSION
echo "~~~ Agent version: ${AGENT_VERSION}"

os_data=$(uname -spr | tr ' ' '_')
root_suffix=""
Expand All @@ -44,8 +44,11 @@ fi
fully_qualified_group_name="${GROUP_NAME}${root_suffix}_${os_data}"
outputXML="build/${fully_qualified_group_name}.integration.xml"
outputJSON="build/${fully_qualified_group_name}.integration.out.json"

echo "~~~ Integration tests: ${GROUP_NAME}"

set +e
TEST_BINARY_NAME="elastic-agent" AGENT_VERSION="${PACKAGE_VERSION}" SNAPSHOT=true gotestsum --no-color -f standard-quiet --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- -tags integration -test.shuffle on -test.timeout 2h0m0s github.com/elastic/elastic-agent/testing/integration -v -args -integration.groups="${GROUP_NAME}" -integration.sudo="${TEST_SUDO}"
TEST_BINARY_NAME="elastic-agent" AGENT_VERSION="${AGENT_VERSION}" SNAPSHOT=true gotestsum --no-color -f standard-quiet --junitfile "${outputXML}" --jsonfile "${outputJSON}" -- -tags integration -test.shuffle on -test.timeout 2h0m0s github.com/elastic/elastic-agent/testing/integration -v -args -integration.groups="${GROUP_NAME}" -integration.sudo="${TEST_SUDO}"
TESTS_EXIT_STATUS=$?
set -e

Expand Down
9 changes: 6 additions & 3 deletions .buildkite/scripts/integration-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ if ($PACKAGE_VERSION) {
$PACKAGE_VERSION = "${PACKAGE_VERSION}-SNAPSHOT"
}
$env:TEST_BINARY_NAME = "elastic-agent"
$env:AGENT_VERSION = $PACKAGE_VERSION
# 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"
Expand All @@ -32,9 +35,9 @@ $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"
try {
Get-Ess-Stack -StackVersion $PACKAGE_VERSION
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"
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"
} finally {
ess_down

Expand Down

0 comments on commit ab3ee92

Please sign in to comment.