Attempt to make itest spoolman up check more robust

This commit is contained in:
Donkie
2024-08-07 15:12:42 +02:00
parent efa93615ec
commit 515722bf4f

View File

@@ -37,17 +37,19 @@ def get_db_type() -> DbType:
return db_type return db_type
@pytest.fixture(scope="session", autouse=True) def pytest_sessionstart(_: pytest.Session) -> None:
def _wait_for_server(): # noqa: ANN202
"""Wait for the server to start up.""" """Wait for the server to start up."""
start_time = time.time() start_time = time.time()
while True: while True:
try: try:
print("pytest: Waiting for spoolman to be available...") # noqa: T201
response = httpx.get(URL, timeout=1) response = httpx.get(URL, timeout=1)
response.raise_for_status() response.raise_for_status()
print("pytest: Spoolman now seems to be up!") # noqa: T201
except httpx.HTTPError: # noqa: PERF203 except httpx.HTTPError: # noqa: PERF203
if time.time() - start_time > TIMEOUT: if time.time() - start_time > TIMEOUT:
raise raise
time.sleep(0.5)
else: else:
break break