Skip to content

Commit 48e567b

Browse files
authored
fix: more HTTP request retries (GoogleCloudPlatform#10140)
* fix: more HTTP request retries * fix: missed return value
1 parent 2968348 commit 48e567b

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

  • appengine/standard_python3/bundled-services/mail/django

appengine/standard_python3/bundled-services/mail/django/main_test.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ def gcloud_cli(command):
5656
raise Exception(output.stderr)
5757

5858

59+
@backoff.on_exception(backoff.expo, requests.exceptions.HTTPError, max_tries=6)
60+
def get_with_retries(url):
61+
r = requests.get(url)
62+
r.raise_for_status()
63+
return r
64+
65+
66+
@backoff.on_exception(backoff.expo, requests.exceptions.HTTPError, max_tries=6)
67+
def post_with_retries(url, data):
68+
r = requests.post(url, data=data)
69+
r.raise_for_status()
70+
return r
71+
72+
5973
@pytest.fixture
6074
def version():
6175
"""Launch a new version of the app for testing, and yield the
@@ -68,12 +82,7 @@ def version():
6882
version_hostname = f"{version_id}-dot-{project_id}.appspot.com"
6983

7084
# Wait for app to initialize
71-
@backoff.on_exception(backoff.expo, requests.exceptions.HTTPError, max_tries=3)
72-
def wait_for_app(url):
73-
r = requests.get(url)
74-
r.raise_for_status()
75-
76-
wait_for_app(f"https://{version_hostname}/")
85+
get_with_retries(f"https://{version_hostname}/")
7786

7887
yield project_id, version_id
7988

@@ -85,12 +94,12 @@ def test_send_receive(version):
8594
version_hostname = f"{version_id}-dot-{project_id}.appspot.com"
8695

8796
# Check that version is serving form in home page
88-
response = requests.get(f"https://{version_hostname}/")
97+
response = get_with_retries(f"https://{version_hostname}/")
8998
assert '<form action="" method="POST">' in response.text
9099
assert response.status_code == 200
91100

92101
# Send valid mail
93-
response = requests.post(
102+
response = post_with_retries(
94103
f"https://{version_hostname}/",
95104
data={
96105
"email": f"valid-user@{version_id}-dot-{project_id}.appspotmail.com",

0 commit comments

Comments
 (0)