From 6fa22f6939d739170146e766d9c26ec3697a3184 Mon Sep 17 00:00:00 2001 From: Chi Cao Minh Date: Tue, 20 Aug 2019 15:36:19 -0700 Subject: [PATCH] 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 --- .travis.yml | 44 ++++++++++++++++++++++++---------------- README.md | 2 +- benchmarks/pom.xml | 3 +++ core/pom.xml | 10 ++++------ pom.xml | 50 +++++++++++++++++++++++++++------------------- processing/pom.xml | 1 + 6 files changed, 65 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index af1378adffc..57471446746 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,35 +40,36 @@ env: -Dpmd.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 # 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. -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: include: - name: "java 11 build" jdk: openjdk11 - script: $MVN test -pl '!web-console' ${MAVEN_SKIP} + script: ${MVN} test -pl '!web-console' ${MAVEN_SKIP} - name: "animal sniffer checks" - script: $MVN animal-sniffer:check --fail-at-end + script: ${MVN} animal-sniffer:check --fail-at-end - name: "checkstyle" - script: $MVN checkstyle:checkstyle --fail-at-end + script: ${MVN} checkstyle:checkstyle --fail-at-end - name: "enforcer checks" - script: $MVN enforcer:enforce --fail-at-end + script: ${MVN} enforcer:enforce --fail-at-end - 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" - 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" - script: $MVN spotbugs:check --fail-at-end -pl '!benchmarks' + script: ${MVN} spotbugs:check --fail-at-end -pl '!benchmarks' - name: "license checks" install: skip @@ -78,7 +79,7 @@ matrix: - pip3 install pyyaml 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 -Drat.consoleOutput=true # Generate dependency reports and checks they are valid. When running on Travis CI, 2 cores are available @@ -91,15 +92,15 @@ matrix: install: skip # Strict compilation requires more than 2 GB script: > - MAVEN_OPTS='-Xmx3000m' $MVN clean -Pstrict compile test-compile --fail-at-end - -pl '!benchmarks' ${MAVEN_SKIP} -DskipTests + MAVEN_OPTS='-Xmx3000m' ${MVN} clean -Pstrict compile test-compile --fail-at-end + -pl '!benchmarks' ${MAVEN_SKIP} ${MAVEN_SKIP_TESTS} - name: "packaging check" install: skip before_script: *setup_generate_license script: > - MAVEN_OPTS='-Xmx3000m' $MVN clean install -Pdist -Pbundle-contrib-exts --fail-at-end - -pl '!benchmarks' ${MAVEN_SKIP} -DskipTests -Ddruid.console.skip=false -T1C + MAVEN_OPTS='-Xmx3000m' ${MVN} clean install -Pdist -Pbundle-contrib-exts --fail-at-end + -pl '!benchmarks' ${MAVEN_SKIP} ${MAVEN_SKIP_TESTS} -Ddruid.console.skip=false -T1C - name: "processing module test" env: &processing_env @@ -110,10 +111,12 @@ matrix: # Set MAVEN_OPTS for Surefire launcher. Skip remoteresources to avoid intermittent connection timeouts when # 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 - sh -c "dmesg | egrep -i '(oom|out of memory|kill process|killed).*' -C 1 || exit 0" - free -m + after_success: &upload_java_unit_test_coverage + - ${MVN} -pl ${MAVEN_PROJECTS} jacoco:report coveralls:report - name: "processing module test (SQL Compatibility)" env: *processing_env @@ -122,54 +125,61 @@ matrix: # Set MAVEN_OPTS for Surefire launcher. Skip remoteresources to avoid intermittent connection timeouts when # 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 - sh -c "dmesg | egrep -i '(oom|out of memory|kill process|killed).*' -C 1 || exit 0" - free -m + after_success: *upload_java_unit_test_coverage - name: "indexing modules test" env: &indexing_env - MAVEN_PROJECTS='indexing-hadoop,indexing-service,extensions-core/kafka-indexing-service,extensions-core/kinesis-indexing-service' before_script: *setup_java_test script: *run_java_test + after_success: *upload_java_unit_test_coverage - name: "indexing modules test (SQL Compatibility)" env: *indexing_env before_script: *setup_java_test script: *run_java_sql_compat_test + after_success: *upload_java_unit_test_coverage - name: "server module test" env: &server_env - MAVEN_PROJECTS='server' before_script: *setup_java_test script: *run_java_test + after_success: *upload_java_unit_test_coverage - name: "server module test (SQL Compatibility)" env: *server_env before_script: *setup_java_test script: *run_java_sql_compat_test + after_success: *upload_java_unit_test_coverage - name: "other modules test" env: &other_env - 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 script: *run_java_test + after_success: *upload_java_unit_test_coverage - name: "other modules test (SQL Compatibility)" env: *other_env before_script: *setup_java_test script: *run_java_sql_compat_test + after_success: *upload_java_unit_test_coverage - name: "web console" script: - - $MVN test -pl 'web-console' + - ${MVN} test -pl 'web-console' - name: "batch index integration test" services: &integration_test_services - docker env: TESTNG_GROUPS='-Dgroups=batch-index' 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 - for v in ~/shared/logs/*.log ; do echo $v logtail ======================== ; tail -100 $v ; diff --git a/README.md b/README.md index 1a1f147cd05..767fbe24e4e 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ [![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) +[![Coverage Status](https://coveralls.io/repos/github/apache/incubator-druid/badge.svg?branch=master)](https://coveralls.io/github/apache/incubator-druid?branch=master) - ## Apache Druid (incubating) diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml index 37f657b0a96..9285d25f65f 100644 --- a/benchmarks/pom.xml +++ b/benchmarks/pom.xml @@ -215,6 +215,9 @@ maven-surefire-plugin + + @{jacocoArgLine} + diff --git a/core/pom.xml b/core/pom.xml index 776f5109869..edb9bdc8caa 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -344,12 +344,10 @@ org.apache.maven.plugins maven-surefire-plugin - - - java.library.path - ${project.build.directory}/hyperic-sigar-${sigar.base.version}/sigar-bin/lib/ - - + + @{jacocoArgLine} + -Djava.library.path=${project.build.directory}/hyperic-sigar-${sigar.base.version}/sigar-bin/lib/ + diff --git a/pom.xml b/pom.xml index 08b473df561..e57b81b1871 100644 --- a/pom.xml +++ b/pom.xml @@ -974,13 +974,38 @@ - org.codehaus.mojo - cobertura-maven-plugin + org.jacoco + jacoco-maven-plugin + 0.8.4 + + + + org/apache/druid/math/expr/antlr/Expr* + org/apache/druid/**/generated/*Benchmark* + org/apache/druid/data/input/influx/InfluxLineProtocol* + + + org/apache/druid/**/*Benchmark.* + org/testng/DruidTestRunnerFactory* + org/apache/druid/testing/**/* + + + + + prepare-agent + + prepare-agent + + + jacocoArgLine + + + org.eluder.coveralls coveralls-maven-plugin - 4.0.0 + 4.3.0 org.apache.maven.plugins @@ -1244,6 +1269,7 @@ + @{jacocoArgLine} -Xmx1500m -XX:MaxDirectMemorySize=512m -Duser.language=en @@ -1352,24 +1378,6 @@ org.apache.hadoop.fs - - org.codehaus.mojo - cobertura-maven-plugin - 2.7 - - - - org.apache.druid.sql.antlr4.* - - - org/apache/druid/sql/antlr4/**/*.class - - - xml - - true - - org.apache.maven.plugins maven-compiler-plugin diff --git a/processing/pom.xml b/processing/pom.xml index 5e29987724b..1fdff9081e0 100644 --- a/processing/pom.xml +++ b/processing/pom.xml @@ -208,6 +208,7 @@ + @{jacocoArgLine} -Xmx512m -XX:MaxDirectMemorySize=2500m -Duser.language=en