From ecf8f5a2134ed4450fb5d3ceff1830ee37af0c90 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Fri, 2 Sep 2016 13:14:37 +0200 Subject: [PATCH] test: fix test-cluster-dgram-1 flakiness Check for the number of messages received in the `exit` event listener instead of the `disconnect` listener. Fixes: https://github.com/nodejs/node/issues/8380 Ref: https://github.com/nodejs/node/pull/8383 Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed By: James M Snell --- test/parallel/test-cluster-dgram-1.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-cluster-dgram-1.js b/test/parallel/test-cluster-dgram-1.js index b1164e3653abdc..60699ac945dfde 100644 --- a/test/parallel/test-cluster-dgram-1.js +++ b/test/parallel/test-cluster-dgram-1.js @@ -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); + })); } } @@ -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(); } });