Uh oh!
There was an error while loading. Please reload this page.
connecting to Bigtable emulator using environment variable - #6067
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.
Uh oh!
There was an error while loading. Please reload this page.
igorbernstein2
left a comment
There was a problem hiding this comment.
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!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
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.
Please handle IndexOutOfBoundsException as well
Uh oh!
There was an error while loading. Please reload this page.
| builder | ||
| .stubSettings() | ||
| .setProjectId("fake-project") | ||
| .setInstanceId("fake-instance") |
There was a problem hiding this comment.
This diverges from the other clients. I don't think we should set project & instance ids any more
Uh oh!
There was an error while loading. Please reload this page.
| * 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.
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.
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.
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.
Thanks for the explanation, I mistook it as emulator without any projectId & instanceId. Have updated with the suggestion. please have a look.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Updated null check with String.isNullOrEmpty - Handled IndexOutOfBoundsException - fixed java doc in newBuilder() - Adapted with TruthJunit.assume() instead of Assert.assume().
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
igorbernstein2
left a comment
There was a problem hiding this comment.
LGTM! Thanks for implementing this!
…s#6067) * connecting to Bigtable emulator using environment variable 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. * Address feedback comment for emulator configs * Address feedback commets - Updated null check with String.isNullOrEmpty - Handled IndexOutOfBoundsException - fixed java doc in newBuilder() - Adapted with TruthJunit.assume() instead of Assert.assume(). * Addressing more comments
Fixes#6057
User can now connect to Bigtable emulator in three ways:
BIGTABLE_EMULATOR_HOSTenvironment variable.