Browse Source

test: fix flaky test-cluster-dgram-2

There is no guarantee that a dgram packet will be received. The test is
currently written to only send exactly as many dgram packets as required
assuming they are all received. As a result, failures like this may
occur (from CI):

```
not ok 719 parallel/test-cluster-dgram-2
  ---
  duration_ms: 120.39
  severity: fail
  stack: |-
    timeout
```

This change has the workers send packets continuously until disconnect.

PR-URL: https://github.com/nodejs/node/pull/9791
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
v6
Rich Trott 8 years ago
parent
commit
56ca9cd1ba
  1. 9
      test/parallel/test-cluster-dgram-2.js

9
test/parallel/test-cluster-dgram-2.js

@ -57,6 +57,13 @@ function worker() {
// send(), explicitly bind them to an ephemeral port.
socket.bind(0);
for (var i = 0; i < PACKETS_PER_WORKER; i++)
// There is no guarantee that a sent dgram packet will be received so keep
// sending until disconnect.
const interval = setInterval(() => {
socket.send(buf, 0, buf.length, common.PORT, '127.0.0.1');
}, 1);
cluster.worker.on('disconnect', () => {
clearInterval(interval);
});
}

Loading…
Cancel
Save