activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq git commit: Tweaking some unit tests to improve reliability
Date Thu, 17 Sep 2015 11:29:07 GMT
Repository: activemq
Updated Branches:
  refs/heads/master ee4672baa -> d2bd15296


Tweaking some unit tests to improve reliability


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

Branch: refs/heads/master
Commit: d2bd152960a74de6a61c2ddbea81ddcdcb70c177
Parents: ee4672b
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Thu Sep 17 11:27:42 2015 +0000
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Thu Sep 17 11:28:14 2015 +0000

----------------------------------------------------------------------
 .../activemq/transport/auto/nio/AutoNIOTransport.java   |  3 +++
 .../cursors/AbstractPendingMessageCursorTest.java       | 12 ++++++------
 .../region/cursors/KahaDBPendingMessageCursorTest.java  |  4 ++--
 .../store/AbstractMessageStoreSizeStatTest.java         |  8 ++++----
 .../store/kahadb/KahaDBMessageStoreSizeStatTest.java    |  2 +-
 .../kahadb/MultiKahaDBMessageStoreSizeStatTest.java     |  4 ++--
 .../transport/auto/AutoTransportMaxConnectionsTest.java |  9 ++++++---
 7 files changed, 24 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/d2bd1529/activemq-broker/src/main/java/org/apache/activemq/transport/auto/nio/AutoNIOTransport.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/transport/auto/nio/AutoNIOTransport.java
b/activemq-broker/src/main/java/org/apache/activemq/transport/auto/nio/AutoNIOTransport.java
index a9a9f5d..8927c8e 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/transport/auto/nio/AutoNIOTransport.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/transport/auto/nio/AutoNIOTransport.java
@@ -64,6 +64,9 @@ public class AutoNIOTransport extends NIOTransport {
             if (nextFrameSize == -1) {
                 readSize = 4;
                 this.initBuffer.buffer.flip();
+                if (this.initBuffer.buffer.remaining() < 8) {
+                    throw new IOException("Protocol type could not be determined.");
+                }
                 for (int i = 0; i < 4; i++) {
                     currentBuffer.put(initBuffer.buffer.get());
                 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/d2bd1529/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java
index 798746b..f496806 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursorTest.java
@@ -179,7 +179,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
         verifyStoreStats(dest, 0, 0);
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testTopicMessageSize() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 
@@ -205,7 +205,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
         connection.close();
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testTopicNonPersistentMessageSize() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 
@@ -232,7 +232,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
         connection.close();
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testTopicPersistentAndNonPersistentMessageSize() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 
@@ -261,7 +261,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
         connection.close();
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSizeOneDurable() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
         Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();
@@ -286,7 +286,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
         connection.close();
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSizeOneDurablePartialConsumption() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 
@@ -312,7 +312,7 @@ public abstract class AbstractPendingMessageCursorTest extends AbstractStoreStat
         connection.close();
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSizeTwoDurables() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/d2bd1529/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java
index b0bca7d..e0921dc 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/KahaDBPendingMessageCursorTest.java
@@ -68,7 +68,7 @@ public class KahaDBPendingMessageCursorTest extends
      *
      * @throws Exception
      */
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testDurableMessageSizeAfterRestartAndPublish() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 
@@ -107,7 +107,7 @@ public class KahaDBPendingMessageCursorTest extends
      *
      * @throws Exception
      */
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testNonPersistentDurableMessageSize() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/d2bd1529/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractMessageStoreSizeStatTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractMessageStoreSizeStatTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractMessageStoreSizeStatTest.java
index 8f17746..9bbbdb6 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractMessageStoreSizeStatTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/AbstractMessageStoreSizeStatTest.java
@@ -92,7 +92,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat
 
     protected abstract void initPersistence(BrokerService brokerService) throws IOException;
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSize() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 
@@ -100,7 +100,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat
         verifyStats(dest, 200, publishedMessageSize.get());
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSizeAfterConsumption() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 
@@ -112,7 +112,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat
         verifyStats(dest, 0, 0);
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSizeOneDurable() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
         Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();
@@ -133,7 +133,7 @@ public abstract class AbstractMessageStoreSizeStatTest extends AbstractStoreStat
         connection.close();
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSizeTwoDurables() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
         Connection connection = new ActiveMQConnectionFactory(brokerConnectURI).createConnection();

http://git-wip-us.apache.org/repos/asf/activemq/blob/d2bd1529/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessageStoreSizeStatTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessageStoreSizeStatTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessageStoreSizeStatTest.java
index 5a302ca..1efb59e 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessageStoreSizeStatTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBMessageStoreSizeStatTest.java
@@ -65,7 +65,7 @@ public class KahaDBMessageStoreSizeStatTest extends
      *
      * @throws Exception
      */
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSizeAfterRestartAndPublish() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
         Destination dest = publishTestQueueMessages(200, publishedMessageSize);

http://git-wip-us.apache.org/repos/asf/activemq/blob/d2bd1529/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/MultiKahaDBMessageStoreSizeStatTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/MultiKahaDBMessageStoreSizeStatTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/MultiKahaDBMessageStoreSizeStatTest.java
index 0adfcff..0c4fc76 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/MultiKahaDBMessageStoreSizeStatTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/MultiKahaDBMessageStoreSizeStatTest.java
@@ -85,7 +85,7 @@ public class MultiKahaDBMessageStoreSizeStatTest extends
      *
      * @throws Exception
      */
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSizeAfterRestartAndPublish() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
 
@@ -104,7 +104,7 @@ public class MultiKahaDBMessageStoreSizeStatTest extends
 
     }
 
-    @Test(timeout=30000)
+    @Test(timeout=60000)
     public void testMessageSizeAfterRestartAndPublishMultiQueue() throws Exception {
         AtomicLong publishedMessageSize = new AtomicLong();
         AtomicLong publishedMessageSize2 = new AtomicLong();

http://git-wip-us.apache.org/repos/asf/activemq/blob/d2bd1529/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportMaxConnectionsTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportMaxConnectionsTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportMaxConnectionsTest.java
index bbc20a3..77fd74f 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportMaxConnectionsTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/auto/AutoTransportMaxConnectionsTest.java
@@ -39,7 +39,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
-import org.springframework.jms.support.JmsUtils;
 
 @RunWith(Parameterized.class)
 public class AutoTransportMaxConnectionsTest {
@@ -95,18 +94,22 @@ public class AutoTransportMaxConnectionsTest {
         return new ActiveMQConnectionFactory(connectionUri);
     }
 
-    @Test
+    @Test(timeout=60000)
     public void testMaxConnectionControl() throws Exception {
         final ConnectionFactory cf = createConnectionFactory();
         final CountDownLatch startupLatch = new CountDownLatch(1);
 
-        for(int i = 0; i < maxConnections + 20; i++) {
+        //create an extra 10 connections above max
+        for(int i = 0; i < maxConnections + 10; i++) {
+            final int count = i;
             executor.submit(new Runnable() {
                 @Override
                 public void run() {
                     Connection conn = null;
                     try {
                         startupLatch.await();
+                        //sleep for a short period of time
+                        Thread.sleep(count * 3);
                         conn = cf.createConnection();
                         conn.start();
                     } catch (Exception e) {


Mime
View raw message