Skip to content
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
b51891f
Update AgentTestRunner to use JUnit5
nikita-tkachenko-datadog Aug 1, 2025
fb23244
Fix iast and appsec test fixtures classpath
nikita-tkachenko-datadog Aug 1, 2025
6195dc7
Fix agent-testing tests
nikita-tkachenko-datadog Aug 8, 2025
dadece6
Fix IAST tests
nikita-tkachenko-datadog Aug 8, 2025
6bd53b0
Fix Jetty tests
nikita-tkachenko-datadog Aug 8, 2025
ee37411
Fix IAST tests
nikita-tkachenko-datadog Aug 8, 2025
cc364ab
Fix servlet tests
nikita-tkachenko-datadog Aug 8, 2025
952eb06
Fix log4j2 tests
nikita-tkachenko-datadog Aug 8, 2025
6a5561f
Fix Jetty tests
nikita-tkachenko-datadog Aug 8, 2025
8e7b825
Fix log4j2 tests
nikita-tkachenko-datadog Aug 8, 2025
96285e4
Removed a file committed accidentally
nikita-tkachenko-datadog Aug 8, 2025
b37d536
Minor cleanups
nikita-tkachenko-datadog Aug 8, 2025
b3600f1
Split CI Visibility test fixtures into a separate project
nikita-tkachenko-datadog Aug 8, 2025
1285825
Fix Appsec tests
nikita-tkachenko-datadog Aug 8, 2025
90ff66f
Fix tests after rebase conflicts
nikita-tkachenko-datadog Sep 1, 2025
092091e
Fix tests after rebase
nikita-tkachenko-datadog Sep 1, 2025
6f45038
Fix a SpotBugs warning
nikita-tkachenko-datadog Sep 1, 2025
3df713f
Remove instrumentation-testing dependency from Gradle and Maven smoke…
nikita-tkachenko-datadog Sep 1, 2025
e09ea5c
Fix compilation error
nikita-tkachenko-datadog Sep 1, 2025
cc30b04
Fix Iast tests
sarahchen6 Aug 21, 2025
d0e2740
Fix servlet/request-2 test
sarahchen6 Aug 28, 2025
7c2ec00
Fix instrumentation test
sarahchen6 Aug 22, 2025
f582dc8
Fix jetty test
sarahchen6 Aug 27, 2025
f4c259a
Give more time for aws sqs, kafka, and vertx tests
sarahchen6 Aug 27, 2025
17f661b
Run latestDepJava11Test on Java 11 only
sarahchen6 Aug 28, 2025
2b923ec
Fix vertx-web tests
sarahchen6 Aug 28, 2025
f8e440a
Fix play-ws tests
sarahchen6 Aug 28, 2025
4cf11b4
Address codenarc issue
sarahchen6 Aug 28, 2025
70ff95a
Loosen exception expectations for PlayWS only
sarahchen6 Aug 28, 2025
bea85ff
Do not run Karate test samples: they're only needed as inputs for ins…
nikita-tkachenko-datadog Sep 1, 2025
e602a2d
Restore super. method calls erroneously replaced with Object. during …
nikita-tkachenko-datadog Sep 1, 2025
2a5479b
Restore formatting
nikita-tkachenko-datadog Sep 1, 2025
b5f73cf
Suppress CIVis warning
sarahchen6 Aug 28, 2025
ef9f98d
Reset classloader matcher's cached state before each instrumentation …
nikita-tkachenko-datadog Sep 2, 2025
6fb4423
Do not load test classes with bootstrap classloader (fixes ExceptionH…
nikita-tkachenko-datadog Sep 2, 2025
4459ff3
Fix bootstrap class check to correctly handle classes whose names end…
nikita-tkachenko-datadog Sep 2, 2025
0ee9943
Evaluate isTest check lazily to avoid overhead
nikita-tkachenko-datadog Sep 2, 2025
dacb913
Extract common code in a utility method
nikita-tkachenko-datadog Sep 2, 2025
73f4895
Add comments for extra test time
sarahchen6 Sep 2, 2025
57315bd
Test jdbc latestdepjava11 on java 11+
sarahchen6 Sep 2, 2025
7ff7d47
Extract common code in a utility method
nikita-tkachenko-datadog Sep 3, 2025
0681bb5
Fix IAST tests
nikita-tkachenko-datadog Sep 3, 2025
11cb5b2
Import AgentTracer instead of FQN
nikita-tkachenko-datadog Sep 3, 2025
7836c1e
Rename AgentTestRunner and other instrumentation-testing classes + up…
nikita-tkachenko-datadog Sep 4, 2025
ef488c9
Merge branch 'master' into nikita-tkachenko/junit5-testing
nikita-tkachenko-datadog Sep 4, 2025
b281647
Rename now-redundant explicit JUnit 5 declaration for forkedTest tasks
nikita-tkachenko-datadog Sep 4, 2025
240ba4d
Rename instrumentation fixtures projects and add readme files
nikita-tkachenko-datadog Sep 4, 2025
f75a988
Restore original timeout for aws-java-sqs-1.0 forked tests
nikita-tkachenko-datadog Sep 4, 2025
95abf16
Restore original timeout for remaining tests
sarahchen6 Sep 4, 2025
94a3be7
Fix MakeTaintableInstrumentation instrumentation in pekko IAST tests
nikita-tkachenko-datadog Sep 4, 2025
679fa0c
Revert "Restore original timeout for remaining tests"
nikita-tkachenko-datadog Sep 4, 2025
c803820
Revert "Restore original timeout for aws-java-sqs-1.0 forked tests"
nikita-tkachenko-datadog Sep 4, 2025
70348ec
Propagate pekko IAST fix to latestDep tests as well
sarahchen6 Sep 4, 2025
450d944
Fix typo in readme
nikita-tkachenko-datadog Sep 5, 2025
65b8e63
Merge branch 'master' into nikita-tkachenko/junit5-testing
nikita-tkachenko-datadog Sep 8, 2025
42ed209
Cleanup gradle dependencies
nikita-tkachenko-datadog Sep 8, 2025
78ae232
Replace hamcrest matchers FQN with short name
nikita-tkachenko-datadog Sep 8, 2025
d9ddbc4
Remove redundant bootstrap prefixes copy
nikita-tkachenko-datadog Sep 8, 2025
525333c
Simplify isBootstrapClass method
nikita-tkachenko-datadog Sep 8, 2025
46cd888
Fix LLMOBS module dependencies
nikita-tkachenko-datadog Sep 8, 2025
ff52d3b
Merge branch 'master' into nikita-tkachenko/junit5-testing
nikita-tkachenko-datadog Sep 9, 2025
f88ddf8
Address review comments
nikita-tkachenko-datadog Sep 9, 2025
c50b95f
Remove redundant commit
nikita-tkachenko-datadog Sep 9, 2025
fd7a0d5
Use utility method instead of repeated code blocks
nikita-tkachenko-datadog Sep 9, 2025
42599ea
Fix compilation error after moving the files around
nikita-tkachenko-datadog Sep 9, 2025
c427898
Housekeeping: codeowners and coverage exclusions
nikita-tkachenko-datadog Sep 9, 2025
6b1df6f
Fix HTTPClientTest post refactoring
nikita-tkachenko-datadog Sep 9, 2025
36f5715
Clean up helper methods
sarahchen6 Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public final class Constants {
* packages which will be loaded on the bootstrap classloader
*
* <p>Updates should be mirrored in
* datadog.trace.agent.test.SpockRunner#BOOTSTRAP_PACKAGE_PREFIXES_COPY
* datadog.trace.agent.test.BootstrapClasspathSetup#BOOTSTRAP_PACKAGE_PREFIXES_COPY
*/
public static final String[] BOOTSTRAP_PACKAGE_PREFIXES = {
"datadog.slf4j",
Expand Down
18 changes: 6 additions & 12 deletions dd-java-agent/agent-ci-visibility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ buildscript {

plugins {
id 'com.gradleup.shadow'
id 'java-test-fixtures'
}

apply from: "$rootDir/gradle/java.gradle"
Expand All @@ -42,29 +41,24 @@ dependencies {
api libs.slf4j

implementation libs.bundles.asm
implementation group: 'org.jacoco', name: 'org.jacoco.core', version: '0.8.12'
implementation group: 'org.jacoco', name: 'org.jacoco.report', version: '0.8.12'
implementation group: 'org.jacoco', name: 'org.jacoco.core', version: '0.8.13'
implementation group: 'org.jacoco', name: 'org.jacoco.report', version: '0.8.13'

implementation project(':communication')
implementation project(':components:json')
implementation project(':internal-api')
implementation project(':internal-api:internal-api-9')

testImplementation project(":utils:test-utils")
testImplementation project(':dd-java-agent:testing')
testImplementation("com.google.jimfs:jimfs:1.1") // an in-memory file system for testing code that works with files

testImplementation libs.scala
testImplementation libs.kotlin

testFixturesApi project(':dd-java-agent:testing')
testFixturesApi project(':utils:test-utils')

testFixturesApi group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.1'
testFixturesApi group: 'org.freemarker', name: 'freemarker', version: '2.3.31'
testFixturesApi group: 'com.jayway.jsonpath', name: 'json-path', version: '2.8.0'
testFixturesApi group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.16.0'
testFixturesApi group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.9.6'
testFixturesApi group: 'org.xmlunit', name: 'xmlunit-core', version: '2.10.3'
testImplementation group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.1'
testImplementation group: 'org.freemarker', name: 'freemarker', version: '2.3.31'
testImplementation group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.9.6'

testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.9.2") // Required to update dependency lock files
}
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Since this actually a fixture, I would suggest to rename these project as fixture, e.g. :dd-java-agent:agent-ci-visibility:civisibility-instrumentation-fixture, (this goes for the other introduced projects)

Also, it might be useful to have a README here or some comment in the build.gradle why these do not use the java-test-fixtures plugin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a side note maybe we can craft a simple plugin similar to java-test-fixture, but for tailored for our needs, e.g. it would not automatically add itself to the testRuntimeClasspath.

In particular something that doesn't do

component.addVariantsFromConfiguration(feature.getRuntimeElementsConfiguration(), new JavaConfigurationVariantMapping("runtime", true, feature.getRuntimeClasspathConfiguration()));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After sleeping on it, I'm not sure that creating a plugin would bring much value there. So let's drop the idea of a custom plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed as suggested, and added README.md files explaining why we cannot use the testFixtures plugin instead of declaring separate projects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"

dependencies {
api project(':dd-java-agent:instrumentation-testing')
api project(':dd-java-agent:agent-ci-visibility:civisibility-testing')
}

Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import datadog.trace.civisibility.writer.ddintake.CiTestCycleMapperV1
import datadog.trace.common.writer.ListWriter
import datadog.trace.common.writer.RemoteMapper
import datadog.trace.core.DDSpan
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import org.msgpack.jackson.dataformat.MessagePackFactory

import java.lang.reflect.Method
Expand Down Expand Up @@ -288,6 +289,7 @@ abstract class CiVisibilityInstrumentationTest extends AgentTestRunner {
return true
}

@SuppressFBWarnings("UMAC_UNCALLABLE_METHOD_OF_ANONYMOUS_CLASS")
boolean waitForSpan(Predicate<DDSpan> predicate, long timeoutMillis) {
long deadline = System.currentTimeMillis() + timeoutMillis
synchronized (lock) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"

dependencies {
api project(':dd-java-agent:agent-ci-visibility')
api project(':dd-java-agent:testing')
api project(':utils:test-utils')

api group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.1'
api group: 'org.freemarker', name: 'freemarker', version: '2.3.31'
api group: 'com.jayway.jsonpath', name: 'json-path', version: '2.8.0'
api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.16.0'
api group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.9.6'
api group: 'org.xmlunit', name: 'xmlunit-core', version: '2.10.3'
}

Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ abstract class CiVisibilityTestUtils {
println "Expected JSON: $expectedJson"
println "Actual JSON: $actualJson"
}
throw new AssertionFailedError("Coverage report events mismatch", expectedJson, actualJson, e)
throw new AssertionFailedError("Expected and actual JSON mismatch", expectedJson, actualJson, e)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import datadog.trace.api.civisibility.config.TestFQN
import datadog.trace.api.civisibility.config.TestIdentifier
import datadog.trace.api.civisibility.config.TestMetadata
import datadog.trace.api.civisibility.telemetry.CiVisibilityMetricCollector
import datadog.trace.civisibility.CiVisibilityTestUtils
import freemarker.core.Environment
import freemarker.core.InvalidReferenceException
import freemarker.template.Template
import freemarker.template.TemplateException
import freemarker.template.TemplateExceptionHandler
import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import org.apache.commons.io.IOUtils
Expand Down Expand Up @@ -233,7 +237,7 @@ class ConfigurationApiImplTest extends Specification {
httpServer {
handlers {
prefix(path) {
def expectedRequestBody = CiVisibilityTestUtils.getFreemarkerTemplate(requestTemplate, requestData)
def expectedRequestBody = getFreemarkerTemplate(requestTemplate, requestData)

def response = response
try {
Expand All @@ -242,7 +246,7 @@ class ConfigurationApiImplTest extends Specification {
response.status(400).send(error.getMessage().bytes)
}

def responseBody = CiVisibilityTestUtils.getFreemarkerTemplate(responseTemplate, responseData).bytes
def responseBody = getFreemarkerTemplate(responseTemplate, responseData).bytes
def header = request.getHeader("Accept-Encoding")
def gzipSupported = header != null && header.contains("gzip")
if (gzipSupported) {
Expand Down Expand Up @@ -315,4 +319,37 @@ class ConfigurationApiImplTest extends Specification {
}
return bitSet
}

static final TemplateExceptionHandler SUPPRESS_EXCEPTION_HANDLER = new TemplateExceptionHandler() {
@Override
void handleTemplateException(TemplateException e, Environment environment, Writer writer) throws TemplateException {
if (e instanceof InvalidReferenceException) {
writer.write('"<VALUE_MISSING>"')
} else {
throw e
}
}
}

static final freemarker.template.Configuration FREEMARKER = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_30) { {
setClassLoaderForTemplateLoading(ConfigurationApiImplTest.classLoader, "")
setDefaultEncoding("UTF-8")
setTemplateExceptionHandler(SUPPRESS_EXCEPTION_HANDLER)
setLogTemplateExceptions(false)
setWrapUncheckedExceptions(true)
setFallbackOnNullLoopVariable(false)
setNumberFormat("0.######")
}
}

static String getFreemarkerTemplate(String templatePath, Map<String, Object> replacements, List<Map<?, ?>> replacementsSource = []) {
try {
Template coveragesTemplate = FREEMARKER.getTemplate(templatePath)
StringWriter coveragesOut = new StringWriter()
coveragesTemplate.process(replacements, coveragesOut)
return coveragesOut.toString()
} catch (Exception e) {
throw new RuntimeException("Could not get Freemarker template " + templatePath + "; replacements map: " + replacements + "; replacements source: " + replacementsSource, e)
}
}
}
5 changes: 2 additions & 3 deletions dd-java-agent/agent-iast/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import net.ltgt.gradle.errorprone.CheckSeverity
plugins {
id 'com.gradleup.shadow'
id 'me.champeau.jmh'
id 'java-test-fixtures'
id 'com.google.protobuf' version '0.8.18'
id 'net.ltgt.errorprone' version '3.1.0'
}
Expand Down Expand Up @@ -52,8 +51,8 @@ dependencies {
implementation libs.moshi
implementation libs.bundles.asm

testFixturesApi project(':dd-java-agent:testing')
testFixturesApi project(':utils:test-utils')
testImplementation project(':utils:test-utils')
testImplementation project(':dd-java-agent:agent-bootstrap')
testImplementation libs.bytebuddy
testImplementation('org.skyscreamer:jsonassert:1.5.1')
testImplementation libs.groovy.yaml
Expand Down
8 changes: 8 additions & 0 deletions dd-java-agent/agent-iast/iast-testing/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"

dependencies {
api project(':dd-java-agent:agent-iast')
api project(':dd-java-agent:instrumentation-testing')
api project(':utils:test-utils')
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ trait IastRequestContextPreparationTrait {
}

static void iastSystemCleanup() {
get().getSubscriptionService(RequestContextSlot.IAST).reset()
datadog.trace.bootstrap.instrumentation.api.AgentTracer.get().getSubscriptionService(RequestContextSlot.IAST).reset()
InstrumentationBridge.clearIastModules()
}

Expand Down Expand Up @@ -75,8 +75,8 @@ trait IastRequestContextPreparationTrait {

private static Logger withLogger(final String name) {
final logger = LoggerFactory.getLogger(name)
if (logger instanceof ch.qos.logback.classic.Logger) {
((ch.qos.logback.classic.Logger) logger).level = ch.qos.logback.classic.Level.DEBUG
if (logger instanceof Logger) {
((Logger) logger).level = ch.qos.logback.classic.Level.DEBUG
}
return logger
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.datadog.iast.test

import datadog.trace.api.iast.SourceTypes
import okhttp3.FormBody
import okhttp3.MediaType
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.FormBody
import org.hamcrest.Matchers
import spock.lang.IgnoreIf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ class TaintedObjectCollection {
} else if (obj instanceof Pattern) {
valueMatcher = Matchers.matchesPattern(obj)
} else {
valueMatcher = equalTo(obj)
valueMatcher = org.hamcrest.Matchers.equalTo(obj)
}
}

private static Matcher toMatcher(Object obj) {
if (obj instanceof Matcher) {
obj
} else if (obj instanceof Pattern) {
matchesPattern(obj)
org.hamcrest.Matchers.matchesPattern(obj)
} else if (obj == null) {
nullValue()
org.hamcrest.Matchers.nullValue()
} else {
equalTo(obj)
org.hamcrest.Matchers.equalTo(obj)
}
}

Expand All @@ -79,15 +79,15 @@ class TaintedObjectCollection {
}

void range(int start, int length, SourceMatcher source) {
ranges << new RangeMatcher(start, equalTo(length), source)
ranges << new RangeMatcher(start, org.hamcrest.Matchers.equalTo(length), source)
}

void range(int start, Matcher<Integer> length, SourceMatcher source) {
ranges << new RangeMatcher(start, length, source)
}

void range(SourceMatcher source) {
ranges << new RangeMatcher(0, greaterThan(0), source)
ranges << new RangeMatcher(0, org.hamcrest.Matchers.greaterThan(0), source)
}

@Override
Expand Down
12 changes: 12 additions & 0 deletions dd-java-agent/appsec/appsec-testing/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"

dependencies {
api project(':dd-java-agent:appsec')
api project(':dd-java-agent:instrumentation-testing')
api project(':utils:test-utils')
}

configurations.api {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
}
7 changes: 1 addition & 6 deletions dd-java-agent/appsec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import groovy.json.JsonSlurper
plugins {
id 'com.gradleup.shadow'
id 'me.champeau.jmh'
id 'java-test-fixtures'
}

apply from: "$rootDir/gradle/java.gradle"
Expand All @@ -26,11 +25,7 @@ dependencies {
testImplementation libs.logback.classic
testImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.16.0'

testFixturesApi project(':dd-java-agent:testing')
}

configurations.testFixturesApi {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
testImplementation project(':utils:test-utils')
}

shadowJar {
Expand Down
27 changes: 27 additions & 0 deletions dd-java-agent/instrumentation-testing/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply from: "$rootDir/gradle/java.gradle"

dependencies {
api libs.bytebuddy
api libs.bytebuddyagent
api libs.slf4j
api libs.bundles.spock
api libs.bundles.test.logging
api libs.guava

api project(':dd-java-agent:testing')

implementation project(':dd-java-agent:agent-debugger')

implementation 'org.junit.platform:junit-platform-runner:1.9.0'

testImplementation project(':utils:test-utils')
testImplementation project(':dd-java-agent:instrumentation:trace-annotation')

testImplementation group: 'cglib', name: 'cglib', version: '3.2.5'
// test instrumenting java 1.1 bytecode
testImplementation group: 'net.sf.jt400', name: 'jt400', version: '6.1'

// We have autoservices defined in test subtree, looks like we need this to be able to properly rebuild this
testAnnotationProcessor libs.autoservice.processor
testCompileOnly libs.autoservice.annotation
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import datadog.trace.agent.test.datastreams.RecordingDatastreamsPayloadWriter
import datadog.trace.agent.tooling.AgentInstaller
import datadog.trace.agent.tooling.InstrumenterModule
import datadog.trace.agent.tooling.TracerInstaller
import datadog.trace.agent.tooling.bytebuddy.matcher.ClassLoaderMatchers
import datadog.trace.agent.tooling.bytebuddy.matcher.GlobalIgnores
import datadog.trace.api.Config
import datadog.trace.api.DDSpanId
Expand Down Expand Up @@ -66,7 +67,7 @@ import net.bytebuddy.dynamic.DynamicType
import net.bytebuddy.utility.JavaModule
import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import org.junit.runner.RunWith
import org.junit.jupiter.api.extension.ExtendWith
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.spockframework.mock.MockUtil
Expand Down Expand Up @@ -107,7 +108,7 @@ import static datadog.trace.util.AgentThreadFactory.AgentThread.TASK_SCHEDULER
*/
// CodeNarc incorrectly thinks ".class" is unnecessary in @RunWith
@SuppressWarnings('UnnecessaryDotClass')
@RunWith(SpockRunner.class)
@ExtendWith(SpockExtension.class)
abstract class AgentTestRunner extends DDSpecification implements AgentBuilder.Listener {
private static final long TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(20)

Expand Down Expand Up @@ -462,6 +463,10 @@ abstract class AgentTestRunner extends DDSpecification implements AgentBuilder.L
spiedAgentSpan
}

// if a test enables the instrumentation it verifies,
// the cache needs to be recomputed taking into account that instrumentation's matchers
ClassLoaderMatchers.resetState()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I wonder if this make sense to move to the SpockExtension ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against moving it, but why do you think the extension is a better place?

Copy link
Contributor

@bric3 bric3 Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this was before splitting SpockExtension in two, maybe now InstrumentationSpecification. My reasoning behind is to group "problems" together.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is in the InstrumentationSpecification now :)

assert ServiceLoader.load(InstrumenterModule, AgentTestRunner.getClassLoader())
.iterator()
.hasNext(): "No instrumentation found"
Expand Down
Loading
Loading