Skip to content

Commit 2895860

Browse files
drifkinrvagg
authored andcommitted
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: #6535 Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 7c932c2 commit 2895860

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/parallel/test-cluster-setup-master.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ if (cluster.isWorker) {
1717
};
1818

1919
var totalWorkers = 2;
20+
var onlineWorkers = 0;
2021

2122
// Setup master
2223
cluster.setupMaster({
@@ -40,6 +41,8 @@ if (cluster.isWorker) {
4041

4142
cluster.on('online', function lisenter(worker) {
4243

44+
onlineWorkers++;
45+
4346
worker.once('message', function(data) {
4447
correctIn += (data === 'custom argument' ? 1 : 0);
4548
if (correctIn === totalWorkers) {
@@ -49,7 +52,7 @@ if (cluster.isWorker) {
4952
});
5053

5154
// All workers are online
52-
if (cluster.onlineWorkers === totalWorkers) {
55+
if (onlineWorkers === totalWorkers) {
5356
checks.workers = true;
5457
}
5558
});
@@ -60,6 +63,7 @@ if (cluster.isWorker) {
6063

6164
// Check all values
6265
process.once('exit', function() {
66+
assert.ok(checks.workers, 'Not all workers went online');
6367
assert.ok(checks.args, 'The arguments was noy send to the worker');
6468
assert.ok(checks.setupEvent, 'The setup event was never emitted');
6569
var m = 'The settingsObject do not have correct properties';

0 commit comments

Comments
 (0)