Skip to content

Commit 947dd26

Browse files
Trottandrew749
authored andcommittedJul 19, 2017
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: nodejs/node#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 fffc588 commit 947dd26

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 = {
@@ -109,11 +106,15 @@ if (cluster.isWorker) {
109106

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

119120
default:

0 commit comments

Comments
 (0)
Please sign in to comment.