summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-dgram-reuse.js
diff options
context:
space:
mode:
authorArtur Vieira <vieira.artur.g@gmail.com>2017-05-08 09:38:53 +0000
committerLuigi Pinca <luigipinca@gmail.com>2017-05-19 15:44:18 +0200
commit6b1819cff59c674d03f0afca80f33369b36b3926 (patch)
tree7db75692b97c3b6aff25f806d90de00ac8aa2f13 /test/parallel/test-cluster-dgram-reuse.js
parent847688018cb166eea7bfff9a9044a7295c17d5d8 (diff)
downloadandroid-node-v8-6b1819cff59c674d03f0afca80f33369b36b3926.tar.gz
android-node-v8-6b1819cff59c674d03f0afca80f33369b36b3926.tar.bz2
android-node-v8-6b1819cff59c674d03f0afca80f33369b36b3926.zip
test: use dynamic port in test-cluster-dgram-reuse
Remove common.PORT from test-cluster-dgram-reuse to eliminate possibility that a dynamic port used in another test will collide with common.PORT. PR-URL: https://github.com/nodejs/node/pull/12901 Ref: https://github.com/nodejs/node/issues/12376 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Diffstat (limited to 'test/parallel/test-cluster-dgram-reuse.js')
-rw-r--r--test/parallel/test-cluster-dgram-reuse.js28
1 files changed, 13 insertions, 15 deletions
diff --git a/test/parallel/test-cluster-dgram-reuse.js b/test/parallel/test-cluster-dgram-reuse.js
index cdb7cc9a4a..1472dcc523 100644
--- a/test/parallel/test-cluster-dgram-reuse.js
+++ b/test/parallel/test-cluster-dgram-reuse.js
@@ -16,24 +16,22 @@ if (cluster.isMaster) {
return;
}
-const sockets = [];
-function next() {
- sockets.push(this);
- if (sockets.length !== 2)
- return;
-
- // Work around health check issue
- process.nextTick(() => {
- for (let i = 0; i < sockets.length; i++)
- sockets[i].close(close);
- });
-}
-
let waiting = 2;
function close() {
if (--waiting === 0)
cluster.worker.disconnect();
}
-for (let i = 0; i < 2; i++)
- dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(common.PORT, next);
+const options = { type: 'udp4', reuseAddr: true };
+const socket1 = dgram.createSocket(options);
+const socket2 = dgram.createSocket(options);
+
+socket1.bind(0, () => {
+ socket2.bind(socket1.address().port, () => {
+ // Work around health check issue
+ process.nextTick(() => {
+ socket1.close(close);
+ socket2.close(close);
+ });
+ });
+});