-
Notifications
You must be signed in to change notification settings - Fork 322
fix: honor custom retry in job.result()
#2302
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
79c44bc
fix(job): honor custom retry in job.result()
google-labs-jules[bot] d9cc9f8
Update tests/unit/test_job_retry.py
chalmerlowe 5476f02
Update tests/unit/test_job_retry.py
chalmerlowe 71e31b3
blacken and lint
chalmerlowe 0114337
Merge branch 'main' into fix-job-result-retry
chalmerlowe 028f741
Merge branch 'main' into fix-job-result-retry
chalmerlowe e0b9ec7
udpates retry handling and testing of retry handling
chalmerlowe 0148336
Update tests/unit/test_job_retry.py
chalmerlowe 5b6012a
Update tests/unit/test_job_retry.py
chalmerlowe e8d5fb0
Update tests/unit/test_job_retry.py
chalmerlowe a3fbcf1
Merge branch 'main' into fix-job-result-retry
chalmerlowe 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
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.
This test seems to ensure that the rpc is being retried, but not that it's using the retry configuration that was actually passed in.
If a regression made it fall back to DEFAULT_RETRY in the handwritten layer, or even the default retry configured in the gapic layer like before, wouldn't the tests still pass? Or is that tested elsewhere?
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.
Spent some time thinking about this PR.
Began to doubt whether checking the
client._connection.api_request()(e.g.conn.api_request) method was the right way to go.Turns out, the
client._call_api()method wraps the call toclient._connection.api_request(). Theretryobject is used by_call_apito manage any needed retries, but theretryobject itself is NOT passed as a direct argument toclient._connection.api_request. Nor is it expected to be.Here's what we did:
client._call_api: we wrapped the originalclient._call_apiusingmock.patch.objectwithwraps=client._call_api. This lets the real_call_api(including theretrydecorator) execute, but we can still inspect the calls.retryargument: we added a loop throughwrapped_call_api.mock_callsto check theretryobject passed as the first argument to_call_api.called_retryobject match theexpected_retry(which is eitherDEFAULT_RETRYor the "custom retry" object). we've included a specific check for the_timeout == 10.0in the "custom retry" case.job.state,result.output_rows, andconn.api_request.call_countare still in place.