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: test clusters --inspect-brk and --debug-brk #11471

Closed
wants to merge 8 commits into from

Conversation

liusy182
Copy link

@liusy182 liusy182 commented Feb 21, 2017

This test ensures that flag --inspect-brk and --debug-brk works
properly for clusters.

Issue #11420

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test

This test ensures that flag --inspect-brk and --debug-brk works
properly for clusters.
@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Feb 21, 2017
@mscdex mscdex added cluster Issues and PRs related to the cluster subsystem. inspector Issues and PRs related to the V8 inspector protocol labels Feb 21, 2017
setTimeout(() => {
worker.removeListener('exit', fail);
worker.kill();
}, 2000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a recipe for a flaky test, I'd suggest waiting until the debug/inspect TCP port is open/can be connected to

liusi added 2 commits February 21, 2017 17:15
This test ensures that flag --inspect-brk and --debug-brk works
properly for clusters.
const debuggerPort = common.PORT;
const script = common.fixturesDir + '/empty.js';

function fail() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, please use common.fail() or common.mustNotCall(), which are designed to do essentially this same thing without cluttering up the tests.

];

process.on('exit', function() {
workers.map((wk) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want forEach(), not map().


process.on('exit', function() {
workers.map((wk) => {
assert.equal(wk.process.killed, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use assert.strictEqual().


worker.on('exit', fail);

let socket = net.connect(debuggerPort + offset, () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add common.mustCall() around the callback.


let socket = net.connect(debuggerPort + offset, () => {
socket.end();
worker.removeListener('exit', fail);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having this fail() function and the process.on('exit', ...) block, it might be better to use the cluster worker exit event and check the exit code and signal to make sure it was killed by signal (there is an example in the docs).

- wrap callbacks in `common.mustCall`.

- check exit code of the cluster worker process instead of checking from main process.

- other misc. corrections.
@liusy182
Copy link
Author

Thanks @cjihrig for your comments. I have updated accordingly.

assert.strictEqual(signal, 'SIGTERM');
}));

let socket = net.connect(debuggerPort + offset, common.mustCall(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would wrap this code inside of a worker.on('online', common.mustCall(...)) just to be sure that the worker is ready for the connection.

fork(3, [`--debug-brk`, script]);
fork(4, [`--debug-brk=${debuggerPort}`, script]);

process.on('exit', (code, signal) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this block can be dropped completely.

@liusy182
Copy link
Author

Thanks @cjihrig I have updated.

@cjihrig
Copy link
Contributor

cjihrig commented Mar 1, 2017

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjihrig
Copy link
Contributor

cjihrig commented Mar 13, 2017

@liusy182 it looks like there are some CI failures.

Remove the check of exit code equals null because on some machines the exit code can be 0
@jasnell
Copy link
Member

jasnell commented Mar 17, 2017

@jasnell
Copy link
Member

jasnell commented Mar 17, 2017

Looks like a few failures on centos

@BridgeAR
Copy link
Member

It seems like this got fixed somewhere else in the meanwhile. Therefore I am going to close this.

@liusy182 I am very sorry your PR could not land!

@BridgeAR BridgeAR closed this Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem. inspector Issues and PRs related to the V8 inspector protocol test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants