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: samples and tests for auto-generated createDatabase and createInstance APIs. #2764

Merged
merged 26 commits into from
Jan 3, 2024

Conversation

arpan14
Copy link
Contributor

@arpan14 arpan14 commented Dec 21, 2023

Notes

  • Adds samples and tests for auto-generated createDatabase and createInstance APIs.
  • The sample code style is mostly consistent with our existing samples.
  • A new file path has been intentionally introduced so that the samples don't get updated immediately on public documentation - https://cloud.google.com/spanner/docs/create-manage-databases.
  • PR also adds some utility methods to manage instance creation/deletion for integration tests.

@arpan14 arpan14 requested review from a team as code owners December 21, 2023 11:03
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: spanner Issues related to the googleapis/java-spanner API. samples Issues that are directly related to samples. labels Dec 21, 2023
@arpan14 arpan14 requested a review from olavloite December 21, 2023 11:13
@arpan14 arpan14 requested a review from blakeli0 December 21, 2023 15:40
* limitations under the License.
*/

package com.example.spanner.v2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that it is going to be confusing if we use .v2 as a package name for these samples, as the actual change is that the code will start using classes that are in a package called .v1, while they before that used classes that were in packages without a version number.

Or could we temporarily use this .v2 package, and when we make the switch, move these samples into com.example.spanner and the old samples into com.example.spanner.deprecated or something like that?

Copy link
Contributor Author

@arpan14 arpan14 Dec 26, 2023

Choose a reason for hiding this comment

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

Yeah as you described, I plan to use this path temporarily. Also instead of calling it .v2, I changed it to .admin.generated. Instead of calling the new path deprecated we can name it archived. So, the new samples will be moved into com.example.spanner and the old samples into com.example.spanner.archived

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@blakeli0 blakeli0 requested a review from lqiu96 December 21, 2023 17:47
Copy link

snippet-bot bot commented Dec 23, 2023

Here is the summary of changes.

You are about to add 2 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@lqiu96
Copy link
Contributor

lqiu96 commented Dec 26, 2023

I think it looks good from my end. One last thing came to mind when looking at the samples (which may or may not be a concern for Spanner). In google-cloud-java, we had some issues with creating instances for certain services. The project were running the code in had some quotas and the tests/samples had some issues properly deleting the created instances. We just ended up prefixing the resources with something like it-test-compute (https://github.com/googleapis/google-cloud-java/blob/d0c836e0b6580ca2b5d9fe6a19d8be5da9496c1f/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/BaseTest.java#L25) and deleting the stale instances prior to the tests being run: https://github.com/googleapis/google-cloud-java/blob/main/java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/Util.java

@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 1, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 1, 2024
// TODO(developer): Replace these variables before running the sample.
final String instanceName = "projects/my-project/instances/my-instance-id";
final String databaseId = "my-database-name";
final String defaultLeader = "my-default-leader";
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Could we use a default leader name here that is more similar to the actual value that a user would have to use. That might help users who don't know what the default leader option is, to understand and learn that.

}

databaseAdminClient.close();
instanceAdminClient.close();
Copy link
Collaborator

Choose a reason for hiding this comment

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

The generated (admin) clients have both a close() and a shutdown() method. Do they do the same (or put another way: Does close() actually shutdown the client)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. @lqiu96 Would you have a quick answer for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe they're pretty much the same. Closing the client will close the underlying stub which closes all the BackgroundResources associated with the client. These are resources like channels, watchdog service, executors, etc.

The underlying implementation for the close() is to call shutdown() and I believe close() was originally offered as a way to utilize the client in try-with-resources

@arpan14 arpan14 merged commit 74a586f into googleapis:main Jan 3, 2024
24 checks passed
@arpan14 arpan14 deleted the auto-gen-admin-client branch January 3, 2024 17:52
gcf-merge-on-green bot pushed a commit that referenced this pull request Jan 5, 2024
🤖 I have created a release *beep* *boop*
---


## [6.56.0](https://togithub.com/googleapis/java-spanner/compare/v6.55.0...v6.56.0) (2024-01-05)


### Features

* Add autoscaling config in the instance to support autoscaling in systests ([#2756](https://togithub.com/googleapis/java-spanner/issues/2756)) ([99ae565](https://togithub.com/googleapis/java-spanner/commit/99ae565c5e90a2862b4f195fe64656ba8a05373d))
* Add support for Directed Read options ([#2766](https://togithub.com/googleapis/java-spanner/issues/2766)) ([26c6c63](https://togithub.com/googleapis/java-spanner/commit/26c6c634b685bce66ce7caf05057a98e9cc6f5dc))
* Update OwlBot.yaml file to pull autogenerated executor code ([#2754](https://togithub.com/googleapis/java-spanner/issues/2754)) ([20562d4](https://togithub.com/googleapis/java-spanner/commit/20562d4d7e62ab20bb1c4e78547b218a9a506f21))


### Dependencies

* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.21.0 ([#2772](https://togithub.com/googleapis/java-spanner/issues/2772)) ([173f520](https://togithub.com/googleapis/java-spanner/commit/173f520f931073c4c6ddf3b3d98d255fb575914f))


### Documentation

* Samples and tests for auto-generated createDatabase and createInstance APIs. ([#2764](https://togithub.com/googleapis/java-spanner/issues/2764)) ([74a586f](https://togithub.com/googleapis/java-spanner/commit/74a586f8713ef742d65400da8f04a750316faf78))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
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: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants