-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Writing quickstart + test for Bigtable #1431
Conversation
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.
Isn't there a pom.xml or something to build & test this? I hate to just check in something that can't be built on an automated basis.
@kurtisvg FYI
Looks like the pom here is being used. |
Sorry, I put out the stuff with the pom in a separate PR cus that code was already existing, but this code is all new. You already reviewed that other PR though. Is there a way to trigger the tests to run for this submit? |
Oh the reason this isn't running tests is because it's not being merged to master. Do you want to merge them into the master branch? |
I'm too til Tuesday
…On Fri, May 24, 2019, 11:45 AM Billy Jacobson ***@***.***> wrote:
@billyjacobson <https://github.com/billyjacobson> requested your review
on: #1431
<#1431>
Writing quickstart + test for Bigtable.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1431?email_source=notifications&email_token=AAIVLDTLP3JAEB3DGT5R5A3PXAZWNA5CNFSM4HOOYDS2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGORUGJPAQ#event-2366412674>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIVLDW3ZT25TNHA5Q65UPTPXAZWNANCNFSM4HOOYDSQ>
.
|
bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java
Outdated
Show resolved
Hide resolved
bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java
Outdated
Show resolved
Hide resolved
bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java
Outdated
Show resolved
Hide resolved
bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java
Outdated
Show resolved
Hide resolved
bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java
Outdated
Show resolved
Hide resolved
…environment variable
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
@BeforeClass | ||
public static void beforeClass() throws IOException { | ||
projectId = System.getProperty(PROJECT_PROPERTY_NAME); | ||
projectId = requireEnv("GOOGLE_CLOUD_PROJECT"); | ||
if (projectId == null) { |
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.
requireEnv
should throw an error if projectID
is null, so you can remove this check
|
||
} catch (Exception e) { | ||
System.out.println("Error during functionName: \n" + e.toString()); | ||
} |
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.
Can we collapse the try-catch blocks into one?
try (BigtableDataClient dataClient = BigtableDataClient.create(settings)) {
...
} catch (NotFoundException e) {
System.err.println("Failed to read from a non-existent table: " + e.getMessage());
} catch (Exception e) {
System.out.println("Error during functionName: \n" + e.toString());
}
} | ||
|
||
} catch (Exception e) { | ||
System.out.println("Error during functionName: \n" + e.toString()); |
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.
Whats functionName?
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.
Also, please use System.err
@@ -40,8 +40,7 @@ | |||
/** Integration tests for {@link HelloWorld} */ | |||
public class HelloWorldTest { | |||
|
|||
private static final String PROJECT_PROPERTY_NAME = "bigtable.project"; | |||
private static final String INSTANCE_PROPERTY_NAME = "bigtable.instance"; | |||
private static final String INSTANCE_PROPERTY_NAME = "BIGTABLE_TESTING_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.
These shouldn't be called properties any more since its using env var now
assertNotNull( | ||
System.getenv(varName), | ||
"System property '%s' is required to perform these tests.".format(varName)); | ||
return System.getenv(varName); |
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.
you can combine the return here:
return assertNotNull(
System.getenv(varName),
"System property '%s' is required to perform these tests.".format(varName));
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.
assertNotNull doesn't return the value of System.getenv(varName)
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.
Oops, I thought you were using Preconditions.checkNotNull, which does. Any reason not to use that?
assertNotNull( | ||
System.getenv(varName), | ||
"System property '%s' is required to perform these tests.".format(varName)); | ||
return System.getenv(varName); |
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.
Same as above
public class QuickstartTest { | ||
|
||
private static final String INSTANCE_PROPERTY_NAME = "BIGTABLE_TESTING_INSTANCE"; | ||
private static final String TABLE_ID = "quickstart-table"; |
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 don't hardcode the table id, it will cause these tests to be flaky when multiple PRs are opened
} | ||
|
||
@Before | ||
public void setupStream() { |
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 use the junit convention of calling this setUp()
assertNotNull( | ||
System.getenv(varName), | ||
"System property '%s' is required to perform these tests.".format(varName)); | ||
return System.getenv(varName); |
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.
Same as above
|
||
public class Quickstart { | ||
|
||
public static void quickstart(String projectId, String instanceId, String tableId) { |
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 include a main()
No description provided.