Skip to content

Commit

Permalink
More robust testrunner validation retry logic (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
andmat900 authored Oct 3, 2024
1 parent e8fb22d commit 0904d92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 4 additions & 2 deletions python/src/etos_api/library/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ async def authorize(
else:
query[key] = value.strip('"')

if not url:
raise ValueError(f"No realm found in www-authenticate header: {www_auth_header}")
if not isinstance(url, str) or not (
url.startswith("http://") or url.startswith("https://")
):
raise ValueError(f"No realm URL found in www-authenticate header: {www_auth_header}")

async with session.get(url, params=query) as response:
response.raise_for_status()
Expand Down
22 changes: 11 additions & 11 deletions python/src/etos_api/library/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"""ETOS API suite validator module."""
import logging
import asyncio
import random
from typing import List, Union
from uuid import UUID

Expand Down Expand Up @@ -198,18 +197,19 @@ async def validate(self, test_suite_url):
test_runners.add(constraint.value)
docker = Docker()
for test_runner in test_runners:
for attempt in range(3):
for attempt in range(5):
if attempt > 0:
span.add_event(f"Test runner validation unsuccessful, retry #{attempt}")
self.logger.warning(
"Test runner %s validation unsuccessful, retry #%d",
test_runner,
attempt,
)
result = await docker.digest(test_runner)
if result:
break
span.add_event(
f"Test runner validation unsuccessful, retrying {3 - attempt} more times"
)
self.logger.warning(
"Test runner %s validation unsuccessful, retrying %d more times",
test_runner,
3 - attempt,
)
await asyncio.sleep(random.randint(1, 3))
# Total wait time with 5 attempts: 55 seconds
sleep_time = (attempt + 1) ** 2
await asyncio.sleep(sleep_time)

assert result is not None, f"Test runner {test_runner} not found"

0 comments on commit 0904d92

Please sign in to comment.