Skip to content

Commit 20f6613

Browse files
fix: wait longer for incoming mail (GoogleCloudPlatform#9052)
Co-authored-by: Karl Weinmeister <[email protected]>
1 parent 54b9cd6 commit 20f6613

File tree

1 file changed

+18
-13
lines changed
  • appengine/standard_python3/bundled-services/mail/wsgi

1 file changed

+18
-13
lines changed

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,24 @@ def test_send_receive(version):
101101
assert "Successfully sent mail" in response.text
102102
assert response.status_code == 201
103103

104-
# Give the mail some time to be delivered and logs to post
105-
time.sleep(60)
106-
107-
# Fetch logs to check messages on received mail
108-
entries = gcloud_cli(
109-
f'logging read "resource.type=gae_app AND resource.labels.version_id={version_id}"'
110-
)
111-
112-
text_payloads = ""
113-
for entry in entries:
114-
if "textPayload" in entry:
115-
text_payloads += entry["textPayload"]
116-
text_payloads += "\n"
104+
# External mail delivery and receipt can take varying lengths of time
105+
for check in range(3):
106+
# Give the mail some time to be delivered and logs to post
107+
time.sleep(60)
108+
109+
# Fetch logs to check messages on received mail
110+
entries = gcloud_cli(
111+
f'logging read "resource.type=gae_app AND resource.labels.version_id={version_id}"'
112+
)
113+
114+
text_payloads = ""
115+
for entry in entries:
116+
if "textPayload" in entry:
117+
text_payloads += entry["textPayload"]
118+
text_payloads += "\n"
119+
120+
if "Received" in text_payloads:
121+
break
117122

118123
expected = f"Received greeting for valid-user@{version_id}-dot-{project_id}.appspotmail.com"
119124
assert expected in text_payloads

0 commit comments

Comments
 (0)