Skip to content

Commit

Permalink
clean up wait fn
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Loftus committed Dec 10, 2024
1 parent 0dfa259 commit d4db986
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:

# Run the Python script that handles the build and execution
- name: Launch Docker Stack and run tests
run: python3 main.py local && python3 main.py wait_for "https://localhost:9001/minio/health/live" && python3 main.py test
run: python3 main.py local && python3 main.py wait_for "http://localhost:9001/minio/health/live" && python3 main.py test
16 changes: 10 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,18 @@ def wait_for_response(url: str):
docker stack does not support conditional waits and the dockerfile logic
would be otherwise messy
"""
TIMEOUT_SEC = 30
while True and TIMEOUT_SEC > 0:
response = requests.get(url)
if response.status_code == 200:
print("Got 200 response from " + url)
TIMEOUT_SEC = 180
counter = 0
while True and counter < TIMEOUT_SEC:
try:
response = requests.get(url)
if response.status_code == 200:
print(f"Got 200 response from {url} after {counter} seconds")
return
except requests.exceptions.ConnectionError:
pass
time.sleep(1)
TIMEOUT_SEC -= 1
counter += 1
raise RuntimeError(
f"Timed out after {TIMEOUT_SEC} seconds waiting for response from " + url
)
Expand Down

0 comments on commit d4db986

Please sign in to comment.