This is an automated email from the ASF dual-hosted git repository.

apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new be51d147fc0c CAMEL-25891: Run the Spring XML throttler tests in 
ConcurrentRequests mode
be51d147fc0c is described below

commit be51d147fc0c593a302a46335d69455f3f0bda9d
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Tue Nov 10 09:57:54 2026 +0100

    CAMEL-25891: Run the Spring XML throttler tests in ConcurrentRequests mode
    
    Part of CAMEL-25891 (shorten the build of camel-spring-xml, see the
    discussion in #28303). Follows the merged #29515 (tests safe to run in
    parallel in one JVM) and #29518 (faster seda polling in SpringTestHelper),
    and is independent from the open #29553 (FastPollSedaComponent).
    
    Problem
    
    SpringThrottlerTest is the longest test class of camel-spring-xml (41 s of
    the module). It extends ConcurrentRequestsThrottlerTest from camel-core,
    whose Java routes all call .concurrentRequestsMode(), but the routes in
    throttler.xml had no mode attribute. The default mode is TotalRequests, 
which
    allows 1 request per second (timePeriodMillis=1000), so the Spring tests 
ran a
    different throttler than the one they are meant to test, and mostly waited
    for throttle periods (testConfigurationWithChangingHeaderExpression alone
    took 13 s, testFifo and testPermitReleaseOnException 7 s each).
    
    This dates back to CAMEL-20355 (commit 22151ef9e2a5), which added the
    throttling modes and renamed ConcurrentRequestsThrottleDefinition to
    ThrottleDefinition with TotalRequests as the default. It updated the Java
    test (and the Spring test classes) but not throttler.xml, nor
    ThrottlerGroupingTest.xml and ThrottlerMethodCallTest.xml, which have the
    same issue for their camel-core base classes 
(concurrent.ThrottlingGroupingTest
    and concurrent.ThrottlerMethodCallTest, also using 
.concurrentRequestsMode()).
    
    The Java base test also had one route without the mode: direct:release in
    ConcurrentRequestsThrottlerTest, so testPermitReleaseOnException took 7 s in
    camel-core as well (0.85 s once fixed).
    
    Change (test code only)
    
    - throttler.xml: mode="ConcurrentRequests" on the 6 <throttle> elements
    - ThrottlerGroupingTest.xml: mode="ConcurrentRequests" on the 5 elements
    - ThrottlerMethodCallTest.xml: mode="ConcurrentRequests" on the element
    - ConcurrentRequestsThrottlerTest (camel-core): .concurrentRequestsMode()
      on direct:release
    
    Measurements
    
    camel-spring-xml, 1186 tests (26 skipped, 0 failures), 4 forks, sequential,
    simulating the 4 vCPU CI with taskset -c 0-3, same machine, runs done one
    after the other (the noise between runs is about 10%). Both sides were
    measured on top of the FastPollSedaComponent of #29553, which is
    independent from this change.
    
      wall time:   before 112 s, 111 s    after 85 s, 82 s  (about -28 s, -25%)
    
      class time (surefire-reports):
        SpringThrottlerTest           41.1 s -> 6.2 s
        SpringThrottlerGroupingTest    8.5 s -> 1.4 s
        SpringThrottlerMethodCallTest            0.1 s
    
      SpringThrottlerTest methods (alone, 1 fork):
        testConfigurationWithChangingHeaderExpression 13.3 s -> 1.7 s
        testFifo                                       7.2 s -> 1.7 s
        testPermitReleaseOnException                   7.2 s -> 1.0 s
        the 3 other 4.2 s tests                        4.2 s -> 0.6 s
    
      camel-core ConcurrentRequestsThrottlerTest: testPermitReleaseOnException
      7.1 s -> 0.85 s, 7 tests pass.
    
    The absolute baseline is higher than the 93 s measured earlier for the same
    module (machine load), but the two baseline runs and the two runs with the
    change were taken next to each other and are consistent.
    
    Not addressed: SpringSamplingThrottlerTest (6 s), a sampling throttler where
    the mode does not apply. ConcurrentRequestsThrottlerTest is time-bound
    (@EnabledOnOs, CAMEL-21438), shorter waits should not make it more fragile
    as the assertions wait on the mocks, but it deserves a few repeated runs on 
