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

orpiske 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 41186b68de8 (chores) camel-jms: cleanup deliveryDelay tests (#11458)
41186b68de8 is described below

commit 41186b68de8585f5a8bca22f680e66069de9a6c4
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Sep 19 11:42:06 2023 +0200

    (chores) camel-jms: cleanup deliveryDelay tests (#11458)
    
    Cleanup tests that are highly susceptible to flakiness as they verify the 
results based on duration.
    
    Also, ensure they use the monotonic clock instead of the system clock to 
avoid the risk of going back in time in rare circumstances.
---
 .../camel/itest/jms2/Jms2DeliveryDelayTest.java    | 35 +++++++++-------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git 
a/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2DeliveryDelayTest.java
 
b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2DeliveryDelayTest.java
index dfa3a1a1622..39c88d31060 100644
--- 
a/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2DeliveryDelayTest.java
+++ 
b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2DeliveryDelayTest.java
@@ -18,10 +18,20 @@ package org.apache.camel.itest.jms2;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.util.StopWatch;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Isolated;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+/*
+ * Note: these tests offer only a naive check of the deliveryDelay 
functionality as they check the
+ * test duration. There is no guarantee that the cause for the delay is 
actually the deliveryDelay
+ * feature per se and not, for instance, caused by bug on the message broker 
or an overloaded scheduler
+ * taking a long time to handle this test workload. Nonetheless, it can still 
be useful for investigating
+ * bugs which is why we keep them here.
+ */
+@Isolated("These tests are highly susceptible to flakiness as they verify the 
results based on duration - which can vary a LOT in loaded systems")
 public class Jms2DeliveryDelayTest extends BaseJms2TestSupport {
 
     @Test
@@ -29,35 +39,18 @@ public class Jms2DeliveryDelayTest extends 
BaseJms2TestSupport {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
 
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         template.sendBody("jms:topic:foo?deliveryDelay=1000", "Hello World");
         MockEndpoint.assertIsSatisfied(context);
-        assertTrue(System.currentTimeMillis() - start >= 1000, "Should take at 
least 1000 millis");
-    }
 
-    @Test
-    void testInOnlyWithoutDelay() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceived("Hello World");
-
-        long start = System.currentTimeMillis();
-        template.sendBody("jms:topic:foo", "Hello World");
-        MockEndpoint.assertIsSatisfied(context);
-        assertTrue(System.currentTimeMillis() - start < 1000, "Should take 
less than 1000 millis");
+        assertTrue(watch.taken() >= 1000, "Should take at least 1000 millis");
     }
 
     @Test
     void testInOutWithDelay() {
-        long start = System.currentTimeMillis();
+        StopWatch watch = new StopWatch();
         template.requestBody("jms:topic:foo?deliveryDelay=1000", "Hello 
World");
-        assertTrue(System.currentTimeMillis() - start >= 1000, "Should take at 
least 1000 millis");
-    }
-
-    @Test
-    void testInOutWithoutDelay() {
-        long start = System.currentTimeMillis();
-        template.requestBody("jms:topic:foo", "Hello World");
-        assertTrue(System.currentTimeMillis() - start < 1000, "Should take 
less than 1000 millis");
+        assertTrue(watch.taken() >= 1000, "Should take at least 1000 millis");
     }
 
     @Override

Reply via email to