Skip to content

Commit 611c23c

Browse files
Trottevanlucas
authored andcommitted
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: #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]>
1 parent a7e13e0 commit 611c23c

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ if (!id){
4646

4747

4848
a.on('message',common.mustCall((m)=>{
49-
if(typeofm==='object')return;
50-
assert.strictEqual(m,'READY');
51-
b.send('START');
49+
assert.strictEqual(m.msg,'READY');
50+
b.send({msg: 'START',port: m.port});
5251
}));
5352

5453
b.on('message',common.mustCall((m)=>{
@@ -60,10 +59,10 @@ if (!id){
6059
}elseif(id==='one'){
6160
if(cluster.isMaster)returnstartWorker();
6261

63-
http.createServer(common.mustNotCall())
64-
.listen(common.PORT,common.mustCall(()=>{
65-
process.send('READY');
66-
}));
62+
constserver=http.createServer(common.mustNotCall());
63+
server.listen(0,common.mustCall(()=>{
64+
process.send({msg: 'READY',port: server.address().port});
65+
}));
6766

6867
process.on('message',common.mustCall((m)=>{
6968
if(m==='QUIT')process.exit();
@@ -74,8 +73,8 @@ if (!id){
7473
constserver=http.createServer(common.mustNotCall());
7574
process.on('message',common.mustCall((m)=>{
7675
if(m==='QUIT')process.exit();
77-
assert.strictEqual(m,'START');
78-
server.listen(common.PORT,common.mustNotCall());
76+
assert.strictEqual(m.msg,'START');
77+
server.listen(m.port,common.mustNotCall());
7978
server.on('error',common.mustCall((e)=>{
8079
assert.strictEqual(e.code,'EADDRINUSE');
8180
process.send(e.code);

0 commit comments

Comments
(0)