- using ping to detect when ES is ready rather than sleep

- reusing es downloads to make local testing faster
- periodic checks will kill the script on failure
- coveralls report is only sent once per build
- failures sending the coveralls report won't cause the build to fail
This commit is contained in:
Spencer Alger
2014-01-07 17:13:05 -07:00
parent d7f12f1d86
commit a7c2417f0d
5 changed files with 114 additions and 83 deletions

View File

@ -1,19 +1,17 @@
language: node_js
node_js: false
matrix:
fast_finish: true
include:
- node_js: "0.8"
env: ES_BRANCH=master
- node_js: "0.10"
env: ES_RELEASE=0.90.8 ES_BRANCH=0.90 NO_UNIT=true
- node_js: "0.10"
env: ES_RELEASE=0.90.9 ES_BRANCH=0.90 NO_UNIT=true
env: ES_BRANCH=master COVERAGE=true
- node_js: "0.10"
env: ES_BRANCH=0.90 NO_UNIT=true
- node_js: "0.10"
env: ES_BRANCH=master
- node_js: "0.8"
env: ES_BRANCH=master
env: ES_RELEASE=0.90.9 ES_BRANCH=0.90 NO_UNIT=true
- node_js: "0.10"
env: ES_RELEASE=0.90.8 ES_BRANCH=0.90 NO_UNIT=true
exclude:
- node_js: false

View File

