activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andytay...@apache.org
Subject [2/5] activemq-6 git commit: Fixing test failure
Date Thu, 12 Feb 2015 15:14:48 GMT
Fixing test failure

This test started to fail after performance improvements from  ACTIVEMQ6-78
After some investigation it turned out that this test was racing with the client
crashing even before the queue was created or sending a non persistent message
asynchronously while the client crashed before the server received the message.

I've also decreased some of the times on pings so the test could run a bit faster


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

Branch: refs/heads/master
Commit: 60179cfc980fba4756d588c3a9d8de44be3e9960
Parents: f7c4d56
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Wed Feb 11 08:36:17 2015 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Wed Feb 11 12:47:14 2015 -0500

----------------------------------------------------------------------
 .../integration/clientcrash/ClientCrashTest.java  | 18 ++++++++++++------
 .../integration/clientcrash/CrashClient.java      |  3 ++-
 .../integration/clientcrash/CrashClient2.java     |  2 +-
 3 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/60179cfc/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/ClientCrashTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/ClientCrashTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/ClientCrashTest.java
index fbab2f4..25177bb 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/ClientCrashTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/ClientCrashTest.java
@@ -44,9 +44,11 @@ import org.apache.activemq.tests.util.SpawnedVMSupport;
  */
 public class ClientCrashTest extends ClientTestBase
 {
-   static final int PING_PERIOD = 2000;
+   // using short values so this test can run fast
+   static final int PING_PERIOD = 100;
 
-   static final int CONNECTION_TTL = 6000;
+   // using short values so this test can run fast
+   static final int CONNECTION_TTL = 1000;
 
    // Constants -----------------------------------------------------
 
@@ -76,18 +78,22 @@ public class ClientCrashTest extends ClientTestBase
    {
       assertActiveConnections(1);
 
+      ClientSession session = sf.createSession(false, true, true);
+      session.createQueue(ClientCrashTest.QUEUE, ClientCrashTest.QUEUE, null, false);
+
       // spawn a JVM that creates a Core client, which sends a message
+      // It has to be spawned after the queue was created.
+      // if the client is too fast you race the send before the queue was created, missing
a message
       Process p = SpawnedVMSupport.spawnVM(CrashClient.class.getName());
 
-      ClientSession session = sf.createSession(false, true, true);
-      session.createQueue(ClientCrashTest.QUEUE, ClientCrashTest.QUEUE, null, false);
       ClientConsumer consumer = session.createConsumer(ClientCrashTest.QUEUE);
       ClientProducer producer = session.createProducer(ClientCrashTest.QUEUE);
 
+
       session.start();
 
       // receive a message from the queue
-      Message messageFromClient = consumer.receive(500000);
+      Message messageFromClient = consumer.receive(5000);
       Assert.assertNotNull("no message received", messageFromClient);
       Assert.assertEquals(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT, messageFromClient.getBodyBuffer().readString());
 
@@ -155,7 +161,7 @@ public class ClientCrashTest extends ClientTestBase
       session.start();
 
       // receive a message from the queue
-      ClientMessage messageFromClient = consumer.receive(10000);
+      ClientMessage messageFromClient = consumer.receive(timeout);
       Assert.assertNotNull("no message received", messageFromClient);
       Assert.assertEquals(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT, messageFromClient.getBodyBuffer().readString());
 

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/60179cfc/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient.java
b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient.java
index 8a0c5d6..406ba56 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient.java
@@ -59,8 +59,9 @@ public class CrashClient
          ClientSession session = sf.createSession(false, true, true);
          ClientProducer producer = session.createProducer(ClientCrashTest.QUEUE);
 
+         // it has to be durable otherwise it may race dying before the client is killed
          ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE,
-                                                             false,
+                                                             true,
                                                              0,
                                                              System.currentTimeMillis(),
                                                              (byte)1);

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/60179cfc/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient2.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient2.java
b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient2.java
index 15a1c07..775b50d 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient2.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/clientcrash/CrashClient2.java
@@ -59,7 +59,7 @@ public class CrashClient2
          ClientSession session = sf.createSession(true, true, 1000000);
          ClientProducer producer = session.createProducer(ClientCrashTest.QUEUE2);
 
-         ClientMessage message = session.createMessage(false);
+         ClientMessage message = session.createMessage(true);
          message.getBodyBuffer().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT);
 
          producer.send(message);


Mime
View raw message