mirror of https://github.com/nodejs/node.git
test: cluster: unhide child errors in bind-twice
Errors in leaf child processes weren't picked up by the test runner because they didn't get bubbled up to the main process. Don't forcibly kill the child processes; tell them to quit gracefully, then inspect their exit codes.pull/5010/head
parent
872e720c9f
commit
45ed546009
|
@ -72,37 +72,39 @@ if (!id) {
|
||||||
b.on('message', function(m) {
|
b.on('message', function(m) {
|
||||||
if (typeof m === 'object') return; // ignore system messages
|
if (typeof m === 'object') return; // ignore system messages
|
||||||
assert.equal(m, 'EADDRINUSE');
|
assert.equal(m, 'EADDRINUSE');
|
||||||
a.kill();
|
|
||||||
b.kill();
|
|
||||||
ok = true;
|
ok = true;
|
||||||
|
a.send('QUIT');
|
||||||
|
b.send('QUIT');
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
a.kill();
|
|
||||||
b.kill();
|
|
||||||
assert(ok);
|
assert(ok);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (id === 'one') {
|
else if (id === 'one') {
|
||||||
if (cluster.isMaster) return startWorker();
|
if (cluster.isMaster) return startWorker();
|
||||||
|
|
||||||
http.createServer(assert.fail).listen(common.PORT, function() {
|
var server = http.createServer(assert.fail).listen(common.PORT, function() {
|
||||||
process.send('READY');
|
process.send('READY');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.on('message', function(m) {
|
||||||
|
if (m === 'QUIT') process.exit();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (id === 'two') {
|
else if (id === 'two') {
|
||||||
if (cluster.isMaster) return startWorker();
|
if (cluster.isMaster) return startWorker();
|
||||||
|
|
||||||
var ok = false;
|
var ok = false;
|
||||||
process.on('SIGTERM', process.exit);
|
|
||||||
process.on('exit', function() {
|
process.on('exit', function() {
|
||||||
assert(ok);
|
assert(ok);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var server = http.createServer(assert.fail);
|
||||||
process.on('message', function(m) {
|
process.on('message', function(m) {
|
||||||
if (typeof m === 'object') return; // ignore system messages
|
if (typeof m === 'object') return; // ignore system messages
|
||||||
|
if (m === 'QUIT') process.exit();
|
||||||
assert.equal(m, 'START');
|
assert.equal(m, 'START');
|
||||||
var server = http.createServer(assert.fail);
|
|
||||||
server.listen(common.PORT, assert.fail);
|
server.listen(common.PORT, assert.fail);
|
||||||
server.on('error', function(e) {
|
server.on('error', function(e) {
|
||||||
assert.equal(e.code, 'EADDRINUSE');
|
assert.equal(e.code, 'EADDRINUSE');
|
||||||
|
@ -117,10 +119,7 @@ else {
|
||||||
|
|
||||||
function startWorker() {
|
function startWorker() {
|
||||||
var worker = cluster.fork();
|
var worker = cluster.fork();
|
||||||
|
worker.on('exit', process.exit);
|
||||||
worker.on('message', process.send.bind(process));
|
worker.on('message', process.send.bind(process));
|
||||||
process.on('message', worker.send.bind(worker));
|
process.on('message', worker.send.bind(worker));
|
||||||
process.on('SIGTERM', function() {
|
|
||||||
worker.destroy();
|
|
||||||
process.exit();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue