File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 44
55import os
66import pytest
7+ import psutil
8+ import gevent
79from gevent import Greenlet
810
911from raiden .app import App
1416from raiden .tests .utils .apitestcontext import ApiTestContext
1517
1618
19+ def wait_for_listening_port (port_number , tries = 10 , sleep = 0.1 ):
20+ for _ in range (tries ):
21+ gevent .sleep (sleep )
22+ connections = psutil .net_connections ()
23+ for conn in connections :
24+ if conn .status == 'LISTEN' and conn .laddr [1 ] == port_number :
25+ return
26+
27+ raise RuntimeError ('{port} is not bound' .format (port_number ))
28+
29+
1730# TODO: Figure out why this fixture can't work as session scoped
1831# What happens is that after one test is done, in the next one
1932# the server is no longer running even though the teardown has not
@@ -34,6 +47,11 @@ def api_backend(rest_api_port_number):
3447 use_evalex = False ,
3548 )
3649
50+ # Fixes flaky test, were requests are done prior to the server initializing
51+ # the listening socket.
52+ # https://github.com/raiden-network/raiden/issues/389#issuecomment-305551563
53+ wait_for_listening_port (rest_api_port_number )
54+
3755 yield api_server , rest_api
3856
3957 server .kill (block = True , timeout = 10 )
You can’t perform that action at this time.
0 commit comments