Skip to content

Commit

Permalink
Attempt to fix timing out tests.
Browse files Browse the repository at this point in the history
Continuation of work started by @nsoranzo here 92a152d. In addition to increasing the max timeout it will now print the timeout in the assertion error so we can see if it is being overridden and attempt to adjust timeouts too small.
  • Loading branch information
jmchilton committed Nov 11, 2015
1 parent 6953bdf commit e4c9f06
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/api/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def _create_collection( self, payload ):
return create_response


def wait_on_state( state_func, assert_ok=False, timeout=5 ):
def wait_on_state( state_func, assert_ok=False, timeout=DEFAULT_TIMEOUT ):
def get_state( ):
response = state_func()
assert response.status_code == 200, "Failed to fetch state update while waiting."
Expand All @@ -454,12 +454,16 @@ def get_state( ):
return wait_on( get_state, desc="state", timeout=timeout)


def wait_on( function, desc, timeout=5 ):
def wait_on( function, desc, timeout=DEFAULT_TIMEOUT ):
delta = .25
iteration = 0
while True:
if (delta * iteration) > timeout:
assert False, "Timed out waiting on %s." % desc
total_wait = delta * iteration
if total_wait > timeout:
timeout_message = "Timed out after %s seconds waiting on %s." % (
total_wait, desc
)
assert False, timeout_message
iteration += 1
value = function()
if value is not None:
Expand Down

0 comments on commit e4c9f06

Please sign in to comment.