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 logging for test-debug-port-cluster #6769

Closed
wants to merge 2 commits into from
Closed
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
26 changes: 15 additions & 11 deletions test/parallel/test-debug-port-cluster.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;

const PORT_MIN = common.PORT + 1337;
const PORT_MIN = common.PORT;
const PORT_MAX = PORT_MIN + 2;

var args = [
const args = [
'--debug=' + PORT_MIN,
common.fixturesDir + '/clustered-server/app.js'
];

const child = spawn(process.execPath, args);
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 = '';
child.stderr.on('data', (data) => {
process.stderr.write(`[DATA] ${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();
});

process.on('exit', () => {
for (let port = PORT_MIN; port <= PORT_MAX; port += 1)
assert(stderr.includes(`Debugger listening on port ${port}`));
checkMessages();
}
Copy link
Member

Choose a reason for hiding this comment

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

There should really be some at-exit check that verifies whether this code is reached.

Copy link
Member Author

Choose a reason for hiding this comment

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

@bnoordhuis Ah, yes, good point. I've extracted the for loop to its own function and wrapped it in common.mustCall() so there will be an at-exit check that the function ran. Stress testing now to see if that re-introduces the problem or not. (If it does, I guess my "solution" was to not check when the problem arose. :-( )

});