0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-28 22:46:31 +01:00
nodejs/test/parallel/test-cluster-worker-isdead.js
Fedor Indutny 0e19476595 test: split test in parallel/sequential
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/iojs/io.js/pull/172
Fix: iojs/io.js#139
2014-12-17 20:45:02 +07:00

28 lines
752 B
JavaScript

var cluster = require('cluster');
var assert = require('assert');
var net = require('net');
if (cluster.isMaster) {
var worker = cluster.fork();
assert.ok(!worker.isDead(),
"isDead() should return false right after the worker has been " +
"created.");
worker.on('exit', function() {
assert.ok(!worker.isConnected(),
"After an event has been emitted, " +
"isDead should return true");
})
worker.on('message', function(msg) {
if (msg === 'readyToDie') {
worker.kill();
}
});
} else if (cluster.isWorker) {
assert.ok(!cluster.worker.isDead(),
"isDead() should return false when called from within a worker");
process.send('readyToDie');
}