Enable code coverage (#8303)

* Enable code coverage

Code coverage was disabled via
https://github.com/apache/incubator-druid/pull/3122 due to an issue with
cobertura in Travis CI. Switch code coverage tool from cobertura to
jacoco to avoid issue and re-enable coveralls for Travis CI.

* Exclude non-production code

* Exclude benchmark generated code

* Exclude DruidTestRunnerFactory
This commit is contained in:
Chi Cao Minh 2019-08-20 15:36:19 -07:00 committed by Gian Merlino
parent cb1339e19a
commit 6fa22f6939
6 changed files with 65 additions and 45 deletions

View File

@ -40,35 +40,36 @@ env:
-Dpmd.skip=true -Dpmd.skip=true
-Dspotbugs.skip=true -Dspotbugs.skip=true
" "
- MAVEN_SKIP_TESTS="-DskipTests -Djacoco.skip=true"
# Add various options to make 'mvn install' fast and skip javascript compile (-Ddruid.console.skip=true) since it is not # Add various options to make 'mvn install' fast and skip javascript compile (-Ddruid.console.skip=true) since it is not
# needed. Depending on network speeds, "mvn -q install" may take longer than the default 10 minute timeout to print any # needed. Depending on network speeds, "mvn -q install" may take longer than the default 10 minute timeout to print any
# output. To compensate, use travis_wait to extend the timeout. # output. To compensate, use travis_wait to extend the timeout.
install: MAVEN_OPTS='-Xmx3000m' travis_wait 15 $MVN clean install -q -ff ${MAVEN_SKIP} -DskipTests -T1C install: MAVEN_OPTS='-Xmx3000m' travis_wait 15 ${MVN} clean install -q -ff ${MAVEN_SKIP} ${MAVEN_SKIP_TESTS} -T1C
matrix: matrix:
include: include:
- name: "java 11 build" - name: "java 11 build"
jdk: openjdk11 jdk: openjdk11
script: $MVN test -pl '!web-console' ${MAVEN_SKIP} script: ${MVN} test -pl '!web-console' ${MAVEN_SKIP}
- name: "animal sniffer checks" - name: "animal sniffer checks"
script: $MVN animal-sniffer:check --fail-at-end script: ${MVN} animal-sniffer:check --fail-at-end
- name: "checkstyle" - name: "checkstyle"
script: $MVN checkstyle:checkstyle --fail-at-end script: ${MVN} checkstyle:checkstyle --fail-at-end
- name: "enforcer checks" - name: "enforcer checks"
script: $MVN enforcer:enforce --fail-at-end script: ${MVN} enforcer:enforce --fail-at-end
- name: "forbidden api checks" - name: "forbidden api checks"
script: $MVN forbiddenapis:check forbiddenapis:testCheck --fail-at-end script: ${MVN} forbiddenapis:check forbiddenapis:testCheck --fail-at-end
- name: "pmd checks" - name: "pmd checks"
script: $MVN pmd:check --fail-at-end # TODO: consider adding pmd:cpd-check script: ${MVN} pmd:check --fail-at-end # TODO: consider adding pmd:cpd-check
- name: "spotbugs checks" - name: "spotbugs checks"
script: $MVN spotbugs:check --fail-at-end -pl '!benchmarks' script: ${MVN} spotbugs:check --fail-at-end -pl '!benchmarks'
- name: "license checks" - name: "license checks"
install: skip install: skip
@ -78,7 +79,7 @@ matrix:
- pip3 install pyyaml - pip3 install pyyaml
script: script:
- > - >
$MVN apache-rat:check -Prat --fail-at-end ${MVN} apache-rat:check -Prat --fail-at-end
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
-Drat.consoleOutput=true -Drat.consoleOutput=true
# Generate dependency reports and checks they are valid. When running on Travis CI, 2 cores are available # Generate dependency reports and checks they are valid. When running on Travis CI, 2 cores are available
@ -91,15 +92,15 @@ matrix:
install: skip install: skip
# Strict compilation requires more than 2 GB # Strict compilation requires more than 2 GB
script: > script: >
MAVEN_OPTS='-Xmx3000m' $MVN clean -Pstrict compile test-compile --fail-at-end MAVEN_OPTS='-Xmx3000m' ${MVN} clean -Pstrict compile test-compile --fail-at-end
-pl '!benchmarks' ${MAVEN_SKIP} -DskipTests -pl '!benchmarks' ${MAVEN_SKIP} ${MAVEN_SKIP_TESTS}
- name: "packaging check" - name: "packaging check"
install: skip install: skip
before_script: *setup_generate_license before_script: *setup_generate_license
script: > script: >
MAVEN_OPTS='-Xmx3000m' $MVN clean install -Pdist -Pbundle-contrib-exts --fail-at-end MAVEN_OPTS='-Xmx3000m' ${MVN} clean install -Pdist -Pbundle-contrib-exts --fail-at-end
-pl '!benchmarks' ${MAVEN_SKIP} -DskipTests -Ddruid.console.skip=false -T1C -pl '!benchmarks' ${MAVEN_SKIP} ${MAVEN_SKIP_TESTS} -Ddruid.console.skip=false -T1C
- name: "processing module test" - name: "processing module test"
env: &processing_env env: &processing_env
@ -110,10 +111,12 @@ matrix:
# Set MAVEN_OPTS for Surefire launcher. Skip remoteresources to avoid intermittent connection timeouts when # Set MAVEN_OPTS for Surefire launcher. Skip remoteresources to avoid intermittent connection timeouts when
# resolving the SIGAR dependency. # resolving the SIGAR dependency.
- > - >
MAVEN_OPTS='-Xmx800m' $MVN test -pl ${MAVEN_PROJECTS} MAVEN_OPTS='-Xmx800m' ${MVN} test -pl ${MAVEN_PROJECTS}
${MAVEN_SKIP} -Dremoteresources.skip=true ${MAVEN_SKIP} -Dremoteresources.skip=true
- sh -c "dmesg | egrep -i '(oom|out of memory|kill process|killed).*' -C 1 || exit 0" - sh -c "dmesg | egrep -i '(oom|out of memory|kill process|killed).*' -C 1 || exit 0"
- free -m - free -m
after_success: &upload_java_unit_test_coverage
- ${MVN} -pl ${MAVEN_PROJECTS} jacoco:report coveralls:report
- name: "processing module test (SQL Compatibility)" - name: "processing module test (SQL Compatibility)"
env: *processing_env env: *processing_env
@ -122,54 +125,61 @@ matrix:
# Set MAVEN_OPTS for Surefire launcher. Skip remoteresources to avoid intermittent connection timeouts when # Set MAVEN_OPTS for Surefire launcher. Skip remoteresources to avoid intermittent connection timeouts when
# resolving the SIGAR dependency. # resolving the SIGAR dependency.
- > - >
MAVEN_OPTS='-Xmx800m' $MVN test -pl ${MAVEN_PROJECTS} -Ddruid.generic.useDefaultValueForNull=false MAVEN_OPTS='-Xmx800m' ${MVN} test -pl ${MAVEN_PROJECTS} -Ddruid.generic.useDefaultValueForNull=false
${MAVEN_SKIP} -Dremoteresources.skip=true ${MAVEN_SKIP} -Dremoteresources.skip=true
- sh -c "dmesg | egrep -i '(oom|out of memory|kill process|killed).*' -C 1 || exit 0" - sh -c "dmesg | egrep -i '(oom|out of memory|kill process|killed).*' -C 1 || exit 0"
- free -m - free -m
after_success: *upload_java_unit_test_coverage
- name: "indexing modules test" - name: "indexing modules test"
env: &indexing_env env: &indexing_env
- MAVEN_PROJECTS='indexing-hadoop,indexing-service,extensions-core/kafka-indexing-service,extensions-core/kinesis-indexing-service' - MAVEN_PROJECTS='indexing-hadoop,indexing-service,extensions-core/kafka-indexing-service,extensions-core/kinesis-indexing-service'
before_script: *setup_java_test before_script: *setup_java_test
script: *run_java_test script: *run_java_test
after_success: *upload_java_unit_test_coverage
- name: "indexing modules test (SQL Compatibility)" - name: "indexing modules test (SQL Compatibility)"
env: *indexing_env env: *indexing_env
before_script: *setup_java_test before_script: *setup_java_test
script: *run_java_sql_compat_test script: *run_java_sql_compat_test
after_success: *upload_java_unit_test_coverage
- name: "server module test" - name: "server module test"
env: &server_env env: &server_env
- MAVEN_PROJECTS='server' - MAVEN_PROJECTS='server'
before_script: *setup_java_test before_script: *setup_java_test
script: *run_java_test script: *run_java_test
after_success: *upload_java_unit_test_coverage
- name: "server module test (SQL Compatibility)" - name: "server module test (SQL Compatibility)"
env: *server_env env: *server_env
before_script: *setup_java_test before_script: *setup_java_test
script: *run_java_sql_compat_test script: *run_java_sql_compat_test
after_success: *upload_java_unit_test_coverage
- name: "other modules test" - name: "other modules test"
env: &other_env env: &other_env
- MAVEN_PROJECTS='!processing,!indexing-hadoop,!indexing-service,!extensions-core/kafka-indexing-service,!extensions-core/kinesis-indexing-service,!server,!web-console' - MAVEN_PROJECTS='!processing,!indexing-hadoop,!indexing-service,!extensions-core/kafka-indexing-service,!extensions-core/kinesis-indexing-service,!server,!web-console'
before_script: *setup_java_test before_script: *setup_java_test
script: *run_java_test script: *run_java_test
after_success: *upload_java_unit_test_coverage
- name: "other modules test (SQL Compatibility)" - name: "other modules test (SQL Compatibility)"
env: *other_env env: *other_env
before_script: *setup_java_test before_script: *setup_java_test
script: *run_java_sql_compat_test script: *run_java_sql_compat_test
after_success: *upload_java_unit_test_coverage
- name: "web console" - name: "web console"
script: script:
- $MVN test -pl 'web-console' - ${MVN} test -pl 'web-console'
- name: "batch index integration test" - name: "batch index integration test"
services: &integration_test_services services: &integration_test_services
- docker - docker
env: TESTNG_GROUPS='-Dgroups=batch-index' env: TESTNG_GROUPS='-Dgroups=batch-index'
script: &run_integration_test script: &run_integration_test
- $MVN verify -pl integration-tests -P integration-tests ${TESTNG_GROUPS} ${MAVEN_SKIP} - ${MVN} verify -pl integration-tests -P integration-tests ${TESTNG_GROUPS} ${MAVEN_SKIP}
after_failure: &integration_test_diags after_failure: &integration_test_diags
- for v in ~/shared/logs/*.log ; do - for v in ~/shared/logs/*.log ; do
echo $v logtail ======================== ; tail -100 $v ; echo $v logtail ======================== ; tail -100 $v ;

View File

@ -19,9 +19,9 @@
[![Slack](https://img.shields.io/badge/slack-%23druid-72eff8?logo=slack)](https://druid.apache.org/community/join-slack) [![Slack](https://img.shields.io/badge/slack-%23druid-72eff8?logo=slack)](https://druid.apache.org/community/join-slack)
[![Build Status](https://travis-ci.org/apache/incubator-druid.svg?branch=master)](https://travis-ci.org/apache/incubator-druid) [![Build Status](https://travis-ci.org/apache/incubator-druid.svg?branch=master)](https://travis-ci.org/apache/incubator-druid)
[![Coverage Status](https://coveralls.io/repos/github/apache/incubator-druid/badge.svg?branch=master)](https://coveralls.io/github/apache/incubator-druid?branch=master)
<!--- Following badges are disabled until they can be fixed: --> <!--- Following badges are disabled until they can be fixed: -->
<!--- [![Inspections Status](https://img.shields.io/teamcity/http/teamcity.jetbrains.com/s/OpenSourceProjects_Druid_Inspections.svg?label=TeamCity%20inspections)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=OpenSourceProjects_Druid_Inspections) --> <!--- [![Inspections Status](https://img.shields.io/teamcity/http/teamcity.jetbrains.com/s/OpenSourceProjects_Druid_Inspections.svg?label=TeamCity%20inspections)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=OpenSourceProjects_Druid_Inspections) -->
<!-- [![Coverage Status](https://coveralls.io/repos/apache/incubator-druid/badge.svg?branch=master)](https://coveralls.io/r/apache/incubator-druid?branch=master) -->
## Apache Druid (incubating) ## Apache Druid (incubating)

View File

@ -215,6 +215,9 @@
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{jacocoArgLine}</argLine>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>

View File

@ -344,12 +344,10 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<systemProperties> <argLine>
<property> @{jacocoArgLine}
<name>java.library.path</name> -Djava.library.path=${project.build.directory}/hyperic-sigar-${sigar.base.version}/sigar-bin/lib/
<value>${project.build.directory}/hyperic-sigar-${sigar.base.version}/sigar-bin/lib/</value> </argLine>
</property>
</systemProperties>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

50
pom.xml
View File

@ -974,13 +974,38 @@
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.jacoco</groupId>
<artifactId>cobertura-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<configuration>
<excludes>
<!-- Ignore generated code -->
<exclude>org/apache/druid/math/expr/antlr/Expr*</exclude> <!-- core -->
<exclude>org/apache/druid/**/generated/*Benchmark*</exclude> <!-- benchmarks -->
<exclude>org/apache/druid/data/input/influx/InfluxLineProtocol*</exclude> <!-- extensions-contrib/influx-extensions -->
<!-- Ignore non-production code -->
<exclude>org/apache/druid/**/*Benchmark.*</exclude> <!-- benchmarks -->
<exclude>org/testng/DruidTestRunnerFactory*</exclude> <!-- benchmarks -->
<exclude>org/apache/druid/testing/**/*</exclude> <!-- integration-tests -->
</excludes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacocoArgLine</propertyName>
</configuration>
</execution>
</executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.eluder.coveralls</groupId> <groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId> <artifactId>coveralls-maven-plugin</artifactId>
<version>4.0.0</version> <version>4.3.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -1244,6 +1269,7 @@
<!-- locale settings must be set on the command line before startup --> <!-- locale settings must be set on the command line before startup -->
<!-- set default options --> <!-- set default options -->
<argLine> <argLine>
@{jacocoArgLine}
-Xmx1500m -Xmx1500m
-XX:MaxDirectMemorySize=512m -XX:MaxDirectMemorySize=512m
-Duser.language=en -Duser.language=en
@ -1352,24 +1378,6 @@
<excludePackageNames>org.apache.hadoop.fs</excludePackageNames> <excludePackageNames>org.apache.hadoop.fs</excludePackageNames>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<instrumentation>
<ignores>
<ignore>org.apache.druid.sql.antlr4.*</ignore>
</ignores>
<excludes>
<exclude>org/apache/druid/sql/antlr4/**/*.class</exclude>
</excludes>
</instrumentation>
<format>xml</format>
<!-- aggregated reports for multi-module projects -->
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>

View File

@ -208,6 +208,7 @@
<!-- locale settings must be set on the command line before startup --> <!-- locale settings must be set on the command line before startup -->
<!-- set default options --> <!-- set default options -->
<argLine> <argLine>
@{jacocoArgLine}
-Xmx512m -Xmx512m
-XX:MaxDirectMemorySize=2500m -XX:MaxDirectMemorySize=2500m
-Duser.language=en -Duser.language=en