summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2019-01-13 20:58:06 -0800
committerRich Trott <rtrott@gmail.com>2019-01-16 06:49:18 -0800
commite675d4bd2b9f8d68f8c5deddbfefa92a79edd8a4 (patch)
tree27f066d068b0c05905288b08cda8f8432be67a29 /test
parentb39234a4a8c9c360a3bff46b6c10f696a542eb23 (diff)
downloadandroid-node-v8-e675d4bd2b9f8d68f8c5deddbfefa92a79edd8a4.tar.gz
android-node-v8-e675d4bd2b9f8d68f8c5deddbfefa92a79edd8a4.tar.bz2
android-node-v8-e675d4bd2b9f8d68f8c5deddbfefa92a79edd8a4.zip
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. PR-URL: https://github.com/nodejs/node/pull/25485 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/pummel/test-net-many-clients.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js
index db7da1ae04..4d114922a9 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();
});
}