qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1546330 - in /qpid/trunk/qpid/java: client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java systests/src/main/java/org/apache/qpid/client/HeartbeatTest.java
Date Thu, 28 Nov 2013 10:11:55 GMT
Author: kwall
Date: Thu Nov 28 10:11:55 2013
New Revision: 1546330

URL: http://svn.apache.org/r1546330
Log:
NO-JIRA: [Java System Tests] Add extra logging to HeartbeatTest in order to understand an
occasional failure on a slow (virtalised) Jenkins environment

Modified:
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/HeartbeatTest.java

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java?rev=1546330&r1=1546329&r2=1546330&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
(original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
Thu Nov 28 10:11:55 2013
@@ -310,7 +310,7 @@ public class AMQProtocolHandler implemen
 
     public void writerIdle()
     {
-        _logger.debug("Protocol Session [" + this + "] idle: reader");
+        _logger.debug("Protocol Session [" + this + "] idle: writer");
         writeFrame(HeartbeatBody.FRAME);
         _heartbeatListener.heartbeatSent();
     }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/HeartbeatTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/HeartbeatTest.java?rev=1546330&r1=1546329&r2=1546330&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/HeartbeatTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/HeartbeatTest.java
Thu Nov 28 10:11:55 2013
@@ -22,18 +22,23 @@ import static org.apache.qpid.configurat
 import static org.apache.qpid.configuration.ClientProperties.IDLE_TIMEOUT_PROP_NAME;
 import static org.apache.qpid.configuration.ClientProperties.QPID_HEARTBEAT_INTERVAL;
 
+import java.util.concurrent.atomic.AtomicInteger;
+
 import javax.jms.Destination;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 
+import org.apache.log4j.Logger;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 public class HeartbeatTest extends QpidBrokerTestCase
 {
+    private static final Logger LOGGER = Logger.getLogger(HeartbeatTest.class);
+
     private static final String CONNECTION_URL_WITH_HEARTBEAT = "amqp://guest:guest@clientid/?brokerlist='localhost:%d?heartbeat='%d''";
-    private TestListener _listener = new TestListener();
+    private TestListener _listener = new TestListener("listener");
 
     @Override
     public void setUp() throws Exception
@@ -54,8 +59,8 @@ public class HeartbeatTest extends QpidB
 
         Thread.sleep(2500);
 
-        assertTrue("Too few heartbeats received: "+_listener._heartbeatsReceived+" (expected
at least 2)", _listener._heartbeatsReceived>=2);
-        assertTrue("Too few heartbeats sent "+_listener._heartbeatsSent+" (expected at least
2)", _listener._heartbeatsSent>=2);
+        assertTrue("Too few heartbeats received: "+_listener.getHeartbeatsReceived() +" (expected
at least 2)", _listener.getHeartbeatsReceived() >=2);
+        assertTrue("Too few heartbeats sent "+_listener.getHeartbeatsSent() +" (expected
at least 2)", _listener.getHeartbeatsSent() >=2);
 
         conn.close();
     }
@@ -69,8 +74,8 @@ public class HeartbeatTest extends QpidB
 
         Thread.sleep(2500);
 
-        assertTrue("Too few heartbeats received: "+_listener._heartbeatsReceived+" (expected
at least 2)", _listener._heartbeatsReceived>=2);
-        assertTrue("Too few heartbeats sent "+_listener._heartbeatsSent+" (expected at least
2)", _listener._heartbeatsSent>=2);
+        assertTrue("Too few heartbeats received: "+_listener.getHeartbeatsReceived() +" (expected
at least 2)", _listener.getHeartbeatsReceived() >=2);
+        assertTrue("Too few heartbeats sent "+_listener.getHeartbeatsSent() +" (expected
at least 2)", _listener.getHeartbeatsSent() >=2);
 
         conn.close();
     }
@@ -84,8 +89,8 @@ public class HeartbeatTest extends QpidB
 
          Thread.sleep(2500);
 
-         assertEquals("Heartbeats unexpectedly received", 0, _listener._heartbeatsReceived);
-         assertEquals("Heartbeats unexpectedly sent ", 0, _listener._heartbeatsSent);
+         assertEquals("Heartbeats unexpectedly received", 0, _listener.getHeartbeatsReceived());
+         assertEquals("Heartbeats unexpectedly sent ", 0, _listener.getHeartbeatsSent());
 
          conn.close();
     }
@@ -101,8 +106,8 @@ public class HeartbeatTest extends QpidB
         AMQConnection receiveConn = (AMQConnection) getConnection();
         AMQConnection sendConn = (AMQConnection) getConnection();
         Destination destination = getTestQueue();
-        TestListener receiveListener = new TestListener();
-        TestListener sendListener = new TestListener();
+        TestListener receiveListener = new TestListener("receiverListener");
+        TestListener sendListener = new TestListener("senderListener");
 
 
         Session receiveSession = receiveConn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
