Skip to content

Commit 307da2d

Browse files
Trottaddaleax
authored andcommitted
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: #25485 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 69c0841 commit 307da2d

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

‎test/pummel/test-net-many-clients.js‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,29 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
constcommon=require('../common');
23+
require('../common');
2424
constassert=require('assert');
2525
constnet=require('net');
2626

2727
// settings
2828
constbytes=1024*40;
29-
constconcurrency=100;
30-
constconnections_per_client=5;
29+
constconcurrency=50;
30+
constconnections_per_client=3;
3131

3232
// measured
3333
lettotal_connections=0;
3434

3535
constbody='C'.repeat(bytes);
3636

3737
constserver=net.createServer(function(c){
38-
console.log('connected');
3938
total_connections++;
40-
console.log('#');
39+
console.log('connected',total_connections);
4140
c.write(body);
4241
c.end();
4342
});
4443

45-
functionrunClient(callback){
46-
constclient=net.createConnection(common.PORT);
44+
functionrunClient(port,callback){
45+
constclient=net.createConnection(port);
4746

4847
client.connections=0;
4948

@@ -79,17 +78,17 @@ function runClient(callback) {
7978
assert.ok(!client.fd);
8079

8180
if(this.connections<connections_per_client){
82-
this.connect(common.PORT);
81+
this.connect(port);
8382
}else{
8483
callback();
8584
}
8685
});
8786
}
8887

89-
server.listen(common.PORT,function(){
88+
server.listen(0,function(){
9089
letfinished_clients=0;
9190
for(leti=0;i<concurrency;i++){
92-
runClient(function(){
91+
runClient(server.address().port,function(){
9392
if(++finished_clients===concurrency)server.close();
9493
});
9594
}

0 commit comments

Comments
 (0)