Skip to content
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

chore: add aggregate test coverage collection of gax within the showcase and gax modules #1430

Merged
merged 22 commits into from
Mar 16, 2023

Conversation

mpeddada1
Copy link
Contributor

@mpeddada1 mpeddada1 commented Mar 2, 2023

Coverage

In order to get test coverage of gax within the showcase and gax modules, a new module coverage-report needed to be created. The coverage module declares gapic-showcase (with a test scope), gax, gax-grpc, gax-httpjson as dependencies and relies on jacoco:report-aggregate to collect aggregate metrics.

Unit test coverage

Gathering just unit test metrics requires mvn clean test -DenableTestCoverage to be called.
Screenshot 2023-03-03 at 6 32 50 PM

Integration test coverage

Gathering just integration test metrics requires mvn clean verify -DskipUnitTests -DenableTestCoverage -Penable-integration-tests to be called. The DskipUnitTests is needed skip the maven-surefire-plugin.
Screenshot 2023-03-03 at 6 36 26 PM

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Mar 2, 2023
@mpeddada1
Copy link
Contributor Author

mpeddada1 commented Mar 2, 2023

graalvm downstream check is resulting in Error: Test configuration file wasn't found. Make sure that test execution wasn't skipped.

@mpeddada1 mpeddada1 marked this pull request as ready for review March 6, 2023 15:24
@mpeddada1 mpeddada1 requested a review from a team as a code owner March 6, 2023 15:24
pom.xml Outdated Show resolved Hide resolved
gax-java/pom.xml Outdated
@@ -222,6 +222,7 @@
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you clarify what this is doing?

@blakeli0 , @suztomo : Is it possible that the <skip>true</skip> three lines down from here is the reason why we have to execute mvn install rather than mvn test to avoid linking errors?

Copy link
Contributor Author

@mpeddada1 mpeddada1 Mar 6, 2023

Choose a reason for hiding this comment

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

Sure! This line helps resolve the compilation error we see when running mvn test at the root. The PR description goes over this briefly but upon comparing the mvn test with mvn install, I noticed that the jar:test-jar step which creates the testlib JAR that gapic-generator-java depends on was being executed when mvn install was called but after thesurefire:test step. On the other hand, it was not being invoked at all when mvn test was executed. This change forces the maven-jar-plugin of GAX to be executed at the test phase.

Copy link
Contributor

Choose a reason for hiding this comment

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

@blakeli0 and @suztomo for visibility. Great work!

@@ -95,8 +95,86 @@
</plugins>
</build>
</profile>

<profile>
<id>test-coverage</id>
Copy link
Contributor

Choose a reason for hiding this comment

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

The PR description does a great job clarifying how this is meant to be used, but that may get lost in obscurity once the PR is merged. Could you add some information in an appropriate .md to explain the different expected workflows + report options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, done. I've added a README to the coverage-report module.

@mpeddada1 mpeddada1 changed the title chore: add aggregate test coverage collection for showcase and gax chore: add aggregate test coverage collection of gax within the showcase and gax modules Mar 8, 2023
pom.xml Outdated
@@ -21,6 +21,8 @@
<module>java-common-protos</module>
<module>java-iam</module>
<module>gapic-generator-java-bom</module>
<module>showcase</module>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding these two modules to the root pom here may have impact to our release, that they might be released automatically. @suztomo Do you have any concerns here?

Copy link
Member

Choose a reason for hiding this comment

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

@mpeddada1 To address the concern of accidental releases, can we define a profile so that the showcase module is part of the root project only when the profile is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! Done.

@mpeddada1
Copy link
Contributor Author

@suztomo @blakeli0 Ready for another round of review.

@suztomo
Copy link
Member

suztomo commented Mar 15, 2023

As described in #1270, calling mvn test was resulting in compilation errors for gax test-jars.

#1474 might resolve this problem. If you had to implement some workaround for the GAX test JARs, would you revisit it? If not applicable, then that's good.

@mpeddada1
Copy link
Contributor Author

#1474 might resolve this problem. If you had to implement some workaround for the GAX test JARs, would you revisit it? If not applicable, then that's good.

Awesome! Thank you. It works without the workaround:)

Copy link
Member

@suztomo suztomo left a comment

Choose a reason for hiding this comment

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

Would you add a check in .github/workflows (either existing one or new file) to run the two commands for unit tests and integration tests.

@@ -0,0 +1,16 @@
## Coverage Report

This module is meant to gather aggregate jacoco test coverage metrics across the `gax-java` and `showcase` modules.
Copy link
Member

@suztomo suztomo Mar 15, 2023

Choose a reason for hiding this comment

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

Suggested change
This module is meant to gather aggregate jacoco test coverage metrics across the `gax-java` and `showcase` modules.
This module gathers aggregated jacoco test coverage metrics across the `gax-java` and `showcase` modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thank you!

In order to view aggregate unit test coverage of GAX in both `gax-java` and `showcase`:

1. At the root of the repository, run `mvn clean test -DenableTestCoverage`.
2. The metrics can be found at `${HOME}/gapic-generator-java/coverage-report/target/site/jacoco-aggregate/index.html`
Copy link
Member

Choose a reason for hiding this comment

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

I believe the home directory is irrelevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, starting with gapic-generator-java should be sufficient.

coverage-report/README.md Outdated Show resolved Hide resolved
coverage-report/README.md Show resolved Hide resolved
coverage-report/README.md Outdated Show resolved Hide resolved
gapic-generator-java-pom-parent/pom.xml Outdated Show resolved Hide resolved
@mpeddada1
Copy link
Contributor Author

Would you add a check in .github/workflows (either existing one or new file) to run the two commands for unit tests and integration tests.

Yup! I modified the Unit Tests check in ci-maven.yaml to use mvn test instead of mvn install now that the issue has been fixed. Additionally, the PR after this (#1482) is going to add both commands (mvn test and mvn verify) on the whole repo to sonar.yaml for piping the metrics to Sonarcloud.

Copy link
Member

@suztomo suztomo left a comment

Choose a reason for hiding this comment

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

I meant a check to ensure “ -DenableTestCoverage” works fine. Does it exist already via SonarCloud?

.github/workflows/ci-maven.yaml Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Mar 16, 2023

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mpeddada1 mpeddada1 merged commit bf68311 into main Mar 16, 2023
@mpeddada1 mpeddada1 deleted the test-coverage branch March 16, 2023 15:23
lqiu96 pushed a commit that referenced this pull request Mar 20, 2023
…ase and gax modules (#1430)

* chore: add aggregate test coverage collection for showcase and gax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants