activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [09/43] activemq-artemis git commit: Fix "Address already in use" issues in testsuite. Excluded a test from test suite that seems to cause hang for now.
Date Tue, 09 Feb 2016 20:20:28 GMT
Fix "Address already in use" issues in testsuite.
Excluded a test from test suite that seems to cause hang for now.


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

Branch: refs/heads/refactor-openwire
Commit: 58cd458c799856fa9c590e4f701760dd08c0bc11
Parents: c1cdfb1
Author: Howard Gao <howard.gao@gmail.com>
Authored: Fri Feb 5 23:05:54 2016 +0800
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Feb 9 15:19:54 2016 -0500

----------------------------------------------------------------------
 tests/activemq5-unit-tests/pom.xml                 |  3 +++
 .../artemiswrapper/ArtemisBrokerHelper.java        |  9 ++++++++-
 .../org/apache/activemq/broker/BrokerService.java  |  2 +-
 .../transport/tcp/TcpTransportFactory.java         |  4 +++-
 .../activemq/ReconnectWithSameClientIDTest.java    |  1 +
 .../org/apache/activemq/RemoveDestinationTest.java |  2 ++
 .../java/org/apache/activemq/TimeStampTest.java    |  6 +++---
 .../apache/activemq/TransactionContextTest.java    | 17 ++++++++++-------
 .../apache/activemq/ZeroPrefetchConsumerTest.java  |  4 +++-
 .../failover/ConnectionHangOnStartupTest.java      |  4 ++++
 .../transport/tcp/TcpTransportBindTest.java        |  5 +++--
 11 files changed, 41 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/pom.xml b/tests/activemq5-unit-tests/pom.xml
index 2782627..a17847e 100644
--- a/tests/activemq5-unit-tests/pom.xml
+++ b/tests/activemq5-unit-tests/pom.xml
@@ -427,6 +427,9 @@
                   <include>**/org/apache/activemq/blob/BlobTransferPolicyUriTest.java</include>
                </includes>
                <excludes>
+                  <!-- this test is know to pass (run in standalone) but it seems hang
when running in testsuite -->
+                  <exclude>**/org/apache/activemq/transport/failover/FailoverTransactionTest.java</exclude>
+
                   <!-- exclude tests that can cause hang -->
                   <exclude>**/org/apache/activemq/PerDestinationStoreLimitTest.java</exclude>
                   <exclude>**/org/apache/activemq/ProducerFlowControlTest.java</exclude>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java
