diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index 0fec1ff877b89b..5d2f00170d45b0 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -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'); @@ -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) { @@ -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); @@ -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(); });