Skip to content

Commit 7912ae6

Browse files
author
Spencer Alger
committed
added test runner for jenkins
1 parent 0fa5da3 commit 7912ae6

File tree

18 files changed

+22408
-10552
lines changed

18 files changed

+22408
-10552
lines changed

Gruntfile.js

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = function (grunt) {
55

66
var _ = require('lodash');
77
var child_process = require('child_process');
8+
89
var sharedBrowserfyExclusions = [
910
'src/lib/connectors/http.js',
1011
'src/lib/loggers/file.js',
@@ -168,12 +169,6 @@ module.exports = function (grunt) {
168169
'--web-security': false
169170
}
170171
}
171-
},
172-
open: {
173-
yaml_suite: {
174-
path: 'http://localhost:8888',
175-
app: 'Google Chrome'
176-
}
177172
}
178173
});
179174

@@ -202,17 +197,47 @@ module.exports = function (grunt) {
202197

203198
grunt.registerTask('build', [
204199
'clean:dist',
200+
'run:yaml_tests',
201+
'run:js_api',
205202
'browserify',
206203
'uglify:dist',
207-
'concat:dist_banners',
208-
'run:yaml_tests',
209-
'run:js_api'
204+
'concat:dist_banners'
210205
]);
211206

212-
grunt.registerTask('browser', [
213-
'run:integration_server',
214-
'open:yaml_suite',
215-
'wait:integration_server'
216-
]);
207+
var browsers = {
208+
safari: 'Safari',
209+
chrome: 'Google Chrome',
210+
firefox: 'Firefox'
211+
};
212+
213+
Object.keys(browsers).forEach(function (browser) {
214+
grunt.config.set('open_browser_tests.' + browser, {
215+
appName: browsers[browser]
216+
});
217+
grunt.registerTask('browser_tests:' + browser, [
218+
'build',
219+
'run:integration_server',
220+
'open_browser_tests:' + browser
221+
]);
222+
});
223+
224+
grunt.registerMultiTask('open_browser_tests', function (host, port) {
225+
host = host || 'localhost';
226+
port = port || 9200;
227+
228+
var taskData = this.data;
229+
230+
grunt.task.requires('run:integration_server');
231+
232+
grunt.config.set('open.yaml_suite_' + this.target, {
233+
path: 'http://localhost:8888?es_hostname=' + encodeURIComponent(host) + '&es_port=' + encodeURIComponent(port),
234+
app: taskData.appName
235+
});
236+
237+
grunt.task.run([
238+
'open:yaml_suite_' + this.target,
239+
'wait:integration_server'
240+
]);
241+
});
217242

218243
};

dist/elasticsearch.angular.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! elasticsearch-js - v0.0.1 - 2013-11-05
1+
/*! elasticsearch-js - v0.0.1 - 2013-11-11
22
* https://github.com/elasticsearch/elasticsearch-js
33
* Copyright (c) 2013 Spencer Alger; Licensed Apache License */
44
// built using browserify
@@ -13906,7 +13906,8 @@ Client.prototype.ping = function (params, cb) {
1390613906

1390713907
this.config.transport.request({
1390813908
method: 'HEAD',
13909-
path: '/'
13909+
path: '/',
13910+
timeout: 100,
1391013911
}, cb);
1391113912
};
1391213913

@@ -14352,7 +14353,7 @@ ConnectionAbstract.prototype.ping = function (params, cb) {
1435214353
return this.request({
1435314354
path: '/',
1435414355
method: 'HEAD',
14355-
timeout: '100'
14356+
timeout: 100
1435614357
}, cb);
1435714358
};
1435814359

@@ -14579,6 +14580,15 @@ errors.ConnectionFault = function ConnectionFault(msg) {
1457914580
};
1458014581
_.inherits(errors.ConnectionFault, ErrorAbstract);
1458114582

14583+
/**
14584+
* No Living Connections
14585+
* @param {String} [msg] - An error message that will probably end up in a log.
14586+
*/
14587+
errors.NoConnections = function NoConnections(msg) {
14588+
ErrorAbstract.call(this, msg || 'No Living connections', errors.NoConnections);
14589+
};
14590+
_.inherits(errors.NoConnections, ErrorAbstract);
14591+
1458214592
/**
1458314593
* Generic Error
1458414594
* @param {String} [msg] - An error message that will probably end up in a log.
@@ -15285,7 +15295,9 @@ Console.prototype.onError = _.handler(function (e) {
1528515295
* @param {String} msg - The message to be logged
1528615296
* @return {undefined}
1528715297
*/
15288-
Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log', 'WARNING');
15298+
Console.prototype.onWarning = function (msg) {
15299+
console[console.warn ? 'warn' : 'log']('WARNING', msg);
15300+
};
1528915301

