Skip to content

Commit 8c81ba0

Browse files
TrottMylesBorins
authored andcommitted
test: remove common.PORT from parallel tests
`common.PORT` should not be used in parallel tests because another test may experience a collision with `common.PORT` when using port 0 to get an open port. This has been observed to result in test failures in CI. PR-URL: #17410 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Lance Ball <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 5fecdba commit 8c81ba0

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

‎test/async-hooks/test-graph.tcp.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const server = net
1515
.createServer(common.mustCall(onconnection))
1616
.on('listening',common.mustCall(onlistening));
1717

18-
server.listen(common.PORT);
18+
server.listen(0);
1919

2020
net.connect({port: server.address().port,host: '::1'},
2121
common.mustCall(onconnected));

‎test/async-hooks/test-graph.tls-write.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const server = tls
2525
})
2626
.on('listening',common.mustCall(onlistening))
2727
.on('secureConnection',common.mustCall(onsecureConnection))
28-
.listen(common.PORT);
28+
.listen(0);
2929

3030
functiononlistening(){
3131
//
3232
// Creating client and connecting it to server
3333
//
3434
tls
35-
.connect(common.PORT,{rejectUnauthorized: false})
35+
.connect(server.address().port,{rejectUnauthorized: false})
3636
.on('secureConnect',common.mustCall(onsecureConnect));
3737
}
3838

‎test/async-hooks/test-tcpwrap.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const server = net
2424

2525
// Calling server.listen creates a TCPWRAP synchronously
2626
{
27-
server.listen(common.PORT);
27+
server.listen(0);
2828
consttcpsservers=hooks.activitiesOfTypes('TCPSERVERWRAP');
2929
consttcpconnects=hooks.activitiesOfTypes('TCPCONNECTWRAP');
3030
assert.strictEqual(tcpsservers.length,1);

‎test/async-hooks/test-writewrap.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const server = tls
2323
})
2424
.on('listening',common.mustCall(onlistening))
2525
.on('secureConnection',common.mustCall(onsecureConnection))
26-
.listen(common.PORT);
26+
.listen(0);
2727

2828
assert.strictEqual(hooks.activitiesOfTypes('WRITEWRAP').length,0);
2929

@@ -33,7 +33,7 @@ function onlistening(){
3333
// Creating client and connecting it to server
3434
//
3535
tls
36-
.connect(common.PORT,{rejectUnauthorized: false})
36+
.connect(server.address().port,{rejectUnauthorized: false})
3737
.on('secureConnect',common.mustCall(onsecureConnect));
3838

3939
assert.strictEqual(hooks.activitiesOfTypes('WRITEWRAP').length,0);

‎test/parallel/test-net-connect-immediate-finish.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ const{
3838

3939
constclient=net.connect({
4040
host: addresses.INVALID_HOST,
41-
port: common.PORT,
41+
port: 80,// port number doesn't matter because host name is invalid
4242
lookup: common.mustCall(errorLookupMock())
43-
});
43+
},common.mustNotCall());
4444

4545
client.once('error',common.mustCall((err)=>{
4646
assert(err);

0 commit comments

Comments
(0)