Browse Source

test: use dynamic port in test-cluster-bind-twice

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: https://github.com/nodejs/node/pull/12418
Ref: https://github.com/nodejs/node/issues/12376
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6
Rich Trott 8 years ago
committed by James M Snell
parent
commit
30a045858a
  1. 17
      test/parallel/test-cluster-bind-twice.js

17
test/parallel/test-cluster-bind-twice.js

@ -67,9 +67,8 @@ if (!id) {
a.on('message', common.mustCall((m) => { a.on('message', common.mustCall((m) => {
if (typeof m === 'object') return; assert.strictEqual(m.msg, 'READY');
assert.strictEqual(m, 'READY'); b.send({msg: 'START', port: m.port});
b.send('START');
})); }));
b.on('message', common.mustCall((m) => { b.on('message', common.mustCall((m) => {
@ -81,10 +80,10 @@ if (!id) {
} else if (id === 'one') { } else if (id === 'one') {
if (cluster.isMaster) return startWorker(); if (cluster.isMaster) return startWorker();
http.createServer(common.mustNotCall()) const server = http.createServer(common.mustNotCall());
.listen(common.PORT, common.mustCall(() => { server.listen(0, common.mustCall(() => {
process.send('READY'); process.send({msg: 'READY', port: server.address().port});
})); }));
process.on('message', common.mustCall((m) => { process.on('message', common.mustCall((m) => {
if (m === 'QUIT') process.exit(); if (m === 'QUIT') process.exit();
@ -95,8 +94,8 @@ if (!id) {
const server = http.createServer(common.mustNotCall()); const server = http.createServer(common.mustNotCall());
process.on('message', common.mustCall((m) => { process.on('message', common.mustCall((m) => {
if (m === 'QUIT') process.exit(); if (m === 'QUIT') process.exit();
assert.strictEqual(m, 'START'); assert.strictEqual(m.msg, 'START');
server.listen(common.PORT, common.mustNotCall()); server.listen(m.port, common.mustNotCall());
server.on('error', common.mustCall((e) => { server.on('error', common.mustCall((e) => {
assert.strictEqual(e.code, 'EADDRINUSE'); assert.strictEqual(e.code, 'EADDRINUSE');
process.send(e.code); process.send(e.code);

Loading…
Cancel
Save