Skip to content

Commit

Permalink
test: remove common.PORT from parallel tests
Browse files Browse the repository at this point in the history
`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>
  • Loading branch information
Trott authored and gibfahn committed Apr 12, 2018
1 parent da16227 commit 53b702f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/async-hooks/test-graph.tcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const server = net
.createServer(common.mustCall(onconnection))
.on('listening', common.mustCall(onlistening));

server.listen(common.PORT);
server.listen(0);

net.connect({ port: server.address().port, host: '::1' },
common.mustCall(onconnected));
Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-graph.tls-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ const server = tls
})
.on('listening', common.mustCall(onlistening))
.on('secureConnection', common.mustCall(onsecureConnection))
.listen(common.PORT);
.listen(0);

function onlistening() {
//
// Creating client and connecting it to server
//
tls
.connect(common.PORT, { rejectUnauthorized: false })
.connect(server.address().port, { rejectUnauthorized: false })
.on('secureConnect', common.mustCall(onsecureConnect));
}

Expand Down
2 changes: 1 addition & 1 deletion test/async-hooks/test-tcpwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const server = net

// Calling server.listen creates a TCPWRAP synchronously
{
server.listen(common.PORT);
server.listen(0);
const tcpsservers = hooks.activitiesOfTypes('TCPSERVERWRAP');
const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP');
assert.strictEqual(tcpsservers.length, 1);
Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-writewrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const server = tls
})
.on('listening', common.mustCall(onlistening))
.on('secureConnection', common.mustCall(onsecureConnection))
.listen(common.PORT);
.listen(0);

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

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

assert.strictEqual(hooks.activitiesOfTypes('WRITEWRAP').length, 0);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-net-connect-immediate-finish.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ const {

const client = net.connect({
host: addresses.INVALID_HOST,
port: common.PORT,
port: 80, // port number doesn't matter because host name is invalid
lookup: common.mustCall(errorLookupMock())
});
}, common.mustNotCall());

client.once('error', common.mustCall((err) => {
assert(err);
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 53b702f

Please sign in to comment.