changes to the testing, incorporating browser_testing

This commit is contained in:
Spencer Alger
2014-01-09 16:23:02 -07:00
parent 9df9b30aa4
commit 3490479eee
36 changed files with 30713 additions and 6410 deletions

156
scripts/ci.sh Executable file
View File

@ -0,0 +1,156 @@
#!/usr/bin/env bash
###########
# Run the tests, and setup es if needed
#
# ENV VARS:
# TRAVIS - Identifies that we're running on travis-ci
# ES_V - version identifier set by Jenkins
# ES_BRANCH - the ES branch we should use to generate the tests and download es
# ES_VERSION - a specific ES version to download in use for testing
# NODE_UNIT=1 - 0/1 run the unit tests in node
# NODE_INTEGRATION=1 - 0/1 run the integration tests in node
# TEST_BROWSER - the browser to run using selemium '{{name}}:{{version}}:{{OS}}'
# COVERAGE - 0/1 check for coverage and ship it to coveralls
#
###########
#####
# Start or stop a group for travis
#####
function group {
if [ -n "$TRAVIS" ]; then
echo -e "travis_fold:$1"
fi
}
#####
# Do, log, and check a call
#####
function call {
DO="$*"
echo -e "\$ ${DO}"
$DO
RESULT=$?
if [ "$RESULT" -gt "0" ]; then
echo "non-zero exit code: $RESULT"
exit $RESULT
fi
}
#####
# call grunt, but make sure it exists first
#####
function grunt_ {
DO="$*"
if [ ! -x "`which grunt`" ]; then
group "start:install_grunt"
echo "installing grunt-cli"
call npm install -g grunt-cli
group "end:install_grunt"
fi
call grunt $DO
}
#####
# Download a version of ES and get it running
# @arg ES_BRANCH - The branch to run off of
# @arg ES_RELEASE - The specific release to run, overrides ES_BRANCH
#####
function get_es {
group "start:setup_es"
ES_BRANCH=$1
ES_RELEASE=$2
ROOT="$PWD"
ES_SUBMODULE="$ROOT/src/elasticsearch"
SNAPSHOTS="$ROOT/.snapshots"
if [ ! -d "$SNAPSHOTS" ]; then
mkdir $SNAPSHOTS
fi
if [ ! -z $ES_RELEASE ]; then
ES_VERSION="v${ES_RELEASE}"
ES_URL="https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${ES_RELEASE}.zip"
ES_DIR="${SNAPSHOTS}/${ES_VERSION}"
else
ES_VERSION="${ES_BRANCH}_nightly"
ES_URL="http://s3-us-west-2.amazonaws.com/build.elasticsearch.org/origin/$ES_BRANCH/nightly/JDK6/elasticsearch-latest-SNAPSHOT.zip"
DATE=`date +%Y_%m_%d`
ES_DIR="${SNAPSHOTS}/${ES_VERSION}_${DATE}"
if [ ! -d $ES_DIR ]; then
call rm -rf ${SNAPSHOTS}/${ES_VERSION}*
fi
fi
ES_BIN="$ES_DIR/bin/elasticsearch"
echo "Killing existsing java processes"
killall java 2>/dev/null
cd $SNAPSHOTS
if [ ! -d "$ES_DIR" ]; then
echo "Downloading Elasticsearch $ES_VERSION"
call curl -#O $ES_URL
call unzip -q elasticsearch-*.zip
call rm elasticsearch-*.zip
call mv elasticsearch-*/ $ES_DIR
fi
cd $ROOT
if [ ! -x "$ES_BIN" ]; then
echo "Unable to find elasticsearch executable"
exit 1
fi
if [ "$ES_BRANCH" = "0.90" ]; then
echo "Starting Elasticsearch $ES_VERSION"
call $ES_BIN \
-Des.network.host=localhost \
-Des.discovery.zen.ping.multicast.enabled=false \
-Des.discovery.zen.ping_timeout=1
else
echo "Starting Elasticsearch $ES_VERSION as a deamon"
call $ES_BIN -d \
-Des.network.host=localhost \
-Des.discovery.zen.ping.multicast.enabled=false \
-Des.discovery.zen.ping_timeout=1
fi
group "end:setup_es"
}
if [ -n "$ES_BRANCH" ]; then
TESTING_BRANCH=$ES_BRANCH
else if [ -n "$ES_V" ]; then
TESTING_BRANCH=$ES_V
else
TESTING_BRANCH="master"
fi
if [[ $NODE_UNIT -eq 1 ]]; then
grunt_ jshint mochacov:unit
fi
if [ flag $NODE_INTEGRATION ]; then
if [ -n "$ES_BRANCH" ] && [[ $USER != "jenkins" ]]; then
get_es $ES_BRANCH $ES_RELEASE
fi
call node scripts/generate --no-api --es_branch=$TESTING_BRANCH
grunt_ mochacov:integration
fi
if [ -n "$TEST_BROWSER" ]; then
call node scripts/browser_tests --browser=\"$TEST_BROWSER\" --es_branch=$TESTING_BRANCH
fi
if [[ $COVERAGE -eq 1 ]]; then
grunt_ mochacov:ship_coverage
fi
killall java 2>/dev/null