Fix flaky spring jms test (#3336)

This commit is contained in:
Lauri Tulmin 2021-06-16 15:37:09 +03:00 committed by GitHub
parent 3e28b01e42
commit f77e8457fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -5,6 +5,8 @@
import static Jms2Test.consumerSpan
import static Jms2Test.producerSpan
import static io.opentelemetry.api.trace.SpanKind.CONSUMER
import static io.opentelemetry.api.trace.SpanKind.PRODUCER
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import javax.jms.ConnectionFactory
@ -18,14 +20,13 @@ class SpringListenerJms2Test extends AgentInstrumentationSpecification {
def context = new AnnotationConfigApplicationContext(Config)
def factory = context.getBean(ConnectionFactory)
def template = new JmsTemplate(factory)
// TODO(anuraaga): There is no defined order between when JMS starts receiving and our attempt
// to send/receive. Sleep a bit to let JMS start to receive first. Ideally, we would not have
// an ordering constraint in our assertTraces for when there is no defined ordering like this
// test case.
template.convertAndSend("SpringListenerJms2", "a message")
expect:
assertTraces(2) {
traces.sort(orderByRootSpanKind(CONSUMER, PRODUCER))
trace(0, 1) {
consumerSpan(it, 0, "queue", "SpringListenerJms2", "", null, "receive")
}