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

   _IBM Bob 2.2.1 on behalf of @apupier_
   
   JIRA: https://issues.apache.org/jira/browse/CAMEL-27280
   
   ## Problem
   
   `SimpleScheduledRoutePolicyTest$SimpleTest1.testScheduledStartRoutePolicy` 
is flaky in Develocity (about 500 flaky runs in 2 months) and fails with:
   
   ```
   ConditionTimeoutException: ... expected: <Started> but was: <Stopped> within 
5 seconds.
   ```
   
   ## Root cause
   
   The test started a route with `autoStartup=true`, then called 
`stopRoute("test")`, then awaited that the scheduled start brings it back to 
`Started`. The policy trigger fires at about +500ms and +1500ms after the route 
is built. `ScheduledRoutePolicy.onJobExecute(START)` only acts when the route 
is `Stopped`; on a `Started` route it does nothing. If the time between the 
route creation and the manual `stopRoute` exceeds the trigger delays (loaded CI 
machine), both firings are no-ops, the test stops the route, and nothing 
restarts it.
   
   Same cause as CAMEL-26378 (`Test1SpringScheduledRoutePolicyTest`, #30267).
   
   ## Reproduction
   
   - Running the old test 9 times with Maven pinned to 2 CPUs and 8 busy loops 
on the same CPUs: all passed (load alone did not reproduce it, as for 
CAMEL-26378).
   - Simulating the slow startup with a temporary `Thread.sleep(2000)` between 
`context.start()` and `stopRoute`: the old test failed 2 out of 2 runs with the 
exact error of the Develocity report.
   - With the fix, a temporary `Thread.sleep(4000)` after `context.start()` 
(longer than both trigger delays) no longer fails the test.
   
   ## Change
   
   - The route is declared with `autoStartup(false)` and the manual `stopRoute` 
is removed: the only way to get it `Started` is the scheduled start, whatever 
the startup duration.
   - The test asserts the route is `Stopped` right after `context.start()`.
   - The start date is moved from +500ms to +2000ms so that the `Stopped` 
assertion does not race the first trigger; it stays inside the 5s Awaitility 
timeout.
   
   Only test code changes. `SimpleScheduledRoutePolicyTest` passes (8 tests).


-- 
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