@@ -123,11 +128,11 @@ public class HeartbeatTest extends QpidB
             // Consumer does not ack the message in  order to generate no bytes from consumer
back to Broker
         }
 
-        assertTrue("Too few heartbeats sent "+receiveListener._heartbeatsSent+" (expected
at least 2)", receiveListener._heartbeatsSent>=2);
-        assertEquals("Unexpected sent at the sender: ",0,sendListener._heartbeatsSent);
+        assertTrue("Too few heartbeats sent "+ receiveListener.getHeartbeatsSent() +" (expected
at least 2)", receiveListener.getHeartbeatsSent()>=2);
+        assertEquals("Unexpected number of heartbeats sent by the sender: ",0,sendListener.getHeartbeatsSent());
 
-        assertTrue("Too few heartbeats received at the sender "+sendListener._heartbeatsReceived+"
(expected at least 2)", sendListener._heartbeatsReceived>=2);
-        assertEquals("Unexpected received at the receiver: ",0,receiveListener._heartbeatsReceived);
+        assertTrue("Too few heartbeats received at the sender "+ sendListener.getHeartbeatsReceived()
+" (expected at least 2)", sendListener.getHeartbeatsReceived()>=2);
+        assertEquals("Unexpected number of heartbeats received by the receiver: ",0,receiveListener.getHeartbeatsReceived());
 
         receiveConn.close();
         sendConn.close();
@@ -142,8 +147,8 @@ public class HeartbeatTest extends QpidB
 
         Thread.sleep(2500);
 
-        assertTrue("Too few heartbeats received: "+_listener._heartbeatsReceived+" (expected
at least 2)", _listener._heartbeatsReceived>=2);
-        assertTrue("Too few heartbeats sent "+_listener._heartbeatsSent+" (expected at least
2)", _listener._heartbeatsSent>=2);
+        assertTrue("Too few heartbeats received: "+_listener.getHeartbeatsReceived() +" (expected
at least 2)", _listener.getHeartbeatsReceived()>=2);
+        assertTrue("Too few heartbeats sent "+ _listener.getHeartbeatsSent() +" (expected
at least 2)", _listener.getHeartbeatsSent() >=2);
 
         conn.close();
     }
@@ -159,8 +164,8 @@ public class HeartbeatTest extends QpidB
 
         Thread.sleep(2500);
 
-        assertTrue("Too few heartbeats received: "+_listener._heartbeatsReceived+" (expected
at least 2)", _listener._heartbeatsReceived>=2);
-        assertTrue("Too few heartbeats sent "+_listener._heartbeatsSent+" (expected at least
2)", _listener._heartbeatsSent>=2);
+        assertTrue("Too few heartbeats received: "+_listener.getHeartbeatsReceived()+" (expected
at least 2)", _listener.getHeartbeatsReceived()>=2);
+        assertTrue("Too few heartbeats sent "+_listener.getHeartbeatsSent() +" (expected
at least 2)", _listener.getHeartbeatsSent()>=2);
 
         conn.close();
     }
@@ -175,26 +180,45 @@ public class HeartbeatTest extends QpidB
 
         Thread.sleep(2500);
 
-        assertTrue("Too few heartbeats received: "+_listener._heartbeatsReceived+" (expected
at least 2)", _listener._heartbeatsReceived>=2);
-        assertTrue("Too few heartbeats sent "+_listener._heartbeatsSent+" (expected at least
2)", _listener._heartbeatsSent>=2);
+        assertTrue("Too few heartbeats received: "+_listener.getHeartbeatsReceived() +" (expected
at least 2)", _listener.getHeartbeatsReceived()>=2);
+        assertTrue("Too few heartbeats sent "+_listener.getHeartbeatsSent() +" (expected
at least 2)", _listener.getHeartbeatsSent()>=2);
 
         conn.close();
     }
 
     private class TestListener implements HeartbeatListener
     {
-        int _heartbeatsReceived;
-        int _heartbeatsSent;
+        private final String _name;
+        private final AtomicInteger _heartbeatsReceived = new AtomicInteger(0);
+        private final AtomicInteger _heartbeatsSent = new AtomicInteger(0);
+
+        public TestListener(String name)
+        {
+            _name = name;
+        }
+
         @Override
         public void heartbeatReceived()
         {
-            _heartbeatsReceived++;
+            LOGGER.debug(_name + " heartbeat received");
+            _heartbeatsReceived.incrementAndGet();
+        }
+
+        public int getHeartbeatsReceived()
+        {
+            return _heartbeatsReceived.get();
         }
 
         @Override
         public void heartbeatSent()
         {
-            _heartbeatsSent++;
+            LOGGER.debug(_name + " heartbeat sent");
+            _heartbeatsSent.incrementAndGet();
+        }
+
+        public int getHeartbeatsSent()
+        {
+            return _heartbeatsSent.get();
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message