-
Notifications
You must be signed in to change notification settings - Fork 64
Retry integration tests on transient service errors #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ppolewicz
wants to merge
5
commits into
master
Choose a base branch
from
ppolewicz/verify-503-integration-retry
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
250f86b
Retry integration tests on transient service errors
ppolewicz 9db5f07
Exercise raw upload retries in integration CI
ppolewicz 84bcfe0
Increase integration retry budget for transient service errors
ppolewicz 2ec8bc2
Reduce fail_some_uploads integration load
ppolewicz 8a1001a
Retry integration tests on too many requests
ppolewicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Retry integration tests automatically when they fail because of a transient HTTP 503 from B2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,44 @@ | |
| # License https://www.backblaze.com/using_b2_code.html | ||
| # | ||
| ###################################################################### | ||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| from b2sdk._internal.exception import ServiceError, TooManyRequests | ||
|
|
||
| RETRYABLE_SERVICE_ERROR_STATUSES = {500, 503} | ||
| INTEGRATION_TEST_RETRY_COUNT = 4 | ||
|
|
||
|
|
||
| @pytest.fixture(scope='session', autouse=True) | ||
| def auto_change_account_info_dir(change_account_info_dir): | ||
| pass | ||
|
|
||
|
|
||
| @pytest.hookimpl(tryfirst=True) | ||
| def pytest_pyfunc_call(pyfuncitem): | ||
| testfunction = pyfuncitem.obj | ||
| funcargs = pyfuncitem.funcargs | ||
| testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames} | ||
|
|
||
| for attempt in range(INTEGRATION_TEST_RETRY_COUNT + 1): | ||
| try: | ||
| testfunction(**testargs) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no async tests but if there ever were in the future, they would never be awaited and unless the test runner sees the runtime warning, they'd never know -> they'd appear to always pass. It might be worth checking that |
||
| return True | ||
| except ServiceError as exc: | ||
| if exc._status not in RETRYABLE_SERVICE_ERROR_STATUSES: | ||
| raise | ||
| if attempt >= INTEGRATION_TEST_RETRY_COUNT: | ||
| raise | ||
| print( | ||
| f'Retrying {pyfuncitem.nodeid} after transient service error {exc._status}:' | ||
| f' attempt {attempt + 1} of {INTEGRATION_TEST_RETRY_COUNT}' | ||
| ) | ||
| except TooManyRequests: | ||
| if attempt >= INTEGRATION_TEST_RETRY_COUNT: | ||
| raise | ||
| print( | ||
| f'Retrying {pyfuncitem.nodeid} after transient too many requests:' | ||
| f' attempt {attempt + 1} of {INTEGRATION_TEST_RETRY_COUNT}' | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are retried on 500 errors but the bucket operations in
_retry_bucket_test_operation()only on 503.a) Is nested retry logic necessary for a test?
b) If so, shouldn't the BucketManager also retry on 500 errors then?