added browser tests, modified ci script, removed testing for version 0.90.x

This commit is contained in:
Spencer Alger
2014-01-10 11:23:08 -07:00
parent 3490479eee
commit 3223fb4a6d
20 changed files with 194 additions and 91 deletions

1
.gitignore vendored
View File

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

View File

@ -1,21 +1,27 @@
language: node_js
node_js: false
env:
global:
- SAUCE_ACCESS_KEY=3259dd1e-a9f2-41cc-afd7-855d80588aeb
- SAUCE_USERNAME=elasticsearch-js
matrix:
include:
- node_js: "0.8"
env: ES_BRANCH=master
- node_js: "0.10"
env: ES_BRANCH=master COVERAGE=1
# - node_js: "0.10"
# env: ES_BRANCH=0.90 NODE_UNIT=0
# - node_js: "0.10"
# env: ES_RELEASE=0.90.9 ES_BRANCH=0.90 NODE_UNIT=0
# - node_js: "0.10"
# env: ES_RELEASE=0.90.8 ES_BRANCH=0.90 NODE_UNIT=0
- node_js: "0.10"
env: ES_BRANCH=0.90 NODE_UNIT=0
env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='chrome'
- node_js: "0.10"
env: ES_RELEASE=0.90.9 ES_BRANCH=0.90 NODE_UNIT=0
env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='firefox'
- node_js: "0.10"
env: ES_RELEASE=0.90.8 ES_BRANCH=0.90 NODE_UNIT=0
- node_js: "0.10"
env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='firefox::Windows\ XP'
- node_js: "0.10"
env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='chrome::Windows\ XP'
env: NODE_UNIT=0 NODE_INTEGRATION=0 TEST_BROWSER='ie'
exclude:
- node_js: false

View File

