Browse Source

test: fix assumption of worker exit on disconnect

Master was disconnecting its workers as soon as they both started up.
Meanwhile, the workers were trying to listen. Its a race, sometimes the
disconnect would happen between when worker gets the response message,
and acks that message with a 'listening'. This worked OK after v0.11
introduced a behaviour where disconnect would always exit the worker,
but once that backwards-incompatible behaviour is removed, the worker
lives long enough to try and respond to the master, and child_process
errors at the attempt to send from a disconnected child.
v0.11.10-release
Sam Roberts 11 years ago
committed by Timothy J Fontaine
parent
commit
cb1646f44e
  1. 3
      test/fixtures/clustered-server/app.js
  2. 5
      test/simple/test-debug-cluster.js
  3. 5
      test/simple/test-debug-port-cluster.js

3
test/fixtures/clustered-server/app.js

@ -13,9 +13,6 @@ if (cluster.isMaster) {
cluster.on('online', function() { cluster.on('online', function() {
if (++workersOnline === NUMBER_OF_WORKERS) { if (++workersOnline === NUMBER_OF_WORKERS) {
console.error('all workers are running'); console.error('all workers are running');
for (var key in cluster.workers) {
cluster.workers[key].disconnect();
}
} }
}); });

5
test/simple/test-debug-cluster.js

@ -35,11 +35,16 @@ child.stderr.on('data', function(data) {
if (line === 'all workers are running') { if (line === 'all workers are running') {
assertOutputLines(); assertOutputLines();
process.exit();
} else { } else {
outputLines = outputLines.concat(lines); outputLines = outputLines.concat(lines);
} }
}); });
process.on('exit', function onExit() {
child.kill();
});
var assertOutputLines = common.mustCall(function() { var assertOutputLines = common.mustCall(function() {
var expectedLines = [ var expectedLines = [
'Debugger listening on port ' + 5858, 'Debugger listening on port ' + 5858,

5
test/simple/test-debug-port-cluster.js

@ -41,11 +41,16 @@ child.stderr.on('data', function(data) {
if (line === 'all workers are running') { if (line === 'all workers are running') {
assertOutputLines(); assertOutputLines();
process.exit();
} else { } else {
outputLines = outputLines.concat(lines); outputLines = outputLines.concat(lines);
} }
}); });
process.on('exit', function onExit() {
child.kill();
});
var assertOutputLines = common.mustCall(function() { var assertOutputLines = common.mustCall(function() {
var expectedLines = [ var expectedLines = [
'Debugger listening on port ' + port, 'Debugger listening on port ' + port,

Loading…
Cancel
Save