Skip to content

Commit

Permalink
test: fix test-cluster-dgram-1 flakiness
Browse files Browse the repository at this point in the history
Check for the number of messages received in the `exit` event listener
instead of the `disconnect` listener.

Fixes: #8380
Ref: #8383
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed By: James M Snell <[email protected]>
  • Loading branch information
santigimeno authored and MylesBorins committed Oct 24, 2016
1 parent f1a7a1a commit ecf8f5a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions test/parallel/test-cluster-dgram-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,14 @@ function master() {
function setupWorker(worker) {
var received = 0;

worker.on('message', function(msg) {
worker.on('message', common.mustCall((msg) => {
received = msg.received;
console.log('worker %d received %d packets', worker.id, received);
});
worker.disconnect();
}));

worker.on('disconnect', function() {
assert(received === PACKETS_PER_WORKER);
console.log('worker %d disconnected', worker.id);
});
worker.on('exit', common.mustCall(() => {
assert.strictEqual(received, PACKETS_PER_WORKER);
}));
}
}

Expand All @@ -88,7 +87,7 @@ function worker() {
// Every 10 messages, notify the master.
if (received == PACKETS_PER_WORKER) {
process.send({received: received});
process.disconnect();
socket.close();
}
});

Expand Down

0 comments on commit ecf8f5a

Please sign in to comment.