Skip to content

Commit 53b702f

Browse files
Trottgibfahn
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 <me@jonathanmoss.me> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent da16227 commit 53b702f

7 files changed

+8
-8
lines changed

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

+1-1
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

+2-2
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

+1-1
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

+2-2
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

+2-2
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.
File renamed without changes.

0 commit comments

Comments
 (0)