Skip to content

Commit 48a9a99

Browse files
author
Daniel Schlör
committed
docker
1 parent 9fd7c1c commit 48a9a99

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

tests/conftest.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,24 @@ def agent(request):
1515
"""Agent URL fixture. Agent must be running before tests start."""
1616
url = request.config.getoption("--agent-url")
1717

18-
try:
19-
response = httpx.get(f"{url}/.well-known/agent-card.json", timeout=2)
20-
if response.status_code != 200:
21-
pytest.exit(f"Agent at {url} returned status {response.status_code}", returncode=1)
22-
except Exception as e:
23-
pytest.exit(f"Could not connect to agent at {url}: {e}", returncode=1)
18+
# Try to connect with retries (agent might still be starting)
19+
max_retries = 10
20+
for attempt in range(max_retries):
21+
try:
22+
response = httpx.get(f"{url}/.well-known/agent-card.json", timeout=5)
23+
if response.status_code == 200:
24+
return url
25+
else:
26+
if attempt < max_retries - 1:
27+
import time
28+
time.sleep(2)
29+
continue
30+
pytest.exit(f"Agent at {url} returned status {response.status_code}", returncode=1)
31+
except Exception as e:
32+
if attempt < max_retries - 1:
33+
import time
34+
time.sleep(2)
35+
continue
36+
pytest.exit(f"Could not connect to agent at {url} after {max_retries} attempts: {e}", returncode=1)
2437

2538
return url

0 commit comments

Comments
 (0)