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: nodejs/node#12418
Ref: nodejs/node#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 andrew749 committed Jul 19, 2017
1 parent eedba1c commit 6d61a09
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 @@ -46,9 +46,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 @@ -60,10 +59,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 @@ -74,8 +73,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 6d61a09

Please sign in to comment.