Skip to content

Commit

Permalink
Merge pull request #744 from kbase/dev-fix_loop
Browse files Browse the repository at this point in the history
Fix loop
  • Loading branch information
Xiangs18 authored Jul 17, 2024
2 parents 0f6d151 + 0863a46 commit 53d4239
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions test/workspace_container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,48 @@ def ready():

def wait_for_auth():
print("waiting for auth service...")
for t in WAIT_TIMES:

attempt = 1
max_attempts = len(WAIT_TIMES) + 1
while attempt <= max_attempts:
print(f"Attempt {attempt} of {max_attempts}")
try:
res = requests.get(AUTH_URL)
res.raise_for_status()
return
except Exception as e:
print(f"Failed to connect to auth, waiting {t} sec and trying again:\n\t{e}")
time.sleep(t)
raise Exception(f"Couldn't connect to the auth after {len(WAIT_TIMES)} attempts")
if attempt < max_attempts:
t = WAIT_TIMES[attempt - 1]
print(
f"Failed to connect to auth, waiting {t} sec "
f"and trying again:\n\t{e}"
)
time.sleep(t)
attempt += 1
raise Exception(f"Couldn't connect to the auth after {max_attempts} attempts")


def wait_for_ws():
print("waiting for workspace service...")

attempt = 1
max_attempts = len(WAIT_TIMES) + 1
ws = Workspace(WS_URL)
for t in WAIT_TIMES:
while attempt <= max_attempts:
print(f"Attempt {attempt} of {max_attempts}")
try:
ws.ver()
return
except Exception as e:
print(f"Failed to connect to workspace, waiting {t} sec and trying again:\n\t{e}")
time.sleep(t)
raise Exception(f"Couldn't connect to the workspace after {len(WAIT_TIMES)} attempts")
if attempt < max_attempts:
t = WAIT_TIMES[attempt - 1]
print(
f"Failed to connect to workspace, waiting {t} sec "
f"and trying again:\n\t{e}"
)
time.sleep(t)
attempt += 1
raise Exception(f"Couldn't connect to the workspace after {max_attempts} attempts")


def test_create_user_create_workspace(ready):
Expand Down

0 comments on commit 53d4239

Please sign in to comment.