Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove common.PORT from test-cluster-basic #12377

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
Trott committed Apr 12, 2017
commit fd333b15d65123cea664630f6a1a50d92617951a
19 changes: 10 additions & 9 deletions test/parallel/test-cluster-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,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 @@ -129,11 +126,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