From 8fdf39004aae8da3225727008e7e1dc0616051d8 Mon Sep 17 00:00:00 2001 From: Rafael Fragoso Date: Sun, 16 Apr 2017 17:52:13 -0300 Subject: [PATCH 1/4] test: use dynamic port in test-dgram-bind-shared-ports Use of common.PORT in parallel tests is not completely safe (because the same port can be previously assigned to another test running in parallel if that test uses port 0 to get an arbitrary available port). Remove common.PORT from test-dgram-bind-shared-ports. --- test/parallel/test-dgram-bind-shared-ports.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-dgram-bind-shared-ports.js b/test/parallel/test-dgram-bind-shared-ports.js index 4eaf9a14d65d1d..2a5df617667aa0 100644 --- a/test/parallel/test-dgram-bind-shared-ports.js +++ b/test/parallel/test-dgram-bind-shared-ports.js @@ -64,10 +64,10 @@ if (cluster.isMaster) { socket1.bind({ address: 'localhost', - port: common.PORT, + port: 0, exclusive: false }, () => { - socket2.bind({ port: common.PORT + 1, exclusive: true }, () => { + socket2.bind({ port: socket1.address().port + 1, exclusive: true }, () => { // the first worker should succeed process.send('success'); }); From f523cff8c8ec4230365b888ee5594a20a85fbd06 Mon Sep 17 00:00:00 2001 From: Rafael Fragoso Date: Sun, 16 Apr 2017 17:58:34 -0300 Subject: [PATCH 2/4] test: adding common.mustCall() to socket1 callback Adding a common.mustCall() to socket1 callback on test-dgram-bind-shared-ports to make sure the callback is being called. --- test/parallel/test-dgram-bind-shared-ports.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-dgram-bind-shared-ports.js b/test/parallel/test-dgram-bind-shared-ports.js index 2a5df617667aa0..5098a3767516cc 100644 --- a/test/parallel/test-dgram-bind-shared-ports.js +++ b/test/parallel/test-dgram-bind-shared-ports.js @@ -66,10 +66,13 @@ if (cluster.isMaster) { address: 'localhost', port: 0, exclusive: false - }, () => { - socket2.bind({ port: socket1.address().port + 1, exclusive: true }, () => { + }, common.mustCall(() => { + socket2.bind({ + port: socket1.address().port + 1, + exclusive: true + }, () => { // the first worker should succeed process.send('success'); }); - }); + })); } From b59f704bc16c40ae18d2c9f572ad326a766f13aa Mon Sep 17 00:00:00 2001 From: Rafael Fragoso Date: Wed, 26 Apr 2017 09:14:45 -0300 Subject: [PATCH 3/4] test: moved test-dgram-bind-shared-ports to sequential As was pointed out on [this review](https://github.com/nodejs/node/pull/12452#pullrequestreview-33060181) I moved the test to the sequential folder. Refs: #12376 --- test/{parallel => sequential}/test-dgram-bind-shared-ports.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{parallel => sequential}/test-dgram-bind-shared-ports.js (100%) diff --git a/test/parallel/test-dgram-bind-shared-ports.js b/test/sequential/test-dgram-bind-shared-ports.js similarity index 100% rename from test/parallel/test-dgram-bind-shared-ports.js rename to test/sequential/test-dgram-bind-shared-ports.js From 07d3bf86197750d79453974911369c7b1d6d3b92 Mon Sep 17 00:00:00 2001 From: Rafael Fragoso Date: Wed, 26 Apr 2017 09:26:32 -0300 Subject: [PATCH 4/4] test: restoring test-dgram-bind-shared-ports to original Restoring the contents of the test to it's original with common.PORT() Refs: #12376 --- test/sequential/test-dgram-bind-shared-ports.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/sequential/test-dgram-bind-shared-ports.js b/test/sequential/test-dgram-bind-shared-ports.js index 5098a3767516cc..4eaf9a14d65d1d 100644 --- a/test/sequential/test-dgram-bind-shared-ports.js +++ b/test/sequential/test-dgram-bind-shared-ports.js @@ -64,15 +64,12 @@ if (cluster.isMaster) { socket1.bind({ address: 'localhost', - port: 0, + port: common.PORT, exclusive: false - }, common.mustCall(() => { - socket2.bind({ - port: socket1.address().port + 1, - exclusive: true - }, () => { + }, () => { + socket2.bind({ port: common.PORT + 1, exclusive: true }, () => { // the first worker should succeed process.send('success'); }); - })); + }); }