test: a short R2 failure while closing an upload: the server's steady retry and the browser's (contract contrato-r2-retry)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 8m2s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m12s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 8m2s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m12s
tests/test_storage_steady.py covers steady() and the storage's parts, size and complete (a 5xx retried after 1, 2, 3 s; a 4xx and other errors at once; NoSuchUpload on an object that exists is done). tests/upload_retry_test.mjs covers closing the upload in web/upload.js (again after 3 s and 6 s; only the last attempt reported; a 409 at once; an abort gives the upload back). Both fail with the retry turned off. steady now looks time.sleep up when it waits, so a patch of it reaches the storage methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -254,15 +254,16 @@ def server_error(exc):
|
||||
return (exc.response.get('ResponseMetadata', {}).get('HTTPStatusCode') or 0) >= 500
|
||||
|
||||
|
||||
def steady(call, sleep=time.sleep):
|
||||
"""`call()`, again after each wait in STEADY_WAITS while storage answers 5xx."""
|
||||
def steady(call, sleep=None):
|
||||
"""`call()`, again after each wait in STEADY_WAITS while storage answers 5xx.
|
||||
`sleep` is time.sleep, looked up when it waits (tests patch it)."""
|
||||
for wait in STEADY_WAITS + (None,):
|
||||
try:
|
||||
return call()
|
||||
except ClientError as exc:
|
||||
if wait is None or not server_error(exc):
|
||||
raise
|
||||
sleep(wait)
|
||||
(sleep or time.sleep)(wait)
|
||||
|
||||
|
||||
class LocalS3Storage:
|
||||
|
||||
Reference in New Issue
Block a user