added test runner for jenkins
This commit is contained in:
47
Gruntfile.js
47
Gruntfile.js
@ -5,6 +5,7 @@ module.exports = function (grunt) {
|
|||||||
|
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var child_process = require('child_process');
|
var child_process = require('child_process');
|
||||||
|
|
||||||
var sharedBrowserfyExclusions = [
|
var sharedBrowserfyExclusions = [
|
||||||
'src/lib/connectors/http.js',
|
'src/lib/connectors/http.js',
|
||||||
'src/lib/loggers/file.js',
|
'src/lib/loggers/file.js',
|
||||||
@ -168,12 +169,6 @@ module.exports = function (grunt) {
|
|||||||
'--web-security': false
|
'--web-security': false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
open: {
|
|
||||||
yaml_suite: {
|
|
||||||
path: 'http://localhost:8888',
|
|
||||||
app: 'Google Chrome'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -202,17 +197,47 @@ module.exports = function (grunt) {
|
|||||||
|
|
||||||
grunt.registerTask('build', [
|
grunt.registerTask('build', [
|
||||||
'clean:dist',
|
'clean:dist',
|
||||||
|
'run:yaml_tests',
|
||||||
|
'run:js_api',
|
||||||
'browserify',
|
'browserify',
|
||||||
'uglify:dist',
|
'uglify:dist',
|
||||||
'concat:dist_banners',
|
'concat:dist_banners'
|
||||||
'run:yaml_tests',
|
|
||||||
'run:js_api'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
grunt.registerTask('browser', [
|
var browsers = {
|
||||||
|
safari: 'Safari',
|
||||||
|
chrome: 'Google Chrome',
|
||||||
|
firefox: 'Firefox'
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.keys(browsers).forEach(function (browser) {
|
||||||
|
grunt.config.set('open_browser_tests.' + browser, {
|
||||||
|
appName: browsers[browser]
|
||||||
|
});
|
||||||
|
grunt.registerTask('browser_tests:' + browser, [
|
||||||
|
'build',
|
||||||
'run:integration_server',
|
'run:integration_server',
|
||||||
'open:yaml_suite',
|
'open_browser_tests:' + browser
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.registerMultiTask('open_browser_tests', function (host, port) {
|
||||||
|
host = host || 'localhost';
|
||||||
|
port = port || 9200;
|
||||||
|
|
||||||
|
var taskData = this.data;
|
||||||
|
|
||||||
|
grunt.task.requires('run:integration_server');
|
||||||
|
|
||||||
|
grunt.config.set('open.yaml_suite_' + this.target, {
|
||||||
|
path: 'http://localhost:8888?es_hostname=' + encodeURIComponent(host) + '&es_port=' + encodeURIComponent(port),
|
||||||
|
app: taskData.appName
|
||||||
|
});
|
||||||
|
|
||||||
|
grunt.task.run([
|
||||||
|
'open:yaml_suite_' + this.target,
|
||||||
'wait:integration_server'
|
'wait:integration_server'
|
||||||
]);
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
31
dist/elasticsearch.angular.js
vendored
31
dist/elasticsearch.angular.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! elasticsearch-js - v0.0.1 - 2013-11-05
|
/*! elasticsearch-js - v0.0.1 - 2013-11-11
|
||||||
* https://github.com/elasticsearch/elasticsearch-js
|
* https://github.com/elasticsearch/elasticsearch-js
|
||||||
* Copyright (c) 2013 Spencer Alger; Licensed Apache License */
|
* Copyright (c) 2013 Spencer Alger; Licensed Apache License */
|
||||||
// built using browserify
|
// built using browserify
|
||||||
@ -13906,7 +13906,8 @@ Client.prototype.ping = function (params, cb) {
|
|||||||
|
|
||||||
this.config.transport.request({
|
this.config.transport.request({
|
||||||
method: 'HEAD',
|
method: 'HEAD',
|
||||||
path: '/'
|
path: '/',
|
||||||
|
timeout: 100,
|
||||||
}, cb);
|
}, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -14352,7 +14353,7 @@ ConnectionAbstract.prototype.ping = function (params, cb) {
|
|||||||
return this.request({
|
return this.request({
|
||||||
path: '/',
|
path: '/',
|
||||||
method: 'HEAD',
|
method: 'HEAD',
|
||||||
timeout: '100'
|
timeout: 100
|
||||||
}, cb);
|
}, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -14579,6 +14580,15 @@ errors.ConnectionFault = function ConnectionFault(msg) {
|
|||||||
};
|
};
|
||||||
_.inherits(errors.ConnectionFault, ErrorAbstract);
|
_.inherits(errors.ConnectionFault, ErrorAbstract);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No Living Connections
|
||||||
|
* @param {String} [msg] - An error message that will probably end up in a log.
|
||||||
|
*/
|
||||||
|
errors.NoConnections = function NoConnections(msg) {
|
||||||
|
ErrorAbstract.call(this, msg || 'No Living connections', errors.NoConnections);
|
||||||
|
};
|
||||||
|
_.inherits(errors.NoConnections, ErrorAbstract);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Error
|
* Generic Error
|
||||||
* @param {String} [msg] - An error message that will probably end up in a log.
|
* @param {String} [msg] - An error message that will probably end up in a log.
|
||||||
@ -15285,7 +15295,9 @@ Console.prototype.onError = _.handler(function (e) {
|
|||||||
* @param {String} msg - The message to be logged
|
* @param {String} msg - The message to be logged
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log', 'WARNING');
|
Console.prototype.onWarning = function (msg) {
|
||||||
|
console[console.warn ? 'warn' : 'log']('WARNING', msg);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for the bridges "info" event
|
* Handler for the bridges "info" event
|
||||||
@ -15295,7 +15307,9 @@ Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log',
|
|||||||
* @param {String} msg - The message to be logged
|
* @param {String} msg - The message to be logged
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'INFO');
|
Console.prototype.onInfo = function (msg) {
|
||||||
|
console[console.warn ? 'info' : 'log']('INFO', msg);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for the bridges "debug" event
|
* Handler for the bridges "debug" event
|
||||||
@ -15305,8 +15319,9 @@ Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'IN
|
|||||||
* @param {String} msg - The message to be logged
|
* @param {String} msg - The message to be logged
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
Console.prototype.onDebug = _.bindKey(console, console.debug ? 'debug' : 'log', 'DEBUG');
|
Console.prototype.onDebug = function (msg) {
|
||||||
|
console[console.debug ? 'debug' : 'log']('DEBUG', msg);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Handler for the bridges "trace" event
|
* Handler for the bridges "trace" event
|
||||||
*
|
*
|
||||||
@ -15528,7 +15543,7 @@ TransportRequest.prototype._sendReqWithCon = _.handler(function (err, con) {
|
|||||||
this._request = con.request(this._params.req, this.bound._checkRespForFail);
|
this._request = con.request(this._params.req, this.bound._checkRespForFail);
|
||||||
} else {
|
} else {
|
||||||
this._log.warning('No living connections');
|
this._log.warning('No living connections');
|
||||||
this._respond(new errors.ConnectionFault('No living connections.'));
|
this._respond(new errors.NoConnections());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
10
dist/elasticsearch.angular.min.js
vendored
10
dist/elasticsearch.angular.min.js
vendored
File diff suppressed because one or more lines are too long
31
dist/elasticsearch.js
vendored
31
dist/elasticsearch.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! elasticsearch-js - v0.0.1 - 2013-11-05
|
/*! elasticsearch-js - v0.0.1 - 2013-11-11
|
||||||
* https://github.com/elasticsearch/elasticsearch-js
|
* https://github.com/elasticsearch/elasticsearch-js
|
||||||
* Copyright (c) 2013 Spencer Alger; Licensed Apache License */
|
* Copyright (c) 2013 Spencer Alger; Licensed Apache License */
|
||||||
// built using browserify
|
// built using browserify
|
||||||
@ -13866,7 +13866,8 @@ Client.prototype.ping = function (params, cb) {
|
|||||||
|
|
||||||
this.config.transport.request({
|
this.config.transport.request({
|
||||||
method: 'HEAD',
|
method: 'HEAD',
|
||||||
path: '/'
|
path: '/',
|
||||||
|
timeout: 100,
|
||||||
}, cb);
|
}, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -14312,7 +14313,7 @@ ConnectionAbstract.prototype.ping = function (params, cb) {
|
|||||||
return this.request({
|
return this.request({
|
||||||
path: '/',
|
path: '/',
|
||||||
method: 'HEAD',
|
method: 'HEAD',
|
||||||
timeout: '100'
|
timeout: 100
|
||||||
}, cb);
|
}, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -14583,6 +14584,15 @@ errors.ConnectionFault = function ConnectionFault(msg) {
|
|||||||
};
|
};
|
||||||
_.inherits(errors.ConnectionFault, ErrorAbstract);
|
_.inherits(errors.ConnectionFault, ErrorAbstract);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No Living Connections
|
||||||
|
* @param {String} [msg] - An error message that will probably end up in a log.
|
||||||
|
*/
|
||||||
|
errors.NoConnections = function NoConnections(msg) {
|
||||||
|
ErrorAbstract.call(this, msg || 'No Living connections', errors.NoConnections);
|
||||||
|
};
|
||||||
|
_.inherits(errors.NoConnections, ErrorAbstract);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Error
|
* Generic Error
|
||||||
* @param {String} [msg] - An error message that will probably end up in a log.
|
* @param {String} [msg] - An error message that will probably end up in a log.
|
||||||
@ -15289,7 +15299,9 @@ Console.prototype.onError = _.handler(function (e) {
|
|||||||
* @param {String} msg - The message to be logged
|
* @param {String} msg - The message to be logged
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log', 'WARNING');
|
Console.prototype.onWarning = function (msg) {
|
||||||
|
console[console.warn ? 'warn' : 'log']('WARNING', msg);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for the bridges "info" event
|
* Handler for the bridges "info" event
|
||||||
@ -15299,7 +15311,9 @@ Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log',
|
|||||||
* @param {String} msg - The message to be logged
|
* @param {String} msg - The message to be logged
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'INFO');
|
Console.prototype.onInfo = function (msg) {
|
||||||
|
console[console.warn ? 'info' : 'log']('INFO', msg);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for the bridges "debug" event
|
* Handler for the bridges "debug" event
|
||||||
@ -15309,8 +15323,9 @@ Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'IN
|
|||||||
* @param {String} msg - The message to be logged
|
* @param {String} msg - The message to be logged
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
Console.prototype.onDebug = _.bindKey(console, console.debug ? 'debug' : 'log', 'DEBUG');
|
Console.prototype.onDebug = function (msg) {
|
||||||
|
console[console.debug ? 'debug' : 'log']('DEBUG', msg);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Handler for the bridges "trace" event
|
* Handler for the bridges "trace" event
|
||||||
*
|
*
|
||||||
@ -15532,7 +15547,7 @@ TransportRequest.prototype._sendReqWithCon = _.handler(function (err, con) {
|
|||||||
this._request = con.request(this._params.req, this.bound._checkRespForFail);
|
this._request = con.request(this._params.req, this.bound._checkRespForFail);
|
||||||
} else {
|
} else {
|
||||||
this._log.warning('No living connections');
|
this._log.warning('No living connections');
|
||||||
this._respond(new errors.ConnectionFault('No living connections.'));
|
this._respond(new errors.NoConnections());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
10
dist/elasticsearch.min.js
vendored
10
dist/elasticsearch.min.js
vendored
File diff suppressed because one or more lines are too long
@ -29,7 +29,8 @@
|
|||||||
"grunt-mocha": "*",
|
"grunt-mocha": "*",
|
||||||
"grunt-contrib-concat": "~0.3.0",
|
"grunt-contrib-concat": "~0.3.0",
|
||||||
"grunt-open": "~0.2.2",
|
"grunt-open": "~0.2.2",
|
||||||
"grunt-run": "~0.1.0"
|
"grunt-run": "~0.1.0",
|
||||||
|
"xmlbuilder": "~0.4.3"
|
||||||
},
|
},
|
||||||
"license": "Apache License",
|
"license": "Apache License",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@ -9,7 +9,8 @@ var urlParamRE = /\{(\w+)\}/g;
|
|||||||
|
|
||||||
var outputPath = _.joinPath(__dirname, '../../../src/lib/api.js');
|
var outputPath = _.joinPath(__dirname, '../../../src/lib/api.js');
|
||||||
|
|
||||||
require('./actions').on('ready', function (actions) {
|
function download() {
|
||||||
|
require('./actions').on('ready', function (actions) {
|
||||||
var defs = [];
|
var defs = [];
|
||||||
|
|
||||||
var namespaces = _.filter(_.map(actions, function (action) {
|
var namespaces = _.filter(_.map(actions, function (action) {
|
||||||
@ -26,6 +27,14 @@ require('./actions').on('ready', function (actions) {
|
|||||||
actions: actions,
|
actions: actions,
|
||||||
namespaces: _.unique(namespaces.sort(), true)
|
namespaces: _.unique(namespaces.sort(), true)
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var stat = fs.statSync(outputPath);
|
||||||
|
if (!stat.isFile() || stat.ctime < Date.now() - 86400000) {
|
||||||
|
download();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
download();
|
||||||
|
}
|
||||||
|
|||||||
@ -63,7 +63,9 @@ Console.prototype.onError = _.handler(function (e) {
|
|||||||
* @param {String} msg - The message to be logged
|
* @param {String} msg - The message to be logged
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log', 'WARNING');
|
Console.prototype.onWarning = function (msg) {
|
||||||
|
console[console.warn ? 'warn' : 'log']('WARNING', msg);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for the bridges "info" event
|
* Handler for the bridges "info" event
|
||||||
@ -73,7 +75,9 @@ Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log',
|
|||||||
* @param {String} msg - The message to be logged
|
* @param {String} msg - The message to be logged
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'INFO');
|
Console.prototype.onInfo = function (msg) {
|
||||||
|
console[console.warn ? 'info' : 'log']('INFO', msg);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for the bridges "debug" event
|
* Handler for the bridges "debug" event
|
||||||
@ -83,8 +87,9 @@ Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'IN
|
|||||||
* @param {String} msg - The message to be logged
|
* @param {String} msg - The message to be logged
|
||||||
* @return {undefined}
|
* @return {undefined}
|
||||||
*/
|
*/
|
||||||
Console.prototype.onDebug = _.bindKey(console, console.debug ? 'debug' : 'log', 'DEBUG');
|
Console.prototype.onDebug = function (msg) {
|
||||||
|
console[console.debug ? 'debug' : 'log']('DEBUG', msg);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Handler for the bridges "trace" event
|
* Handler for the bridges "trace" event
|
||||||
*
|
*
|
||||||
|
|||||||
0
test/browser_integration/console.shim.js
Normal file
0
test/browser_integration/console.shim.js
Normal file
14
test/browser_integration/esjs_reporter.css
Normal file
14
test/browser_integration/esjs_reporter.css
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#mocha h1 {
|
||||||
|
font-size: .7em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.test {
|
||||||
|
font-size: .8em;
|
||||||
|
color: yellow;
|
||||||
|
}
|
||||||
|
.test.passed {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
.test.failed {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
213
test/browser_integration/esjs_reporter.js
Normal file
213
test/browser_integration/esjs_reporter.js
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
(function (global) {
|
||||||
|
/* jshint browser:true */
|
||||||
|
/* global alert */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save timer references to avoid Sinon interfering (see GH-237).
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Date = global.Date;
|
||||||
|
var setTimeout = global.setTimeout;
|
||||||
|
var setInterval = global.setInterval;
|
||||||
|
var clearTimeout = global.clearTimeout;
|
||||||
|
var clearInterval = global.clearInterval;
|
||||||
|
var mocha = global.mocha;
|
||||||
|
var Base = mocha.reporter('base')._reporter;
|
||||||
|
var $ = global.jQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose `HTML`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
global.EsjsReporter = EsjsReporter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize a new `HTML` reporter.
|
||||||
|
*
|
||||||
|
* @param {Runner} runner
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function EsjsReporter(runner, root) {
|
||||||
|
Base.call(this, runner);
|
||||||
|
|
||||||
|
var stats = this.stats;
|
||||||
|
var rootSuite = {
|
||||||
|
$el: $('<ul id="mocha-report"></ul>'),
|
||||||
|
results: []
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var stack = [rootSuite];
|
||||||
|
rootSuite.$el.appendTo(root || '#mocha');
|
||||||
|
|
||||||
|
runner.on('suite', function (suite) {
|
||||||
|
if (suite.root) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// suite
|
||||||
|
suite = {
|
||||||
|
name: suite.title,
|
||||||
|
results: [],
|
||||||
|
start: Date.now(),
|
||||||
|
stdout: '',
|
||||||
|
stderr: '',
|
||||||
|
$el: $('<li class="suite">').append($('<h1>').text(suite.title)),
|
||||||
|
$results: $('<ul>')
|
||||||
|
};
|
||||||
|
|
||||||
|
// append the list of results to the main element
|
||||||
|
suite.$results.appendTo(suite.$el);
|
||||||
|
|
||||||
|
// append to the previous stack leader
|
||||||
|
stack[0].$el.append(suite.$el);
|
||||||
|
if (!stack[0].suites) {
|
||||||
|
stack[0].suites = [];
|
||||||
|
}
|
||||||
|
stack[0].suites.push(suite);
|
||||||
|
|
||||||
|
// push the suite onto the top of the stack
|
||||||
|
stack.unshift(suite);
|
||||||
|
});
|
||||||
|
|
||||||
|
runner.on('suite end', function (suite) {
|
||||||
|
if (suite.root) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
stack[0].time = Date.now() - stack[0].start;
|
||||||
|
stack.shift();
|
||||||
|
});
|
||||||
|
|
||||||
|
runner.on('fail', function (test, err) {
|
||||||
|
if ('hook' === test.type) {
|
||||||
|
runner.emit('test end', test);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
runner.on('test end', function (test) {
|
||||||
|
// test
|
||||||
|
var $test = $('<li>')
|
||||||
|
.addClass('test')
|
||||||
|
.addClass(test.state)
|
||||||
|
.text(test.title + ' (' + test.duration + 'ms)');
|
||||||
|
|
||||||
|
var errMsg = void 0;
|
||||||
|
|
||||||
|
if ('passed' !== test.state && !test.pending) {
|
||||||
|
errMsg = test.err.stack || test.err.toString();
|
||||||
|
|
||||||
|
// FF / Opera do not add the message
|
||||||
|
if (!~errMsg.indexOf(test.err.message)) {
|
||||||
|
errMsg = test.err.message + '\n' + errMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
|
||||||
|
// check for the result of the stringifying.
|
||||||
|
if ('[object Error]' === errMsg) {
|
||||||
|
errMsg = test.err.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Safari doesn't give you a stack. Let's at least provide a source line.
|
||||||
|
if (!test.err.stack && test.err.sourceURL && test.err.line !== undefined) {
|
||||||
|
errMsg += '\n(' + test.err.sourceURL + ':' + test.err.line + ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$test.append($('<pre class="error">').text(errMsg));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!test.pending) {
|
||||||
|
if (stack[0]) {
|
||||||
|
stack[0].results.push({
|
||||||
|
name: test.title,
|
||||||
|
time: test.duration,
|
||||||
|
pass: test.state === 'passed',
|
||||||
|
errMsg: errMsg
|
||||||
|
});
|
||||||
|
$test.appendTo(stack[0].$results);
|
||||||
|
}
|
||||||
|
if (test.type === 'hook' || stats.tests === this.total) {
|
||||||
|
allTestsDone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function allTestsDone() {
|
||||||
|
window.testResults = {
|
||||||
|
stats: stats,
|
||||||
|
suites: $.map(rootSuite.suites, function removeElements(suite) {
|
||||||
|
var s = {
|
||||||
|
name: suite.name,
|
||||||
|
start: suite.start,
|
||||||
|
time: suite.time,
|
||||||
|
results: suite.results,
|
||||||
|
stdout: suite.stdout,
|
||||||
|
stderr: suite.stderr
|
||||||
|
};
|
||||||
|
|
||||||
|
if (suite.suites) {
|
||||||
|
s.suites = $.map(suite.suites, removeElements);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
$.post('/tests-complete', JSON.stringify(window.testResults), function () {
|
||||||
|
// alert('test complete');
|
||||||
|
window.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** override console to force all output to go to log and err, then we have all the output **/
|
||||||
|
global.console = (function () {
|
||||||
|
function flattenArgs(_arguments) {
|
||||||
|
var args = [];
|
||||||
|
for (var i = 0; i < _arguments.length; i++) {
|
||||||
|
args.push(_arguments[i]);
|
||||||
|
}
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
function argsToString(args) {
|
||||||
|
return $.map(flattenArgs(args), function (arg) {
|
||||||
|
return String(arg);
|
||||||
|
}).join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
var origLog = $.noop;
|
||||||
|
var origErr = $.noop;
|
||||||
|
if (global.console) {
|
||||||
|
if (global.console.log) {
|
||||||
|
origLog = $.proxy(global.console, 'log');
|
||||||
|
}
|
||||||
|
if (global.console.error) {
|
||||||
|
origErr = $.proxy(global.console, 'error');
|
||||||
|
} else {
|
||||||
|
origErr = origLog;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
log: function () {
|
||||||
|
if (stack[0]) {
|
||||||
|
stack[0].stdout += argsToString(arguments) + '\n';
|
||||||
|
} else {
|
||||||
|
origLog(argsToString(arguments));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
if (stack[0]) {
|
||||||
|
stack[0].stderr += argsToString(arguments) + '\n';
|
||||||
|
} else {
|
||||||
|
origErr(argsToString(arguments));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mocha.reporter(EsjsReporter);
|
||||||
|
|
||||||
|
}(this));
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
@ -6,11 +7,28 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="mocha"></div>
|
<div id="mocha"></div>
|
||||||
<script src="expect.js?_c={{ts}}"></script>
|
|
||||||
<script src="mocha.js?_c={{ts}}"></script>
|
<!-- libs -->
|
||||||
|
<script type="text/javascript" src="expect.js?_c=<%= ts %>"></script>
|
||||||
|
<script type="text/javascript" src="mocha.js?_c=<%= ts %>"></script>
|
||||||
|
<script type="text/javascript" src="jquery.js?_c=<%= ts %>"></script>
|
||||||
|
|
||||||
|
<!-- ESJS Reporter - sets itself as the reporter -->
|
||||||
|
<link rel="stylesheet" href="esjs_reporter.css?_c=<%= ts %>"/>
|
||||||
|
<script type="text/javascript" src="esjs_reporter.js?_c=<%= ts %>"></script>
|
||||||
|
|
||||||
|
<!-- global vars -->
|
||||||
|
<script>
|
||||||
|
var ES_HOSTNAME = '<%- es_hostname %>';
|
||||||
|
var ES_PORT = <%= es_port %>;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- test -->
|
||||||
<script>mocha.setup('bdd')</script>
|
<script>mocha.setup('bdd')</script>
|
||||||
<script src="client.js?_c={{ts}}"></script>
|
<script type="text/javascript" src="client.js?_c=<%= ts %>"></script>
|
||||||
<script src="yaml_tests.js?_c={{ts}}"></script>
|
<script type="text/javascript" src="yaml_tests.js?_c=<%= ts %>"></script>
|
||||||
|
|
||||||
|
<!-- begin -->
|
||||||
<script>
|
<script>
|
||||||
mocha.checkLeaks();
|
mocha.checkLeaks();
|
||||||
mocha.slow(1000);
|
mocha.slow(1000);
|
||||||
|
|||||||
6
test/browser_integration/jquery.js
vendored
Normal file
6
test/browser_integration/jquery.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -2,6 +2,13 @@ var http = require('http');
|
|||||||
var url = require('url');
|
var url = require('url');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
var crypto = require('crypto');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var util = require('util');
|
||||||
|
var chalk = require('chalk');
|
||||||
|
var moment = require('moment');
|
||||||
|
chalk.enabled = true;
|
||||||
|
|
||||||
var browserify = require('browserify');
|
var browserify = require('browserify');
|
||||||
var port = process.argv[2] || 8888;
|
var port = process.argv[2] || 8888;
|
||||||
|
|
||||||
@ -9,6 +16,15 @@ var middleware = [];
|
|||||||
|
|
||||||
Error.stackTraceLimit = Infinity;
|
Error.stackTraceLimit = Infinity;
|
||||||
|
|
||||||
|
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
function rand(length) {
|
||||||
|
var str = '';
|
||||||
|
while (str.length < length) {
|
||||||
|
str += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
function sendBundle(req, resp, files, opts, extend) {
|
function sendBundle(req, resp, files, opts, extend) {
|
||||||
resp.setHeader('Content-Type', 'application/javascript');
|
resp.setHeader('Content-Type', 'application/javascript');
|
||||||
resp.writeHead(200);
|
resp.writeHead(200);
|
||||||
@ -30,14 +46,126 @@ function sendBundle(req, resp, files, opts, extend) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function collectTestResults(req, resp) {
|
||||||
|
var body = '';
|
||||||
|
|
||||||
|
req.on('data', function (chunk) {
|
||||||
|
body += chunk;
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', function (err) {
|
||||||
|
resp.writeHead(500);
|
||||||
|
resp.end(err.message || 'failed to receive request completely');
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('end', function () {
|
||||||
|
var testDetails;
|
||||||
|
try {
|
||||||
|
testDetails = JSON.parse(body);
|
||||||
|
} catch (e) {
|
||||||
|
resp.writeHead(500);
|
||||||
|
resp.end('encoding failure');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.writeHead(200);
|
||||||
|
resp.end('good work');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The JUnit xml output desired by Jenkins essentially looks like this:
|
||||||
|
*
|
||||||
|
* testsuites:
|
||||||
|
* - testsuite: (name, timestamp, hostname, tests, failures, errors, time)
|
||||||
|
* - testcase: (error or failure, name, classname, time)
|
||||||
|
*
|
||||||
|
* Full XSD avaliable [here](http://windyroad.com.au/dl/Open%20Source/JUnit.xsd)
|
||||||
|
*
|
||||||
|
* from
|
||||||
|
*
|
||||||
|
* {
|
||||||
|
* stats: {
|
||||||
|
*
|
||||||
|
* }
|
||||||
|
* suite: [
|
||||||
|
* {
|
||||||
|
* name:
|
||||||
|
* results: []
|
||||||
|
* suites: [] // optional
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
var testXml = require('xmlbuilder');
|
||||||
|
var suites = testXml.create('testsuites');
|
||||||
|
var suiteCount = 0;
|
||||||
|
|
||||||
|
_.each(testDetails.suites, function serializeSuite(suiteInfo) {
|
||||||
|
|
||||||
|
var suite = suites.ele('testsuite', {
|
||||||
|
package: 'elasticsearch-js:yaml_tests',
|
||||||
|
id: suiteCount++,
|
||||||
|
name: suiteInfo.name,
|
||||||
|
timestamp: moment(suiteInfo.start).toJSON(),
|
||||||
|
hostname: 'localhost',
|
||||||
|
tests: (suiteInfo.results && suiteInfo.results.length) || 0,
|
||||||
|
failures: _.where(suiteInfo.results, {pass: false}).length,
|
||||||
|
errors: 0,
|
||||||
|
time: suiteInfo.time / 1000
|
||||||
|
});
|
||||||
|
|
||||||
|
_.each(suiteInfo.results, function (testInfo) {
|
||||||
|
var testcase = suite.ele('testcase', {
|
||||||
|
name: testInfo.name,
|
||||||
|
time: (testInfo.time || 0) / 1000,
|
||||||
|
classname: suiteInfo.name
|
||||||
|
});
|
||||||
|
|
||||||
|
if (testInfo.errMsg) {
|
||||||
|
testcase.ele('failure', {
|
||||||
|
message: testInfo.errMsg,
|
||||||
|
type: 'AssertError'
|
||||||
|
});
|
||||||
|
} else if (!testInfo.pass) {
|
||||||
|
testcase.ele('error', {
|
||||||
|
message: 'Unknown Error',
|
||||||
|
type: 'TestError'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (suiteInfo.suites) {
|
||||||
|
_.each(suiteInfo.suites, serializeSuite);
|
||||||
|
}
|
||||||
|
|
||||||
|
suite.ele('system-out', {}, suiteInfo.stdout);
|
||||||
|
suite.ele('system-err', {}, suiteInfo.stderr);
|
||||||
|
});
|
||||||
|
|
||||||
|
var filename = path.join(__dirname, 'test-output.xml');
|
||||||
|
fs.writeFile(filename, suites.toString({ pretty: true}), function (err) {
|
||||||
|
if (err) {
|
||||||
|
console.log('unable to save test-output', err.message);
|
||||||
|
console.trace();
|
||||||
|
process.exit(1);
|
||||||
|
} else {
|
||||||
|
console.log('test output written to ', filename);
|
||||||
|
process.exit(testDetails.stats.failures ? 1 : 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var server = http.createServer(function (req, resp) {
|
var server = http.createServer(function (req, resp) {
|
||||||
req.uri = url.parse(req.url).pathname;
|
var parsedUrl = url.parse(req.url, true);
|
||||||
|
req.uri = parsedUrl.pathname;
|
||||||
|
req.query = parsedUrl.query;
|
||||||
req.filename = path.join(__dirname, req.uri);
|
req.filename = path.join(__dirname, req.uri);
|
||||||
|
|
||||||
resp._end = resp.end;
|
var end = resp.end;
|
||||||
resp.end = function () {
|
resp.end = function () {
|
||||||
console.log(this.statusCode, req.uri);
|
console.log(chalk[this.statusCode < 300 ? 'green' : 'red'](this.statusCode), req.uri);
|
||||||
resp._end.apply(resp, arguments);
|
end.apply(resp, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
var middleIndex = -1;
|
var middleIndex = -1;
|
||||||
@ -57,6 +185,8 @@ var server = http.createServer(function (req, resp) {
|
|||||||
middleware.push(function (req, resp, next) {
|
middleware.push(function (req, resp, next) {
|
||||||
// resolve filenames
|
// resolve filenames
|
||||||
switch (req.uri) {
|
switch (req.uri) {
|
||||||
|
case '/tests-complete':
|
||||||
|
return collectTestResults(req, resp);
|
||||||
case '/expect.js':
|
case '/expect.js':
|
||||||
req.filename = path.join(__dirname, '../../node_modules/expect.js/expect.js');
|
req.filename = path.join(__dirname, '../../node_modules/expect.js/expect.js');
|
||||||
break;
|
break;
|
||||||
@ -131,13 +261,17 @@ middleware.push(function (req, resp, next) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.setHeader('Content-Type', contentType);
|
if (contentType === 'text/html') {
|
||||||
resp.writeHead(200);
|
resp.end(_.template(data, _.defaults(req.query, {
|
||||||
resp.end(
|
es_hostname: 'localhost',
|
||||||
data
|
es_port: 9200,
|
||||||
.replace(/\{\{ts\}\}/g, Date.now())
|
ts: rand(5)
|
||||||
.replace(/\{\{phantom\}\}/g, req.filename === '/phantom.html' ? '-phantom' : '')
|
})));
|
||||||
);
|
} else {
|
||||||
|
resp.end(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
12676
test/browser_integration/test-output.xml
Normal file
12676
test/browser_integration/test-output.xml
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,15 @@ var defaults = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (process.browser) {
|
if (process.browser) {
|
||||||
|
/* jshint browser:true */
|
||||||
|
if (window.ES_HOST) {
|
||||||
|
defaults.host = window.ES_HOST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.ES_PORT) {
|
||||||
|
defaults.port = window.ES_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = defaults;
|
module.exports = defaults;
|
||||||
} else {
|
} else {
|
||||||
module.exports = require('optimist')
|
module.exports = require('optimist')
|
||||||
|
|||||||
@ -8393,7 +8393,7 @@
|
|||||||
"do": {
|
"do": {
|
||||||
"index": {
|
"index": {
|
||||||
"index": "test_index",
|
"index": "test_index",
|
||||||
"type": "_percolator",
|
"type": ".percolator",
|
||||||
"id": "test_percolator",
|
"id": "test_percolator",
|
||||||
"body": {
|
"body": {
|
||||||
"query": {
|
"query": {
|
||||||
@ -8919,7 +8919,7 @@
|
|||||||
],
|
],
|
||||||
"suggest/10_basic.yaml": [
|
"suggest/10_basic.yaml": [
|
||||||
{
|
{
|
||||||
"Basic tests for suggest API": [
|
"setup": [
|
||||||
{
|
{
|
||||||
"skip": {
|
"skip": {
|
||||||
"version": "0 - 0.90.2",
|
"version": "0 - 0.90.2",
|
||||||
@ -8942,6 +8942,16 @@
|
|||||||
"do": {
|
"do": {
|
||||||
"indices.refresh": {}
|
"indices.refresh": {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Basic tests for suggest API - pre v1": [
|
||||||
|
{
|
||||||
|
"skip": {
|
||||||
|
"version": "1 - 99",
|
||||||
|
"reason": "Standard analyzer uses stopwords"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"do": {
|
"do": {
|
||||||
@ -8968,6 +8978,40 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Basic tests for suggest API - post v1": [
|
||||||
|
{
|
||||||
|
"skip": {
|
||||||
|
"version": "0 - 0.90.9",
|
||||||
|
"reason": "Standard analyzer ignores stopwords"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"do": {
|
||||||
|
"suggest": {
|
||||||
|
"body": {
|
||||||
|
"test_suggestion": {
|
||||||
|
"text": "The Amsterdma meetpu",
|
||||||
|
"term": {
|
||||||
|
"field": "body"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
"test_suggestion.1.options.0.text": "amsterdam"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": {
|
||||||
|
"test_suggestion.2.options.0.text": "meetup"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"update/10_doc.yaml": [
|
"update/10_doc.yaml": [
|
||||||
|
|||||||
Reference in New Issue
Block a user