Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add cluster inspector debug port test #8958

Merged
merged 1 commit into from
Oct 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: add cluster inspector debug port test
This commit adds a test for the debug port value in cluster
workers using the inspector debugger.

Refs: #8201
Refs: #8386
Refs: #8550
PR-URL: #8958
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Ilkka Myller <[email protected]>
  • Loading branch information
cjihrig committed Oct 10, 2016
commit 2aa2f85e467120959778e8fab9b69b72959f1856
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();
}