Make inspection timeout a bit more forgiving.
There are several steps we must wait for that happen on a asynchronous basis on the backend of cloudigrade in integrade/tests/api/v1/test_discovery_and_inspection.py.
Right now, we get spurious failures because we just have hard coded timeouts for each step.
One idea to be a bit more forgiving and allow just one test-level timeout.
Perhaps it could be an object that can hold the time left remaining for the whole tests, and this object gets passed around in the function.
example:
import time
import pytest
class Waiter(object):
def __init__(self, whole_test_timeout=10):
self.timeout = whole_test_timeout
def time_left_after_sleep(self, sleep_time=1):
time.sleep(sleep_time)
self.timeout -= sleep_time
if self.timeout < 0:
return False
return True
def test_foo():
"""Foo."""
foo_waiter = Waiter()
for i in range(5):
if foo_waiter.time_left_after_sleep():
# do stuff
print("Lots of things to do")
else:
raise TimeoutError()