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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Rich Trott 2017-11-22 14:39:38 -08:00
parent 35c01d84a8
commit e18390032e
7 changed files with 8 additions and 8 deletions

View File

@ -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));

View File

@ -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));
}

View File

@ -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);

View File

@ -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);
@ -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);

View File

@ -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);