Apply jacoco to every java project
Some projects have ignores/whitelists, but generally coverage is pretty high. AFAIK, this doesn’t really capture instrumentation test coverage though.
This commit is contained in:
parent
7dfdc2d50e
commit
9a52303376
|
@ -53,7 +53,3 @@ tasks.withType(Test) {
|
||||||
parent.subprojects.collect { it.tasks.withType(Test) } each {
|
parent.subprojects.collect { it.tasks.withType(Test) } each {
|
||||||
test.shouldRunAfter it
|
test.shouldRunAfter it
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jacoco must be applied after the test javaagent config block above,
|
|
||||||
// otherwise the javaagent args conflict. (It's order dependent and added LIFO)
|
|
||||||
apply from: "${rootDir}/gradle/jacoco.gradle"
|
|
||||||
|
|
|
@ -5,6 +5,10 @@ plugins {
|
||||||
|
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
|
|
||||||
|
whitelistedInstructionClasses += whitelistedBranchClasses += [
|
||||||
|
'datadog.trace.bootstrap.*'
|
||||||
|
]
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':dd-trace-api')
|
compile project(':dd-trace-api')
|
||||||
compile deps.opentracing
|
compile deps.opentracing
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
|
|
||||||
|
whitelistedInstructionClasses += whitelistedBranchClasses += [
|
||||||
|
'datadog.trace.agent.tooling.*'
|
||||||
|
]
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':dd-java-agent:agent-bootstrap')
|
compile project(':dd-java-agent:agent-bootstrap')
|
||||||
compile deps.bytebuddy
|
compile deps.bytebuddy
|
||||||
|
|
|
@ -6,13 +6,8 @@ description = 'dd-java-agent'
|
||||||
|
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
apply from: "${rootDir}/gradle/publish.gradle"
|
apply from: "${rootDir}/gradle/publish.gradle"
|
||||||
apply from: "${rootDir}/gradle/jacoco.gradle"
|
|
||||||
jacocoTestReport.dependsOn ':dd-java-agent-ittests:test'
|
|
||||||
|
|
||||||
whitelistedInstructionClasses += whitelistedBranchClasses += [
|
jacocoTestReport.dependsOn ':dd-java-agent-ittests:test'
|
||||||
'datadog.agent.*',
|
|
||||||
'datadog.agent.decorators.*',
|
|
||||||
]
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Include subproject's shadowJar in the dd-java-agent jar.
|
* Include subproject's shadowJar in the dd-java-agent jar.
|
||||||
|
|
|
@ -15,6 +15,10 @@ subprojects { subProj ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
whitelistedInstructionClasses += whitelistedBranchClasses += [
|
||||||
|
'datadog.trace.instrumentation.*'
|
||||||
|
]
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile(project(':dd-java-agent:agent-tooling')) {
|
compile(project(':dd-java-agent:agent-tooling')) {
|
||||||
exclude module: ':dd-java-agent:agent-bootstrap'
|
exclude module: ':dd-java-agent:agent-bootstrap'
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
apply plugin: 'scala'
|
apply plugin: 'scala'
|
||||||
|
|
||||||
|
whitelistedInstructionClasses += whitelistedBranchClasses += [
|
||||||
|
'*'
|
||||||
|
]
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':dd-trace-api')
|
compile project(':dd-trace-api')
|
||||||
compile project(':dd-trace-ot')
|
compile project(':dd-trace-ot')
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
|
|
||||||
|
minimumBranchCoverage = 0.5
|
||||||
|
minimumInstructionCoverage = 0.6
|
||||||
|
whitelistedInstructionClasses += whitelistedBranchClasses += [
|
||||||
|
'datadog.trace.agent.test.*Assert',
|
||||||
|
'datadog.trace.agent.test.AgentTestRunner.1',
|
||||||
|
'datadog.trace.agent.test.TestUtils'
|
||||||
|
]
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile deps.bytebuddy
|
compile deps.bytebuddy
|
||||||
compile deps.bytebuddyagent
|
compile deps.bytebuddyagent
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
apply from: "${rootDir}/gradle/publish.gradle"
|
apply from: "${rootDir}/gradle/publish.gradle"
|
||||||
apply from: "${rootDir}/gradle/jacoco.gradle"
|
|
||||||
|
|
||||||
description = 'dd-trace-api'
|
description = 'dd-trace-api'
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -6,15 +6,12 @@ description = 'dd-trace-ot'
|
||||||
|
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
apply from: "${rootDir}/gradle/publish.gradle"
|
apply from: "${rootDir}/gradle/publish.gradle"
|
||||||
apply from: "${rootDir}/gradle/jacoco.gradle"
|
|
||||||
minimumBranchCoverage = 0.3
|
minimumBranchCoverage = 0.5
|
||||||
minimumInstructionCoverage = 0.5
|
minimumInstructionCoverage = 0.6
|
||||||
whitelistedInstructionClasses += whitelistedBranchClasses += [
|
whitelistedInstructionClasses += whitelistedBranchClasses += [
|
||||||
'datadog.opentracing.decorators.*',
|
'datadog.opentracing.decorators.*',
|
||||||
'datadog.trace.common.writer.ListWriter',
|
'datadog.trace.common.writer.ListWriter',
|
||||||
'datadog.trace.common.util.Clock',
|
|
||||||
'datadog.trace.api.DDTags',
|
|
||||||
'datadog.trace.common.util.ConfigUtils',
|
|
||||||
'datadog.trace.common.sampling.PrioritySampling'
|
'datadog.trace.common.sampling.PrioritySampling'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
package datadog.trace.common;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonValue;
|
|
||||||
|
|
||||||
public class Service {
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final String appName;
|
|
||||||
private final Service.AppType appType;
|
|
||||||
|
|
||||||
public Service(final String name, final String appName, final AppType appType) {
|
|
||||||
this.name = name;
|
|
||||||
this.appName = appName;
|
|
||||||
this.appType = appType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty("app")
|
|
||||||
public String getAppName() {
|
|
||||||
return appName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty("app_type")
|
|
||||||
public AppType getAppType() {
|
|
||||||
return appType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Service { "
|
|
||||||
+ "name='"
|
|
||||||
+ name
|
|
||||||
+ "\', appName='"
|
|
||||||
+ appName
|
|
||||||
+ "', appType="
|
|
||||||
+ appType
|
|
||||||
+ " }";
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum AppType {
|
|
||||||
WEB("web"),
|
|
||||||
DB("db"),
|
|
||||||
CUSTOM("custom"),
|
|
||||||
CACHE("cache"),
|
|
||||||
WORKER("worker");
|
|
||||||
|
|
||||||
private final String type;
|
|
||||||
|
|
||||||
AppType(final String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonValue
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,6 +7,7 @@ import datadog.opentracing.PendingTrace
|
||||||
import datadog.trace.common.writer.ListWriter
|
import datadog.trace.common.writer.ListWriter
|
||||||
import io.opentracing.Scope
|
import io.opentracing.Scope
|
||||||
import io.opentracing.Span
|
import io.opentracing.Span
|
||||||
|
import io.opentracing.noop.NoopSpan
|
||||||
import spock.lang.Specification
|
import spock.lang.Specification
|
||||||
import spock.lang.Subject
|
import spock.lang.Subject
|
||||||
import spock.lang.Unroll
|
import spock.lang.Unroll
|
||||||
|
@ -25,6 +26,21 @@ class ScopeManagerTest extends Specification {
|
||||||
scopeManager.tlsScope.remove()
|
scopeManager.tlsScope.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def "non-ddspan activation results in a simple scope"() {
|
||||||
|
when:
|
||||||
|
def scope = scopeManager.activate(NoopSpan.INSTANCE, true)
|
||||||
|
|
||||||
|
then:
|
||||||
|
scopeManager.active() == scope
|
||||||
|
scope instanceof SimpleScope
|
||||||
|
|
||||||
|
when:
|
||||||
|
scope.close()
|
||||||
|
|
||||||
|
then:
|
||||||
|
scopeManager.active() == null
|
||||||
|
}
|
||||||
|
|
||||||
def "threadlocal is empty"() {
|
def "threadlocal is empty"() {
|
||||||
setup:
|
setup:
|
||||||
def builder = tracer.buildSpan("test")
|
def builder = tracer.buildSpan("test")
|
||||||
|
|
|
@ -8,6 +8,25 @@ import spock.lang.Specification
|
||||||
|
|
||||||
class RateByServiceSamplerTest extends Specification {
|
class RateByServiceSamplerTest extends Specification {
|
||||||
|
|
||||||
|
def "invalid rate -> 1"() {
|
||||||
|
setup:
|
||||||
|
RateByServiceSampler serviceSampler = new RateByServiceSampler()
|
||||||
|
ObjectMapper serializer = new ObjectMapper()
|
||||||
|
String response = '{"rate_by_service": {"service:,env:":' + rate + '}}'
|
||||||
|
serviceSampler.onResponse("traces", serializer.readTree(response))
|
||||||
|
expect:
|
||||||
|
serviceSampler.baseSampler.sampleRate == expectedRate
|
||||||
|
|
||||||
|
where:
|
||||||
|
rate | expectedRate
|
||||||
|
null | 1
|
||||||
|
1 | 1
|
||||||
|
0 | 1
|
||||||
|
-5 | 1
|
||||||
|
5 | 1
|
||||||
|
0.5 | 0.5
|
||||||
|
}
|
||||||
|
|
||||||
def "rate by service name"() {
|
def "rate by service name"() {
|
||||||
setup:
|
setup:
|
||||||
RateByServiceSampler serviceSampler = new RateByServiceSampler()
|
RateByServiceSampler serviceSampler = new RateByServiceSampler()
|
||||||
|
|
|
@ -4,7 +4,6 @@ plugins {
|
||||||
|
|
||||||
apply plugin: 'application'
|
apply plugin: 'application'
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
apply from: "${rootDir}/gradle/jacoco.gradle"
|
|
||||||
|
|
||||||
version = 'demo'
|
version = 'demo'
|
||||||
description = 'dropwizard-mongo-client'
|
description = 'dropwizard-mongo-client'
|
||||||
|
|
|
@ -4,7 +4,6 @@ plugins {
|
||||||
|
|
||||||
apply plugin: 'application'
|
apply plugin: 'application'
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
apply from: "${rootDir}/gradle/jacoco.gradle"
|
|
||||||
|
|
||||||
version = 'demo'
|
version = 'demo'
|
||||||
description = 'rest-spark'
|
description = 'rest-spark'
|
||||||
|
|
|
@ -3,7 +3,6 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "${rootDir}/gradle/java.gradle"
|
apply from: "${rootDir}/gradle/java.gradle"
|
||||||
apply from: "${rootDir}/gradle/jacoco.gradle"
|
|
||||||
|
|
||||||
version = 'demo'
|
version = 'demo'
|
||||||
description = 'spring-boot-jdbc-redis'
|
description = 'spring-boot-jdbc-redis'
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
apply plugin: "jacoco"
|
apply plugin: "jacoco"
|
||||||
|
|
||||||
|
jacoco {
|
||||||
|
toolVersion = "0.8.0"
|
||||||
|
}
|
||||||
|
|
||||||
jacocoTestReport {
|
jacocoTestReport {
|
||||||
dependsOn test
|
dependsOn test
|
||||||
reports {
|
reports {
|
||||||
|
@ -9,11 +13,21 @@ jacocoTestReport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
project.ext.whitelistedBranchClasses = []
|
if (project.parent.hasProperty("whitelistedBranchClasses")) {
|
||||||
project.ext.whitelistedInstructionClasses = []
|
project.ext.whitelistedBranchClasses = parent.whitelistedBranchClasses
|
||||||
|
} else {
|
||||||
|
project.ext.whitelistedBranchClasses = []
|
||||||
|
}
|
||||||
|
|
||||||
project.ext.minimumBranchCoverage = 0.6
|
if (project.parent.hasProperty("whitelistedInstructionClasses")) {
|
||||||
project.ext.minimumInstructionCoverage = 0.6
|
project.ext.whitelistedInstructionClasses = parent.whitelistedInstructionClasses
|
||||||
|
} else {
|
||||||
|
project.ext.whitelistedInstructionClasses = []
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults can be overridden per project:
|
||||||
|
project.ext.minimumBranchCoverage = 0.9
|
||||||
|
project.ext.minimumInstructionCoverage = 0.9
|
||||||
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
jacocoTestCoverageVerification {
|
jacocoTestCoverageVerification {
|
||||||
|
|
|
@ -153,6 +153,7 @@ tasks.withType(Test) {
|
||||||
|
|
||||||
apply from: "$rootDir/gradle/checkstyle.gradle"
|
apply from: "$rootDir/gradle/checkstyle.gradle"
|
||||||
apply from: "$rootDir/gradle/codenarc.gradle"
|
apply from: "$rootDir/gradle/codenarc.gradle"
|
||||||
|
apply from: "$rootDir/gradle/jacoco.gradle"
|
||||||
|
|
||||||
plugins.withType(BasePlugin) {
|
plugins.withType(BasePlugin) {
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
|
|
Loading…
Reference in New Issue