Skip to content

Commit 0dc63d7

Browse files
committed
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.
1 parent ec9e220 commit 0dc63d7

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

dd-java-agent/instrumentation/elasticsearch/transport-5.3/src/test/groovy/springdata/Elasticsearch53SpringRepositoryTest.groovy

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,43 @@ import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
1212

1313
@RetryOnFailure(times = 3, delaySeconds = 1)
1414
class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
15-
@Shared
16-
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Config)
15+
static def repo
1716

18-
@Shared
19-
DocRepository repo = applicationContext.getBean(DocRepository)
17+
def createRepo() {
18+
def applicationContext
19+
def repo
2020

21-
def setup() {
21+
runUnderTrace("createRepo") {
22+
applicationContext = new AnnotationConfigApplicationContext(Config)
23+
repo = applicationContext.getBean(DocRepository)
24+
}
25+
// NodeStatsAction
26+
// IndicesExistAction
27+
// IndexAction
28+
// RefreshAction
29+
TEST_WRITER.waitForTraces(1)
2230
TEST_WRITER.clear()
31+
32+
return repo
33+
}
34+
35+
def setupRepo() {
36+
if (repo == null) {
37+
repo = createRepo()
38+
}
39+
2340
runUnderTrace("delete") {
2441
repo.deleteAll()
2542
}
2643
TEST_WRITER.waitForTraces(1)
2744
TEST_WRITER.clear()
45+
46+
return repo
2847
}
2948

3049
def "test empty repo"() {
50+
def repo = setupRepo()
51+
3152
when:
3253
def result = repo.findAll()
3354

@@ -62,6 +83,8 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
6283
}
6384

6485
def "test CRUD"() {
86+
def repo = setupRepo()
87+
6588
when:
6689
def doc = new Doc()
6790

dd-java-agent/instrumentation/elasticsearch/transport-5.3/transport-5.3.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dependencies {
3535

3636
testCompile project(':dd-java-agent:instrumentation:apache-httpasyncclient-4')
3737
testCompile project(':dd-java-agent:instrumentation:netty-4.1')
38+
// testCompile project(':dd-java-agent:instrumentation:spring-data-1.9')
3839

3940
testCompile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
4041
testCompile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'

0 commit comments

Comments
 (0)