Skip to content
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

docs: improve timeout and retry sample #2630

Merged
merged 4 commits into from Sep 28, 2023
Merged

Conversation

olavloite
Copy link
Collaborator

The timeout and retry sample used 60 seconds for both initial, max, and total timeout. It also used a 1.0 multiplier for the timeout value. This made it impossible to explain how to set an increasing RPC timeout value. It also rendered adding the DEADLINE_EXCEEDED error code as a retryable code superfluous.

The timeout and retry sample used 60 seconds for both initial,
max, and total timeout. It also used a 1.0 multiplier for the
timeout value. This made it impossible to explain how to set
an increasing RPC timeout value. It also rendered adding the
DEADLINE_EXCEEDED error code as a retryable code superfluous.
@olavloite olavloite requested a review from a team as a code owner September 17, 2023 08:38
@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. api: spanner Issues related to the googleapis/java-spanner API. samples Issues that are directly related to samples. labels Sep 17, 2023
@gcf-owl-bot gcf-owl-bot bot requested a review from a team as a code owner September 17, 2023 08:40
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Sep 17, 2023
@olavloite olavloite marked this pull request as draft September 17, 2023 08:50
@olavloite olavloite marked this pull request as ready for review September 25, 2023 08:20
@olavloite olavloite added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2023
@@ -3419,6 +3419,48 @@ public void testRetryOnResourceExhausted() {
}
}

@Test
public void testSampleRetrySettings() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we carve it into a separate test class similar to what we do for most other samples code? It improves the discoverability of the test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally only do that for the integration tests that actually execute the sample code. See for example https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/test/java/com/example/spanner/DmlReturningSampleIT.java. This test does not run the actual sample code, as we don't have any infrastructure in place for running the samples against an in-mem mock server. Instead, it only verifies that not setting DEADLINE_EXCEEDED as one of the retryable codes will cause the operation to fail with DEADLINE_EXCEEDED.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Consider adding the new test in a separate class. google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java is already overloaded for testing too many things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the sample test to a separate class (and created an abstract base class for creating mock server tests, so it's easier to set up more of those test classes).

@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Sep 25, 2023
@olavloite olavloite merged commit f03ce56 into main Sep 28, 2023
24 checks passed
@olavloite olavloite deleted the improve-timeout-sample branch September 28, 2023 06:21
surbhigarg92 pushed a commit to surbhigarg92/java-spanner that referenced this pull request Oct 5, 2023
* docs: improve timeout and retry sample

The timeout and retry sample used 60 seconds for both initial,
max, and total timeout. It also used a 1.0 multiplier for the
timeout value. This made it impossible to explain how to set
an increasing RPC timeout value. It also rendered adding the
DEADLINE_EXCEEDED error code as a retryable code superfluous.

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore: update timeout values based on what is possible with other languages

* test: move sample test to separate class

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. samples Issues that are directly related to samples. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants