Skip to content

Commit

Permalink
test: refactor pummel/test-keep-alive
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Trott authored and addaleax committed Jan 23, 2019
1 parent 5ee2bec commit 817b44d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/pummel/test-keep-alive.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

'use strict';

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

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

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

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

const child = spawn('wrk', args);
child.stderr.pipe(process.stderr);
Expand Down Expand Up @@ -90,11 +90,12 @@ const runAb = (opts, callback) => {
});
};

server.listen(common.PORT, () => {
runAb({ keepalive: true }, (reqSec) => {
server.listen(0, () => {
const port = server.address().port;
runAb({ keepalive: true, port: port }, (reqSec) => {
keepAliveReqSec = reqSec;

runAb({ keepalive: false }, (reqSec) => {
runAb({ keepalive: false, port: port }, (reqSec) => {
normalReqSec = reqSec;
server.close();
});
Expand Down

0 comments on commit 817b44d

Please sign in to comment.