Skip to content

Commit 9062864

Browse files
committed
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.
1 parent e1054ab commit 9062864

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
function onlistening() {
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
const tcpsservers = hooks.activitiesOfTypes('TCPSERVERWRAP');
2929
const tcpconnects = 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
const client = 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);
File renamed without changes.

0 commit comments

Comments
Β (0)