Another possible approach for connection check
This commit is contained in:
parent
d9d1cdb5d8
commit
e9073d736a
|
@ -167,7 +167,7 @@ class TestCore(unittest.TestCase):
|
||||||
def _check_connection(self):
|
def _check_connection(self):
|
||||||
"""
|
"""
|
||||||
Check if there is at least one outbound connection to remote host
|
Check if there is at least one outbound connection to remote host
|
||||||
with name not starting with "bootstrap" in 3 minutes,
|
with name not starting with "bootstrap" in 6 minutes at most,
|
||||||
fail otherwise.
|
fail otherwise.
|
||||||
"""
|
"""
|
||||||
_started = time.time()
|
_started = time.time()
|
||||||
|
@ -180,10 +180,19 @@ class TestCore(unittest.TestCase):
|
||||||
connection_base = Socks4aBMConnection
|
connection_base = Socks4aBMConnection
|
||||||
else:
|
else:
|
||||||
connection_base = TCPConnection
|
connection_base = TCPConnection
|
||||||
for _ in range(180):
|
c = 360
|
||||||
|
while c > 0:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
c -= 2
|
||||||
for peer, con in BMConnectionPool().outboundConnections.iteritems():
|
for peer, con in BMConnectionPool().outboundConnections.iteritems():
|
||||||
if not peer.host.startswith('bootstrap'):
|
if peer.host.startswith('bootstrap'):
|
||||||
|
if c < 60:
|
||||||
|
self.fail(
|
||||||
|
'Still connected to bootstrap node %s after % seconds' %
|
||||||
|
(peer, time.time() - _started))
|
||||||
|
c += 1
|
||||||
|
break
|
||||||
|
else:
|
||||||
self.assertIsInstance(con, connection_base)
|
self.assertIsInstance(con, connection_base)
|
||||||
self.assertNotEqual(peer.host, '127.0.0.1')
|
self.assertNotEqual(peer.host, '127.0.0.1')
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user