Skip to content

Fix JMS test flakiness in JMSDestinationTest#2970

Open
gnodet wants to merge 1 commit intomainfrom
fix/jms-test-flakiness
Open

Fix JMS test flakiness in JMSDestinationTest#2970
gnodet wants to merge 1 commit intomainfrom
fix/jms-test-flakiness

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 13, 2026

Summary

  • Replace hardcoded Thread.sleep() calls with Awaitility-based polling where possible, and increase remaining sleep durations to accommodate CI environments under load
  • Fix testSessionsExceptionHandling where the sleep (4s) was shorter than the minimum required time (5 failures x 1s retry = 5s)
  • Use Awaitility to poll connectionsCreated counter in connection/session fault tests, and poll for broker connectivity after broker restart

Changes

Test Before After
testDurableSubscriber Thread.sleep(500) Thread.sleep(2000)
testMessageObserverExceptionHandling Thread.sleep(500) Thread.sleep(2000)
testTemporaryQueueDeletionUponReset atMost(1s) atMost(5s)
testConnectionFactoryExceptionHandling Thread.sleep(4000) Awaitility polling connectionsCreated
testBrokerExceptionHandling Thread.sleep(500) + Thread.sleep(2000) Thread.sleep(2000) + Awaitility broker connectivity poll + Thread.sleep(5000)
testSessionsExceptionHandling Thread.sleep(4000) (too short) Awaitility polling connectionsCreated >= 2

Test plan

  • mvn -B test -pl rt/transports/jms -Dtest=JMSDestinationTest passes (16 tests, 0 failures)
  • mvn -B validate -pl rt/transports/jms passes (no checkstyle/PMD violations)

🤖 Generated with Claude Code

Replace hardcoded Thread.sleep() calls in JMSDestinationTest with
Awaitility-based polling where possible, and increase remaining sleep
durations to accommodate CI environments under load.

- testDurableSubscriber: increase sleep from 500ms to 2000ms
- testMessageObserverExceptionHandling: increase sleep from 500ms to 2000ms
- testTemporaryQueueDeletionUponReset: increase Awaitility atMost from 1s to 5s
- testConnectionFactoryExceptionHandling: replace Thread.sleep(4000) with
  Awaitility polling on connectionsCreated counter
- testBrokerExceptionHandling: replace Thread.sleep(2000) with Awaitility
  polling for broker connectivity, plus additional reconnect wait
- testSessionsExceptionHandling: replace Thread.sleep(4000) with Awaitility
  polling on connectionsCreated counter (was shorter than 5x1000ms retry math)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant