gnodet opened a new pull request, #24443:
URL: https://github.com/apache/camel/pull/24443

   ## Summary
   
   _Claude Code on behalf of Guillaume Nodet_
   
   Replace all 10 `Thread.sleep(50)` calls in `MockEndpointTimeClauseTest` with 
Awaitility-based assertions, following the project's testing guidelines that 
prohibit `Thread.sleep()` in test code.
   
   ### Changes
   - Replace `Thread.sleep(50)` between message sends with `await().atMost(5, 
TimeUnit.SECONDS).until(() -> mock.getReceivedCounter() >= N)` to wait for 
message receipt with proper timeout
   - For tests with `between()` timing bounds that require a minimum 
inter-message gap, use `pollDelay(20, TimeUnit.MILLISECONDS)` to ensure 
sufficient delay for lower-bound assertions
   - Widen timing assertion upper bounds (`between(10, 500)` → `between(10, 
2000)`, `noLaterThan(250).millis()` → `noLaterThan(2).seconds()`) to prevent 
flakiness on slow CI systems
   - Replace the `Thread.sleep(50)` + try/catch inside the executor thread in 
`testAssertPeriodSecondMessageArrives` with a direct Awaitility wait for 
message receipt
   
   ### Why this prevents flakiness
   - `Thread.sleep(50)` is unreliable — on busy CI systems, it may sleep for 
much longer, causing tight timing assertions to fail
   - Awaitility provides deterministic synchronization: it waits until the mock 
endpoint has actually received the expected messages, rather than hoping a 
fixed sleep is sufficient
   - Widened upper bounds accommodate CI environments where GC pauses or thread 
scheduling delays can cause unexpected timing variations
   
   ## Test plan
   - [x] All 11 tests in `MockEndpointTimeClauseTest` pass locally
   - [x] Verified stability with 3 consecutive runs (0 failures)
   - [x] Code formatted with `mvn formatter:format impsort:sort`
   - [ ] CI passes
   
   JIRA: [CAMEL-23915](https://issues.apache.org/jira/browse/CAMEL-23915)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to