Skip to content

Commit 2e5188d

Browse files
tarunbatrajasnell
authored andcommitted
test: remove common.PORT from multiple tests
PR-URL: #12451 Ref: #12376 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 3cf88a4 commit 2e5188d

7 files changed

+11
-13
lines changed

test/parallel/test-cluster-master-error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (cluster.isWorker) {
3131
const http = require('http');
3232
http.Server(() => {
3333

34-
}).listen(common.PORT, '127.0.0.1');
34+
}).listen(0, '127.0.0.1');
3535

3636
} else if (process.argv[2] === 'cluster') {
3737

test/parallel/test-cluster-master-kill.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if (cluster.isWorker) {
2828

2929
// keep the worker alive
3030
const http = require('http');
31-
http.Server().listen(common.PORT, '127.0.0.1');
31+
http.Server().listen(0, '127.0.0.1');
3232

3333
} else if (process.argv[2] === 'cluster') {
3434

test/parallel/test-cluster-net-send.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ if (process.argv[2] !== 'child') {
6767
socketConnected();
6868
});
6969

70-
server.listen(common.PORT, function() {
71-
socket = net.connect(common.PORT, '127.0.0.1', socketConnected);
70+
server.listen(0, function() {
71+
socket = net.connect(server.address().port, '127.0.0.1', socketConnected);
7272
});
7373

7474
process.on('disconnect', function() {

test/parallel/test-cluster-rr-domain-listen.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if (cluster.isWorker) {
3232
d.run(common.noop);
3333

3434
const http = require('http');
35-
http.Server(common.noop).listen(common.PORT, '127.0.0.1');
35+
http.Server(common.noop).listen(0, '127.0.0.1');
3636

3737
} else if (cluster.isMaster) {
3838

test/parallel/test-cluster-rr-ref.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (cluster.isMaster) {
1010
});
1111
} else {
1212
const server = net.createServer(common.mustNotCall());
13-
server.listen(common.PORT, function() {
13+
server.listen(0, function() {
1414
server.unref();
1515
server.ref();
1616
server.close(function() {

test/parallel/test-cluster-shared-leak.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ if (cluster.isMaster) {
1313
let conn, worker2;
1414

1515
const worker1 = cluster.fork();
16-
worker1.on('message', common.mustCall(function() {
16+
worker1.on('listening', common.mustCall(function(address) {
1717
worker2 = cluster.fork();
1818
worker2.on('online', function() {
19-
conn = net.connect(common.PORT, common.mustCall(function() {
19+
conn = net.connect(address.port, common.mustCall(function() {
2020
worker1.disconnect();
2121
worker2.disconnect();
2222
}));
@@ -48,6 +48,4 @@ const server = net.createServer(function(c) {
4848
c.end('bye');
4949
});
5050

51-
server.listen(common.PORT, function() {
52-
process.send('listening');
53-
});
51+
server.listen(0);

test/parallel/test-cluster-worker-no-exit.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
const common = require('../common');
23+
require('../common');
2424
const assert = require('assert');
2525
const cluster = require('cluster');
2626
const net = require('net');
@@ -55,7 +55,7 @@ if (cluster.isMaster) {
5555
success = true;
5656
});
5757

58-
}).listen(common.PORT, function() {
58+
}).listen(0, function() {
5959
const port = this.address().port;
6060

6161
worker = cluster.fork()

0 commit comments

Comments
 (0)