File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments