From 149bea0fc41fab035981c17fbc3e7719fb5694b4 Mon Sep 17 00:00:00 2001 From: Devon Rifkin Date: Mon, 2 May 2016 14:59:46 -0700 Subject: [PATCH] test: cluster-setup-master online workers check Previously a `checks.workers` boolean was conditionally set, but never checked. Additionally, it was never actually set because `cluster.onlineWorkers` is always undefined. PR-URL: https://github.com/nodejs/node/pull/6535 Reviewed-By: Anna Henningsen --- test/parallel/test-cluster-setup-master.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-cluster-setup-master.js b/test/parallel/test-cluster-setup-master.js index 561371afb0..66193203fd 100644 --- a/test/parallel/test-cluster-setup-master.js +++ b/test/parallel/test-cluster-setup-master.js @@ -17,6 +17,7 @@ if (cluster.isWorker) { }; var totalWorkers = 2; + var onlineWorkers = 0; // Setup master cluster.setupMaster({ @@ -40,6 +41,8 @@ if (cluster.isWorker) { cluster.on('online', function lisenter(worker) { + onlineWorkers++; + worker.once('message', function(data) { correctIn += (data === 'custom argument' ? 1 : 0); if (correctIn === totalWorkers) { @@ -49,7 +52,7 @@ if (cluster.isWorker) { }); // All workers are online - if (cluster.onlineWorkers === totalWorkers) { + if (onlineWorkers === totalWorkers) { checks.workers = true; } }); @@ -60,6 +63,7 @@ if (cluster.isWorker) { // Check all values process.once('exit', function() { + assert.ok(checks.workers, 'Not all workers went online'); assert.ok(checks.args, 'The arguments was noy send to the worker'); assert.ok(checks.setupEvent, 'The setup event was never emitted'); var m = 'The settingsObject do not have correct properties';