Skip to content

Commit 5ed9ed3

Browse files
Trottevanlucas
authored andcommitted
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: #12377 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent e4b2f61 commit 5ed9ed3

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/parallel/test-cluster-basic.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ function forEach(obj, fn) {
1414

1515

1616
if (cluster.isWorker) {
17-
const http = require('http');
18-
http.Server(function() {
19-
20-
}).listen(common.PORT, '127.0.0.1');
17+
require('http').Server(common.noop).listen(0, '127.0.0.1');
2118
} else if (cluster.isMaster) {
2219

2320
const checks = {
@@ -108,11 +105,15 @@ if (cluster.isWorker) {
108105

109106
case 'listening':
110107
assert.strictEqual(arguments.length, 1);
111-
const expect = { address: '127.0.0.1',
112-
port: common.PORT,
113-
addressType: 4,
114-
fd: undefined };
115-
assert.deepStrictEqual(arguments[0], expect);
108+
assert.strictEqual(Object.keys(arguments[0]).length, 4);
109+
assert.strictEqual(arguments[0].address, '127.0.0.1');
110+
assert.strictEqual(arguments[0].addressType, 4);
111+
assert(arguments[0].hasOwnProperty('fd'));
112+
assert.strictEqual(arguments[0].fd, undefined);
113+
const port = arguments[0].port;
114+
assert(Number.isInteger(port));
115+
assert(port >= 1);
116+
assert(port <= 65535);
116117
break;
117118

118119
default:

0 commit comments

Comments
 (0)