Fix sporadic test failure (#28)
This commit is contained in:
parent
1f67af03ef
commit
2971fbe75a
|
@ -1,6 +1,7 @@
|
||||||
package springdata
|
package springdata
|
||||||
|
|
||||||
import com.anotherchrisberry.spock.extensions.retry.RetryOnFailure
|
import com.anotherchrisberry.spock.extensions.retry.RetryOnFailure
|
||||||
|
import datadog.opentracing.DDSpan
|
||||||
import datadog.trace.agent.test.AgentTestRunner
|
import datadog.trace.agent.test.AgentTestRunner
|
||||||
import datadog.trace.api.DDSpanTypes
|
import datadog.trace.api.DDSpanTypes
|
||||||
import datadog.trace.instrumentation.api.Tags
|
import datadog.trace.instrumentation.api.Tags
|
||||||
|
@ -34,13 +35,8 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
|
||||||
return repo
|
return repo
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_WRITER.clear()
|
|
||||||
runUnderTrace("setup") {
|
|
||||||
def applicationContext = new AnnotationConfigApplicationContext(Config)
|
def applicationContext = new AnnotationConfigApplicationContext(Config)
|
||||||
repo = applicationContext.getBean(DocRepository)
|
repo = applicationContext.getBean(DocRepository)
|
||||||
}
|
|
||||||
TEST_WRITER.waitForTraces(1)
|
|
||||||
TEST_WRITER.clear()
|
|
||||||
|
|
||||||
return repo
|
return repo
|
||||||
}
|
}
|
||||||
|
@ -68,6 +64,7 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
|
||||||
!result.iterator().hasNext()
|
!result.iterator().hasNext()
|
||||||
|
|
||||||
and:
|
and:
|
||||||
|
waitForTracesAndSortSpans(1)
|
||||||
assertTraces(1) {
|
assertTraces(1) {
|
||||||
trace(0, 2) {
|
trace(0, 2) {
|
||||||
span(0) {
|
span(0) {
|
||||||
|
@ -114,8 +111,31 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
|
||||||
repo.index(doc) == doc
|
repo.index(doc) == doc
|
||||||
|
|
||||||
and:
|
and:
|
||||||
assertTraces(1) {
|
waitForTracesAndSortSpans(2)
|
||||||
trace(0, 3) {
|
// need to normalize trace ordering since they are finished by different threads
|
||||||
|
if (TEST_WRITER[1][0].resourceName == "PutMappingAction") {
|
||||||
|
def tmp = TEST_WRITER[1]
|
||||||
|
TEST_WRITER[1] = TEST_WRITER[0]
|
||||||
|
TEST_WRITER[0] = tmp
|
||||||
|
}
|
||||||
|
assertTraces(2) {
|
||||||
|
trace(0, 1) {
|
||||||
|
span(0) {
|
||||||
|
serviceName "elasticsearch"
|
||||||
|
resourceName "PutMappingAction"
|
||||||
|
operationName "elasticsearch.query"
|
||||||
|
spanType DDSpanTypes.ELASTICSEARCH
|
||||||
|
tags {
|
||||||
|
"$Tags.COMPONENT" "elasticsearch-java"
|
||||||
|
"$Tags.DB_TYPE" "elasticsearch"
|
||||||
|
"$Tags.SPAN_KIND" Tags.SPAN_KIND_CLIENT
|
||||||
|
"elasticsearch.action" "PutMappingAction"
|
||||||
|
"elasticsearch.request" "PutMappingRequest"
|
||||||
|
defaultTags()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trace(1, 3) {
|
||||||
span(0) {
|
span(0) {
|
||||||
resourceName "ElasticsearchRepository.index"
|
resourceName "ElasticsearchRepository.index"
|
||||||
operationName "repository.operation"
|
operationName "repository.operation"
|
||||||
|
@ -174,6 +194,7 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
|
||||||
repo.findById("1").get() == doc
|
repo.findById("1").get() == doc
|
||||||
|
|
||||||
and:
|
and:
|
||||||
|
waitForTracesAndSortSpans(1)
|
||||||
assertTraces(1) {
|
assertTraces(1) {
|
||||||
trace(0, 2) {
|
trace(0, 2) {
|
||||||
span(0) {
|
span(0) {
|
||||||
|
@ -217,6 +238,7 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
|
||||||
repo.findById("1").get() == doc
|
repo.findById("1").get() == doc
|
||||||
|
|
||||||
and:
|
and:
|
||||||
|
waitForTracesAndSortSpans(2)
|
||||||
assertTraces(2) {
|
assertTraces(2) {
|
||||||
trace(0, 3) {
|
trace(0, 3) {
|
||||||
span(0) {
|
span(0) {
|
||||||
|
@ -309,6 +331,7 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
|
||||||
!repo.findAll().iterator().hasNext()
|
!repo.findAll().iterator().hasNext()
|
||||||
|
|
||||||
and:
|
and:
|
||||||
|
waitForTracesAndSortSpans(2)
|
||||||
assertTraces(2) {
|
assertTraces(2) {
|
||||||
trace(0, 3) {
|
trace(0, 3) {
|
||||||
span(0) {
|
span(0) {
|
||||||
|
@ -395,4 +418,17 @@ class Elasticsearch53SpringRepositoryTest extends AgentTestRunner {
|
||||||
where:
|
where:
|
||||||
indexName = "test-index"
|
indexName = "test-index"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def waitForTracesAndSortSpans(int number) {
|
||||||
|
TEST_WRITER.waitForTraces(number)
|
||||||
|
for (List<DDSpan> trace : TEST_WRITER) {
|
||||||
|
// need to normalize span ordering since they are finished by different threads
|
||||||
|
if (trace.size() > 1 && trace[1].operationName == "repository.operation") {
|
||||||
|
def tmp = trace[1]
|
||||||
|
trace[1] = trace[0]
|
||||||
|
trace[0] = tmp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue