function test (file) { file = join('fixtures', 'broken-pipe', file) t.test(file, { parallel: true }, async ({ is }) => { const child = fork(join(__dirname, file), { silent: true }) child.stdout.destroy() child.stderr.pipe(process.stdout) const res = await once(child, 'close') is(res, 0) // process exits successfully }) }
t.test('let error pass through', ({ is, plan }) => { plan(3) const stream = pino.destination() // side effect of the pino constructor is that it will set an // event handler for error pino(stream) process.nextTick(() => stream.emit('error', new Error('kaboom'))) process.nextTick(() => stream.emit('error', new Error('kaboom'))) stream.on('error', (err) => { is(err.message, 'kaboom') }) })
tap.test('Appmetrics should be a global singleton', function(t) { var appmetrics = require('../'); // Delete cached module delete require.cache[require.resolve('../')]; var appmetrics2 = require('../'); t.equals(appmetrics, appmetrics2); t.end(); });
monitor.on('request', function(data) { if (completedTests < 4) { tap.test('HTTP Request Event', function(t) { checkHttpRequestData(data.request.context, t); t.end(); completedTests++; }); } });
monitor.once('initialized', function() { tap.test('Environment Data', function(t) { var nodeEnv = monitor.getEnvironment(); console.log('Got initialized event!'); console.dir(nodeEnv); runNodeEnvTests(nodeEnv, t); runCommonEnvTests(nodeEnv, t); t.end(); }); });
tap.test('probe attached', function(t) { t.ok(mongo.__ddProbeAttached__); t.end(); });
tap.test('lrtime is a function or undefined', function(t) { var lrtime = app.appmetrics.lrtime; if (lrtime) { t.doesNotThrow(lrtime, 'callable, not just present'); } else { t.notEqual(process.platform, 'linux', 'lrtime mandatory on linux'); } t.end(); });
// Regression test for issue #375 tap.test('Calling require without start should not break', function(t) { require('../'); var server = require('./test_http_server').server; var http = require('http'); // HTTP outbound request // (previously triggered http-outbound probe to emit an event which caused a SIGSEGV) http.get(`http://localhost:${server.address().port}/`, function(res) { server.close(); t.end(); }); });
monitor.on('http-outbound', function(data) { tap.test('HTTP Outbound Event', function(t) { checkHttpOutboundData(data, t); t.end(); }); });
tap.test('start returns this', function(t) { t.equal(appmetrics, app.appmetrics); t.equal(appmetrics, require('../')); t.end(); });
monitor.on('http', function(data) { if (completedTests < 2) { tap.test('HTTP Event', function(t) { checkHttpData(data, t); t.end(); completedTests++; }); } });
monitor.on('request', function(data) { tap.test('HTTPS Request Event', function(t) { checkHttpsRequestData(data.request.context, t); t.end(); }); });
monitor.on('https', function(data) { // First 3 calls should have an 'https' event emitted, then 2 'request' events, // so don't allow more than 3 tests to run here. if (completedTests < 3) { tap.test('HTTPS Event', function(t) { checkHttpsData(data, t); t.end(); completedTests++; }); } });
monitor.on('https-outbound', function(data) { tap.test('HTTPS Outbound Event', function(t) { checkHttpOutboundData(data, t); t.end(); }); });