Updated testing to pull yaml tests from a specific es branch, and setup

travis script that will download the latest build from a branch or a release
based on the config it receives.
This commit is contained in:
Spencer Alger
2014-01-07 14:34:37 -07:00
parent bbbfcfa33e
commit d1e04c57fb
8 changed files with 160 additions and 80 deletions

3
.gitignore vendored
View File

@ -13,4 +13,5 @@ test/integration/yaml_suite/yaml_tests.json
junit-*.xml
test.log
elasticsearch*.log
coverage.html
coverage.html
.snapshots

View File

@ -2,9 +2,22 @@ language: node_js
node_js:
- "0.10"
- "0.8"
services:
- elasticsearch
before_script:
- npm install -g grunt-cli
script:
- grunt travis
env:
# - ES_RELEASE=0.90.0 ES_BRANCH=0.90
# - ES_RELEASE=0.90.1 ES_BRANCH=0.90
# - ES_RELEASE=0.90.2 ES_BRANCH=0.90
# - ES_RELEASE=0.90.3 ES_BRANCH=0.90
# - ES_RELEASE=0.90.4 ES_BRANCH=0.90
# - ES_RELEASE=0.90.5 ES_BRANCH=0.90
# - ES_RELEASE=0.90.6 ES_BRANCH=0.90
- ES_RELEASE=0.90.7 ES_BRANCH=0.90
- ES_RELEASE=0.90.8 ES_BRANCH=0.90
- ES_RELEASE=0.90.9 ES_BRANCH=0.90
- ES_BRANCH=0.90
- ES_BRANCH=master
script: ./scripts/travis.sh
email:
recipients:
- spencer.alger@elasticsearch.com
on_success: change
on_failure: always

View File

@ -1,18 +1,24 @@
module.exports = {
options: {
cwd: './scripts'
},
generate: {
exec: 'node generate/index.js',
exec: 'node ./scripts/generate/index.js',
options: {
passArgs: [
'verbose',
'es_version'
'es_branch'
]
}
},
generate_yaml_tests: {
exec: 'node ./scripts/generate/index.js --no-api',
options: {
passArgs: [
'verbose',
'es_branch'
]
}
},
browser_integration_tests: {
exec: 'node run_browser_integration_suite',
exec: 'node ./scripts/run_browser_integration_suite',
options: {
passArgs: [
'browsers'

View File

@ -5,14 +5,10 @@ module.exports = function (grunt) {
'test'
]);
grunt.registerTask('generate', [
'run:generate'
]);
grunt.registerTask('test', [
'jshint',
'mochacov:unit',
'generate',
'run:generate',
'mochacov:integration',
]);
@ -25,9 +21,4 @@ module.exports = function (grunt) {
'mochacov:make_coverage_html',
'open:coverage'
]);
grunt.registerTask('travis', [
'test',
'mochacov:ship_coverage'
]);
};

View File

@ -20,7 +20,7 @@ var argv = require('optimist')
default: true,
boolean: true
},
es_version: {
es_branch: {
default: 'master',
string: true,
alias: 'b'
@ -39,62 +39,58 @@ if (!argv.force && process.env.FORCE || process.env.FORCE_GEN) {
argv.force = argv.f = process.env.FORCE || process.env.FORCE_GEN;
}
function updateSubmodules(done) {
var branch = argv.es_version;
// branch can be prefixed with = or suffixed with _nightly
if (branch.indexOf) {
['='].forEach(function removePrefix(pref) {
if (branch.indexOf(pref) === 0) {
branch = branch.substring(pref.length);
}
});
['_nightly'].forEach(function removeSuffix(suf) {
if (branch.indexOf(suf) === branch.length - suf.length) {
branch = branch.substr(0, branch.length - suf.length);
}
});
}
var stdio = [
'ignore',
argv.verbose ? process.stdout : 'ignore',
process.stderr
];
async.series([
function (done) {
// init submodules
cp.spawn('git', ['submodule', 'update', '--init'], {
stdio: stdio
}).on('exit', function (status) {
done(status ? new Error('Unable to init submodules.') : void 0);
});
},
function (done) {
// checkout branch and clean it
cp.spawn('git', ['submodule', 'foreach', 'git checkout --detach origin/' + branch + ' && git clean -f'], {
stdio: stdio
}).on('exit', function (status) {
done(status ? new Error('Unable to init submodules.') : void 0);
});
var branch = argv.es_branch;
// branch can be prefixed with = or suffixed with _nightly
if (branch.indexOf) {
['='].forEach(function removePrefix(pref) {
if (branch.indexOf(pref) === 0) {
branch = branch.substring(pref.length);
}
], done);
});
['_nightly'].forEach(function removeSuffix(suf) {
if (branch.indexOf(suf) === branch.length - suf.length) {
branch = branch.substr(0, branch.length - suf.length);
}
});
}
updateSubmodules(function (err) {
var stdio = [
'ignore',
argv.verbose ? process.stdout : 'ignore',
process.stderr
];
async.series([
function (done) {
cp.spawn('git', ['submodule', 'update', '--init'], {
stdio: stdio
}).on('exit', function (status) {
done(status ? new Error('Unable to init submodules.') : void 0);
});
},
function (done) {
// checkout branch and clean it
cp.spawn('git', ['submodule', 'foreach', 'git checkout origin/' + branch + ' && git clean -f'], {
stdio: stdio
}).on('exit', function (status) {
done(status ? new Error('Unable to checkout ' + branch) : void 0);
});
},
function (done) {
var tasks = [];
if (argv.api) {
tasks.push(require('./js_api'));
}
if (argv.tests) {
tasks.push(require('./yaml_tests'));
}
async.parallel(tasks, done);
}
], function (err) {
if (err) {
throw err;
}
var tasks = [];
if (argv.api) {
tasks.push(require('./js_api'));
}
if (argv.tests) {
tasks.push(require('./yaml_tests'));
}
async.parallel(tasks, function () {});
});

View File

@ -1,8 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
# generate the latest version of the yaml-tests
node scripts/generate/ --no-api --es_version="=$ES_V"
./node_modules/.bin/grunt run:generate_yaml_tests --es_branch="=$ES_V"
export VERBOSE="true"

74
scripts/travis.sh Executable file
View File

@ -0,0 +1,74 @@
#!/usr/bin/env bash
if [ -z $ES_BRANCH ]; then
echo "Missing ES_BRANCH environment var"
exit 1
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"
if [ ! -z $ES_RELEASE ]; then
ES_VERSION="v${ES_RELEASE}"
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
fi
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 \
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"
exit 1
fi
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
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
fi
sleep 3
echo -en 'travis_fold:end:setup_es\\r'
echo -en 'travis_fold:start:install_grunt\\r'
npm install -g grunt-cli
echo -en 'travis_fold:end:install_grunt\\r'
grunt --es_branch="=$ES_BRANCH" jshint mochacov:unit run:generate_yaml_tests mochacov:integration mochacov:ship_coverage
RESULT=$?
killall java 2>/dev/null
exit $RESULT