Skip to content

Commit

Permalink
fix sleep time for request attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
cwcummings committed Nov 20, 2023
1 parent d0b40e6 commit 936c1b1
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ def create_magpie_user(user_name, password, session):
# Make sure Cowbird is running before creating user
resp = None
for i in range(MAX_ATTEMPTS):
time.sleep(i * TIMEOUT_DELAY)
try:
resp = requests.get(COWBIRD_URL, verify=VERIFY_SSL)
assert resp.status_code == 200
print("Cowbird availability checked successfully.")
break
except Exception as exc:
print(f"Failed to connect to Cowbird [{exc}]. \nAttempting again ({i + 1})...")
time.sleep((i + 1) * TIMEOUT_DELAY)
else:
raise ConnectionError("Failed to connect to Cowbird on url {}".format(COWBIRD_URL))

Expand All @@ -117,11 +117,11 @@ def create_magpie_user(user_name, password, session):

# Make sure cowbird had time to create user workspace before executing following operations
for i in range(MAX_ATTEMPTS):
time.sleep(i * TIMEOUT_DELAY)
if os.path.exists(user_workspace_dir):
print(f"User workspace successfully found at path `{user_workspace_dir}`.")
break
print(f"Failed to find user workspace at path [{user_workspace_dir}]. Attempting again ({i + 1})...")
time.sleep((i + 1) * TIMEOUT_DELAY)
else:
raise ConnectionError("Failed to create user workspace to Cowbird on url {}".format(COWBIRD_URL))

Expand Down Expand Up @@ -149,13 +149,13 @@ def create_magpie_user(user_name, password, session):
# Check user permissions on WPS outputs user data
resp = None
for i in range(MAX_ATTEMPTS):
time.sleep(i * TIMEOUT_DELAY)
try:
resp = magpie_admin_session.get(f"{MAGPIE_URL}/services/secure-data-proxy")
break
except Exception as exc:
print(f"Exception received when attempting to check for the `secure-data-proxy` service : \n{repr(exc)}\n"
f"Attempting to refresh admin login and to access `secure-data-proxy` again ({i + 1})...")
time.sleep((i + 1) * TIMEOUT_DELAY)
# Make sure admin cookies are still valid
magpie_admin_session.cookies = magpie_signin(TEST_MAGPIE_ADMIN_USERNAME, TEST_MAGPIE_ADMIN_PASSWORD).cookies
else:
Expand Down Expand Up @@ -193,11 +193,11 @@ def create_magpie_user(user_name, password, session):
# Make sure cowbird has created the user WPS outputs hardlink successfuly before continuing with the tests.
expected_user_wps_outputs_hardlink = f"{user_workspace_dir}/wps_outputs/weaver/test_user_file.txt"
for i in range(MAX_ATTEMPTS):
time.sleep(i * TIMEOUT_DELAY)
if os.path.exists(expected_user_wps_outputs_hardlink):
print(f"User WPS outputs hardlink successfully found at path `{expected_user_wps_outputs_hardlink}`.")
break
print(f"Failed to find user hardlink at path [{expected_user_wps_outputs_hardlink}]. Attempting again ({i + 1})...")
time.sleep((i + 1) * TIMEOUT_DELAY)
else:
raise RuntimeError(f"Failed to create `{expected_user_wps_outputs_hardlink}` hardlink in the user workspace.")

Expand Down

0 comments on commit 936c1b1

Please sign in to comment.