From ac67eab8d8cb561966b6df9cc5932c6d6672f980 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Tue, 14 Jan 2014 23:44:00 -0700 Subject: [PATCH] Added support for jenkins to the ci script --- grunt/config/mochacov.js | 2 +- grunt/config/run.js | 12 ++---------- grunt/tasks.js | 8 ++++---- scripts/_utils.sh | 16 +++++++++++----- scripts/ci.sh | 29 ++++++++++++++++++----------- scripts/es.sh | 3 ++- scripts/jenkins.sh | 23 ++--------------------- 7 files changed, 40 insertions(+), 53 deletions(-) diff --git a/grunt/config/mochacov.js b/grunt/config/mochacov.js index d1ab2cc58..cb1190031 100644 --- a/grunt/config/mochacov.js +++ b/grunt/config/mochacov.js @@ -9,7 +9,7 @@ module.exports = { src: 'test/integration/yaml_suite/index.js' }, - integration_0_90: { + 'integration_0.90': { src: 'test/integration/yaml_suite/index_0_90.js' }, diff --git a/grunt/config/run.js b/grunt/config/run.js index 96097d52b..9448488ab 100644 --- a/grunt/config/run.js +++ b/grunt/config/run.js @@ -18,14 +18,6 @@ module.exports = { ] } }, - generate_yaml_tests: { - exec: 'node ./scripts/generate/index.js --no-api', - options: { - passArgs: [ - 'verbose' - ] - } - }, browser_test_server: { exec: 'node ./test/utils/server', options: { @@ -49,10 +41,10 @@ module.exports = { } } }, - install_es_0_90: { + 'install_es_0.90': { exec: './scripts/es.sh install 0.90', }, - es_0_90: { + 'es_0.90': { exec: './.snapshots/0.90_nightly/bin/elasticsearch -f ' + esOpts, options: { wait: false, diff --git a/grunt/tasks.js b/grunt/tasks.js index 4cd791c31..659004c60 100644 --- a/grunt/tasks.js +++ b/grunt/tasks.js @@ -15,10 +15,10 @@ module.exports = function (grunt) { 'mochacov:integration_master', 'stop:es_master', - 'run:install_es_0_90', - 'run:es_0_90', - 'mochacov:integration_0_90', - 'stop:es_0_90' + 'run:install_es_0.90', + 'run:es_0.90', + 'mochacov:integration_0.90', + 'stop:es_0.90' ]); grunt.registerTask('unit_test', [ diff --git a/scripts/_utils.sh b/scripts/_utils.sh index 13b48e519..03cf360b1 100644 --- a/scripts/_utils.sh +++ b/scripts/_utils.sh @@ -59,7 +59,7 @@ function manage_es { case "$DO" in install) - if [ ! -d "$ES_DIR" ]; then + if [ ! -x "$ES_BIN" ]; then echo "Downloading Elasticsearch $ES_VERSION" call rm -rf ${SNAPSHOTS}/${ES_VERSION}* call curl -#O $ES_URL @@ -69,6 +69,8 @@ function manage_es { if [ -z "$ES_RELEASE" ]; then ln -sf $ES_DIR "${SNAPSHOTS}/${ES_VERSION}" fi + else + echo "$ES_VERSION installed" fi ;; start) @@ -80,7 +82,7 @@ function manage_es { if [ $RUNNING -eq 0 ]; then echo "Already running $ES_VERSION" - exit 1 + return 1 else echo "PID file was left behind by ES" call rm $PIDFILE @@ -91,11 +93,15 @@ function manage_es { if [ ! -x "$ES_BIN" ]; then echo "Unable to find elasticsearch executable" - exit 1 + return 1 fi local ES_OPTS="-p $PIDFILE -Des.network.host=localhost -Des.discovery.zen.ping.multicast.enabled=false -Des.discovery.zen.ping_timeout=1" + if [ -n "$ES_NODE_NAME" ]; then + ES_OPTS="$ES_OPTS -Des.node.name=$ES_NODE_NAME" + fi + if [ "$ES_BRANCH" = "0.90" ]; then echo "Starting Elasticsearch $ES_VERSION" call $ES_BIN $ES_OPTS @@ -113,13 +119,13 @@ function manage_es { if [ $RUNNING -eq 0 ]; then kill $PID echo "Elasticsearch $ES_VERSION stopped" - exit 0 + return 0 fi rm $PIDFILE fi echo "Elasticsearch $ES_VERSION is not running." - exit 1 + return 1 ;; esac group "end:$DO es" diff --git a/scripts/ci.sh b/scripts/ci.sh index 7cc53abe3..d2313c44b 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -15,7 +15,10 @@ # ########### -source _utils.sh +HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ES_NODE_NAME="elasticsearch_js_test_runner" + +source $HERE/_utils.sh ##### # call grunt, but make sure it's installed first @@ -33,11 +36,16 @@ function grunt_ { call grunt $DO } - if [ -n "$ES_BRANCH" ]; then TESTING_BRANCH=$ES_BRANCH elif [ -n "$ES_V" ]; then - TESTING_BRANCH=$ES_V + re='^(.*)_nightly$'; + if [[ $ES_V =~ $re ]]; then + TESTING_BRANCH=${BASH_REMATCH[1]} + else + echo "unable to parse ES_V $ES_V" + exit 1 + fi else TESTING_BRANCH="master" fi @@ -47,15 +55,14 @@ if [[ "$NODE_UNIT" != "0" ]]; then fi if [[ "$NODE_INTEGRATION" != "0" ]]; then - if [[ -n "$ES_BRANCH" ]] && [[ "$USER" != "jenkins" ]]; then - manage_es start $ES_BRANCH $ES_RELEASE + call node scripts/generate --no-api + + if [[ "$USER" != "jenkins" ]]; then + manage_es start $TESTING_BRANCH $ES_RELEASE fi - - call node scripts/generate --no-api --es_branch=\"$TESTING_BRANCH\" - grunt_ mochacov:integration - - if [[ -n "$ES_BRANCH" ]] && [[ "$USER" != "jenkins" ]]; then - manage_es stop $ES_BRANCH $ES_RELEASE + grunt_ mochacov:integration_$TESTING_BRANCH + if [[ "$USER" != "jenkins" ]]; then + manage_es stop $TESTING_BRANCH $ES_RELEASE fi fi diff --git a/scripts/es.sh b/scripts/es.sh index 19625a6d3..245ae8122 100755 --- a/scripts/es.sh +++ b/scripts/es.sh @@ -16,4 +16,5 @@ fi source scripts/_utils.sh -manage_es $* \ No newline at end of file +manage_es $* +exit $? \ No newline at end of file diff --git a/scripts/jenkins.sh b/scripts/jenkins.sh index 866c1524c..297478cc1 100755 --- a/scripts/jenkins.sh +++ b/scripts/jenkins.sh @@ -1,25 +1,6 @@ #!/usr/bin/env bash export VERBOSE="true" +HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -if [ -x $ES_V ]; then - echo "missing ES_V environment var" - exit 1 -fi - -# generate the latest version of the yaml-tests -node scripts/generate --es_branch="=$ES_V" --no-api - -# unit tests -./node_modules/.bin/mocha test/unit/test_*.js \ - --require should \ - --reporter ../../../test/utils/jenkins-reporter.js \ - 2> test/junit-node-unit.xml - -# run the integration tests -./node_modules/.bin/mocha test/integration/yaml_suite/index.js \ - --require should \ - --host localhost \ - --port $es_port \ - --reporter ../../../test/utils/jenkins-reporter.js \ - 2> test/junit-node-integration.xml \ No newline at end of file +source $HERE/ci.sh \ No newline at end of file