@ -35,6 +35,11 @@ module.exports = function (grunt) {
's3:upload_archives'
]);
grunt.registerTask('browser_clients:test', [
'run:browser_test_server',
'saucelabs-mocha'
]);
grunt.registerTask('__check_for_confirmation', function () {
if (grunt.config.get('confirm.release')) {
grunt.log.verbose.writeln('release confirmed');

View File

@ -17,20 +17,11 @@ module.exports = {
]
}
},
browser_integration_tests: {
exec: 'node ./scripts/run_browser_integration_suite',
browser_test_server: {
exec: 'node ./test/utils/server',
options: {
passArgs: [
'browsers'
]
}
},
browser_unit_tests: {
exec: './node_modules/.bin/testling .',
options: {
passArgs: [
'x'
]
wait: false,
ready: /listening/
}
}
};

View File

@ -0,0 +1,63 @@
module.exports = {
options: {
urls: [
'http://127.0.0.1:8000/jquery.html',
'http://127.0.0.1:8000/browser.html',
'http://127.0.0.1:8000/angular.html'
],
build: process.env.TRAVIS_JOB_ID || 'local_' + Date.now(),
detailedError: true
},
chrome: {
options: {
browsers: [
{
browserName: 'chrome',
platform: 'Windows 8'
},
{
browserName: 'chrome',
platform: 'Linux'
}
],
tags: ['master', 'chrome']
}
},
ie: {
options: {
browsers: [
{
browserName: 'internet explorer',
version: '11',
platform: 'Windows 8.1'
},
{
browserName: 'internet explorer',
version: '10',
platform: 'Windows 8'
},
{
browserName: 'internet explorer',
version: '9',
platform: 'Windows 7'
}
],
tags: ['master', 'ie']
}
},
firefox: {
options: {
browsers: [
{
browserName: 'firefox',
platform: 'Windows 7'
},
{
browserName: 'firefox',
platform: 'Linux'
}
],
tags: ['master', 'firefox']
}
}
};

View File

@ -48,7 +48,8 @@
"glob": "~3.2.7",
"expect.js": "~0.2.0",
"aliasify": "~1.2.1",
"express": "~3.4.7"
"express": "~3.4.7",
"grunt-saucelabs": "git://github.com/spenceralger/grunt-saucelabs.git#stable_mocha_runner"
},
"license": "Apache 2.0",
"dependencies": {
@ -66,8 +67,7 @@
"test/unit/angular-*.js"
],
"files": [
"test/unit/test_!(file_logger|http_connector|stdio_logger|console_logger|stream_logger|tracer_logger|transport_with_server)*",
"test/unit/browser_test_*.js"
"test/unit/test_!(file_logger|http_connector|stdio_logger|console_logger|stream_logger|tracer_logger|transport_with_server)*"
],
"harness": "mocha",
"browsers": {

View File

@ -30,7 +30,7 @@ function group {
function call {
DO="$*"
echo -e "\$ ${DO}"
$DO
echo $DO | bash
RESULT=$?
if [ "$RESULT" -gt "0" ]; then
echo "non-zero exit code: $RESULT"
@ -69,10 +69,10 @@ function get_es {
SNAPSHOTS="$ROOT/.snapshots"
if [ ! -d "$SNAPSHOTS" ]; then
mkdir $SNAPSHOTS
mkdir -p $SNAPSHOTS
fi
if [ ! -z $ES_RELEASE ]; then
if [ -n "$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}"
@ -88,20 +88,17 @@ function get_es {
ES_BIN="$ES_DIR/bin/elasticsearch"
echo "Killing existsing java processes"
killall java 2>/dev/null
cd $SNAPSHOTS
call 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
unzip -q elasticsearch-*.zip
rm elasticsearch-*.zip
mv elasticsearch-*/ $ES_DIR
fi
cd $ROOT
call cd $ROOT
if [ ! -x "$ES_BIN" ]; then
echo "Unable to find elasticsearch executable"
@ -126,31 +123,34 @@ function get_es {
if [ -n "$ES_BRANCH" ]; then
TESTING_BRANCH=$ES_BRANCH
else if [ -n "$ES_V" ]; then
elif [ -n "$ES_V" ]; then
TESTING_BRANCH=$ES_V
else
TESTING_BRANCH="master"
fi
if [[ $NODE_UNIT -eq 1 ]]; then
if [[ "$NODE_UNIT" != "0" ]]; then
grunt_ jshint mochacov:unit
fi
if [ flag $NODE_INTEGRATION ]; then
if [ -n "$ES_BRANCH" ] && [[ $USER != "jenkins" ]]; then
if [[ "$NODE_INTEGRATION" != "0" ]]; then
if [[ -n "$ES_BRANCH" ]] && [[ "$USER" != "jenkins" ]]; then
killall java 2>/dev/null
get_es $ES_BRANCH $ES_RELEASE
fi
call node scripts/generate --no-api --es_branch=$TESTING_BRANCH
call node scripts/generate --no-api --es_branch=\"$TESTING_BRANCH\"
grunt_ mochacov:integration
if [[ -n "$ES_BRANCH" ]] && [[ "$USER" != "jenkins" ]]; then
killall java 2>/dev/null
fi
fi
if [ -n "$TEST_BROWSER" ]; then
call node scripts/browser_tests --browser=\"$TEST_BROWSER\" --es_branch=$TESTING_BRANCH
if [[ -n "$TEST_BROWSER" ]]; then
grunt_ run:browser_test_server saucelabs-mocha:${TEST_BROWSER}
fi
if [[ $COVERAGE -eq 1 ]]; then
if [[ "$COVERAGE" == "1" ]]; then
grunt_ mochacov:ship_coverage
fi
killall java 2>/dev/null

View File

@ -349,7 +349,7 @@ aliases = {
'/{index}/_stats/search/{search_groups}',
'/{index}/_stats/fielddata/{fields}'
],
'search': [
'/_search'
]
// 'search': [
// '/_search'
// ]
};

View File

@ -3513,6 +3513,9 @@ api.search = ca({
type: 'list'
}
}
},
{
fmt: '/_search'
}
],
method: 'POST'

View File

@ -213,10 +213,8 @@ function exec(transport, spec, params, cb) {
if (!request.path) {
// there must have been some mimimun requirements that were not met
throw new TypeError(
'Unable to build a path with those params. Supply at least ' +
_.keys(spec.urls[spec.urls.length - 1].req).join(', ')
);
var minUrl = spec.url || spec.urls[spec.urls.length - 1];
throw new TypeError('Unable to build a path with those params. Supply at least ' + _.keys(minUrl.req).join(', '));
}
// build the query string

View File

@ -8,10 +8,13 @@
<div id="mocha"></div>
<script src="expect.js"></script>
<script src="mocha.js"></script>
<script>mocha.setup('bdd');</script>
<script>mocha.checkLeaks();</script>
<script>
mocha.setup('bdd');
mocha.checkLeaks();
mocha.globals(['mochaRunner']);
</script>
<script src="angular.js"></script>
<script src="angular_build.js"></script>
<script src="begin!"></script>
<script>var mochaRunner = mocha.run();</script>
</body>
</html>

View File

@ -8,10 +8,12 @@
<div id="mocha"></div>
<script src="expect.js"></script>
<script src="mocha.js"></script>
<script>mocha.setup('bdd');</script>
<script>mocha.checkLeaks();</script>
<script src="angular.js"></script>
<script src="angular_build.js"></script>
<script src="begin!"></script>
<script>
mocha.setup('bdd');
mocha.checkLeaks();
mocha.globals(['mochaRunner', 'elasticsearch']);
</script>
<script src="browser_build.js"></script>
<script>var mochaRunner = mocha.run();</script>
</body>
</html>

View File

@ -117,24 +117,34 @@ function YamlDoc(doc, file) {
expect(method).to.be.a('function');
if (_.isPlainObject(action.args)) {
action.name += ' ' + _.keys(action.args).join(', ');
action.name += '(' + JSON.stringify(action.args) + ')';
} else if (action.args) {
action.name += ' ' + action.args;
action.name += '(' + action.args + ')';
}
// wrap in a check for skipping
action.bound = _.bind(method, self, action.args);
// create a function that can be passed to
// create a function that can be passed to mocha or async
action.testable = function (done) {
if (self.skipping || self.file.skipping) {
return done();
}
if (method.length > 1) {
action.bound(done);
action.bound(function (err) {
if (err) {
err.message += ' in ' + action.name;
}
done(err);
});
} else {
action.bound();
done();
try {
action.bound();
done();
} catch (err) {
err.message += ' in ' + action.name;
done(err);
}
}
};

View File

@ -8,10 +8,13 @@
<div id="mocha"></div>
<script src="expect.js"></script>
<script src="mocha.js"></script>
<script>mocha.setup('bdd');</script>
<script>mocha.checkLeaks();</script>
<script src="angular.js"></script>
<script src="angular_build.js"></script>
<script src="begin!"></script>
<script>
mocha.setup('bdd');
mocha.checkLeaks();
mocha.globals(['mochaRunner', 'jQuery']);
</script>
<script src="jquery.js"></script>
<script src="jquery_build.js"></script>
<script>var mochaRunner = mocha.run();</script>
</body>
</html>

View File

@ -0,0 +1,17 @@
/* jshint browser:true */
var expect = require('expect.js');
describe('elasticsearch namespace', function () {
var es = window.elasticsearch;
it('is defined on the window', function () {
expect(es).to.be.ok();
});
it('has Client, ConnectionPool, Transport, and errors keys', function () {
expect(es).to.have.keys('Client', 'ConnectionPool', 'Transport', 'errors');
});
it('can create a client', function () {
var client = new es.Client({ hosts: null });
expect(client).to.be.a(es.Client);
client.close();
});
});

View File

@ -0,0 +1,18 @@
/* jshint browser:true */
var expect = require('expect.js');
describe('jQuery.es namespace', function () {
var $ = window.jQuery;
it('is defined on the global jQuery', function () {
expect($.es).to.be.ok();
});
it('has Client, ConnectionPool, Transport, and errors keys', function () {
expect($.es).to.have.keys('Client', 'ConnectionPool', 'Transport', 'errors');
});
it('can create a client', function () {
var client = new $.es.Client({ hosts: null });
expect(client).to.be.a($.es.Client);
client.close();
});
});

View File

@ -98,7 +98,7 @@ describe('Client Action runner', function () {
it('handles passing just the callback', function () {
var action = makeClientActionProxy(function (params, cb) {
expect(_.isObject(params)).to.be.ok;
expect(_.isObject(params)).to.be.ok();
expect(cb).to.be.a('function');
});

View File

@ -479,6 +479,7 @@ describe('Transport Class', function () {
expect(err).to.be.a(errors.ConnectionFault);
expect(resp).to.be(undefined);
expect(body).to.be(undefined);
trans.close();
done();
});
};

View File

@ -11,7 +11,6 @@ var pkg = require(root + '/package.json');
var defaultFiles = _.transform(pkg.testling.files, function (files, pattern) {
[].push.apply(files, _.map(glob.sync(pattern), function (filename) {
console.log('resolving', filename);
return path.resolve(root, filename);
}));
}, []);
@ -25,7 +24,6 @@ var aliasify = require('aliasify').configure({
function browserBuild(name) {
return function (req, res, next) {
res.set('Content-Type', 'application/javascript');
var b = browserify(_.union(defaultFiles, [
@ -66,23 +64,7 @@ app
// bundles
.get('/angular_build.js', browserBuild('angular'))
.get('/jquery_build.js', browserBuild('jquery'))
.get('/browser_build.js', browserBuild('browser'))
// stupid
.get('/begin!', function (req, res) {
res.set('Content-Type', 'application/javascript');
res.send([
'mocha.run().on(\'end\', function () {',
' var stats = window.completeTestStats = {};',
' for (var key in this.stats) {',
' if (this.stats.hasOwnProperty(key)) {',
' stats[key] = this.stats[key];',
' }',
' }',
' console && console.dir && console.dir(window.completeTestStats);',
'});'
].join('\n'));
});
.get('/browser_build.js', browserBuild('browser'));
http.createServer(app).listen(8000, function () {
console.log('listening on port 8000');