Include PAX Exam Code Coverage in Sonar 82/9482/2
authorDave Tucker <djt@redhat.com>
Wed, 30 Jul 2014 11:45:03 +0000 (12:45 +0100)
committerDave Tucker <djt@redhat.com>
Wed, 30 Jul 2014 14:14:41 +0000 (15:14 +0100)
- Create an aggregate jacoco report in the root target direcorty
- Combine surefire and failsafe reports to all tests run in Sonar
- Split the Maven profiles for integrationtest and coverage
- Add a jenkins profilei
- Remove root IT profile so IT modules are complied every time

To run the integration tests

 mvn clean install
 mvn verify -Pintegrationtest

To run the IT with JaCoCo

 mvn verify -Pintegrationtest -Pcoverage

To upload results to Sonar

 mvn sonar:sonar

Change-Id: Ia0875de7efe67fc7a7d067adabed2d9588e284f4
Signed-off-by: Dave Tucker <djt@redhat.com>
commons/integrationtest/pom.xml
commons/parent/pom.xml
pom.xml

index e1d647e42979fb4b48daddd0d2e921d97ac7277c..4a8816ca4bda794556810a2b9839ba5b16001cb4 100644 (file)
@@ -8,6 +8,7 @@
     <relativePath>../parent</relativePath>
   </parent>
   <artifactId>commons.integrationtest</artifactId>
+  <name>OVSDB Integration Test Parent POM</name>
   <version>1.2.0-SNAPSHOT</version>
   <packaging>pom</packaging>
 
index 3da53e38a98f2f6d699aa85448a4d020793c7f50..a1d813e8bdb09b6074a906e72ab1c958f77a65bd 100755 (executable)
@@ -11,6 +11,7 @@
 
   <groupId>org.opendaylight.ovsdb</groupId>
   <artifactId>commons</artifactId>
+  <name>OVSDB Parent POM</name>
   <version>1.2.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <prerequisites>
@@ -20,7 +21,9 @@
   <properties>
     <!-- ODL repository / plugin repository -->
     <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
+    <!-- Surefire/Failsafe Arguments -->
     <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
+    <!-- OVSB Component Versions -->
     <ovsdb.library.version>1.0.0-SNAPSHOT</ovsdb.library.version>
     <ovsdb.plugin.version>1.0.0-SNAPSHOT</ovsdb.plugin.version>
     <openstack.netvirt.version>1.0.0-SNAPSHOT</openstack.netvirt.version>
     <ovsdb.northbound.version>0.6.0-SNAPSHOT</ovsdb.northbound.version>
     <schema.openvswitch.version>1.0.0-SNAPSHOT</schema.openvswitch.version>
     <schema.hardwarevtep.version>1.0.0-SNAPSHOT</schema.hardwarevtep.version>
+    <!-- Skip Coverage and IT by default -->
+    <skip.coverage>true</skip.coverage>
     <skip.integrationtest>true</skip.integrationtest>
+    <!-- The directory where maven was executed -->
+    <root.directory>${env.PWD}</root.directory>
+    <!-- UT reports are per-module -->
     <sonar.jacoco.reportPath>target/code-coverage/jacoco.exec</sonar.jacoco.reportPath>
-    <sonar.jacoco.itReportPath>target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
+    <!-- IT report is aggregated to enable PAX Exam coverage to be logged -->
+    <sonar.jacoco.itReportPath>${root.directory}/target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
-    <!-- Override -->
+    <!-- Override the JaCoCo version in ODL Parent -->
     <jacoco.version>0.6.4.201312101107</jacoco.version>
     <!-- ODL Dependency Versions -->
     <containermanager.version>0.5.2-SNAPSHOT</containermanager.version>
           <groupId>org.jacoco</groupId>
           <artifactId>jacoco-maven-plugin</artifactId>
           <version>${jacoco.version}</version>
+          <configuration>
+            <skip>${skip.coverage}</skip>
+          </configuration>
           <executions>
             <execution>
               <id>pre-unit-test</id>
               </goals>
               <configuration>
                 <destFile>${sonar.jacoco.itReportPath}</destFile>
+                <append>true</append>
                 <skip>${skip.integrationtest}</skip>
               </configuration>
             </execution>
                 <goal>verify</goal>
               </goals>
               <configuration>
+                <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                 <skipTests>${skip.integrationtest}</skipTests>
               </configuration>
             </execution>
         <skip.integrationtest>false</skip.integrationtest>
       </properties>
     </profile>
+    <profile>
+      <id>coverage</id>
+      <activation>
+        <activeByDefault>false</activeByDefault>
+      </activation>
+      <properties>
+        <skip.coverage>false</skip.coverage>
+      </properties>
+    </profile>
+    <profile>
+      <id>jenkins</id>
+      <activation>
+        <activeByDefault>false</activeByDefault>
+      </activation>
+      <properties>
+        <root.directory>${env.WORKSPACE}</root.directory>
+      </properties>
+    </profile>
   </profiles>
-
 </project>
diff --git a/pom.xml b/pom.xml
index 63eb3fc46c37e18d717098319f35b15d01241020..5b11cb7494c2c776d5fbd46d55dab625eaaf5b2d 100755 (executable)
--- a/pom.xml
+++ b/pom.xml
   </prerequisites>
 
   <modules>
+    <!-- Parent POM files -->
+    <module>commons/parent</module>
+    <module>commons/integrationtest</module>
+    <!-- OVSDB Components -->
     <module>library</module>
     <module>schemas/openvswitch</module>
     <module>schemas/hardwarevtep</module>
     <module>plugin</module>
-    <module>commons/parent</module>
     <module>northbound</module>
     <module>openstack/net-virt</module>
     <module>openstack/net-virt-providers</module>
-    <module>distribution/opendaylight</module>
+    <!-- Integration Tests -->
+    <module>integrationtest</module>
     <!-- Karaf Distribution -->
     <module>features</module>
+    <!-- OVSDB Distribution -->
+    <module>distribution/opendaylight</module>
   </modules>
 
-  <profiles>
-    <profile>
-      <id>integrationtest</id>
-      <activation>
-        <activeByDefault>false</activeByDefault>
-      </activation>
-      <modules>
-        <module>commons/integrationtest</module>
-        <module>integrationtest</module>
-      </modules>
-      <properties>
-        <skip.integrationtest>false</skip.integrationtest>
-      </properties>
-    </profile>
-  </profiles>
-
   <scm>
     <connection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</connection>
     <developerConnection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</developerConnection>