Skip to content

Commit 2b66741

Browse files
hhellyertobespc
authored andcommitted
Remove hardcoded port at 8000 to allow tests to run in parallel. (#493)
1 parent c4cc528 commit 2b66741

10 files changed

+25
-23
lines changed

tests/heapdump/test-callback-without-filename.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function testFuncCall(test) {
2525
res.end();
2626
});
2727
server.on('listening', function() {
28-
console.log('Listening on http://127.0.0.1:8000/');
28+
console.log(`Listening on http://localhost:${server.address().port}/`);
2929
console.log('PID %d', process.pid);
3030

3131
var heapSnapshotFile = 'heapdump-' + Date.now() + '.heapsnapshot';

tests/heapdump/test-callback.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function testFuncCall(test) {
2525
res.end();
2626
});
2727
server.on('listening', function() {
28-
console.log('Listening on http://127.0.0.1:8000/');
28+
console.log(`Listening on http://localhost:${server.address().port}/`);
2929
console.log('PID %d', process.pid);
3030

3131
var heapSnapshotFile = 'heapdump-*.heapsnapshot';

tests/heapdump/test-sigusr2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function testSigUsr2(test) {
2828
});
2929

3030
server.on('listening', function() {
31-
console.log('Listening on http://127.0.0.1:8000/');
31+
console.log(`Listening on http://localhost:${server.address().port}/`);
3232
console.log('now sending SIGUSR2 to %d', process.pid);
3333

3434
var heapSnapshotFile = 'heapdump-*.heapsnapshot';

tests/probes/http-outbound-probe-test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ monitor.on('http-outbound', function(data) {
3939
function checkHttpOutboundData(data, t) {
4040
t.ok(isInteger(data.time), 'Timestamp is an integer');
4141
t.equals(data.method, 'GET', 'Should report GET as HTTP request method');
42-
t.equals(data.url, 'http://localhost:8000/', 'Should report http://localhost:8000/ as URL');
42+
t.equals(data.url, `http://localhost:${server.address().port}/`,
43+
`Should report http://localhost:${server.address().port}/ as URL`);
4344
if (data.requestHeaders) {
4445
t.equals(data.requestHeaders.hello, 'world', 'Should report world as value of hello header');
4546
}
@@ -55,17 +56,17 @@ function isNumeric(n) {
5556

5657
var options = {
5758
host: 'localhost',
58-
port: 8000,
59+
port: server.address().port,
5960
headers: {
6061
hello: 'world',
6162
},
6263
};
6364

6465
// Request with a callback
65-
http.get('http://localhost:8000/', function(res) {});
66+
http.get(`http://localhost:${server.address().port}/`, function(res) {});
6667

6768
// Request without a callback
68-
http.get('http://localhost:8000/');
69+
http.get(`http://localhost:${server.address().port}/`);
6970

7071
// Request with headers
7172
http.request(options).end();

tests/probes/http-probe-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ function isNumeric(n) {
8282
}
8383

8484
// Request with a callback
85-
http.get('http://localhost:8000', function(res) {});
85+
http.get(`http://localhost:${server.address().port}/`, function(res) {});
8686

8787
// Request without a callback
88-
http.get('http://localhost:8000');
88+
http.get(`http://localhost:${server.address().port}/`);
8989

9090
// Enable requests
9191
monitor.enable('requests');
9292
monitor.disable('http');
9393

9494
// Request with a callback
95-
http.get('http://localhost:8000', function(res) {});
95+
http.get(`http://localhost:${server.address().port}/`, function(res) {});
9696

9797
// Request without a callback
98-
http.get('http://localhost:8000');
98+
http.get(`http://localhost:${server.address().port}/`);

tests/probes/https-outbound-probe-test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ monitor.on('https-outbound', function(data) {
4141
function checkHttpOutboundData(data, t) {
4242
t.ok(isInteger(data.time), 'Timestamp is an integer');
4343
t.equals(data.method, 'GET', 'Should report GET as HTTP request method');
44-
t.equals(data.url, 'https://localhost:8000/', 'Should report https://localhost:8000/ as URL');
44+
t.equals(data.url, `https://localhost:${server.address().port}/`,
45+
`Should report https://localhost:${server.address().port}/ as URL`);
4546
if (data.requestHeaders) {
4647
t.equals(data.requestHeaders.hello, 'world', 'Should report world as value of hello header');
4748
}
@@ -57,17 +58,17 @@ function isNumeric(n) {
5758

5859
var options = {
5960
host: 'localhost',
60-
port: 8000,
61+
port: server.address().port,
6162
headers: {
6263
hello: 'world',
6364
},
6465
};
6566

6667
// Request with a callback
67-
https.get('https://localhost:8000/', function(res) {});
68+
https.get(`https://localhost:${server.address().port}/`, function(res) {});
6869

6970
// Request without a callback
70-
https.get('https://localhost:8000/');
71+
https.get(`https://localhost:${server.address().port}/`);
7172

7273
// Request with headers
7374
https.request(options).end();

tests/probes/https-probe-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ function isNumeric(n) {
8282
}
8383

8484
// Request with a callback
85-
https.get('https://localhost:8000/', function(res) {});
85+
https.get(`https://localhost:${server.address().port}/`, function(res) {});
8686

8787
// Request without a callback
88-
https.get('https://localhost:8000/');
88+
https.get(`https://localhost:${server.address().port}/`);
8989

9090
var options = {
9191
host: 'localhost',
92-
port: 8000,
92+
port: server.address().port,
9393
headers: {
9494
hello: 'world',
9595
},
@@ -104,8 +104,8 @@ setTimeout(function() {
104104
monitor.disable('https');
105105

106106
// Request with a callback
107-
https.get('https://localhost:8000/', function(res) {});
107+
https.get(`https://localhost:${server.address().port}/`, function(res) {});
108108

109109
// Request without a callback
110-
https.get('https://localhost:8000/');
110+
https.get(`https://localhost:${server.address().port}/`);
111111
}, 2000);

tests/require_tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tap.test('Calling require without start should not break', function(t) {
2525

2626
// HTTP outbound request
2727
// (previously triggered http-outbound probe to emit an event which caused a SIGSEGV)
28-
http.get('http://localhost:8000', function(res) {
28+
http.get(`http://localhost:${server.address().port}/`, function(res) {
2929
server.close();
3030
t.end();
3131
});

tests/test_http_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ module.exports.server = http.createServer((req, res) => {
2323
res.end('Hello World');
2424
});
2525

26-
this.server.listen(8000);
26+
this.server.listen(0);

tests/test_https_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ module.exports.server = https.createServer(httpsOptions, (req, res) => {
3030
res.end('Hello World');
3131
});
3232

33-
this.server.listen(8000);
33+
this.server.listen(0);

0 commit comments

Comments
 (0)