From ab3ee925e60e1c63af6f9012a123c04e12856b5f Mon Sep 17 00:00:00 2001 From: Pavel Zorin Date: Thu, 30 Jan 2025 17:08:11 +0100 Subject: [PATCH] Integration tests: Parse agent version from version.go (#6611) * 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 cab384c5735ddfa9e4d66d6c551b1486c34a4cb4) --- .buildkite/scripts/buildkite-integration-tests.sh | 15 +++++++++------ .buildkite/scripts/integration-tests.ps1 | 9 ++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.buildkite/scripts/buildkite-integration-tests.sh b/.buildkite/scripts/buildkite-integration-tests.sh index 1659a4059d8..bc509eef2b0 100755 --- a/.buildkite/scripts/buildkite-integration-tests.sh +++ b/.buildkite/scripts/buildkite-integration-tests.sh @@ -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="" @@ -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 diff --git a/.buildkite/scripts/integration-tests.ps1 b/.buildkite/scripts/integration-tests.ps1 index 34cceb843ba..36602d2730b 100755 --- a/.buildkite/scripts/integration-tests.ps1 +++ b/.buildkite/scripts/integration-tests.ps1 @@ -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" @@ -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