@ -71,7 +71,7 @@ async.series([
},
function (done) {
// checkout branch and clean it
cp.spawn('git', ['submodule', 'foreach', 'git checkout origin/' + branch + ' && git clean -f'], {
cp.spawn('git', ['submodule', 'foreach', 'git fetch origin master && git checkout origin/' + branch + ' && git clean -f'], {
stdio: stdio
}).on('exit', function (status) {
done(status ? new Error('Unable to checkout ' + branch) : void 0);

View File

@ -8,7 +8,6 @@ fi
ROOT="$PWD"
ES_SUBMODULE="$ROOT/src/elasticsearch"
SNAPSHOTS="$ROOT/.snapshots"
ES_BIN="$SNAPSHOTS/es/bin/elasticsearch"
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"
@ -17,63 +16,97 @@ if [ ! -z $ES_RELEASE ]; then
ES_URL="https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${ES_RELEASE}.zip"
fi
echo -en 'travis_fold:start:setup_es\\r'
if [ -d $SNAPSHOTS ]; then
echo "wiping out existing snapshots"
rm -rf $SNAPSHOTS
ES_DIR="$SNAPSHOTS/$ES_VERSION"
ES_BIN="$ES_DIR/bin/elasticsearch"
function fold {
echo -e "travis_fold:$1"
if [[ $1 =~ ^end ]]; then
echo ""
echo ""
fi
}
function check {
RESULT=$1
if [ "$RESULT" -gt "0" ]; then
echo "non-zero exit code: $RESULT"
exit $RESULT
fi
}
fold "start:setup_es"
echo "Setting up elasticsearch"
echo "Killing existsing java processes"
killall java 2>/dev/null
echo "Downloading Elasticsearch $ES_VERSION to $SNAPSHOTS"
mkdir $SNAPSHOTS &&
cd $SNAPSHOTS \
&& curl -O $ES_URL \
&& unzip elasticsearch-*.zip \
if [ ! -d "$SNAPSHOTS" ]; then
mkdir $SNAPSHOTS
fi
cd $SNAPSHOTS
if [ ! -d "$ES_DIR" ]; then
echo "Downloading Elasticsearch $ES_VERSION to $ES_DIR"
curl -O $ES_URL \
&& unzip elasticsearch-*.zip
check $?
rm elasticsearch-*.zip
check $?
mv elasticsearch-*/ $ES_DIR
check $?
fi
cd $ROOT
if [ ! -d $SNAPSHOTS ]; then
echo "Failed to download ES"
exit 1;
fi
mv $SNAPSHOTS/elasticsearch-*/ $SNAPSHOTS/es/
if [ ! -x $ES_BIN ]; then
echo "Unable to find elasticsearch binary $ES_BIN"
if [ ! -x "$ES_BIN" ]; then
echo "Unable to find elasticsearch executable"
exit 1
fi
if [ $ES_BRANCH = "0.90" ]; then
if [ "$ES_BRANCH" = "0.90" ]; then
echo "Starting Elasticsearch $ES_VERSION"
$ES_BIN \
-Des.network.host=localhost \
-Des.discovery.zen.ping.multicast.enabled=false \
-Des.discovery.zen.ping_timeout=1
check $?
else
echo "Starting Elasticsearch $ES_VERSION as a deamon"
$ES_BIN -d \
-Des.network.host=localhost \
-Des.discovery.zen.ping.multicast.enabled=false \
-Des.discovery.zen.ping_timeout=1
check $?
fi
fold "end:setup_es"
sleep 3
echo -en 'travis_fold:end:setup_es\\r\\n'
echo -en 'travis_fold:start:install_grunt\\r'
npm install -g grunt-cli
echo -en 'travis_fold:end:install_grunt\\r'
if [ $NO_UNIT = "true" ]; then
grunt --es_branch="=$ES_BRANCH" run:generate_yaml_tests mochacov:integration
RESULT=$?
else
grunt --es_branch="=$ES_BRANCH" jshint mochacov:unit run:generate_yaml_tests mochacov:integration mochacov:ship_coverage
RESULT=$?
if [ ! -x "`which grunt`" ]; then
fold "start:install_grunt"
echo "installing grunt-cli"
npm install -g grunt-cli
check $?
fold "end:install_grunt"
fi
killall java 2>/dev/null
exit $RESULT
if [ -z "$NO_UNIT" ]; then
grunt jshint mochacov:unit
check $?
fi
if [ -z "$NO_INTEGRATION" ]; then
grunt --es_branch="=$ES_BRANCH" run:generate_yaml_tests mochacov:integration
check $?
fi
if [ -n "$COVERAGE" ]; then
grunt mochacov:ship_coverage
fi
killall java 2>/dev/null

View File

@ -24,41 +24,51 @@ var esServer = null;
module.exports = {
create: function create(cb) {
if (argv.createServer || externalExists === false) {
if (!esServer) {
server.start(function (err, _server) {
esServer = _server;
if (err) {
done(err);
} else {
doCreateClient(done);
}
});
} else {
doCreateClient(done);
}
} else if (externalExists === void 0) {
doCreateClient(function () {
// create a client and ping the server for up to 15 seconds
doCreateClient({
logConfig: null
}, function () {
var attemptsRemaining = 30;
var timeout = 500;
(function ping() {
client.ping({
requestTimeout: 1000
maxRetries: 0,
requestTimeout: 100
}, function (err) {
if (err instanceof es.errors.ConnectionFault) {
externalExists = false;
create(done);
if (err && --attemptsRemaining) {
setTimeout(ping, timeout);
} else if (err) {
cb(new Error('unable to establish contact with ES'));
} else {
done(err);
// create a new client
doCreateClient(function () {
cb(void 0, client);
});
}
});
});
} else {
doCreateClient(done);
}
}());
});
function done(err) {
cb(err, client);
}
function doCreateClient(options, cb) {
if (typeof options === 'function') {
cb = options, options = {};
}
var logConfig = _.has(options, 'logConfig')
? options.logConfig
: {
type: BROWSER
? 'console'
: VERBOSE
? 'tracer'
: 'stdio',
level: VERBOSE
? 'trace'
: 'warning',
path: VERBOSE ? undefined : false
};
function doCreateClient(cb) {
// close existing client
if (client) {
client.close();
@ -71,17 +81,7 @@ module.exports = {
port: esServer ? esServer.__port : argv.port
}
],
log: {
type: BROWSER
? 'console'
: VERBOSE
? 'tracer'
: 'stdio',
level: VERBOSE
? 'trace'
: 'warning',
path: VERBOSE ? undefined : false
}
log: logConfig
});
_.nextTick(cb);