From 5d7265f601f733b8a08b65f05379e39904a64593 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 2 Mar 2016 15:23:55 -0700 Subject: [PATCH] test: prevent flakey test on pi2 Looping rapidly and making new connections causes problems on pi2. Instead create a new connection when an old connection has already been made. Running a stress test of 600 times and they all passed. Fixes: https://github.com/nodejs/node/issues/5302 PR-URL: https://github.com/nodejs/node/pull/5537 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: Alexis Campailla --- test/parallel/parallel.status | 1 - test/parallel/test-process-getactivehandles.js | 17 ++++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 213e962683a..fb3d39e9f40 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -10,7 +10,6 @@ prefix parallel test-tick-processor : PASS,FLAKY [$system==linux] -test-process-getactivehandles : PASS,FLAKY test-tick-processor : PASS,FLAKY [$system==macos] diff --git a/test/parallel/test-process-getactivehandles.js b/test/parallel/test-process-getactivehandles.js index 96464cf3b22..e257439f7ba 100644 --- a/test/parallel/test-process-getactivehandles.js +++ b/test/parallel/test-process-getactivehandles.js @@ -10,13 +10,16 @@ var clients_counter = 0; const server = net.createServer(function listener(c) { connections.push(c); -}).listen(common.PORT, function makeConnections() { - for (var i = 0; i < NUM; i++) { - net.connect(common.PORT, function connected() { - clientConnected(this); - }); - } -}); +}).listen(common.PORT, makeConnection); + + +function makeConnection() { + if (clients_counter >= NUM) return; + net.connect(common.PORT, function connected() { + clientConnected(this); + makeConnection(); + }); +} function clientConnected(client) {