Skip to content

Commit

Permalink
test: remove common.PORT from assorted pummel tests
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trott authored and codebytere committed Feb 27, 2020
1 parent aa16d80 commit 4fe9e04
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions test/pummel/test-http-many-keep-alive-connections.js
Expand Up @@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
const common = require('../common');
require('../common');
const assert = require('assert');
const http = require('http');

Expand All @@ -40,9 +40,9 @@ server.once('connection', function(c) {
connection = c;
});

server.listen(common.PORT, function connect() {
server.listen(0, function connect() {
const request = http.get({
port: common.PORT,
port: server.address().port,
path: '/',
headers: {
'Connection': 'Keep-alive'
Expand Down
6 changes: 3 additions & 3 deletions test/pummel/test-http-upload-timeout.js
Expand Up @@ -23,7 +23,7 @@
// This tests setTimeout() by having multiple clients connecting and sending
// data in random intervals. Clients are also randomly disconnecting until there
// are no more clients left. If no false timeout occurs, this test has passed.
const common = require('../common');
require('../common');
const http = require('http');
const server = http.createServer();
let connections = 0;
Expand All @@ -44,13 +44,13 @@ server.on('request', function(req, res) {
req.resume();
});

server.listen(common.PORT, '127.0.0.1', function() {
server.listen(0, '127.0.0.1', function() {
for (let i = 0; i < 10; i++) {
connections++;

setTimeout(function() {
const request = http.request({
port: common.PORT,
port: server.address().port,
method: 'POST',
path: '/'
});
Expand Down
4 changes: 2 additions & 2 deletions test/pummel/test-https-large-response.js
Expand Up @@ -43,9 +43,9 @@ const server = https.createServer(options, common.mustCall(function(req, res) {
res.end(body);
}));

server.listen(common.PORT, common.mustCall(function() {
server.listen(0, common.mustCall(function() {
https.get({
port: common.PORT,
port: server.address().port,
rejectUnauthorized: false
}, common.mustCall(function(res) {
console.log('response!');
Expand Down
4 changes: 2 additions & 2 deletions test/pummel/test-https-no-reader.js
Expand Up @@ -43,10 +43,10 @@ const server = https.createServer(options, function(req, res) {
res.end();
});

server.listen(common.PORT, function() {
server.listen(0, function() {
const req = https.request({
method: 'POST',
port: common.PORT,
port: server.address().port,
rejectUnauthorized: false
}, function(res) {
res.read(0);
Expand Down
8 changes: 4 additions & 4 deletions test/pummel/test-net-pingpong-delay.js
Expand Up @@ -24,7 +24,7 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');

function pingPongTest(port, host, on_complete) {
function pingPongTest(host, on_complete) {
const N = 100;
const DELAY = 1;
let count = 0;
Expand Down Expand Up @@ -63,8 +63,8 @@ function pingPongTest(port, host, on_complete) {
});
});

server.listen(port, host, common.mustCall(function() {
const client = net.createConnection(port, host);
server.listen(0, host, common.mustCall(function() {
const client = net.createConnection(server.address().port, host);

client.setEncoding('utf8');

Expand Down Expand Up @@ -104,4 +104,4 @@ function pingPongTest(port, host, on_complete) {
}));
}

pingPongTest(common.PORT);
pingPongTest();
4 changes: 2 additions & 2 deletions test/pummel/test-net-timeout2.js
Expand Up @@ -48,7 +48,7 @@ const server = net.createServer(function(socket) {
});


server.listen(common.PORT, function() {
const s = net.connect(common.PORT);
server.listen(0, function() {
const s = net.connect(server.address().port);
s.pipe(process.stdout);
});
4 changes: 2 additions & 2 deletions test/pummel/test-regress-GH-892.js
Expand Up @@ -52,7 +52,7 @@ function makeRequest() {
// more easily. Also, this is handy when using this test to
// view V8 opt/deopt behavior.
const args = process.execArgv.concat([ childScript,
common.PORT,
server.address().port,
bytesExpected ]);

const child = spawn(process.execPath, args);
Expand Down Expand Up @@ -101,7 +101,7 @@ const server = https.Server(serverOptions, function(req, res) {
});
});

server.listen(common.PORT, function() {
server.listen(0, function() {
console.log(`expecting ${bytesExpected} bytes`);
makeRequest();
});
Expand Down
4 changes: 2 additions & 2 deletions test/pummel/test-tls-throttle.js
Expand Up @@ -46,9 +46,9 @@ const server = tls.Server(options, common.mustCall(function(socket) {

let recvCount = 0;

server.listen(common.PORT, function() {
server.listen(0, function() {
const client = tls.connect({
port: common.PORT,
port: server.address().port,
rejectUnauthorized: false
});

Expand Down

0 comments on commit 4fe9e04

Please sign in to comment.