-
Notifications
You must be signed in to change notification settings - Fork 1.1k
connecting to Bigtable emulator using environment variable #6067
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
Conversation
Now user can connect to Bigtable emulator in three ways: - By settings hostName:portNum in BIGTABLE_EMULATOR_HOST environment variable. - By providing only port number within the local workstation. - By providing hostName & port Number.
...gle-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java
Outdated
Show resolved
Hide resolved
igorbernstein2
left a comment
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.
A couple more things:
- please add a log statement notifying the user that the client is targeting the emulator.
- in the test rule please add a precondition preventing tests from running when the environment variable is set. The test environment should be controlled via maven profiles not environment variables and the mixture will just create confusion
- Please add a safe guard to the instance admin client that prevents its use when the env var is set (the emulator doesn't support instance admin api)
Thanks!
...ud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java
Outdated
Show resolved
Hide resolved
...gle-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java
Outdated
Show resolved
Hide resolved
...ud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java
Outdated
Show resolved
Hide resolved
...ud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #6067 +/- ##
============================================
+ Coverage 47.11% 47.38% +0.26%
+ Complexity 27195 27182 -13
============================================
Files 2522 2523 +1
Lines 274264 274599 +335
Branches 31326 31383 +57
============================================
+ Hits 129231 130124 +893
- Misses 134602 134862 +260
+ Partials 10431 9613 -818
Continue to review full report at Codecov.
|
igorbernstein2
left a comment
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 is looking good.
| try { | ||
| port = Integer.parseInt(hostAndPort.substring(hostAndPort.lastIndexOf(":") + 1)); | ||
| return newBuilderForEmulator(hostAndPort.substring(0, hostAndPort.lastIndexOf(":")), port); | ||
| } catch (NumberFormatException ex) { |
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.
Please handle IndexOutOfBoundsException as well
...ud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettings.java
Outdated
Show resolved
Hide resolved
| builder | ||
| .stubSettings() | ||
| .setProjectId("fake-project") | ||
| .setInstanceId("fake-instance") |
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 diverges from the other clients. I don't think we should set project & instance ids any more
...gle-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java
Outdated
Show resolved
Hide resolved
| * Create a new builder preconfigured to connect to the Bigtable emulator with host & port number. | ||
| */ | ||
| public static Builder newBuilderForEmulator(String hostname, int port) { | ||
| Builder builder = new Builder().setProjectId("fake-project").setInstanceId("fake-instance"); |
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.
I don't think we should be setting the project instance ids to stay consistent with other languages
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.
For Java, we have projectId & instanceId required. Shall I remove the Preconditions checks for projectId & InstanceId?
I would vote to keep these checks and continue with "fake-project" & "fake-instance".
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.
I'm not sure what you mean by that. I'm picturing something along the lines of:
BigtableTableAdminSettings.newBuilderForEmulator("localhost", 1234).setProjectId("blah").setInstanceId("blah2").build()
I think the other client languages require something similar
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.
Thanks for the explanation, I mistook it as emulator without any projectId & instanceId. Have updated with the suggestion. please have a look.
...gle-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java
Outdated
Show resolved
Hide resolved
...gle-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java
Outdated
Show resolved
Hide resolved
...oogle-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/TestEnvRule.java
Outdated
Show resolved
Hide resolved
...oogle-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/TestEnvRule.java
Outdated
Show resolved
Hide resolved
- Updated null check with String.isNullOrEmpty - Handled IndexOutOfBoundsException - fixed java doc in newBuilder() - Adapted with TruthJunit.assume() instead of Assert.assume().
...oogle-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/TestEnvRule.java
Outdated
Show resolved
Hide resolved
...oogle-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/env/TestEnvRule.java
Outdated
Show resolved
Hide resolved
igorbernstein2
left a comment
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! Thanks for implementing this!
Fixes #6057
User can now connect to Bigtable emulator in three ways:
BIGTABLE_EMULATOR_HOSTenvironment variable.