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: #9791
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
  • Loading branch information
Trott authored and addaleax committed Dec 5, 2016
1 parent 3f1b068 commit 3b193de
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 3b193de

Please sign in to comment.