Fix flaky XACompletionTest by adding wait for async states#1862
Conversation
jbonofre
left a comment
There was a problem hiding this comment.
LGTM, I have just 2 suggestions for you.
| resource.recover(XAResource.TMSTARTRSCAN); | ||
| resource.recover(XAResource.TMNOFLAGS); | ||
|
|
||
| Wait.waitFor(() -> proxy.getInFlightCount() == 0L && proxy.cursorSize() == 0); |
There was a problem hiding this comment.
I suggest to wrap Watit.waitFor() in a assertTrue for better diagnostics on failure:
| Wait.waitFor(() -> proxy.getInFlightCount() == 0L && proxy.cursorSize() == 0); | |
| assertTrue("Timed out waiting for inFlight and cursor to clear", | |
| Wait.waitFor(() -> proxy.getInFlightCount() == 0L && proxy.cursorSize() == 0)); |
There was a problem hiding this comment.
The wait condition doesn't cover getQueueSize(). The wait checks getInFlightCount() == 0 && cursorSize() == 0, but the very next assertion also checks getQueueSize() == 10.
If getQueueSize() is also subject to async updates, it could still flake.
Worth considering whether to include it in the wait condition.
There was a problem hiding this comment.
Good point — thanks for calling that out.
I initially assumed that inFlightCount == 0 would imply the queue state (including queueSize) had fully settled. I've updated the wait condition to include getQueueSize()
e87d689 to
6c7cab0
Compare
|
Thanks @jbonofre for feedback! I updated the pr with suggested changes. |
|
@gurpartap3697 good job ! I will merge as soon as CI is green. |
XACompletionTest.testStatsAndBrowseAfterAckPreparedRolledback was failing intermittently:
ref: https://github.com/apache/activemq/actions/runs/23623154131/job/68806975829
The test relied on immediate JMX state, which is asynchronous and can lead to flakiness.