Skip to content

Commit e927809

Browse files
Sebastian Plesciucaddaleax
Sebastian Plesciuc
authored andcommitted
test: dynamic port in parallel regress tests
Removed common.PORT from test-regress-GH-5051 and test-regress-GH-5727 in order to eliminate the possibility of port collision. Refs: #12376 PR-URL: #12639 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
1 parent 1d96803 commit e927809

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

test/parallel/test-regress-GH-5051.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ agent.maxSockets = 0;
1212

1313
// localAddress is used when naming requests / sockets
1414
// while using the Legacy API
15-
agent.addRequest(req, 'localhost', common.PORT, '127.0.0.1');
15+
// port 8080 is hardcoded since this does not create a network connection
16+
agent.addRequest(req, 'localhost', 8080, '127.0.0.1');
1617
assert.strictEqual(Object.keys(agent.requests).length, 1);
1718
assert.strictEqual(
1819
Object.keys(agent.requests)[0],
19-
'localhost:' + common.PORT + ':127.0.0.1');
20+
'localhost:8080:127.0.0.1');
2021

2122
// path is *not* used when naming requests / sockets
23+
// port 8080 is hardcoded since this does not create a network connection
2224
agent.addRequest(req, {
2325
host: 'localhost',
24-
port: common.PORT,
26+
port: 8080,
2527
localAddress: '127.0.0.1',
2628
path: '/foo'
2729
});
2830
assert.strictEqual(Object.keys(agent.requests).length, 1);
2931
assert.strictEqual(
3032
Object.keys(agent.requests)[0],
31-
'localhost:' + common.PORT + ':127.0.0.1');
33+
'localhost:8080:127.0.0.1');

test/parallel/test-regress-GH-5727.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const net = require('net');
66
const invalidPort = -1 >>> 0;
77
const errorMessage = /"port" argument must be >= 0 and < 65536/;
88

9-
net.Server().listen(common.PORT, function() {
9+
net.Server().listen(0, function() {
1010
const address = this.address();
11-
const key = `${address.family.slice(-1)}:${address.address}:${common.PORT}`;
11+
const key = `${address.family.slice(-1)}:${address.address}:0`;
1212

1313
assert.strictEqual(this._connectionKey, key);
1414
this.close();

0 commit comments

Comments
 (0)