shlist

share and manage lists between multiple people
Log | Files | Refs

commit 5a3a3a1c32e852b743ff1b544a37efae1a1c399f
parent f99ba396105eb2790b3d4ff87df1721e0e086337
Author: kyle <kyle@0x30.net>
Date:   Sun, 27 Dec 2015 18:16:59 -0700

tests: try and de-confuse test reconnect loop

- each test tries to connect to the test server for 5 seconds
- keep trying to connect if we get ECONNREFUSED
  - bail otherwise

Diffstat:
Mtests/test.pm | 21+++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/tests/test.pm b/tests/test.pm @@ -26,8 +26,8 @@ sub new_socket } my $sock = undef; - my $i = 0; - while (! $sock) { + my $timeout = time + 5; + while (1) { $sock = new IO::Socket::SSL->new( PeerHost => 'localhost', PeerPort => $ENV{PORT}, @@ -37,13 +37,18 @@ sub new_socket ); if ($!{ECONNREFUSED}) { - # print "$i: connection refused, retrying\n"; - $i++; - usleep(50 * 1000); - } - else { - die "error=$!, ssl_error=$SSL_ERROR\n" unless $sock; + if (time > $timeout) { + fail "server not ready after 5 seconds"; + } + usleep(100 * 1000); + next; } + + last; + } + + unless ($sock) { + die "failed connect or ssl handshake: $!,$SSL_ERROR"; } return $sock;