You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2021/12/13 17:05:20 UTC

[activemq-artemis] branch main updated: ARTEMIS-3604 Test Improvement

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

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new b5eb7d2  ARTEMIS-3604 Test Improvement
b5eb7d2 is described below

commit b5eb7d234212d2e7ad0276f5a6b84857a6f1d842
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Mon Dec 13 12:04:25 2021 -0500

    ARTEMIS-3604 Test Improvement
---
 .../artemis/utils/actors/ThresholdActorTest.java   | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/ThresholdActorTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/ThresholdActorTest.java
index 01e5471..94642a3 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/ThresholdActorTest.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/ThresholdActorTest.java
@@ -121,7 +121,7 @@ public class ThresholdActorTest {
 
    public void block() {
       try {
-         if (!semaphore.tryAcquire(10, TimeUnit.SECONDS)) {
+         if (!semaphore.tryAcquire()) {
             errors.incrementAndGet();
             System.err.println("acquire failed");
          }
@@ -136,6 +136,20 @@ public class ThresholdActorTest {
 
    @Test
    public void testFlow() throws Exception {
+      testFlow(true);
+   }
+
+   /**
+    * This test will actually not respect the semaphore and keep going.
+    * The blockers and unblocks should still perform ok.
+    * @throws Exception
+    */
+   @Test
+   public void testFlow2() throws Exception {
+      testFlow(false);
+   }
+
+   public void testFlow(boolean respectSemaphore) throws Exception {
       final ExecutorService executorService = Executors.newFixedThreadPool(2);
 
       try {
@@ -148,8 +162,10 @@ public class ThresholdActorTest {
          executorService.execute(() -> {
             for (int i = 0; i <= LAST_ELEMENT; i++) {
                try {
-                  semaphore.acquire();
-                  semaphore.release();
+                  if (respectSemaphore) {
+                     semaphore.acquire();
+                     semaphore.release();
+                  }
                   actor.act(new Element(i, i % 2 == 0 ? 20 : 1));
                } catch (Exception e) {
                   e.printStackTrace();