Skip to content

Commit

Permalink
test: use dynamic port in test-cluster-bind-twice
Browse files Browse the repository at this point in the history
Remove common.PORT from test-cluster-bind-twice to eliminate possibility
that a dynamic port used in another test will collide with common.PORT.

PR-URL: #12418
Ref: #12376
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and jasnell committed Apr 18, 2017
1 parent 415098f commit 30a0458
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions test/parallel/test-cluster-bind-twice.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ if (!id) {


a.on('message', common.mustCall((m) => {
if (typeof m === 'object') return;
assert.strictEqual(m, 'READY');
b.send('START');
assert.strictEqual(m.msg, 'READY');
b.send({msg: 'START', port: m.port});
}));

b.on('message', common.mustCall((m) => {
Expand All @@ -81,10 +80,10 @@ if (!id) {
} else if (id === 'one') {
if (cluster.isMaster) return startWorker();

http.createServer(common.mustNotCall())
.listen(common.PORT, common.mustCall(() => {
process.send('READY');
}));
const server = http.createServer(common.mustNotCall());
server.listen(0, common.mustCall(() => {
process.send({msg: 'READY', port: server.address().port});
}));

process.on('message', common.mustCall((m) => {
if (m === 'QUIT') process.exit();
Expand All @@ -95,8 +94,8 @@ if (!id) {
const server = http.createServer(common.mustNotCall());
process.on('message', common.mustCall((m) => {
if (m === 'QUIT') process.exit();
assert.strictEqual(m, 'START');
server.listen(common.PORT, common.mustNotCall());
assert.strictEqual(m.msg, 'START');
server.listen(m.port, common.mustNotCall());
server.on('error', common.mustCall((e) => {
assert.strictEqual(e.code, 'EADDRINUSE');
process.send(e.code);
Expand Down

0 comments on commit 30a0458

Please sign in to comment.