Skip to content

Commit 4fe9e04

Browse files
Trottcodebytere
authored andcommittedFeb 27, 2020
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 <michael_dawson@ca.ibm.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
1 parent aa16d80 commit 4fe9e04

8 files changed

+20
-20
lines changed
 

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

+3-3
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-
const common = require('../common');
23+
require('../common');
2424
const assert = require('assert');
2525
const http = require('http');
2626

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

43-
server.listen(common.PORT, function connect() {
43+
server.listen(0, function connect() {
4444
const request = 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

+3-3
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-
const common = require('../common');
26+
require('../common');
2727
const http = require('http');
2828
const server = http.createServer();
2929
let connections = 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 (let i = 0; i < 10; i++) {
4949
connections++;
5050

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

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

+2-2
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

+2-2
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
const req = 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

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const common = require('../common');
2424
const assert = require('assert');
2525
const net = require('net');
2626

27-
function pingPongTest(port, host, on_complete) {
27+
function pingPongTest(host, on_complete) {
2828
const N = 100;
2929
const DELAY = 1;
3030
let count = 0;
@@ -63,8 +63,8 @@ function pingPongTest(port, host, on_complete) {
6363
});
6464
});
6565

66-
server.listen(port, host, common.mustCall(function() {
67-
const client = net.createConnection(port, host);
66+
server.listen(0, host, common.mustCall(function() {
67+
const client = 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

+2-2
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-
const s = net.connect(common.PORT);
51+
server.listen(0, function() {
52+
const s = net.connect(server.address().port);
5353
s.pipe(process.stdout);
5454
});

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

+2-2
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
const args = process.execArgv.concat([ childScript,
55-
common.PORT,
55+
server.address().port,
5656
bytesExpected ]);
5757

5858
const child = 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

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

4747
let recvCount = 0;
4848

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

0 commit comments

Comments
 (0)
Please sign in to comment.