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
PR-URL: #8383
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed By: James M Snell <jasnell@gmail.com>
  • Loading branch information
santigimeno authored and mhdawson committed Sep 2, 2016
1 parent 8361c26 commit 2d2a2d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/parallel/test-cluster-dgram-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ function master() {

worker.on('message', common.mustCall((msg) => {
received = msg.received;
worker.disconnect();
}));

worker.on('disconnect', common.mustCall(() => {
worker.on('exit', common.mustCall(() => {
assert.strictEqual(received, PACKETS_PER_WORKER);
}));
}
Expand All @@ -85,7 +86,7 @@ function worker() {
// Every 10 messages, notify the master.
if (received === PACKETS_PER_WORKER) {
process.send({received: received});
process.disconnect();
socket.close();
}
}, PACKETS_PER_WORKER));

Expand Down

0 comments on commit 2d2a2d7

Please sign in to comment.