2016-04-07 08:34:58 -04:00
|
|
|
#!/bin/sh
|
|
|
|
# This script is used as a single command to run the x-plugins 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
|
|
|
|
# unless the environment variable `USE_EXISTING_ES` has a value
|
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-28 06:19:48 -05:00
|
|
|
if [ -n "$BASH" ]; then
|
|
|
|
set -o pipefail
|
|
|
|
fi
|
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-11-23 06:44:15 -05:00
|
|
|
GRADLE_OPT_STRING="--info -Pvagrant.boxes=all :x-plugins:qa:vagrant:packagingTest"
|
|
|
|
break;;
|
2016-11-28 06:19:48 -05:00
|
|
|
check)
|
2016-11-23 06:44:15 -05:00
|
|
|
GRADLE_OPT_STRING="--info check -Dtests.network=true -Dtests.badapples=true"
|
|
|
|
break;;
|
2016-11-28 06:19:48 -05:00
|
|
|
*)
|
|
|
|
echo "Unsupported cli argument $1. Allowed parameters are packagingTest or check. No argument defaults to check."
|
|
|
|
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
|
|
|
|
ls=`ls -ld "$SCRIPT"`
|
|
|
|
# Drop everything prior to ->
|
|
|
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
|
|
if expr "$link" : '/.*' > /dev/null; then
|
|
|
|
SCRIPT="$link"
|
|
|
|
else
|
|
|
|
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
|
|
|
fi
|
|
|
|
done
|
2016-01-18 18:20:33 -05:00
|
|
|
|
2016-04-07 08:34:58 -04:00
|
|
|
# determine base directory
|
|
|
|
BASE_DIR=`dirname "$SCRIPT"`/..
|
|
|
|
|
|
|
|
# make BASE_DIR absolute
|
|
|
|
BASE_DIR=`cd "$BASE_DIR"; pwd`
|
|
|
|
|
|
|
|
PARENT_DIR=`cd "$BASE_DIR"/..; pwd`
|
|
|
|
|
|
|
|
# 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
|
|
|
|
echo "Checking out Elasticsearch 'master' branch..."
|
|
|
|
git clone https://github.com/elastic/elasticsearch.git --depth=1
|
|
|
|
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"
|
|
|
|
|
2016-09-13 08:34:22 -04:00
|
|
|
if ! grep -q -e '^xpack\.kibana\.build=false$' ~/.gradle/gradle.properties
|
|
|
|
then
|
|
|
|
# install the correct node.js version
|
|
|
|
if [ -z ${NVM_DIR:+x} ]; then
|
|
|
|
export NVM_DIR="/var/lib/jenkins/.nvm";
|
|
|
|
fi
|
2016-09-12 14:32:12 -04:00
|
|
|
|
2016-09-13 08:34:22 -04:00
|
|
|
NVM_SCRIPT="$NVM_DIR/nvm.sh"
|
|
|
|
if [ -s "$NVM_SCRIPT" ]; then
|
|
|
|
. "$NVM_SCRIPT" # load nvm
|
|
|
|
else
|
|
|
|
echo "Unable to find the nvm script at \"$NVM_SCRIPT\""
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-09-12 14:32:12 -04:00
|
|
|
|
2016-09-13 08:34:22 -04:00
|
|
|
echo "Installing node.js version $(cat ./kibana/.node-version)..."
|
|
|
|
nvm install "$(cat ./kibana/.node-version)"
|
|
|
|
fi
|
2016-09-12 14:32:12 -04:00
|
|
|
|
2016-01-18 18:20:33 -05:00
|
|
|
echo "Running X-Plugins 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-11-23 06:44:15 -05:00
|
|
|
gradle $GRADLE_OPT_STRING
|
2016-01-18 18:20:33 -05:00
|
|
|
|
|
|
|
# ~*~ shell-script-mode ~*~
|