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 <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Santiago Gimeno authored and Myles Borins committed 2016-10-26 14:09:27 -04:00
1 parent 72be320962
commit d5f03db819
1 file changed
+7 -8
+7 -8
View File
@@ -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();
}
});