ASTERIXDB-1344: Capture Code Coverage Metrics
Optionally capture code coverage data with Jacoco when 'coverage'
property is set or 'coverage' profile is enabled. Reports are
generated at: coverage/target/coverage-report/html/index.html
Change-Id: Ic428230934a46c64baa60933b75c214f5b138387
Reviewed-on: https://asterix-gerrit.ics.uci.edu/721
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterix-coverage/pom.xml b/asterix-coverage/pom.xml
new file mode 100644
index 0000000..3f77ed8
--- /dev/null
+++ b/asterix-coverage/pom.xml
@@ -0,0 +1,134 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements. See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership. The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License. You may obtain a copy of the License at
+ !
+ ! http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied. See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>asterix-coverage</artifactId>
+ <packaging>pom</packaging>
+ <name>asterix-coverage</name>
+
+ <parent>
+ <groupId>org.apache.asterix</groupId>
+ <artifactId>asterix</artifactId>
+ <version>0.8.8-SNAPSHOT</version>
+ </parent>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target if="coverage" unless="skipTests">
+ <echo message="Generating JaCoCo Reports" />
+ <property name="asterix.dir" location="${basedir}/.."/>
+ <!-- special case for jenkins -->
+ <condition property="hyracks.dir" value="${asterix.dir}/hyracks">
+ <available file="${asterix.dir}/hyracks/pom.xml"/>
+ </condition>
+ <pathconvert property="hyracks.dir">
+ <first>
+ <dirset dir="${asterix.dir}/..">
+ <include name="*hyracks"/>
+ </dirset>
+ </first>
+ </pathconvert>
+ <!-- gather all of the source dirs -->
+ <pathconvert property="source.dirs" pathsep=",">
+ <dirset dir="${asterix.dir}">
+ <include name="**/src/main/java"/>
+ <!-- special case for jenkins -->
+ <exclude name="hyracks/**"/>
+ </dirset>
+ </pathconvert>
+ <pathconvert property="hyracks.source.dirs" pathsep=",">
+ <dirset dir="${hyracks.dir}">
+ <include name="**/src/main/java"/>
+ </dirset>
+ </pathconvert>
+ <echo message="asterix dir: ${asterix.dir}/"/>
+ <echo message="hyracks dir: ${hyracks.dir}"/>
+ <echo message="asterix source dirs: ${source.dirs}/"/>
+ <echo message="hyracks source dirs: ${hyracks.source.dirs}/"/>
+
+ <taskdef name="report" classname="org.jacoco.ant.ReportTask">
+ <classpath path="${basedir}/target/jacoco-jars/org.jacoco.ant.jar" />
+ </taskdef>
+ <mkdir dir="${basedir}/target/coverage-report" />
+ <report>
+ <executiondata>
+ <fileset dir="${asterix.dir}">
+ <include name="**/jacoco.exec" />
+ </fileset>
+ </executiondata>
+ <structure name="AsterixDB Coverage Project">
+ <group name="AsterixDB">
+ <classfiles>
+ <fileset dir="${asterix.dir}">
+ <include name="**/target/classes/**/*.class"/>
+ <!-- special case for jenkins -->
+ <exclude name="hyracks/**"/>
+ </fileset>
+ </classfiles>
+ <sourcefiles encoding="UTF-8">
+ <multirootfileset basedirs="${source.dirs}" type="file">
+ <include name="**/*.java"/>
+ </multirootfileset>
+ </sourcefiles>
+ </group>
+ <group name="Hyracks">
+ <classfiles>
+ <fileset dir="${hyracks.dir}">
+ <include name="**/target/classes/**/*.class"/>
+ <exclude name="hyracks/hyracks-hdfs/hyracks-hdfs-1.x/**"/>
+ </fileset>
+ </classfiles>
+ <sourcefiles encoding="UTF-8">
+ <multirootfileset basedirs="${hyracks.source.dirs}" type="file">
+ <include name="**/*.java"/>
+ </multirootfileset>
+ </sourcefiles>
+ </group>
+ </structure>
+ <html destdir="${basedir}/target/coverage-report/html" />
+ <xml destfile="${basedir}/target/coverage-report/coverage-report.xml" />
+ <csv destfile="${basedir}/target/coverage-report/coverage-report.csv" />
+ </report>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jacoco</groupId>
+ <artifactId>org.jacoco.ant</artifactId>
+ <version>${jacoco.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/asterix-installer/pom.xml b/asterix-installer/pom.xml
index b257e71..893a983 100644
--- a/asterix-installer/pom.xml
+++ b/asterix-installer/pom.xml
@@ -30,6 +30,7 @@
<cluster.test.excludes>**/AsterixClusterLifeCycleIT.java</cluster.test.excludes>
<cluster.extest.excludes>**/ClusterExecutionIT.java</cluster.extest.excludes>
<replication.test.excludes>**/ReplicationIT.java</replication.test.excludes>
+ <jacocoArgLine/>
</properties>
<licenses>
diff --git a/pom.xml b/pom.xml
index 581b8b7..2bf4e4f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,7 +53,8 @@
<invalid.tests>**/DmlTest.java</invalid.tests>
<global.test.includes>**/*TestSuite.java,**/*Test.java,${execution.tests}</global.test.includes>
<global.test.excludes>${optimizer.tests},${metadata.tests},${invalid.tests},${repeated.tests}</global.test.excludes>
- <!-- Versions under dependencymanagement or used in many projects via properties -->
+
+ <!-- Versions under dependencymanagement or used in many projects via properties -->
<algebricks.version>0.2.17-SNAPSHOT</algebricks.version>
<hyracks.version>0.2.17-SNAPSHOT</hyracks.version>
<hadoop.version>2.2.0</hadoop.version>
@@ -61,6 +62,7 @@
<commons.io.version>2.4</commons.io.version>
<servlet.api.version>2.5</servlet.api.version>
<json.version>20090211</json.version>
+ <jacoco.version>0.7.6.201602180812</jacoco.version>
</properties>
<build>
@@ -76,12 +78,15 @@
</systemPropertyVariables>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
- <argLine>-enableassertions -Xmx${test.heap.size}m
+ <argLine>
+ -enableassertions -Xmx${test.heap.size}m
-Dfile.encoding=UTF-8
-Djava.util.logging.config.file=${user.home}/logging.properties
-DrunSlowAQLTests=${runSlowAQLTests}
-Xdebug
- -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n</argLine>
+ -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n
+ ${coverageArgLine}
+ </argLine>
<includes>
<include>${global.test.includes},${test.includes}</include>
</includes>
@@ -345,6 +350,49 @@
<jdk.version>1.8</jdk.version>
</properties>
</profile>
+ <!-- Code Coverage -->
+ <profile>
+ <id>coverage</id>
+ <activation>
+ <property>
+ <name>coverage</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${jacoco.version}</version>
+ <executions>
+ <execution>
+ <id>default-prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <propertyName>coverageArgLine</propertyName>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <coverage/>
+ </properties>
+ </profile>
+ <profile>
+ <id>no-coverage</id>
+ <activation>
+ <property>
+ <name>!coverage</name>
+ </property>
+ </activation>
+ <properties>
+ <coverageArgLine/>
+ </properties>
+ </profile>
</profiles>
<modules>
@@ -371,6 +419,7 @@
<module>asterix-yarn</module>
<module>asterix-replication</module>
<module>asterix-experiments</module>
+ <module>asterix-coverage</module>
</modules>
<repositories>