Skip to content

Commit

Permalink
test: fix flaky test-cluster-dgram-2
Browse files Browse the repository at this point in the history
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: nodejs#9791
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
  • Loading branch information
Trott committed Nov 28, 2016
1 parent 566a151 commit 56ca9cd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/parallel/test-cluster-dgram-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

0 comments on commit 56ca9cd

Please sign in to comment.