Skip to content

Commit e3ef803

Browse files
bm1549devflow.devflow-routing-intake
andauthored
Fix JMS1 CLIENT_ACKNOWLEDGE flaky test with high scope iteration keep-alive (#10798)
Mark receiving messages with manual acknowledgement as @flaky for JMS1V1ForkedTest The TEMPORARY_TOPIC variant of this test has a race condition where the 3rd consumer trace can complete before acknowledge() is called, yielding 6 traces instead of the expected 5 at the first assertion point. This is inherent to the async nature of JMS message processing with TEMPORARY_TOPICs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Fix JMS1 CLIENT_ACKNOWLEDGE flaky test by tolerating early scope cleanup The "receiving messages from TEMPORARY_TOPIC with manual acknowledgement" test in JMS1V1ForkedTest was flaky because the scope iteration keep-alive cleanup (set to 1 second in tests) could finish the 3rd consumer span before acknowledge() was called, producing 6 traces instead of expected 5. Root cause: In the legacy context manager path, activateNext() schedules a root iteration scope cleanup. If this fires before the test's intermediate assertTraces(5) check, the 3rd consumer trace is already complete. Fix: Use assertTraces(5, true) for the intermediate assertion to tolerate additional traces. Also fix ListWriterAssert.ignoreAdditionalTraces to properly use >= instead of == for the size check, matching the behavior of the Java TraceAssertions class. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Fix JMS1 CLIENT_ACKNOWLEDGE flaky test with low scope iteration keep-alive Set SCOPE_ITERATION_KEEP_ALIVE to 1ms in the manual acknowledgement test so the 3rd consumer span is always cleaned up before assertion, making the test deterministic with assertTraces(6) instead of tolerating 5 or 6. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Retry CI after infrastructure failures Retry CI - ghcr.io connectivity issue ci: retrigger pipeline (infrastructure failures) fix: restore acknowledge() before assertTraces to fix timeout The 3rd consumer span needs acknowledge() to complete before assertTraces(6) can succeed. SCOPE_ITERATION_KEEP_ALIVE alone is not sufficient — the acknowledge triggers the span to finish. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> fix: restore two-phase assertion with high keep-alive to prevent flakiness Set SCOPE_ITERATION_KEEP_ALIVE to 10s to prevent early cleanup of the 3rd consumer span. This makes the test deterministic: - Phase 1: 5 traces (3rd consumer span still open, not yet acknowledged) - Phase 2: 6 traces (after receivedMessage3.acknowledge()) The original flakiness was caused by the default keep-alive being short enough that the 3rd consumer span sometimes got cleaned up before the first assertion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> ci: retrigger pipeline to resolve SSI infrastructure failures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent 1e2a36d commit e3ef803

File tree

1 file changed

+6
-2
lines changed
  • dd-java-agent/instrumentation/jms/javax-jms-1.1/src/test/groovy

1 file changed

+6
-2
lines changed

dd-java-agent/instrumentation/jms/javax-jms-1.1/src/test/groovy/JMS1Test.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import datadog.trace.agent.test.naming.VersionedNamingTestBase
77
import datadog.trace.api.Config
88
import datadog.trace.api.DDSpanTypes
99
import datadog.trace.api.Trace
10+
import datadog.trace.api.config.TracerConfig
1011
import datadog.trace.api.config.TraceInstrumentationConfig
1112
import datadog.trace.bootstrap.instrumentation.api.InstrumentationTags
1213
import datadog.trace.bootstrap.instrumentation.api.Tags
@@ -257,6 +258,9 @@ abstract class JMS1Test extends VersionedNamingTestBase {
257258

258259
def "receiving messages from #destinationType with manual acknowledgement"() {
259260
setup:
261+
// Use a long scope iteration keep-alive to prevent early cleanup of the 3rd
262+
// consumer span, ensuring exactly 5 traces before acknowledge (not 6).
263+
injectSysConfig(TracerConfig.SCOPE_ITERATION_KEEP_ALIVE, "10000")
260264
def destination = destinationType.create(session)
261265
def clientSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE)
262266
def producer = session.createProducer(destination)
@@ -276,7 +280,8 @@ abstract class JMS1Test extends VersionedNamingTestBase {
276280
receivedMessage1.text == messageText1
277281
receivedMessage2.text == messageText2
278282
receivedMessage3.text == messageText3
279-
// only two consume traces will be finished at this point
283+
// only two consume traces will be finished at this point because message 3
284+
// has not been acknowledged and the long keep-alive prevents early cleanup
280285
assertTraces(5) {
281286
producerTraceWithNaming(it, destination)
282287
producerTraceWithNaming(it, destination)
@@ -300,7 +305,6 @@ abstract class JMS1Test extends VersionedNamingTestBase {
300305
}
301306

302307
cleanup:
303-
receivedMessage3.acknowledge()
304308
producer.close()
305309
consumer.close()
306310
clientSession.close()

0 commit comments

Comments
 (0)