Writing quickstart + test for Bigtable#1431
Conversation
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>
.
|
…environment variable
| 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.
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.
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.
Also, please use System.err
|
|
||
| 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.
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.
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.
assertNotNull doesn't return the value of System.getenv(varName)
There was a problem hiding this comment.
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); |
| 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.
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.
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); |
|
|
||
| public class Quickstart { | ||
|
|
||
| public static void quickstart(String projectId, String instanceId, String tableId) { |
There was a problem hiding this comment.
Please include a main()
No description provided.