Skip to content

Commit

Permalink
test: cluster-setup-master online workers check
Browse files Browse the repository at this point in the history
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: #6535
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
drifkin authored and rvagg committed Jun 2, 2016
1 parent 7c932c2 commit 2895860
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/parallel/test-cluster-setup-master.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if (cluster.isWorker) {
};

var totalWorkers = 2;
var onlineWorkers = 0;

// Setup master
cluster.setupMaster({
Expand All @@ -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) {
Expand All @@ -49,7 +52,7 @@ if (cluster.isWorker) {
});

// All workers are online
if (cluster.onlineWorkers === totalWorkers) {
if (onlineWorkers === totalWorkers) {
checks.workers = true;
}
});
Expand All @@ -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';
Expand Down

0 comments on commit 2895860

Please sign in to comment.