gnodet opened a new pull request, #30269:
URL: https://github.com/apache/camel/pull/30269
## Summary
Fix flaky test `ForegroundTimeTaskTest.testRunNoMorePredicateMaxDuration` by
relaxing the
overly strict exact-count assertion.
## Root Cause
The test configured a time budget of 1000ms with an interval of 200ms and
asserted
**exactly** 5 iterations. On slow CI, the time budget can expire before the
5th iteration
gets to execute, causing the test to fail with 3 or 4 iterations instead of
5.
The assertion `assertEquals(maxIterations, taskCount.intValue())` has two
problems:
1. It confuses `maxIterations` from `TaskTestSupport` (5) with the iteration
cap in the
budget (50). The test's intent is to prove the **time budget** stops the
task, not the
iteration cap.
2. An exact count is inherently racy on loaded CI — elapsed time per
iteration is not fixed.
## Fix
Replace the exact-count assertion with a range check:
```java
assertTrue(count >= 1 && count < 50,
"Expected task to be stopped by time budget (ran " + count + "
iterations)");
```
This correctly validates the actual intent: the task ran at least once and
was stopped
by the time budget (count < 50 iteration cap), regardless of how many
iterations fit
in 1000ms on a given machine.
## Tests
All 7 tests in `ForegroundTimeTaskTest` pass locally.
Fixes CAMEL-27108
---
_Hermes Agent (Claude Sonnet 4.6) 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]