1529015302
/**
1529115303
* Handler for the bridges "info" event
@@ -15295,7 +15307,9 @@ Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log',
1529515307
* @param {String} msg - The message to be logged
1529615308
* @return {undefined}
1529715309
*/
15298-
Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'INFO');
15310+
Console.prototype.onInfo = function (msg) {
15311+
console[console.warn ? 'info' : 'log']('INFO', msg);
15312+
};
1529915313

1530015314
/**
1530115315
* Handler for the bridges "debug" event
@@ -15305,8 +15319,9 @@ Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'IN
1530515319
* @param {String} msg - The message to be logged
1530615320
* @return {undefined}
1530715321
*/
15308-
Console.prototype.onDebug = _.bindKey(console, console.debug ? 'debug' : 'log', 'DEBUG');
15309-
15322+
Console.prototype.onDebug = function (msg) {
15323+
console[console.debug ? 'debug' : 'log']('DEBUG', msg);
15324+
};
1531015325
/**
1531115326
* Handler for the bridges "trace" event
1531215327
*
@@ -15528,7 +15543,7 @@ TransportRequest.prototype._sendReqWithCon = _.handler(function (err, con) {
1552815543
this._request = con.request(this._params.req, this.bound._checkRespForFail);
1552915544
} else {
1553015545
this._log.warning('No living connections');
15531-
this._respond(new errors.ConnectionFault('No living connections.'));
15546+
this._respond(new errors.NoConnections());
1553215547
}
1553315548
});
1553415549

dist/elasticsearch.angular.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/elasticsearch.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! elasticsearch-js - v0.0.1 - 2013-11-05
1+
/*! elasticsearch-js - v0.0.1 - 2013-11-11
22
* https://github.com/elasticsearch/elasticsearch-js
33
* Copyright (c) 2013 Spencer Alger; Licensed Apache License */
44
// built using browserify
@@ -13866,7 +13866,8 @@ Client.prototype.ping = function (params, cb) {
1386613866

1386713867
this.config.transport.request({
1386813868
method: 'HEAD',
13869-
path: '/'
13869+
path: '/',
13870+
timeout: 100,
1387013871
}, cb);
1387113872
};
1387213873

@@ -14312,7 +14313,7 @@ ConnectionAbstract.prototype.ping = function (params, cb) {
1431214313
return this.request({
1431314314
path: '/',
1431414315
method: 'HEAD',
14315-
timeout: '100'
14316+
timeout: 100
1431614317
}, cb);
1431714318
};
1431814319

@@ -14583,6 +14584,15 @@ errors.ConnectionFault = function ConnectionFault(msg) {
1458314584
};
1458414585
_.inherits(errors.ConnectionFault, ErrorAbstract);
1458514586

14587+
/**
14588+
* No Living Connections
14589+
* @param {String} [msg] - An error message that will probably end up in a log.
14590+
*/
14591+
errors.NoConnections = function NoConnections(msg) {
14592+
ErrorAbstract.call(this, msg || 'No Living connections', errors.NoConnections);
14593+
};
14594+
_.inherits(errors.NoConnections, ErrorAbstract);
14595+
1458614596
/**
1458714597
* Generic Error
1458814598
* @param {String} [msg] - An error message that will probably end up in a log.
@@ -15289,7 +15299,9 @@ Console.prototype.onError = _.handler(function (e) {
1528915299
* @param {String} msg - The message to be logged
1529015300
* @return {undefined}
1529115301
*/
15292-
Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log', 'WARNING');
15302+
Console.prototype.onWarning = function (msg) {
15303+
console[console.warn ? 'warn' : 'log']('WARNING', msg);
15304+
};
1529315305

1529415306
/**
1529515307
* Handler for the bridges "info" event
@@ -15299,7 +15311,9 @@ Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log',
1529915311
* @param {String} msg - The message to be logged
1530015312
* @return {undefined}
1530115313
*/
15302-
Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'INFO');
15314+
Console.prototype.onInfo = function (msg) {
15315+
console[console.warn ? 'info' : 'log']('INFO', msg);
15316+
};
1530315317

