Skip to content

Commit

Permalink
chore: add aggregate test coverage collection of gax within the showc…
Browse files Browse the repository at this point in the history
…ase and gax modules (#1430)

* chore: add aggregate test coverage collection for showcase and gax
  • Loading branch information
mpeddada1 committed Mar 16, 2023
1 parent b6b99da commit bf68311
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 5 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci-maven.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ jobs:
- run: java -version
- name: Unit Tests
run: |
mvn install --batch-mode --no-transfer-progress -Dcheckstyle.skip \
-Dfmt.skip
mvn test --batch-mode --no-transfer-progress -Dcheckstyle.skip \
-Dfmt.skip -DenableTestCoverage
- run: bazelisk version
- name: Install maven modules
run: |
mvn install -B -ntp -DskipTests -Dclirr.skip -Dcheckstyle.skip
- name: Integration Tests
run: |
bazelisk --batch test //test/integration/...
Expand Down Expand Up @@ -71,7 +74,6 @@ jobs:
set -x
export JAVA_HOME=$JAVA11_HOME
export PATH=${JAVA_HOME}/bin:$PATH
# Why not compile? It's because the process needs to package jar so
# that gapic-generator-java module can use testlib modules of gax.
mvn verify --batch-mode --no-transfer-progress -Dcheckstyle.skip \
Expand Down
23 changes: 23 additions & 0 deletions coverage-report/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Coverage Report

This module gathers aggregated jacoco test coverage metrics across the `gax-java` and `showcase` modules. The purpose of
the metrics is to provide insights into how much of GAX code is being exercised by showcase and GAX tests and where
(unit tests versus integration tests). They will also provide information on any change in coverage observed
as showcase tests continue to be added to the repository.

### Unit Test Coverage
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 `gapic-generator-java/coverage-report/target/site/jacoco-aggregate/index.html`

![Screenshot 2023-03-03 at 6 32 50 PM](https://user-images.githubusercontent.com/66699525/222854612-787b4dde-f9a3-469a-8227-8f46dc0a4a20.png)

### Integration Test Coverage

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

1. At the root of the repository, run `mvn clean verify -DskipUnitTests -DenableTestCoverage -Penable-integration-tests`.
2. The metrics can be found at `gapic-generator-java/coverage-report/target/site/jacoco-aggregate/index.html`

![Screenshot 2023-03-03 at 6 36 26 PM](https://user-images.githubusercontent.com/66699525/222854973-f8a96f01-abc1-4e6b-9ab8-99b5e50dec6a.png)
81 changes: 81 additions & 0 deletions coverage-report/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>coverage-report</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Jacoco Aggregrate Test Coverage Report</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<checkstyle.skip>true</checkstyle.skip>
<clirr.skip>true</clirr.skip>
<enforcer.skip>true</enforcer.skip>
<maven.compiler.release>8</maven.compiler.release>
<fmt.skip>true</fmt.skip>
<sonar.coverage.jacoco.xmlReportPaths>
${project.basedir}/coverage-report/target/site/
jacoco-aggregate/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
</properties>

<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>gapic-showcase</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>2.23.3-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<version>2.23.3-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
<version>0.108.3-SNAPSHOT</version> <!-- {x-version-update:gax:current} -->
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<id>unit-tests-report-aggregate</id>
<goals>
<goal>report-aggregate</goal>
</goals>
<phase>test</phase>
</execution>
<execution>
<id>integration-tests-report-aggregate</id>
<goals>
<goal>report-aggregate</goal>
</goals>
<phase>integration-test</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.9</version>
</plugin>
</plugins>
</build>


</project>
83 changes: 82 additions & 1 deletion gapic-generator-java-pom-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,89 @@
</plugins>
</build>
</profile>
</profiles>

<profile>
<id>test-coverage</id>
<activation>
<property>
<name>enableTestCoverage</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M8</version>
<configuration>
<!-- Excludes integration tests and smoke tests when unit tests are run -->
<excludes>
<exclude>**/*SmokeTest.java</exclude>
<exclude>**/IT*.java</exclude>
</excludes>
<reportNameSuffix>sponge_log</reportNameSuffix>
<argLine>${surefire.jacoco.args}</argLine>
<skipTests>${skipUnitTests}</skipTests>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M8</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<forkedProcessTimeoutInSeconds>3600</forkedProcessTimeoutInSeconds>
<reportNameSuffix>sponge_log</reportNameSuffix>
<includes>
<include>**/IT*.java</include>
<include>**/*SmokeTest.java</include>
</includes>
<argLine>${failsafe.jacoco.args}</argLine>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<id>unit-test-execution</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefire.jacoco.args</propertyName>
</configuration>
</execution>
<execution>
<id>integration-test-execution</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>failsafe.jacoco.args</propertyName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<repositories>
<repository>
<id>google-maven-central-copy</id>
Expand Down
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@
</plugins>
</build>
</profile>

<profile>
<id>activate-test-coverage</id>
<activation>
<property>
<name>enableTestCoverage</name>
</property>
</activation>
<modules>
<module>showcase</module>
<module>coverage-report</module>
</modules>
</profile>
</profiles>

</project>
5 changes: 4 additions & 1 deletion showcase/gapic-showcase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>gapic-showcase</artifactId>
<version>0.0.1-SHAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>GAPIC Showcase Client</name>
<description>
Expand Down Expand Up @@ -171,18 +171,21 @@
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<type>test-jar</type>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<type>test-jar</type>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
<type>test-jar</type>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
Expand Down

0 comments on commit bf68311

Please sign in to comment.