Changing test set-up timing
runs before the spring-data instrumentation is enabled.
Switching to more explicitly set-up code to change the timing; however, this change doesn't enabled spring-data instrumentation to keep this non-functional.
MODIFY
dd-java-agent/instrumentation/elasticsearch/transport-5.3/src/test/groovy/springdata/Elasticsearch53SpringRepositoryTest.groovy
dd-java-agent/instrumentation/elasticsearch/transport-5.3/src/test/groovy/springdata/Elasticsearch53SpringRepositoryTest.groovy
@@ -12,22 +12,43 @@ import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
@RetryOnFailure(times = 3, delaySeconds = 1)
class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
- @Shared
- ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Config)
+ static def repo
- @Shared
- DocRepository repo = applicationContext.getBean(DocRepository)
+ def createRepo() {
+ def applicationContext
+ def repo
- def setup() {
+ runUnderTrace("createRepo") {
+ applicationContext = new AnnotationConfigApplicationContext(Config)
+ repo = applicationContext.getBean(DocRepository)
+ }
+ // NodeStatsAction
+ // IndicesExistAction
+ // IndexAction
+ // RefreshAction
+ TEST_WRITER.waitForTraces(1)
TEST_WRITER.clear()
+
+ return repo
+ }
+
+ def setupRepo() {
+ if (repo == null) {
+ repo = createRepo()
+ }
+
runUnderTrace("delete") {
repo.deleteAll()
}
TEST_WRITER.waitForTraces(1)
TEST_WRITER.clear()
+
+ return repo
}
def "test empty repo"() {
+ def repo = setupRepo()
+
when:
def result = repo.findAll()
@@ -62,6 +83,8 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
}
def "test CRUD"() {
+ def repo = setupRepo()
+
when:
def doc = new Doc()

MODIFY
dd-java-agent/instrumentation/elasticsearch/transport-5.3/transport-5.3.gradle
dd-java-agent/instrumentation/elasticsearch/transport-5.3/transport-5.3.gradle
@@ -35,6 +35,7 @@ dependencies {
testCompile project(':dd-java-agent:instrumentation:apache-httpasyncclient-4')
testCompile project(':dd-java-agent:instrumentation:netty-4.1')
+ // testCompile project(':dd-java-agent:instrumentation:spring-data-1.9')
testCompile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
testCompile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'

Changing test set-up timing

@Shared runs before the spring-data instrumentation is enabled.

Switching to more explicitly set-up code to change the timing; however, this change doesn't enabled spring-data instrumentation to keep this non-functional.