1530415318
/**
1530515319
* Handler for the bridges "debug" event
@@ -15309,8 +15323,9 @@ Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'IN
1530915323
* @param {String} msg - The message to be logged
1531015324
* @return {undefined}
1531115325
*/
15312-
Console.prototype.onDebug = _.bindKey(console, console.debug ? 'debug' : 'log', 'DEBUG');
15313-
15326+
Console.prototype.onDebug = function (msg) {
15327+
console[console.debug ? 'debug' : 'log']('DEBUG', msg);
15328+
};
1531415329
/**
1531515330
* Handler for the bridges "trace" event
1531615331
*
@@ -15532,7 +15547,7 @@ TransportRequest.prototype._sendReqWithCon = _.handler(function (err, con) {
1553215547
this._request = con.request(this._params.req, this.bound._checkRespForFail);
1553315548
} else {
1553415549
this._log.warning('No living connections');
15535-
this._respond(new errors.ConnectionFault('No living connections.'));
15550+
this._respond(new errors.NoConnections());
1553615551
}
1553715552
});
1553815553

dist/elasticsearch.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"grunt-mocha": "*",
3030
"grunt-contrib-concat": "~0.3.0",
3131
"grunt-open": "~0.2.2",
32-
"grunt-run": "~0.1.0"
32+
"grunt-run": "~0.1.0",
33+
"xmlbuilder": "~0.4.3"
3334
},
3435
"license": "Apache License",
3536
"dependencies": {

scripts/generate/js_api/index.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,32 @@ var urlParamRE = /\{(\w+)\}/g;
99

1010
var outputPath = _.joinPath(__dirname, '../../../src/lib/api.js');
1111

12-
require('./actions').on('ready', function (actions) {
13-
var defs = [];
12+
function download() {
13+
require('./actions').on('ready', function (actions) {
14+
var defs = [];
1415

15-
var namespaces = _.filter(_.map(actions, function (action) {
16-
if (~action.location.indexOf('.')) {
17-
var path = action.location.split('.').slice(0, -1);
18-
_.pull(path, 'prototype');
19-
return path.join('.');
20-
}
21-
}));
22-
23-
clean(outputPath);
24-
console.log('writing', actions.length, 'api actions to', outputPath);
25-
fs.writeFileSync(outputPath, templates.apiFile({
26-
actions: actions,
27-
namespaces: _.unique(namespaces.sort(), true)
28-
}));
29-
});
16+
var namespaces = _.filter(_.map(actions, function (action) {
17+
if (~action.location.indexOf('.')) {
18+
var path = action.location.split('.').slice(0, -1);
19+
_.pull(path, 'prototype');
20+
return path.join('.');
21+
}
22+
}));
3023

24+
clean(outputPath);
25+
console.log('writing', actions.length, 'api actions to', outputPath);
26+
fs.writeFileSync(outputPath, templates.apiFile({
27+
actions: actions,
28+
namespaces: _.unique(namespaces.sort(), true)
29+
}));
30+
});
31+
}
3132

33+
try {
34+
var stat = fs.statSync(outputPath);
35+
if (!stat.isFile() || stat.ctime < Date.now() - 86400000) {
36+
download();
37+
}
38+
} catch (e) {
39+
download();
40+
}

src/lib/loggers/console.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ Console.prototype.onError = _.handler(function (e) {
6363
* @param {String} msg - The message to be logged
6464
* @return {undefined}
6565
*/
66-
Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log', 'WARNING');
66+
Console.prototype.onWarning = function (msg) {
67+
console[console.warn ? 'warn' : 'log']('WARNING', msg);
68+
};
6769

6870
/**
6971
* Handler for the bridges "info" event
@@ -73,7 +75,9 @@ Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log',
7375
* @param {String} msg - The message to be logged
7476
* @return {undefined}
7577
*/
76-
Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'INFO');
78+
Console.prototype.onInfo = function (msg) {
79+
console[console.warn ? 'info' : 'log']('INFO', msg);
80+
};
7781

7882
/**
7983
* Handler for the bridges "debug" event
@@ -83,8 +87,9 @@ Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'IN
8387
* @param {String} msg - The message to be logged
8488
* @return {undefined}
8589
*/
86-
Console.prototype.onDebug = _.bindKey(console, console.debug ? 'debug' : 'log', 'DEBUG');
87-
90+
Console.prototype.onDebug = function (msg) {
91+
console[console.debug ? 'debug' : 'log']('DEBUG', msg);
92+
};
8893
/**
8994
* Handler for the bridges "trace" event
9095
*

test/browser_integration/console.shim.js

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#mocha h1 {
2+
font-size: .7em;
3+
}
4+
5+
.test {
6+
font-size: .8em;
7+
color: yellow;
8+
}
9+
.test.passed {
10+
color: green;
11+
}
12+
.test.failed {
13+
color: red;
14+
}

0 commit comments

Comments
 (0)