File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,10 @@ def test_status(self):
2626 """/_status should return 200 if proxy can reach to the backend"""
2727 response = ImmunisationApi .make_request_with_backoff (http_method = "GET" ,
2828 url = f"{ self .proxy_url } /_status" ,
29- headers = {"apikey" : self .status_api_key })
30- print ( f"Calling { self . proxy_url } /_status with api key: { self . status_api_key } " )
29+ headers = {"apikey" : self .status_api_key },
30+ is_status_check = True )
3131 self .assertEqual (response .status_code , 200 , response .text )
3232 body = response .json ()
33- print (f"Status code { response .status_code } { body ['status' ]} " )
3433
3534 self .assertEqual (body ["status" ].lower (), "pass" ,
3635 f"service is not healthy: status: { body ['status' ]} " )
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ def make_request_with_backoff(
5656 expected_connection_failure : bool = False ,
5757 max_retries : int = 5 ,
5858 delay_seconds : float = 2.0 ,
59+ is_status_check : bool = False ,
5960 ** kwargs
6061 ):
6162 for attempt in range (max_retries ):
@@ -71,6 +72,13 @@ def make_request_with_backoff(
7172 f"URL: { url } "
7273 )
7374
75+ # Sometimes it can take time for the new endpoint to activate
76+ if is_status_check :
77+ body = response .json ()
78+ if body ["status" ].lower () != "pass" :
79+ raise RuntimeError (f"Server status check at { url } returned status code { response .status_code } , "
80+ f"but status is: { body ['status' ]} " )
81+
7482 # Check if the response matches the expected status code to identify potential issues
7583 if response .status_code != expected_status_code :
7684 if response .status_code >= 500 :
You can’t perform that action at this time.
0 commit comments