Skip to content

Commit

Permalink
Merge branch '8.16' into mergify/bp/8.16/pr-6030
Browse files Browse the repository at this point in the history
  • Loading branch information
jlind23 authored Jan 6, 2025
2 parents 63953b1 + a8d8132 commit e8f8a8c
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .buildkite/scripts/buildkite-integration-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash


GROUP_NAME=$1
TEST_SUDO=$2

if [ -z "$GROUP_NAME" ]; then
echo "Error: Specify the group name: sudo-integration-tests.sh [group_name]" >&2
exit 1
fi

if [ -z "$TEST_SUDO" ]; then
echo "Error: Specify the test sudo: sudo-integration-tests.sh [group_name] [test_sudo]" >&2
exit 1
fi

if [ "$TEST_SUDO" == "true" ]; then
echo "Re-initializing ASDF. The user is changed to root..."
export ASDF_DATA_DIR="/opt/buildkite-agent/.asdf"
export PATH="$ASDF_DATA_DIR/bin:$ASDF_DATA_DIR/shims:$PATH"
source /opt/buildkite-agent/hooks/pre-command
source .buildkite/hooks/pre-command || echo "No pre-command hook found"
fi

# Make sure that all tools are installed
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

os_data=$(uname -spr | tr ' ' '_')
root_suffix=""
if [ "$TEST_SUDO" == "true" ]; then
root_suffix="_sudo"
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"
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}"
TESTS_EXIT_STATUS=$?
set -e

if [ -f "$outputXML" ]; then
go install github.com/alexec/junit2html@latest
junit2html < "$outputXML" > build/TEST-report.html
else
echo "Cannot generate HTML test report: $outputXML not found"
fi

exit $TESTS_EXIT_STATUS

0 comments on commit e8f8a8c

Please sign in to comment.