From 506e3cc8b7f9824d2ddaf1fb8531b2c13af2fcb8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 13 Jan 2019 20:09:17 -0800 Subject: [PATCH 1/4] 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. --- 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(); }); From d079adcfff0854394999e4f81da23e5f770c1cb0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 13 Jan 2019 20:35:52 -0800 Subject: [PATCH 2/4] test: refactor pummel/test-net-connect-econnrefused * Reduce ROUNDS and ATTEMPTS_PER_ROUND by half to avoid spurious test failures as a result of side effects from other tests. (For my local setup, test-keep-alive seems to cause this test to fail with ETIMEDOUT and/or EADDRNOTAVAIL. It would seem to be a result of throttling. Reducing the pummel-iness of that test and this one seems to solve the problem.) * Apply capitalization and punctuation to comment. --- test/pummel/test-net-connect-econnrefused.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/pummel/test-net-connect-econnrefused.js b/test/pummel/test-net-connect-econnrefused.js index 0f350bd572f177..39737f73bf0831 100644 --- a/test/pummel/test-net-connect-econnrefused.js +++ b/test/pummel/test-net-connect-econnrefused.js @@ -20,14 +20,14 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -// verify that connect reqs are properly cleaned up +// Verify that connect reqs are properly cleaned up. const common = require('../common'); const assert = require('assert'); const net = require('net'); -const ROUNDS = 10; -const ATTEMPTS_PER_ROUND = 100; +const ROUNDS = 5; +const ATTEMPTS_PER_ROUND = 50; let rounds = 1; let reqs = 0; From 1a3589e9e2d353a4a11498298b8186c4633a878c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 13 Jan 2019 20:58:06 -0800 Subject: [PATCH 3/4] test: refactor pummel/test-net-many-clients * Use port 0 instead of `common.PORT`. * Reduce `concurrent` from 100 to 50 and `connections_per_client` from 5 to 3. This is to avoid side effects from other tests. Prior to this change, running this along with test-keep-alive would result in failures on my local setup, apparently due to network throttling. * Remove unnecessary `console.log()` and improve remaining `console.log()` to provide clearer information. --- test/pummel/test-net-many-clients.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js index db7da1ae041341..4d114922a92ad8 100644 --- a/test/pummel/test-net-many-clients.js +++ b/test/pummel/test-net-many-clients.js @@ -20,14 +20,14 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); // settings const bytes = 1024 * 40; -const concurrency = 100; -const connections_per_client = 5; +const concurrency = 50; +const connections_per_client = 3; // measured let total_connections = 0; @@ -35,15 +35,14 @@ let total_connections = 0; const body = 'C'.repeat(bytes); const server = net.createServer(function(c) { - console.log('connected'); total_connections++; - console.log('#'); + console.log('connected', total_connections); c.write(body); c.end(); }); -function runClient(callback) { - const client = net.createConnection(common.PORT); +function runClient(port, callback) { + const client = net.createConnection(port); client.connections = 0; @@ -79,17 +78,17 @@ function runClient(callback) { assert.ok(!client.fd); if (this.connections < connections_per_client) { - this.connect(common.PORT); + this.connect(port); } else { callback(); } }); } -server.listen(common.PORT, function() { +server.listen(0, function() { let finished_clients = 0; for (let i = 0; i < concurrency; i++) { - runClient(function() { + runClient(server.address().port, function() { if (++finished_clients === concurrency) server.close(); }); } From f8373a0cf0b8c464373c83411375c204851ed690 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 13 Jan 2019 21:01:43 -0800 Subject: [PATCH 4/4] test: refactor pummel/test-net-pingpong * Use port 0 instead of `common.PORT`. * Use `//` for comments, capitalize comments, and add punctuation. --- test/pummel/test-net-pingpong.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index 29ffd0bdf7261b..b9507d519d8e6d 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -26,7 +26,7 @@ const net = require('net'); let tests_run = 0; -function pingPongTest(port, host, on_complete) { +function pingPongTest(host, on_complete) { const N = 1000; let count = 0; let sent_final_ping = false; @@ -69,8 +69,8 @@ function pingPongTest(port, host, on_complete) { }); }); - server.listen(port, host, function() { - const client = net.createConnection(port, host); + server.listen(0, host, function() { + const client = net.createConnection(server.address().port, host); client.setEncoding('utf8'); @@ -110,12 +110,12 @@ function pingPongTest(port, host, on_complete) { }); } -/* All are run at once, so run on different ports */ -pingPongTest(common.PORT, 'localhost'); -pingPongTest(common.PORT + 1, null); +// All are run at once and will run on different ports. +pingPongTest('localhost'); +pingPongTest(null); -// This IPv6 isn't working on Solaris -if (!common.isSunOS) pingPongTest(common.PORT + 2, '::1'); +// This IPv6 isn't working on Solaris. +if (!common.isSunOS) pingPongTest('::1'); process.on('exit', function() { assert.strictEqual(tests_run, common.isSunOS ? 2 : 3);