Skip to content

Commit

Permalink
test: fix debug-signal-cluster after da update
Browse files Browse the repository at this point in the history
The cluster children are hitting breakpoint at `cluster.onread` and
hanging on a Semaphore wait now. This prevents them from disconnecting
gracefully. Considering that the test is checking different thing, the
cluster children needs to be force killed from the grand parent process.

Reviewed-By: Trevor Norris <trevnorris@gmail.com>
PR-URL: nodejs/node-v0.x-archive#8476
  • Loading branch information
indutny committed Oct 8, 2014
1 parent 685ac09 commit d87480b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
10 changes: 10 additions & 0 deletions test/fixtures/clustered-server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ if (cluster.isMaster) {
}
});

process.on('message', function(msg) {
if (msg.type === 'getpids') {
var pids = [];
pids.push(process.pid);
for (var key in cluster.workers)
pids.push(cluster.workers[key].process.pid);
process.send({ type: 'pids', pids: pids });
}
});

for (var i = 0; i < NUMBER_OF_WORKERS; i++) {
cluster.fork();
}
Expand Down
26 changes: 22 additions & 4 deletions test/simple/test-debug-signal-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ var assert = require('assert');
var spawn = require('child_process').spawn;

var args = [ common.fixturesDir + '/clustered-server/app.js' ];
var child = spawn(process.execPath, args);
var child = spawn(process.execPath, args, {
stdio: [ 'pipe', 'pipe', 'pipe', 'ipc' ]
});
var outputLines = [];
var outputTimerId;
var waitingForDebuggers = false;

var pids = null;

child.stderr.on('data', function(data) {
var lines = data.toString().replace(/\r/g, '').trim().split('\n');
var line = lines[0];
Expand All @@ -42,8 +46,20 @@ child.stderr.on('data', function(data) {
outputLines = outputLines.concat(lines);
outputTimerId = setTimeout(onNoMoreLines, 800);
} else if (line === 'all workers are running') {
waitingForDebuggers = true;
process._debugProcess(child.pid);
child.on('message', function(msg) {
if (msg.type !== 'pids')
return;

pids = msg.pids;
console.error('got pids %j', pids);

waitingForDebuggers = true;
process._debugProcess(child.pid);
});

child.send({
type: 'getpids'
});
}
});

Expand All @@ -57,7 +73,9 @@ setTimeout(function testTimedOut() {
}, 6000);

process.on('exit', function onExit() {
child.kill();
pids.forEach(function(pid) {
process.kill(pid);
});
});

function assertOutputLines() {
Expand Down

0 comments on commit d87480b

Please sign in to comment.