gnodet opened a new pull request, #23175:
URL: https://github.com/apache/camel/pull/23175
## Summary
Fix 10 flaky tests in `camel-core` and `camel-management` by replacing
`Thread.sleep()` with Awaitility, increasing tight timeouts, and fixing
ordering assumptions on async routes.
## Changes by test
| # | Test | Root Cause | Fix |
|---|---|---|---|
| 1 | `FileConsumeAlterFileNameHeaderIssueTest` | File consumer reads
partially-written files (`initialDelay=0`); file move/delete assertion races
I/O | Increase `initialDelay` to 500ms; wrap file existence assertions with
Awaitility |
| 2 | `DurationRoutePolicyFactoryTest` | `maxSeconds=2` too tight — context
startup consumes time, fewer messages arrive | Increase `maxSeconds` to 4;
Awaitility `atMost` 10→15s |
| 3 | `ManagedAThrottlerTest` | Throttle delay 250ms × 10 msgs ≈ 2.5s;
`NotifyBuilder` 5s timeout too tight under load | Increase `NotifyBuilder`
timeout to 10s; wrap exchange count assertion with Awaitility |
| 4 | `MulticastParallelStreamingTest` | Assumes B (no delay) always
aggregates before A (500ms delay) — insufficient margin | Increase `direct:a`
delay to 2000ms |
| 5 | `OnCompletionBeforeChainedSedaRoutesTest` | Expects strict body
ordering across async seda boundaries | Use `expectedBodiesReceivedInAnyOrder` |
| 6 | `ResequenceStreamNotIgnoreInvalidExchangesTest` | Resequencer
`timeout=150ms` — messages arrive after timeout under load | Increase timeout
to 2000ms; `deliveryAttemptInterval` 10→100ms |
| 7 | `SagaTimeoutTest` | Saga `timeout=350ms` — processing exceeds timeout
under load, triggering unexpected compensation | Increase saga timeout to
2000ms; `resultWaitTime` 500→2000ms |
| 8 | `ThrottlingExceptionRoutePolicyHalfOpenHandlerSedaTest` |
`halfOpenAfter=250ms` too tight; Awaitility `atMost=2s` insufficient | Increase
`halfOpenAfter` to 1000ms; Awaitility `atMost` 2→5s |
| 9 | `ThrottlingExceptionRoutePolicyOpenViaConfigTest` | Uses
`Thread.sleep(3)` and `Thread.sleep(500)` for timing | Replace all
`Thread.sleep()` with Awaitility consumer state checks; add `routeId` |
| 10 | `ForegroundTimeTaskTest` | Budget `maxDuration=6500ms` for 6s ideal —
only 500ms margin | Increase `maxDuration` to 10000ms |
## Verification
Each test was run in a **100-iteration loop** before and after the fix to
demonstrate flakiness and stability.
### Pre-fix results (before this PR)
- **camel-core (9 tests):** **8 failures out of 100 iterations**
- `FileConsumeAlterFileNameHeaderIssueTest` (iter 55)
- `ForegroundTimeTaskTest` (iters 93, 94, 95, 96, 97, 99, 100)
- `DurationRoutePolicyFactoryTest` (iter 100)
- **camel-management (1 test):** **7 failures out of 100 iterations**
- `ManagedAThrottlerTest` (iters 76, 77, 78, 79, 80, 91, 92)
### Post-fix results (this PR)
- **camel-core (9 tests):** **0 failures out of 100 iterations**
- **camel-management (1 test):** **0 failures out of 100 iterations**
_Claude Code on behalf of Guillaume Nodet_
--
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]