-
Notifications
You must be signed in to change notification settings - Fork 537
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
feat(spanner): add admin instance wrapper #16080
feat(spanner): add admin instance wrapper #16080
Conversation
@bajajneha27 Can you please fix the tests before we can review this PR? Thanks. |
Yeah, I'm working on it. I'll update once done. Thanks. |
Hi @hengfengli , does emulator support update instance request? I'm getting the following error here:
|
No I don't think it supports that. You have to skip the test just for the emulator. |
Gapic::ServiceStub.stub :new, :stub do | ||
client = Google::Cloud::Spanner::Admin::Instance.instance_admin project_id: "1234" | ||
assert_kind_of Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client, client | ||
assert_equal emulator_host, client.configure.endpoint |
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.
In #13456, I was also trying to assert if the credentials are :this_channel_is_insecure
. But I couldn't get it working. Would you be able to figure out how to get it working?
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.
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.
@bajajneha27 @skuruppu Unfortunately the actual GRPC::Core::Channel
object does not expose the provided credentials
, afaik. However, you can use stub
to intercept and test the arguments provided to GRPC::Core::Channel#new
. I will provide a GH suggestion.
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.
See suggested change, above.
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.
Thank you @quartzmo
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.
LGTM.
327ad09
to
06f9a16
Compare
require "gapic/grpc" | ||
|
||
class Google::Cloud::Spanner::AdminInstanceClientConstructionMinitest < Minitest::Test | ||
def test_instance_admin |
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.
def test_instance_admin | |
def test_instance_admin | |
emulator_host = "localhost:4567" | |
channel_args = { "grpc.service_config_disable_resolution" => 1 } | |
channel_creds = :this_channel_is_insecure | |
channel = GRPC::Core::Channel.new emulator_host, channel_args, channel_creds | |
emulator_check = ->(name) { (name == "SPANNER_EMULATOR_HOST") ? emulator_host : nil } | |
channel_check = ->(chan_host, chan_args, chan_creds) do | |
assert_equal emulator_host, chan_host | |
assert_equal channel_args, chan_args | |
assert_equal channel_creds, chan_creds | |
channel | |
end | |
# Clear all environment variables, except SPANNER_EMULATOR_HOST | |
ENV.stub :[], emulator_check do | |
Gapic::ServiceStub.stub :new, :stub do | |
GRPC::Core::Channel.stub :new, channel_check do | |
client = Google::Cloud::Spanner::Admin::Instance.instance_admin project_id: "1234" | |
assert_kind_of Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client, client | |
assert_equal emulator_host, client.configure.endpoint | |
end | |
end | |
end | |
end |
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.
LGTM. I added a suggested change in response to @skuruppu's comment on client_test.rb:30
.
06f9a16
to
e659113
Compare
🤖 I have created a release \*beep\* \*boop\* --- ### 2.11.0 / 2021-12-10 #### Features * add admin instance wrapper ([#16080](https://www.github.com/googleapis/google-cloud-ruby/issues/16080)) * Updated benchwrapper and proto for spanner. ([#16152](https://www.github.com/googleapis/google-cloud-ruby/issues/16152)) * use gRPC clients for instance/database management ([#13157](https://www.github.com/googleapis/google-cloud-ruby/issues/13157)) * wrapper to create generated admin database client. ([#13456](https://www.github.com/googleapis/google-cloud-ruby/issues/13456)) --- ### Commits since last release: * [feat(spanner): Updated benchwrapper and proto for spanner. (#16152)](c67d621) * [feat(spanner): use gRPC clients for instance/database management (#13157)](b6fdf2f) * [feat(spanner): add admin instance wrapper (#16080)](d26c9c9) * [feat(spanner): wrapper to create generated admin database client. (#13456)](24bf835) ### Files edited since last release: <pre><code>google-cloud-spanner/benchmark/benchwrapper/benchwrapper.rb google-cloud-spanner/benchmark/benchwrapper/spanner.proto google-cloud-spanner/benchmark/benchwrapper/spanner_pb.rb google-cloud-spanner/benchmark/benchwrapper/spanner_services_pb.rb google-cloud-spanner/OVERVIEW.md google-cloud-spanner/README.md google-cloud-spanner/lib/google/cloud/spanner/backup.rb google-cloud-spanner/lib/google/cloud/spanner/backup/job.rb google-cloud-spanner/lib/google/cloud/spanner/backup/job/list.rb google-cloud-spanner/lib/google/cloud/spanner/backup/list.rb google-cloud-spanner/lib/google/cloud/spanner/backup/restore/job.rb google-cloud-spanner/lib/google/cloud/spanner/database.rb google-cloud-spanner/lib/google/cloud/spanner/database/backup_info.rb google-cloud-spanner/lib/google/cloud/spanner/database/job.rb google-cloud-spanner/lib/google/cloud/spanner/database/job/list.rb google-cloud-spanner/lib/google/cloud/spanner/database/list.rb google-cloud-spanner/lib/google/cloud/spanner/database/restore_info.rb google-cloud-spanner/lib/google/cloud/spanner/instance.rb google-cloud-spanner/lib/google/cloud/spanner/instance/config.rb google-cloud-spanner/lib/google/cloud/spanner/instance/config/list.rb google-cloud-spanner/lib/google/cloud/spanner/instance/job.rb google-cloud-spanner/lib/google/cloud/spanner/instance/list.rb google-cloud-spanner/lib/google/cloud/spanner/project.rb google-cloud-spanner/acceptance/instance_client_test.rb google-cloud-spanner/lib/google/cloud/spanner/admin/instance.rb google-cloud-spanner/test/google/cloud/spanner/admin/instance/client_config_test.rb google-cloud-spanner/test/google/cloud/spanner/admin/instance/client_test.rb google-cloud-spanner/acceptance/spanner/database_client_test.rb google-cloud-spanner/lib/google/cloud/spanner/admin/database.rb google-cloud-spanner/test/google/cloud/spanner/admin/database/client_config_test.rb google-cloud-spanner/test/google/cloud/spanner/database/client_test.rb </code></pre> [Compare Changes](8b1d497...HEAD) This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
bundle exec rake ci
in the gem subdirectory.