Skip to content

Commit

Permalink
test: add cluster inspector debug port test
Browse files Browse the repository at this point in the history
This commit adds a test for the debug port value in cluster
workers using the inspector debugger.

Refs: nodejs#8201
Refs: nodejs#8386
Refs: nodejs#8550
PR-URL: nodejs#8958
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
  • Loading branch information
cjihrig committed Oct 10, 2016
1 parent 13a204e commit 2aa2f85
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/parallel/test-cluster-inspector-debug-port.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';
// Flags: --inspect={PORT}
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const debuggerPort = common.PORT;

if (cluster.isMaster) {
function checkExitCode(code, signal) {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
}

function fork(offset, execArgv) {
if (execArgv)
cluster.setupMaster({execArgv});

const check = common.mustCall(checkExitCode);
cluster.fork({portSet: debuggerPort + offset}).on('exit', check);
}

assert.strictEqual(process.debugPort, debuggerPort);

fork(1);
fork(2, ['--inspect']);
fork(3, [`--inspect=${debuggerPort}`]);
fork(4, ['--inspect', '--debug']);
fork(5, [`--debug=${debuggerPort}`, '--inspect']);
fork(6, ['--inspect', `--debug-port=${debuggerPort}`]);
} else {
const hasDebugArg = process.execArgv.some(function(arg) {
return /inspect/.test(arg);
});

assert.strictEqual(hasDebugArg, true);
assert.strictEqual(process.debugPort, +process.env.portSet);
process.exit();
}

0 comments on commit 2aa2f85

Please sign in to comment.