activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [68/69] [abbrv] activemq-artemis git commit: Put a limit on finding free port Improve FailoverTransactionTest
Date Thu, 31 Mar 2016 02:31:50 GMT
Put a limit on finding free port
Improve FailoverTransactionTest


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/cae8a545
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/cae8a545
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/cae8a545

Branch: refs/heads/refactor-openwire
Commit: cae8a545a3adbd13ce76a731e3412f64d2c5158a
Parents: 2419d7f
Author: Howard Gao <howard.gao@gmail.com>
Authored: Wed Mar 23 16:16:24 2016 +0800
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Wed Mar 30 22:29:44 2016 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/broker/BrokerService.java    | 12 ++++++++++++
 .../transport/failover/FailoverTransactionTest.java  | 15 ++++++++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cae8a545/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
index b6acee4..4bcfee2 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -34,6 +34,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.WeakHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.activemq.ActiveMQConnectionMetaData;
@@ -584,8 +585,19 @@ public class BrokerService implements Service {
 
    private int getPseudoRandomPort() {
       int port = RANDOM_PORT_BASE.getAndIncrement();
+      int maxTry = 20;
       while (!checkPort(port)) {
          port = RANDOM_PORT_BASE.getAndIncrement();
+         maxTry--;
+         if (maxTry == 0) {
+            LOG.error("Too many port used");
+            break;
+         }
+         try {
+            TimeUnit.SECONDS.sleep(5);
+         }
+         catch (InterruptedException e) {
+         }
       }
       return port;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/cae8a545/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
index 54fedf1..8403ee3 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
@@ -87,6 +87,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
 
    @After
    public void tearDown() throws Exception {
+      doByteman.set(false);
       stopBroker();
    }
 
@@ -665,11 +666,11 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest
{
          for (Connection c : connections) {
             c.close();
          }
-      }
 
-      // ensure no dangling messages with fresh broker etc
-      if (broker != null) {
-         broker.stop();
+         // ensure no dangling messages with fresh broker etc
+         if (broker != null) {
+            broker.stop();
+         }
       }
 
       LOG.info("Checking for remaining/hung messages..");
@@ -693,8 +694,8 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
       }
       finally {
          connection.close();
+         broker.stop();
       }
-      broker.stop();
    }
 
    @Test
@@ -710,6 +711,7 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest {
    )
    public void testPoolingNConsumesAfterReconnect() throws Exception {
       LOG.info(this + " running test testPoolingNConsumesAfterReconnect");
+      count = 0;
       broker = createBroker();
       startBrokerWithDurableQueue();
 
@@ -1047,13 +1049,16 @@ public class FailoverTransactionTest extends OpenwireArtemisBaseTest
{
    }
 
    public static void stopBrokerOnCounter() {
+      LOG.info("in stopBrokerOnCounter, byteman " + doByteman.get() + " count " + count);
       if (doByteman.get()) {
          if (count++ == 1) {
+            LOG.info("ok stop broker...");
             new Thread() {
                public void run() {
                   try {
                      broker.stop();
                      broker = null;
+                     LOG.info("broker stopped.");
                   }
                   catch (Exception e) {
                      e.printStackTrace();


Mime
View raw message