Skip to content

Commit 817b44d

Browse files
Trottaddaleax
authored andcommittedJan 23, 2019
test: refactor pummel/test-keep-alive
* Reduce concurrent and duration options by half so as to avoid interference with other tests. (Excessive TCP activity in this test resulted in throttling that caused subsequent tests to fail on my local setup.) * Use an OS-provided port rather than `common.PORT`. This possibly reduces side-effects on other tests (that may also be using `common.PORT`). * Add punctuation in comments. PR-URL: #25485 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 5ee2bec commit 817b44d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed
 

‎test/pummel/test-keep-alive.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
'use strict';
2323

24-
// This test requires the program 'wrk'
24+
// This test requires the program 'wrk'.
2525
const common = require('../common');
2626
if (common.isWindows)
2727
common.skip('no `wrk` on windows');
@@ -47,9 +47,9 @@ let normalReqSec = 0;
4747

4848
const runAb = (opts, callback) => {
4949
const args = [
50-
'-c', opts.concurrent || 100,
50+
'-c', opts.concurrent || 50,
5151
'-t', opts.threads || 2,
52-
'-d', opts.duration || '10s',
52+
'-d', opts.duration || '5s',
5353
];
5454

5555
if (!opts.keepalive) {
@@ -58,7 +58,7 @@ const runAb = (opts, callback) => {
5858
}
5959

6060
args.push(url.format({ hostname: '127.0.0.1',
61-
port: common.PORT, protocol: 'http' }));
61+
port: opts.port, protocol: 'http' }));
6262

6363
const child = spawn('wrk', args);
6464
child.stderr.pipe(process.stderr);
@@ -90,11 +90,12 @@ const runAb = (opts, callback) => {
9090
});
9191
};
9292

93-
server.listen(common.PORT, () => {
94-
runAb({ keepalive: true }, (reqSec) => {
93+
server.listen(0, () => {
94+
const port = server.address().port;
95+
runAb({ keepalive: true, port: port }, (reqSec) => {
9596
keepAliveReqSec = reqSec;
9697

97-
runAb({ keepalive: false }, (reqSec) => {
98+
runAb({ keepalive: false, port: port }, (reqSec) => {
9899
normalReqSec = reqSec;
99100
server.close();
100101
});

0 commit comments

Comments
 (0)