2016-11-29 07:44:56 -05:00
|
|
|
#!/bin/bash
|
2016-12-14 18:02:28 -05:00
|
|
|
# This script is used as a single command to run the x-pack tests.
|
2016-01-18 18:20:33 -05:00
|
|
|
#
|
2016-04-07 08:34:58 -04:00
|
|
|
# It will attempt to check out 'elasticsearch' into a sibling directory
|
2016-12-05 19:10:33 -05:00
|
|
|
# unless the environment variable `USE_EXISTING_ES` has a value. The
|
|
|
|
# branch of elasticsearch which will be checked out depends on
|
|
|
|
# environment variables. If running locally, set GIT_BRANCH. When
|
|
|
|
# running in Jenkins, that env var is set. When running a PR
|
|
|
|
# jenkins job, the variables PR_SOURCE_BRANCH and PR_TARGET_BRANCH
|
|
|
|
# will be set and the source branch will be looked for in elasticsearch
|
|
|
|
# before falling back to the target branch name.
|
2016-01-18 18:20:33 -05:00
|
|
|
#
|
2016-09-12 14:32:12 -04:00
|
|
|
# It will also attempt to install the appropriate version of node.js
|
2016-09-13 08:34:22 -04:00
|
|
|
# for the Kibana plugin tests using nvm, unless
|
|
|
|
# `xpack.kibana.build=false` is defined in
|
|
|
|
# ~/.gradle/gradle.properties. Set a custom nvm directory using the
|
|
|
|
# `NVM_DIR` environment variable.
|
2016-09-12 14:32:12 -04:00
|
|
|
#
|
2016-01-18 18:20:33 -05:00
|
|
|
|
2016-11-23 06:44:15 -05:00
|
|
|
# Turn on semi-strict mode
|
|
|
|
set -e
|
2016-11-29 07:44:56 -05:00
|
|
|
set -o pipefail
|
2016-11-21 09:36:55 -05:00
|
|
|
|
2016-11-23 06:44:15 -05:00
|
|
|
# Allow the user choose different test through a single cli arg
|
2016-11-28 06:19:48 -05:00
|
|
|
# default to `check` if no argument has been supplied
|
|
|
|
key=${1-check}
|
2016-11-21 09:36:55 -05:00
|
|
|
case $key in
|
2016-11-28 06:19:48 -05:00
|
|
|
packagingTest)
|
2016-12-19 12:53:00 -05:00
|
|
|
GRADLE_CLI_ARGS=(
|
|
|
|
"--info"
|
|
|
|
"-Pvagrant.boxes=all"
|
2017-05-22 11:53:36 -04:00
|
|
|
"packagingTest"
|
|
|
|
)
|
|
|
|
;;
|
|
|
|
bwcTest)
|
|
|
|
GRADLE_CLI_ARGS=(
|
|
|
|
"--info"
|
|
|
|
"bwcTest"
|
2016-12-19 12:53:00 -05:00
|
|
|
)
|
2016-11-29 07:44:56 -05:00
|
|
|
;;
|
2016-11-28 06:19:48 -05:00
|
|
|
check)
|
2016-12-19 12:53:00 -05:00
|
|
|
GRADLE_CLI_ARGS=(
|
|
|
|
"--info"
|
|
|
|
"check"
|
|
|
|
"-Dtests.network=true"
|
|
|
|
"-Dtests.badapples=true"
|
|
|
|
)
|
|
|
|
;;
|
|
|
|
jdk9)
|
|
|
|
GRADLE_CLI_ARGS=(
|
|
|
|
"-Pxpack.kibana.build=false"
|
|
|
|
"--info"
|
|
|
|
"check"
|
|
|
|
"-Dtests.network=true"
|
|
|
|
"-Dtests.badapples=true"
|
2016-12-20 09:35:18 -05:00
|
|
|
-Dtests.jvm.argline="--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.file=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/javax.net.ssl=ALL-UNNAMED"
|
2016-12-19 12:53:00 -05:00
|
|
|
)
|
2016-11-29 07:44:56 -05:00
|
|
|
;;
|
2016-11-28 06:19:48 -05:00
|
|
|
*)
|
2016-11-29 07:44:56 -05:00
|
|
|
echo "Unsupported cli argument $1. Allowed arguments are packagingTest or check. No argument defaults to check."
|
2016-11-28 06:19:48 -05:00
|
|
|
exit 1;;
|
2016-11-21 09:36:55 -05:00
|
|
|
esac
|
2016-01-18 18:20:33 -05:00
|
|
|
|
2016-04-07 08:34:58 -04:00
|
|
|
SCRIPT="$0"
|
2016-01-18 18:20:33 -05:00
|
|
|
|
2016-04-07 08:34:58 -04:00
|
|
|
# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path.
|
|
|
|
while [ -h "$SCRIPT" ] ; do
|
2016-11-29 07:44:56 -05:00
|
|
|
ls=$(ls -ld "$SCRIPT")
|
2016-04-07 08:34:58 -04:00
|
|
|
# Drop everything prior to ->
|
2016-11-29 07:44:56 -05:00
|
|
|
link=$(expr "$ls" : '.*-> \(.*\)$')
|
2016-04-07 08:34:58 -04:00
|
|
|
if expr "$link" : '/.*' > /dev/null; then
|
|
|
|
SCRIPT="$link"
|
|
|
|
else
|
2016-11-29 07:44:56 -05:00
|
|
|
SCRIPT=$(dirname "$SCRIPT")/"$link"
|
2016-04-07 08:34:58 -04:00
|
|
|
fi
|
|
|
|
done
|
2016-01-18 18:20:33 -05:00
|
|
|
|
2016-04-07 08:34:58 -04:00
|
|
|
# determine base directory
|
2016-11-29 07:44:56 -05:00
|
|
|
BASE_DIR=$(dirname "$SCRIPT")/..
|
2016-04-07 08:34:58 -04:00
|
|
|
|
|
|
|
# make BASE_DIR absolute
|
2016-11-29 07:44:56 -05:00
|
|
|
BASE_DIR=$(cd "$BASE_DIR"; pwd)
|
2016-04-07 08:34:58 -04:00
|
|
|
|
2016-12-14 18:02:28 -05:00
|
|
|
PARENT_DIR=$(cd "$BASE_DIR"/../..; pwd)
|
2016-04-07 08:34:58 -04:00
|
|
|
|
|
|
|
# go to the parent directory
|
|
|
|
cd $PARENT_DIR
|
|
|
|
|
|
|
|
if [ -z ${USE_EXISTING_ES:+x} ]; then
|
2016-01-18 18:20:33 -05:00
|
|
|
if [ -d "./elasticsearch" ]; then
|
2016-04-07 08:34:58 -04:00
|
|
|
echo "I expected a clean workspace but an 'elasticsearch' sibling directory already exists in [$PARENT_DIR]!"
|
2016-01-18 18:20:33 -05:00
|
|
|
echo
|
2016-04-07 08:34:58 -04:00
|
|
|
echo "Either define 'USE_EXISTING_ES' or remove the existing 'elasticsearch' sibling."
|
2016-01-18 18:20:33 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-12-06 03:52:03 -05:00
|
|
|
BRANCH=${PR_SOURCE_BRANCH:-${GIT_BRANCH#*/}} # GIT_BRANCH starts with the repo, i.e., origin/master
|
2016-12-06 03:43:28 -05:00
|
|
|
BRANCH=${BRANCH:-master} # fall back to CI branch if not testing a PR
|
2016-12-05 19:10:33 -05:00
|
|
|
echo "Checking if branch '$BRANCH' has elasticsearch sibling..."
|
2016-12-06 05:37:50 -05:00
|
|
|
if [[ -z "$(git ls-remote --heads https://github.com/elastic/elasticsearch.git $BRANCH)" ]]; then
|
2016-12-05 19:10:33 -05:00
|
|
|
echo "No sibling branch, using PR target branch"
|
|
|
|
BRANCH=$PR_TARGET_BRANCH
|
|
|
|
fi
|
|
|
|
echo "Checking out Elasticsearch '$BRANCH' branch..."
|
2017-03-24 14:50:02 -04:00
|
|
|
git clone -b $BRANCH https://github.com/elastic/elasticsearch.git
|
2017-02-06 18:36:49 -05:00
|
|
|
printf "Checked out Elasticsearch revision: %s\n" "$(git -C elasticsearch rev-parse HEAD)"
|
2016-01-18 18:20:33 -05:00
|
|
|
else
|
|
|
|
if [ -d "./elasticsearch" ]; then
|
|
|
|
echo "Using existing 'elasticsearch' checkout"
|
|
|
|
else
|
2016-04-07 08:34:58 -04:00
|
|
|
echo "You have defined 'USE_EXISTING_ES' but no existing Elasticsearch directory exists!"
|
2016-01-18 18:20:33 -05:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2016-09-12 14:32:12 -04:00
|
|
|
# back to base directory
|
|
|
|
cd "$BASE_DIR"
|
|
|
|
|
2017-02-10 14:02:42 -05:00
|
|
|
echo "Running x-pack-elasticsearch tests..."
|
2016-09-12 14:32:12 -04:00
|
|
|
echo "Running in $PWD"
|
2016-04-07 08:34:58 -04:00
|
|
|
|
|
|
|
# output the commands
|
2016-09-12 14:32:12 -04:00
|
|
|
set -xuf
|
2016-04-07 08:34:58 -04:00
|
|
|
|
|
|
|
# clean
|
|
|
|
gradle --stacktrace clean
|
2016-01-18 18:20:33 -05:00
|
|
|
|
2016-04-07 08:34:58 -04:00
|
|
|
# Actually run the tests
|
2016-12-19 12:53:00 -05:00
|
|
|
gradle "${GRADLE_CLI_ARGS[@]}"
|
2016-01-18 18:20:33 -05:00
|
|
|
|
|
|
|
# ~*~ shell-script-mode ~*~
|