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:
parent
35c01d84a8
commit
e18390032e
@ -15,7 +15,7 @@ const server = net
|
|||||||
.createServer(common.mustCall(onconnection))
|
.createServer(common.mustCall(onconnection))
|
||||||
.on('listening', common.mustCall(onlistening));
|
.on('listening', common.mustCall(onlistening));
|
||||||
|
|
||||||
server.listen(common.PORT);
|
server.listen(0);
|
||||||
|
|
||||||
net.connect({ port: server.address().port, host: '::1' },
|
net.connect({ port: server.address().port, host: '::1' },
|
||||||
common.mustCall(onconnected));
|
common.mustCall(onconnected));
|
||||||
|
@ -25,14 +25,14 @@ const server = tls
|
|||||||
})
|
})
|
||||||
.on('listening', common.mustCall(onlistening))
|
.on('listening', common.mustCall(onlistening))
|
||||||
.on('secureConnection', common.mustCall(onsecureConnection))
|
.on('secureConnection', common.mustCall(onsecureConnection))
|
||||||
.listen(common.PORT);
|
.listen(0);
|
||||||
|
|
||||||
function onlistening() {
|
function onlistening() {
|
||||||
//
|
//
|
||||||
// Creating client and connecting it to server
|
// Creating client and connecting it to server
|
||||||
//
|
//
|
||||||
tls
|
tls
|
||||||
.connect(common.PORT, { rejectUnauthorized: false })
|
.connect(server.address().port, { rejectUnauthorized: false })
|
||||||
.on('secureConnect', common.mustCall(onsecureConnect));
|
.on('secureConnect', common.mustCall(onsecureConnect));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ const server = net
|
|||||||
|
|
||||||
// Calling server.listen creates a TCPWRAP synchronously
|
// Calling server.listen creates a TCPWRAP synchronously
|
||||||
{
|
{
|
||||||
server.listen(common.PORT);
|
server.listen(0);
|
||||||
const tcpsservers = hooks.activitiesOfTypes('TCPSERVERWRAP');
|
const tcpsservers = hooks.activitiesOfTypes('TCPSERVERWRAP');
|
||||||
const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP');
|
const tcpconnects = hooks.activitiesOfTypes('TCPCONNECTWRAP');
|
||||||
assert.strictEqual(tcpsservers.length, 1);
|
assert.strictEqual(tcpsservers.length, 1);
|
||||||
|
@ -23,7 +23,7 @@ const server = tls
|
|||||||
})
|
})
|
||||||
.on('listening', common.mustCall(onlistening))
|
.on('listening', common.mustCall(onlistening))
|
||||||
.on('secureConnection', common.mustCall(onsecureConnection))
|
.on('secureConnection', common.mustCall(onsecureConnection))
|
||||||
.listen(common.PORT);
|
.listen(0);
|
||||||
|
|
||||||
assert.strictEqual(hooks.activitiesOfTypes('WRITEWRAP').length, 0);
|
assert.strictEqual(hooks.activitiesOfTypes('WRITEWRAP').length, 0);
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ function onlistening() {
|
|||||||
// Creating client and connecting it to server
|
// Creating client and connecting it to server
|
||||||
//
|
//
|
||||||
tls
|
tls
|
||||||
.connect(common.PORT, { rejectUnauthorized: false })
|
.connect(server.address().port, { rejectUnauthorized: false })
|
||||||
.on('secureConnect', common.mustCall(onsecureConnect));
|
.on('secureConnect', common.mustCall(onsecureConnect));
|
||||||
|
|
||||||
assert.strictEqual(hooks.activitiesOfTypes('WRITEWRAP').length, 0);
|
assert.strictEqual(hooks.activitiesOfTypes('WRITEWRAP').length, 0);
|
||||||
|
@ -38,9 +38,9 @@ const {
|
|||||||
|
|
||||||
const client = net.connect({
|
const client = net.connect({
|
||||||
host: addresses.INVALID_HOST,
|
host: addresses.INVALID_HOST,
|
||||||
port: common.PORT,
|
port: 80, // port number doesn't matter because host name is invalid
|
||||||
lookup: common.mustCall(errorLookupMock())
|
lookup: common.mustCall(errorLookupMock())
|
||||||
});
|
}, common.mustNotCall());
|
||||||
|
|
||||||
client.once('error', common.mustCall((err) => {
|
client.once('error', common.mustCall((err) => {
|
||||||
assert(err);
|
assert(err);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user