Moves acceptance test about statsd uncaugth exception to integration
This commit is contained in:
parent
208dd209a4
commit
bbac1df463
@ -102,37 +102,4 @@ describe('regressions', function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// See https://github.com/CartoDB/Windshaft/issues/167
|
|
||||||
it("#167 does not die on unexistent statsd host", function(done) {
|
|
||||||
var CustomOptions = _.clone(ServerOptions);
|
|
||||||
CustomOptions.statsd = _.clone(CustomOptions.statsd);
|
|
||||||
CustomOptions.statsd.host = 'whoami.vizzuality.com';
|
|
||||||
CustomOptions.statsd.cacheDns = false;
|
|
||||||
var server = cartodbServer(CustomOptions);
|
|
||||||
server.req2params = CustomOptions.req2params;
|
|
||||||
server.setMaxListeners(0);
|
|
||||||
|
|
||||||
var errors = [];
|
|
||||||
// We need multiple requests to make sure
|
|
||||||
// statsd_client eventually tries to send
|
|
||||||
// stats _and_ DNS lookup is given enough
|
|
||||||
// time (an interval is used later for that)
|
|
||||||
var numreq = 10;
|
|
||||||
var pending = numreq;
|
|
||||||
var completed = function(err) {
|
|
||||||
if ( err ) {
|
|
||||||
errors.push(err);
|
|
||||||
}
|
|
||||||
if ( ! --pending ) {
|
|
||||||
setTimeout(function() {
|
|
||||||
done(errors.length ? new Error(errors.join(',')) : null);
|
|
||||||
}, 10);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var mapConfig = testClient.defaultTableMapConfig('test_table');
|
|
||||||
for (var i=0; i<numreq; ++i) {
|
|
||||||
testClient.createLayergroup(mapConfig, { server: server }, completed);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
46
test/integration/profiler.js
Normal file
46
test/integration/profiler.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
require('../support/test_helper');
|
||||||
|
|
||||||
|
var assert = require('assert');
|
||||||
|
var StatsClient = require('../../lib/cartodb/stats/client');
|
||||||
|
var ProfilerProxy = require('../../lib/cartodb/stats/profiler_proxy');
|
||||||
|
|
||||||
|
describe('profiler + statsd', function() {
|
||||||
|
var statsInstance;
|
||||||
|
|
||||||
|
before(function() {
|
||||||
|
statsInstance = StatsClient.instance;
|
||||||
|
StatsClient.instance = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function() {
|
||||||
|
StatsClient.instance = statsInstance;
|
||||||
|
});
|
||||||
|
|
||||||
|
var statsdConfig = {
|
||||||
|
host: 'whoami.vizzuality.com',
|
||||||
|
port: 8125,
|
||||||
|
prefix: 'test.',
|
||||||
|
cacheDns: false
|
||||||
|
// support all allowed node-statsd options
|
||||||
|
};
|
||||||
|
|
||||||
|
// See https://github.com/CartoDB/Windshaft/issues/167
|
||||||
|
it('profiler does not throw uncaught exception on invalid host/port', function(done) {
|
||||||
|
|
||||||
|
var statsClient = StatsClient.getInstance(statsdConfig);
|
||||||
|
var profiler = new ProfilerProxy({profile: true, statsd_client: statsClient});
|
||||||
|
|
||||||
|
profiler.start('test');
|
||||||
|
profiler.done('wadus');
|
||||||
|
profiler.end();
|
||||||
|
|
||||||
|
profiler.sendStats();
|
||||||
|
|
||||||
|
// force a call to validate sendStats does not throw and uncaught exception
|
||||||
|
statsClient.timing('forced', 50, 1, function(err) {
|
||||||
|
assert.ok(err);
|
||||||
|
assert.equal(err.code, 'ENOTFOUND');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user