test: remove common.PORT from test-cluster-basic
Use of `common.PORT` in `parallel` tests is not completely safe (because the same port can be previously assigned to another test running in parallel if that test uses port `0` to get an arbitrary available port). Remove `common.PORT` from test-cluster-basic. PR-URL: https://github.com/nodejs/node/pull/12377 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
2841f478e4
commit
c05e5bfa7b
@ -35,10 +35,7 @@ function forEach(obj, fn) {
|
|||||||
|
|
||||||
|
|
||||||
if (cluster.isWorker) {
|
if (cluster.isWorker) {
|
||||||
const http = require('http');
|
require('http').Server(common.noop).listen(0, '127.0.0.1');
|
||||||
http.Server(function() {
|
|
||||||
|
|
||||||
}).listen(common.PORT, '127.0.0.1');
|
|
||||||
} else if (cluster.isMaster) {
|
} else if (cluster.isMaster) {
|
||||||
|
|
||||||
const checks = {
|
const checks = {
|
||||||
@ -129,11 +126,15 @@ if (cluster.isWorker) {
|
|||||||
|
|
||||||
case 'listening':
|
case 'listening':
|
||||||
assert.strictEqual(arguments.length, 1);
|
assert.strictEqual(arguments.length, 1);
|
||||||
const expect = { address: '127.0.0.1',
|
assert.strictEqual(Object.keys(arguments[0]).length, 4);
|
||||||
port: common.PORT,
|
assert.strictEqual(arguments[0].address, '127.0.0.1');
|
||||||
addressType: 4,
|
assert.strictEqual(arguments[0].addressType, 4);
|
||||||
fd: undefined };
|
assert(arguments[0].hasOwnProperty('fd'));
|
||||||
assert.deepStrictEqual(arguments[0], expect);
|
assert.strictEqual(arguments[0].fd, undefined);
|
||||||
|
const port = arguments[0].port;
|
||||||
|
assert(Number.isInteger(port));
|
||||||
|
assert(port >= 1);
|
||||||
|
assert(port <= 65535);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user