Skip to content

Commit

Permalink
test: remove common.PORT from test-cluster-basic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trott authored and evanlucas committed Apr 25, 2017
1 parent ab963c1 commit c01e7a7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/parallel/test-cluster-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ function forEach(obj, fn) {


if (cluster.isWorker) {
const http = require('http');
http.Server(function() {

}).listen(common.PORT, '127.0.0.1');
require('http').Server(common.noop).listen(0, '127.0.0.1');
} else if (cluster.isMaster) {

const checks = {
Expand Down Expand Up @@ -108,11 +105,15 @@ if (cluster.isWorker) {

case 'listening':
assert.strictEqual(arguments.length, 1);
const expect = { address: '127.0.0.1',
port: common.PORT,
addressType: 4,
fd: undefined };
assert.deepStrictEqual(arguments[0], expect);
assert.strictEqual(Object.keys(arguments[0]).length, 4);
assert.strictEqual(arguments[0].address, '127.0.0.1');
assert.strictEqual(arguments[0].addressType, 4);
assert(arguments[0].hasOwnProperty('fd'));
assert.strictEqual(arguments[0].fd, undefined);
const port = arguments[0].port;
assert(Number.isInteger(port));
assert(port >= 1);
assert(port <= 65535);
break;

default:
Expand Down

0 comments on commit c01e7a7

Please sign in to comment.