Skip to content

Writing quickstart + test for Bigtable#1431

Merged
billyjacobson merged 17 commits into
masterfrom
cbt-quickstart
Jun 3, 2019
Merged

Writing quickstart + test for Bigtable#1431
billyjacobson merged 17 commits into
masterfrom
cbt-quickstart

Conversation

@billyjacobson

Copy link
Copy Markdown
Member

No description provided.

@billyjacobson billyjacobson requested a review from a team May 21, 2019 21:11
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 21, 2019

@lesv lesv left a comment

Copy link
Copy Markdown
Contributor

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

@kurtisvg

Copy link
Copy Markdown
Contributor

Isn't there a pom.xml or something to build & test this

Looks like the pom here is being used.

@billyjacobson

billyjacobson commented May 23, 2019

Copy link
Copy Markdown
Member Author

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

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?

@kurtisvg

Copy link
Copy Markdown
Contributor

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?

@billyjacobson billyjacobson changed the base branch from bigtable-veneer-samples to master May 23, 2019 16:48
@billyjacobson billyjacobson requested a review from lesv May 24, 2019 18:45
@lesv

lesv commented May 24, 2019 via email

Copy link
Copy Markdown
Contributor

@kurtisvg kurtisvg requested review from kurtisvg and removed request for lesv May 24, 2019 19:18
Comment thread bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java Outdated
Comment thread bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java Outdated
Comment thread bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java Outdated
Comment thread bigtable/src/main/java/com/m/examples/bigtable/Quickstart.java Outdated
Comment thread bigtable/src/main/java/com/m/examples/bigtable/Quickstart.java Outdated
Comment thread bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java Outdated
Comment thread bigtable/src/main/java/com/m/examples/bigtable/Quickstart.java Outdated
Comment thread bigtable/src/test/java/com/m/examples/bigtable/QuickstartTest.java Outdated
@kurtisvg kurtisvg added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 30, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 30, 2019
@billyjacobson billyjacobson requested a review from kurtisvg June 3, 2019 17:38

@kurtisvg kurtisvg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

public static void beforeClass() throws IOException {
projectId = System.getProperty(PROJECT_PROPERTY_NAME);
projectId = requireEnv("GOOGLE_CLOUD_PROJECT");
if (projectId == null) {

Copy link
Copy Markdown
Contributor

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

@billyjacobson billyjacobson merged commit 1a491c8 into master Jun 3, 2019
@billyjacobson billyjacobson deleted the cbt-quickstart branch June 3, 2019 19:49

} catch (Exception e) {
System.out.println("Error during functionName: \n" + e.toString());
}

Copy link
Copy Markdown
Contributor

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());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats functionName?

Copy link
Copy Markdown
Contributor

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


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";

Copy link
Copy Markdown
Contributor

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);

Copy link
Copy Markdown
Contributor

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));

Copy link
Copy Markdown
Member Author

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)

Copy link
Copy Markdown
Contributor

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);

Copy link
Copy Markdown
Contributor

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";

Copy link
Copy Markdown
Contributor

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() {

Copy link
Copy Markdown
Contributor

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);

Copy link
Copy Markdown
Contributor

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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include a main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants