Browse Source

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>
v4.x
Santiago Gimeno 8 years ago
committed by Myles Borins
parent
commit
d5f03db819
  1. 15
      test/parallel/test-cluster-dgram-1.js

15
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();
}
});

Loading…
Cancel
Save