From c1e21e328bb8f73b13190f9c084e989df5b6944a Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Fri, 7 Dec 2018 09:40:29 -0500 Subject: [PATCH] Small improvement for jms tests to hopefully make them more stable --- .../jms/src/test/groovy/SpringTemplateJMS1Test.groovy | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dd-java-agent/instrumentation/jms/src/test/groovy/SpringTemplateJMS1Test.groovy b/dd-java-agent/instrumentation/jms/src/test/groovy/SpringTemplateJMS1Test.groovy index f285d4de3f..8c53977778 100644 --- a/dd-java-agent/instrumentation/jms/src/test/groovy/SpringTemplateJMS1Test.groovy +++ b/dd-java-agent/instrumentation/jms/src/test/groovy/SpringTemplateJMS1Test.groovy @@ -26,7 +26,6 @@ class SpringTemplateJMS1Test extends AgentTestRunner { def setupSpec() { broker.start() final ActiveMQConnectionFactory connectionFactory = broker.createConnectionFactory() - final Connection connection = connectionFactory.createConnection() connection.start() session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE) @@ -59,11 +58,12 @@ class SpringTemplateJMS1Test extends AgentTestRunner { def "send and receive message generates spans"() { setup: Thread.start { - TEST_WRITER.waitForTraces(1) TextMessage msg = template.receive(destination) assert msg.text == messageText - // There's a chance this might be reported last, messing up the assertion. + // Make sure that first pair of send/receive traces has landed to simplify assertions + TEST_WRITER.waitForTraces(2) + template.send(msg.getJMSReplyTo()) { session -> template.getMessageConverter().toMessage("responded!", session) } @@ -74,6 +74,11 @@ class SpringTemplateJMS1Test extends AgentTestRunner { TEST_WRITER.waitForTraces(4) // Manually reorder if reported in the wrong order. + if (TEST_WRITER[1][0].operationName == "jms.produce") { + def producerTrace = TEST_WRITER[1] + TEST_WRITER[1] = TEST_WRITER[0] + TEST_WRITER[0] = producerTrace + } if (TEST_WRITER[3][0].operationName == "jms.produce") { def producerTrace = TEST_WRITER[3] TEST_WRITER[3] = TEST_WRITER[2]