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

   # Description
   
   Part of [CAMEL-25891](https://issues.apache.org/jira/browse/CAMEL-25891) 
(shorten the build of `camel-spring-xml`, see the discussion in #28303). Third 
step after two merged PRs:
   
   1. #29515: make the tests safe to run in parallel in the same JVM
   2. #29518: SEDA consumers poll faster in tests created with 
`SpringTestHelper`
   3. this PR: do the same for all the other tests, which #29518 could not reach
   
   ## Problem
   
   A seda consumer blocks in `queue.poll(pollTimeout)` (1000 ms by default) and 
stopping a `CamelContext` waits for the consumer thread to leave that poll. A 
test stopping a context with seda routes therefore spends up to a second per 
route in its shutdown, e.g. `shutdown in 1s0ms` for `ErrorHandlerTest`.
   
   `ContextTestSupport` / `SpringTestSupport` call `setDefaultPollTimeout(10)` 
on the component and #29518 did the same in `SpringTestHelper`. This cannot 
work for the ~186 tests extending `SpringTestSupport` (and the others building 
their context from a Spring XML): their `CamelContext` is started when the 
Spring context is refreshed, so the seda endpoints are created, with the 
default of 1000 ms, before `createCamelContext()` gets the component. A probe 
on `errorHandler.xml` confirmed it: the component default was `10` but the 
endpoint `pollTimeout` was `1000`.
   
   I also tried not to start the context during the refresh (`setNoStart`), but 
it breaks the tests relying on the start with the Spring refresh event 
(`EventRouteTest`, `MistypedPackageTest`, ... 12 failures), so this is not an 
option.
   
   ## Change
   
   Register in the test resources a `seda` component whose default poll timeout 
is 10 ms (`FastPollSedaComponent` + 
`META-INF/services/org/apache/camel/component/seda`, which hides the one of 
`camel-seda`), so it is in place when the endpoints are created, whatever the 
way the context is started. The explicit `setDefaultPollTimeout(10)` calls in 
`SpringTestSupport` and `SpringTestHelper` are redundant and removed, to have a 
single place for this setting. Test code only.
   
   ## Measurements
   
   `camel-spring-xml`, 1186 tests, 4 forks, sequential, same machine, runs done 
one after the other (the noise between runs is about 10%):
   
   | | before | after |
   |---|---|---|
   | wall time | 106 s, 107 s | 93 s, 93 s |
   | total time of the context shutdowns | 54 s | 19 s |
   | context shutdowns taking >= 1 s | 36 (52 s) | 12 (17 s) |
   
   All tests pass. For reference, from the start of #28303's investigation 
(before #29518): 71 shutdowns >= 1 s, 120 s in total.
   
   ## Remaining
   
   12 shutdowns still take >= 1 s (17 s in total). They are mostly on the 1 s 
wait loop of `DefaultShutdownStrategy` when an exchange is still in flight at 
the stop (`SpringResequenceStreamRejectOldExchangesTest`, 
`SpringSamplingThrottlerTest`, `SpringThrottlingInflightRoutePolicyTest`, ...). 
That is not addressed here.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes. (formatter/impsort run on the 
module; test code only)
   
   # AI-assisted contributions
   
   - [x] This PR was prepared with IBM Bob 2.2.1 (AI agent); the commit has the 
`Co-authored-by` trailer.
   
   _IBM Bob 2.2.1 on behalf of @apupier. This description was AI-generated; 
please verify._
   


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