Skip to content

Commit

Permalink
tests: Handle URL cache response timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
spbnick committed Feb 9, 2024
1 parent 284799f commit 45e7da8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@ def check_url_in_cache(url):
"""Check whether the URL is sourced from storage or not."""
url_encoded = quote(url)
cache_redirector_url = os.environ["KCIDB_CACHE_REDIRECTOR_URL"]
response = requests.get(
f"{cache_redirector_url}?{url_encoded}",
timeout=10, # Time in secs
allow_redirects=False
)
try:
response = requests.get(
f"{cache_redirector_url}?{url_encoded}",
timeout=10, # Time in secs
allow_redirects=False
)
except requests.exceptions.Timeout:
return False
if response.status_code == 302:
# Check if the redirect URL matches the blob storage URL pattern
if (
Expand Down

0 comments on commit 45e7da8

Please sign in to comment.