Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7d47b02

Browse filesBrowse files
TrottMylesBorins
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 <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>
1 parent a6e0673 commit 7d47b02
Copy full SHA for 7d47b02

File tree

Expand file treeCollapse file tree

1 file changed

+10
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-9
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-cluster-basic.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-basic.js
+10-9Lines changed: 10 additions & 9 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.