summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-message.js
diff options
context:
space:
mode:
authorSam Roberts <sam@strongloop.com>2015-02-14 18:50:56 -0800
committerSam Roberts <sam@strongloop.com>2015-07-23 14:51:10 -0700
commit66fc8ca22b05036f88cf457873332e67f5b576b2 (patch)
tree4d30e599d35ca62b0a8ebbab0b5df88c8839d790 /test/parallel/test-cluster-message.js
parente11fc67225821c76d35a483690b952b01f1f7c67 (diff)
downloadnode-new-66fc8ca22b05036f88cf457873332e67f5b576b2.tar.gz
cluster: emit 'message' event on cluster master
For consistency with the worker 'exit', 'online', 'disconnect', and 'listening' events which are emitted on worker and cluster, also emit 'message' on cluster. Reviewed-by: Sam Roberts <vieuxtech@gmail.com> Reviewed-by: Christian Tellnes <christian@tellnes.no> Reviewed-by: Stephen Belanger <admin@stephenbelanger.com> PR-URL: https://github.com/nodejs/io.js/pull/861
Diffstat (limited to 'test/parallel/test-cluster-message.js')
-rw-r--r--test/parallel/test-cluster-message.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/test/parallel/test-cluster-message.js b/test/parallel/test-cluster-message.js
index a72d1f079e..427c305890 100644
--- a/test/parallel/test-cluster-message.js
+++ b/test/parallel/test-cluster-message.js
@@ -6,7 +6,7 @@ var net = require('net');
function forEach(obj, fn) {
Object.keys(obj).forEach(function(name, index) {
- fn(obj[name], name, index);
+ fn(obj[name], name);
});
}
@@ -45,6 +45,10 @@ if (cluster.isWorker) {
else if (cluster.isMaster) {
var checks = {
+ global: {
+ 'receive': false,
+ 'correct': false
+ },
master: {
'receive': false,
'correct': false
@@ -76,12 +80,15 @@ else if (cluster.isMaster) {
// Spawn worker
var worker = cluster.fork();
- // When a IPC message is received form the worker
+ // When a IPC message is received from the worker
worker.on('message', function(message) {
check('master', message === 'message from worker');
});
+ cluster.on('message', function(message) {
+ check('global', message === 'message from worker');
+ });
- // When a TCP connection is made with the worker connect to it
+ // When a TCP server is listening in the worker connect to it
worker.on('listening', function() {
client = net.connect(common.PORT, function() {