b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java
index bc4bb11..4161859 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/artemiswrapper/ArtemisBrokerHelper.java
@@ -42,6 +42,7 @@ public class ArtemisBrokerHelper {
    // start a tcp transport artemis broker, the broker need to
    // be invm with client.
    public static void startArtemisBroker(URI location) throws IOException {
+      System.out.println("---starting broker, service is there? " + service);
       if (service != null) {
          return;
       }
@@ -49,6 +50,7 @@ public class ArtemisBrokerHelper {
          service = serviceClass.newInstance();
          Method startMethod = serviceClass.getMethod("start");
          startMethod.invoke(service, (Object[]) null);
+         System.out.println("started a service instance: " + service);
       }
       catch (InstantiationException e) {
          throw new IOException("Inst exception", e);
@@ -79,19 +81,24 @@ public class ArtemisBrokerHelper {
    //to prevent auto broker creation.
    public static void setBroker(Object startedBroker) {
       service = startedBroker;
+      System.out.println("somebody set a broker service: " + service);
    }
 
    public static BrokerService getBroker() {
       return (BrokerService) service;
    }
 
-   public static void stopArtemisBroker() throws Exception {
+   public static void stopArtemisBroker() {
       try {
          if (service != null) {
             Method startMethod = serviceClass.getMethod("stop");
             startMethod.invoke(service, (Object[]) null);
+            System.out.println("stopped the service instance: " + service);
          }
       }
+      catch (Exception e) {
+         e.printStackTrace();
+      }
       finally {
          service = null;
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/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 d34f943..b7b02b3 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
@@ -130,7 +130,7 @@ public class BrokerService implements Service {
 
    @Override
    public String toString() {
-      return "BrokerService[" + getBrokerName() + "]";
+      return "BrokerService[" + getBrokerName() + "]" + super.toString();
    }
 
    private String getBrokerVersion() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
index 4ddc2a6..5b07f48 100644
--- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
+++ b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
@@ -61,18 +61,20 @@ public class TcpTransportFactory extends TransportFactory {
       LOG.info("deciding whether starting an internal broker: " + brokerService + " flag:
" + BrokerService.disableWrapper);
       if (brokerService == null && !BrokerService.disableWrapper) {
 
+         LOG.info("starting internal broker: " + location1);
          ArtemisBrokerHelper.startArtemisBroker(location1);
          brokerService = location.toString();
 
          if (brokerId != null) {
             BrokerRegistry.getInstance().bind(brokerId, ArtemisBrokerHelper.getBroker());
-            System.out.println("bound: " + brokerId);
+            LOG.info("bound: " + brokerId);
          }
       }
       //remove unused invm parameters
       params.remove("broker.persistent");
       params.remove("broker.useJmx");
       params.remove("marshal");
+      params.remove("create");
       URI location2 = URISupport.createRemainingURI(location, params);
       return super.doConnect(location2);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java
index adda445..d737f2c 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ReconnectWithSameClientIDTest.java
@@ -102,6 +102,7 @@ public class ReconnectWithSameClientIDTest extends EmbeddedBrokerTestSupport
{
    @Override
    protected void setUp() throws Exception {
       bindAddress = "tcp://localhost:0";
+      disableWrapper = true;
       super.setUp();
    }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RemoveDestinationTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RemoveDestinationTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RemoveDestinationTest.java
index 894abe3..ff1c6c6 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RemoveDestinationTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/RemoveDestinationTest.java
@@ -55,6 +55,7 @@ public class RemoveDestinationTest {
 
    @Before
    public void setUp() throws Exception {
+      BrokerService.disableWrapper = true;
       broker = BrokerFactory.createBroker(new URI(BROKER_URL));
       broker.start();
       broker.waitUntilStarted();
@@ -62,6 +63,7 @@ public class RemoveDestinationTest {
 
    @After
    public void tearDown() throws Exception {
+      BrokerService.disableWrapper = false;
       broker.stop();
       broker.waitUntilStopped();
       broker = null;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java
index c1c058f..d423442 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TimeStampTest.java
@@ -26,6 +26,7 @@ import javax.jms.Session;
 
 import junit.framework.TestCase;
 
+import org.apache.activemq.artemiswrapper.ArtemisBrokerHelper;
 import org.apache.activemq.broker.BrokerPlugin;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.TransportConnector;
@@ -35,12 +36,12 @@ import org.apache.activemq.broker.view.ConnectionDotFilePlugin;
 public class TimeStampTest extends TestCase {
 
    @Override
-   public void setUp() {
+   public void setUp() throws Exception {
       BrokerService.disableWrapper = true;
    }
-
    @Override
    public void tearDown() {
+      ArtemisBrokerHelper.stopArtemisBroker();
       BrokerService.disableWrapper = false;
    }
 
@@ -101,6 +102,5 @@ public class TimeStampTest extends TestCase {
       consumer.close();
       session.close();
       connection.close();
-      broker.stop();
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java
index 4991c92..d2e917d 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/TransactionContextTest.java
@@ -41,13 +41,14 @@ public class TransactionContextTest {
 
    @Before
    public void setup() throws Exception {
-      connection = factory.createActiveMQConnection();
-      underTest = new TransactionContext(connection);
-   }
-
-   @AfterClass
-   public static void cleanup() throws Exception {
-      TcpTransportFactory.clearService();
+      try {
+         connection = factory.createActiveMQConnection();
+         underTest = new TransactionContext(connection);
+      }
+      catch (Exception e) {
+         e.printStackTrace();
+         throw e;
+      }
    }
 
    @After
@@ -55,6 +56,7 @@ public class TransactionContextTest {
       if (connection != null) {
          connection.close();
       }
+      TcpTransportFactory.clearService();
    }
 
    @Test
@@ -116,6 +118,7 @@ public class TransactionContextTest {
 
    @Test
    public void testSyncIndexCleared() throws Exception {
+      System.out.println("================================= test testSyncIndexCleared ===========");
       final AtomicInteger beforeEndCountA = new AtomicInteger(0);
       final AtomicInteger rollbackCountA = new AtomicInteger(0);
       Synchronization sync = new Synchronization() {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
index d207da7..953032b 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ZeroPrefetchConsumerTest.java
@@ -377,6 +377,7 @@ public class ZeroPrefetchConsumerTest extends EmbeddedBrokerTestSupport
{
 
    @Override
    protected void setUp() throws Exception {
+      disableWrapper = true;
       bindAddress = "tcp://localhost:0";
       super.setUp();
 
@@ -388,11 +389,12 @@ public class ZeroPrefetchConsumerTest extends EmbeddedBrokerTestSupport
{
    @Override
    protected void startBroker() throws Exception {
       super.startBroker();
-      bindAddress = broker.getTransportConnectors().get(0).getConnectUri().toString();
+      bindAddress = newURI("localhost", 0);
    }
 
    @Override
    protected void tearDown() throws Exception {
+      BrokerService.disableWrapper = false;
       connection.close();
       super.tearDown();
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
index f40ee4f..756337e 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/ConnectionHangOnStartupTest.java
@@ -27,6 +27,7 @@ import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -75,6 +76,8 @@ public class ConnectionHangOnStartupTest extends OpenwireArtemisBaseTest
{
 
    @Test(timeout = 60000)
    public void testInitialWireFormatNegotiationTimeout() throws Exception {
+      Assert.fail("this test pass but it'll leave a thread running all the time, fix it before
adding the test to the testsuite!");
+      /*
       final AtomicReference<Connection> conn = new AtomicReference<>();
       final CountDownLatch connStarted = new CountDownLatch(1);
 
@@ -97,6 +100,7 @@ public class ConnectionHangOnStartupTest extends OpenwireArtemisBaseTest
{
       //createSlave();
 
       conn.get().stop();
+      */
    }
 
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/58cd458c/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
index 1c34d83..38188ce 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/tcp/TcpTransportBindTest.java
@@ -37,10 +37,11 @@ public class TcpTransportBindTest extends EmbeddedBrokerTestSupport {
     */
    @Override
    protected void setUp() throws Exception {
+      disableWrapper = true;
       bindAddress = addr + "?transport.reuseAddress=true&transport.soTimeout=1000";
       super.setUp();
 
-      addr = broker.getTransportConnectors().get(0).getPublishableConnectString();
+      addr = newURI("localhost", 0);
    }
 
    public void testConnect() throws Exception {
@@ -58,7 +59,7 @@ public class TcpTransportBindTest extends EmbeddedBrokerTestSupport {
          @Override
          public void run() {
             try {
-               broker.stop();
+               artemisBroker.stop();
             }
             catch (Exception e) {
                e.printStackTrace();


Mime
View raw message