diff options
author | Sam Roberts <sam@strongloop.com> | 2013-12-30 21:36:49 -0800 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-12-31 11:43:44 -0800 |
commit | cb1646f44eb092f1771740fc5f0ec6775d5fbe73 (patch) | |
tree | a82861a5bd908b04ca182821f271ec61db7767d0 | |
parent | 876d3bd85aabe7fce71a025a89c6b3f6ddbf2053 (diff) | |
download | node-cb1646f44eb092f1771740fc5f0ec6775d5fbe73.tar.gz |
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.
-rw-r--r-- | test/fixtures/clustered-server/app.js | 3 | ||||
-rw-r--r-- | test/simple/test-debug-cluster.js | 5 | ||||
-rw-r--r-- | test/simple/test-debug-port-cluster.js | 5 |
3 files changed, 10 insertions, 3 deletions
diff --git a/test/fixtures/clustered-server/app.js b/test/fixtures/clustered-server/app.js index 86d66c5e8..4053cd3af 100644 --- a/test/fixtures/clustered-server/app.js +++ b/test/fixtures/clustered-server/app.js @@ -13,9 +13,6 @@ if (cluster.isMaster) { cluster.on('online', function() { if (++workersOnline === NUMBER_OF_WORKERS) { console.error('all workers are running'); - for (var key in cluster.workers) { - cluster.workers[key].disconnect(); - } } }); diff --git a/test/simple/test-debug-cluster.js b/test/simple/test-debug-cluster.js index 18e8ffaef..c0963c35a 100644 --- a/test/simple/test-debug-cluster.js +++ b/test/simple/test-debug-cluster.js @@ -35,11 +35,16 @@ child.stderr.on('data', function(data) { if (line === 'all workers are running') { assertOutputLines(); + process.exit(); } else { outputLines = outputLines.concat(lines); } }); +process.on('exit', function onExit() { + child.kill(); +}); + var assertOutputLines = common.mustCall(function() { var expectedLines = [ 'Debugger listening on port ' + 5858, diff --git a/test/simple/test-debug-port-cluster.js b/test/simple/test-debug-port-cluster.js index 7e71dffd5..34ae3a029 100644 --- a/test/simple/test-debug-port-cluster.js +++ b/test/simple/test-debug-port-cluster.js @@ -41,11 +41,16 @@ child.stderr.on('data', function(data) { if (line === 'all workers are running') { assertOutputLines(); + process.exit(); } else { outputLines = outputLines.concat(lines); } }); +process.on('exit', function onExit() { + child.kill(); +}); + var assertOutputLines = common.mustCall(function() { var expectedLines = [ 'Debugger listening on port ' + port, |