CI.
    
    Co-authored-by: IBM Bob 2.2.1
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../apache/camel/spring/processor/ThrottlerGroupingTest.xml  | 10 +++++-----
 .../camel/spring/processor/ThrottlerMethodCallTest.xml       |  2 +-
 .../org/apache/camel/spring/processor/throttler.xml          | 12 ++++++------
 .../throttle/concurrent/ConcurrentRequestsThrottlerTest.java |  3 ++-
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/ThrottlerGroupingTest.xml
 
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/ThrottlerGroupingTest.xml
index d8a28cec2b9f..665541dac792 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/ThrottlerGroupingTest.xml
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/ThrottlerGroupingTest.xml
@@ -31,7 +31,7 @@
     <errorHandler id="dlc" deadLetterUri="mock:dead" type="DeadLetterChannel"/>
     <route errorHandlerRef="dlc">
       <from uri="seda:a"/>
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <header>max</header>
         <correlationExpression>
           <constant>1</constant>
@@ -43,7 +43,7 @@
     
     <route errorHandlerRef="dlc">
       <from uri="seda:b"/>
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <header>max</header>
         <correlationExpression>
           <constant>2</constant>
@@ -55,7 +55,7 @@
     
     <route errorHandlerRef="dlc">
       <from uri="seda:c"/>
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <header>max</header>
         <correlationExpression>
           <header>key</header>
@@ -68,7 +68,7 @@
     <route errorHandlerRef="dlc">
       <from uri="direct:ga"/>
       <!-- throttle max of 5 concurrent messages -->
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <constant>2</constant>
         <correlationExpression>
           <header>key</header>
@@ -85,7 +85,7 @@
     
     <route errorHandlerRef="dlc">
       <from uri="direct:gexpressionHeader"/>
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <!-- use a header to determine the max number of concurrent requests 
to set on the throttle-->
         <header>throttleValue</header>
         <correlationExpression>
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/ThrottlerMethodCallTest.xml
 
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/ThrottlerMethodCallTest.xml
index d23d5a4bcd2a..6197f609f6f8 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/ThrottlerMethodCallTest.xml
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/ThrottlerMethodCallTest.xml
@@ -31,7 +31,7 @@
 
     <route>
       <from uri="direct:expressionMethod"/>
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <!-- use a java bean method call to determine the max number of 
concurrent messages to set on the throttle -->
         <method ref="myBean" method="getConcurrentMessages"/>
       </throttle>
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/throttler.xml
 
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/throttler.xml
index d48593eb5afc..362f008a8735 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/throttler.xml
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/throttler.xml
@@ -40,7 +40,7 @@
     <route>
       <from uri="direct:a"/>
       <!-- throttle max of 2 concurrent messages -->
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <constant>2</constant>
       </throttle>
       <process ref="incrementProcessor"/>
@@ -54,7 +54,7 @@
 
     <route>
       <from uri="direct:expressionConstant"/>
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <constant>2</constant>
       </throttle>
       <process ref="incrementProcessor"/>
@@ -69,7 +69,7 @@
     <!-- START SNIPPET: e2 -->
     <route>
       <from uri="direct:expressionHeader"/>
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <!-- use a header to determine the max number of current messages -->
         <header>throttleValue</header>
       </throttle>
@@ -86,7 +86,7 @@
     <route>
       <from uri="direct:start"/>
       <!-- throttle max of 2 concurrent messages -->
-      <throttle rejectExecution="true">
+      <throttle mode="ConcurrentRequests" rejectExecution="true">
         <constant>2</constant>
       </throttle>
       <delay>
@@ -99,7 +99,7 @@
     <route>
       <from uri="direct:fifo"/>
       <!-- throttle max of 1 concurrent request -->
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <constant>1</constant>
       </throttle>
       <delay>
@@ -111,7 +111,7 @@
     <route errorHandlerRef="myDLC">
       <from uri="direct:release"/>
       <!-- throttle max of 1 concurrent request -->
-      <throttle>
+      <throttle mode="ConcurrentRequests">
         <constant>1</constant>
       </throttle>
       <delay>
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/processor/throttle/concurrent/ConcurrentRequestsThrottlerTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/processor/throttle/concurrent/ConcurrentRequestsThrottlerTest.java
index 2f5566c33077..a42433709b56 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/processor/throttle/concurrent/ConcurrentRequestsThrottlerTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/processor/throttle/concurrent/ConcurrentRequestsThrottlerTest.java
@@ -246,7 +246,8 @@ public class ConcurrentRequestsThrottlerTest extends 
ContextTestSupport {
 
                 
from("direct:fifo").throttle(1).concurrentRequestsMode().delay(100).to("mock:result");
 
-                
from("direct:release").errorHandler(deadLetterChannel("mock:error")).throttle(1).delay(100)
+                
from("direct:release").errorHandler(deadLetterChannel("mock:error")).throttle(1).concurrentRequestsMode()
+                        .delay(100)
                         .process(exchange -> {
                             throw new RuntimeException();
                         }).to("mock:result");

Reply via email to