Browse Source

test: add logging for test-debug-port-cluster

The test is currently flaky and CI provides no real information because
the test times out rather than failing on an assertion. Add logging to
gather more information about the failure.

Refs: https://github.com/nodejs/node/issues/6754
PR-URL: https://github.com/nodejs/node/pull/6769
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v7.x
Rich Trott 9 years ago
parent
commit
2c926dc6eb
  1. 24
      test/parallel/test-debug-port-cluster.js

24
test/parallel/test-debug-port-cluster.js

@ -1,12 +1,12 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var spawn = require('child_process').spawn; const spawn = require('child_process').spawn;
const PORT_MIN = common.PORT + 1337; const PORT_MIN = common.PORT + 1337;
const PORT_MAX = PORT_MIN + 2; const PORT_MAX = PORT_MIN + 2;
var args = [ const args = [
'--debug=' + PORT_MIN, '--debug=' + PORT_MIN,
common.fixturesDir + '/clustered-server/app.js' common.fixturesDir + '/clustered-server/app.js'
]; ];
@ -14,14 +14,18 @@ var args = [
const child = spawn(process.execPath, args); const child = spawn(process.execPath, args);
child.stderr.setEncoding('utf8'); child.stderr.setEncoding('utf8');
const checkMessages = common.mustCall(() => {
for (let port = PORT_MIN; port <= PORT_MAX; port += 1) {
assert(stderr.includes(`Debugger listening on port ${port}`));
}
});
let stderr = ''; let stderr = '';
child.stderr.on('data', (data) => { child.stderr.on('data', (data) => {
process.stderr.write(`[DATA] ${data}`);
stderr += data; stderr += data;
if (child.killed !== true && stderr.includes('all workers are running')) if (child.killed !== true && stderr.includes('all workers are running')) {
child.kill(); child.kill();
}); checkMessages();
}
process.on('exit', () => {
for (let port = PORT_MIN; port <= PORT_MAX; port += 1)
assert(stderr.includes(`Debugger listening on port ${port}`));
}); });

Loading…
Cancel
Save