From 817b44db54feacb5f14e733d3338560e3b1cf29f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 13 Jan 2019 20:09:17 -0800 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/25485 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- test/pummel/test-keep-alive.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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(); });