aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-dgram-2.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-11-24 15:04:14 -0800
committerRich Trott <rtrott@gmail.com>2016-11-27 21:54:47 -0800
commit56ca9cd1ba50cdccad4f1fa2a8b40986bd40bd88 (patch)
treedd12cd8596b71b490756ef9124fcf449369fc4ef /test/parallel/test-cluster-dgram-2.js
parent566a1513d1a21674a35153f28db051c372047f24 (diff)
downloadandroid-node-v8-56ca9cd1ba50cdccad4f1fa2a8b40986bd40bd88.tar.gz
android-node-v8-56ca9cd1ba50cdccad4f1fa2a8b40986bd40bd88.tar.bz2
android-node-v8-56ca9cd1ba50cdccad4f1fa2a8b40986bd40bd88.zip
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>
Diffstat (limited to 'test/parallel/test-cluster-dgram-2.js')
-rw-r--r--test/parallel/test-cluster-dgram-2.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/parallel/test-cluster-dgram-2.js b/test/parallel/test-cluster-dgram-2.js
index 179b1ee153..863e0fa358 100644
--- a/test/parallel/test-cluster-dgram-2.js
+++ b/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);
+ });
}