-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(cherry picked from commit 0a74d21) # Conflicts: # .buildkite/scripts/buildkite-integration-tests.sh Co-authored-by: Olga Naydyonock <yanto.johnes@gmail.com> Co-authored-by: Michal Pristas <michal.pristas@gmail.com>
- Loading branch information
1 parent
5761ede
commit a8d8132
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters