Skip to content

Commit 3deee05

Browse files
Trottcodebytere
authored andcommitted
test: remove common.PORT from assorted pummel tests
Use port "0" for an OS-provided open port instead of common.PORT. PR-URL: #31897 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Denys Otrishko <[email protected]>
1 parent fd5aa41 commit 3deee05

8 files changed

+20
-20
lines changed

‎test/pummel/test-http-many-keep-alive-connections.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
constcommon=require('../common');
23+
require('../common');
2424
constassert=require('assert');
2525
consthttp=require('http');
2626

@@ -40,9 +40,9 @@ server.once('connection', function(c){
4040
connection=c;
4141
});
4242

43-
server.listen(common.PORT,functionconnect(){
43+
server.listen(0,functionconnect(){
4444
constrequest=http.get({
45-
port: common.PORT,
45+
port: server.address().port,
4646
path: '/',
4747
headers: {
4848
'Connection': 'Keep-alive'

‎test/pummel/test-http-upload-timeout.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// This tests setTimeout() by having multiple clients connecting and sending
2424
// data in random intervals. Clients are also randomly disconnecting until there
2525
// are no more clients left. If no false timeout occurs, this test has passed.
26-
constcommon=require('../common');
26+
require('../common');
2727
consthttp=require('http');
2828
constserver=http.createServer();
2929
letconnections=0;
@@ -44,13 +44,13 @@ server.on('request', function(req, res){
4444
req.resume();
4545
});
4646

47-
server.listen(common.PORT,'127.0.0.1',function(){
47+
server.listen(0,'127.0.0.1',function(){
4848
for(leti=0;i<10;i++){
4949
connections++;
5050

5151
setTimeout(function(){
5252
constrequest=http.request({
53-
port: common.PORT,
53+
port: server.address().port,
5454
method: 'POST',
5555
path: '/'
5656
});

‎test/pummel/test-https-large-response.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const server = https.createServer(options, common.mustCall(function(req, res){
4343
res.end(body);
4444
}));
4545

46-
server.listen(common.PORT,common.mustCall(function(){
46+
server.listen(0,common.mustCall(function(){
4747
https.get({
48-
port: common.PORT,
48+
port: server.address().port,
4949
rejectUnauthorized: false
5050
},common.mustCall(function(res){
5151
console.log('response!');

‎test/pummel/test-https-no-reader.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ const server = https.createServer(options, function(req, res){
4343
res.end();
4444
});
4545

46-
server.listen(common.PORT,function(){
46+
server.listen(0,function(){
4747
constreq=https.request({
4848
method: 'POST',
49-
port: common.PORT,
49+
port: server.address().port,
5050
rejectUnauthorized: false
5151
},function(res){
5252
res.read(0);

‎test/pummel/test-net-pingpong-delay.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const common = require('../common');
2424
constassert=require('assert');
2525
constnet=require('net');
2626

27-
functionpingPongTest(port,host,on_complete){
27+
functionpingPongTest(host,on_complete){
2828
constN=100;
2929
constDELAY=1;
3030
letcount=0;
@@ -63,8 +63,8 @@ function pingPongTest(port, host, on_complete){
6363
});
6464
});
6565

66-
server.listen(port,host,common.mustCall(function(){
67-
constclient=net.createConnection(port,host);
66+
server.listen(0,host,common.mustCall(function(){
67+
constclient=net.createConnection(server.address().port,host);
6868

6969
client.setEncoding('utf8');
7070

@@ -104,4 +104,4 @@ function pingPongTest(port, host, on_complete){
104104
}));
105105
}
106106

107-
pingPongTest(common.PORT);
107+
pingPongTest();

‎test/pummel/test-net-timeout2.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const server = net.createServer(function(socket){
4848
});
4949

5050

51-
server.listen(common.PORT,function(){
52-
consts=net.connect(common.PORT);
51+
server.listen(0,function(){
52+
consts=net.connect(server.address().port);
5353
s.pipe(process.stdout);
5454
});

‎test/pummel/test-regress-GH-892.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function makeRequest(){
5252
// more easily. Also, this is handy when using this test to
5353
// view V8 opt/deopt behavior.
5454
constargs=process.execArgv.concat([childScript,
55-
common.PORT,
55+
server.address().port,
5656
bytesExpected]);
5757

5858
constchild=spawn(process.execPath,args);
@@ -101,7 +101,7 @@ const server = https.Server(serverOptions, function(req, res){
101101
});
102102
});
103103

104-
server.listen(common.PORT,function(){
104+
server.listen(0,function(){
105105
console.log(`expecting ${bytesExpected} bytes`);
106106
makeRequest();
107107
});

‎test/pummel/test-tls-throttle.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ const server = tls.Server(options, common.mustCall(function(socket){
4646

4747
letrecvCount=0;
4848

49-
server.listen(common.PORT,function(){
49+
server.listen(0,function(){
5050
constclient=tls.connect({
51-
port: common.PORT,
51+
port: server.address().port,
5252
rejectUnauthorized: false
5353
});
5454

0 commit comments

Comments
(0)