Windshaft-cartodb/test/integration/profiler-test.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

'use strict';
require('../support/test-helper');
var assert = require('assert');
2019-10-07 15:40:50 +08:00
var StatsClient = require('../../lib/stats/client');
var ProfilerProxy = require('../../lib/stats/profiler-proxy');
2019-10-22 01:07:24 +08:00
describe('profiler + statsd', function () {
var statsInstance;
2019-10-22 01:07:24 +08:00
before(function () {
statsInstance = StatsClient.instance;
StatsClient.instance = null;
});
2019-10-22 01:07:24 +08:00
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
2019-10-22 01:07:24 +08:00
it('profiler does not throw uncaught exception on invalid host/port', function (done) {
var statsClient = StatsClient.getInstance(statsdConfig);
2019-10-22 01:07:24 +08:00
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
2019-10-22 01:07:24 +08:00
statsClient.timing('forced', 50, 1, function (err) {
assert.ok(err);
assert.strictEqual(err.code, 'ENOTFOUND');
done();
});
});
});