qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r800376 - in /qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging: AbstractTestLogging.java ConnectionLoggingTest.java
Date Mon, 03 Aug 2009 13:34:34 GMT
Author: ritchiem
Date: Mon Aug  3 13:34:33 2009
New Revision: 800376

URL: http://svn.apache.org/viewvc?rev=800376&view=rev
Log:
QPID-2002 : Updated ConnectionLoggingTest to protect against message reordering of connection
closure during negotiation.

Modified:
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java?rev=800376&r1=800375&r2=800376&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
Mon Aug  3 13:34:33 2009
@@ -24,6 +24,9 @@
 import org.apache.qpid.util.LogMonitor;
 
 import java.io.IOException;
+import java.util.List;
+import java.util.HashMap;
+import java.util.LinkedList;
 
 public class AbstractTestLogging extends QpidTestCase
 {
@@ -53,7 +56,7 @@
 
     protected void validateMessageID(String id, String log)
     {
-        assertEquals("Incorrect CHN message",id, getMessageID(log));
+        assertEquals("Incorrect message",id, getMessageID(log));
     }
 
     protected String getMessageID(String log)
@@ -219,4 +222,41 @@
         return rawLog.substring(start);
     }
 
+    /**
+       * Given a list of messages that have been pulled out of a log file
+       * Process the results splitting the log statements in to lists based on the
+       * actor's connection ID.
+       *
+       * So for each log entry extract the Connecition ID from the Actor of the log
+       *
+       * Then use that as a key to a HashMap storing the list of log messages for
+       * that connection.
+       *
+       * @param logMessages The list of mixed connection log messages
+       * @return Map indexed by connection id to a list of log messages just for that connection.
+       */
+      protected HashMap<Integer,List<String>> splitResultsOnConnectionID(List<String>
logMessages)
+      {
+          HashMap<Integer,List<String>> connectionSplitList = new HashMap<Integer,
List<String>>();
+
+          for (String log : logMessages)
+          {
+              // Get the connectionID from the Actor in the Message Log.
+              int cID = extractConnectionID(fromActor(getLog(log)));
+
+              List<String> connectionData = connectionSplitList.get(cID);
+
+              // Create the initial List if we don't have one already
+              if (connectionData == null)
+              {
+                  connectionData = new LinkedList<String>();
+                  connectionSplitList.put(cID, connectionData);
+              }
+
+              // Store the log
+              connectionData.add(log);
+          }
+
+          return connectionSplitList;
+      }
 }

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java?rev=800376&r1=800375&r2=800376&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
Mon Aug  3 13:34:33 2009
@@ -20,9 +20,16 @@
 */
 package org.apache.qpid.server.logging;
 
+import org.apache.qpid.test.unit.client.forwardall.Client;
+
 import javax.jms.Connection;
 import java.io.File;
 import java.util.List;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.SortedSet;
+import java.util.Collections;
+import java.util.TreeSet;
 
 public class ConnectionLoggingTest extends AbstractTestLogging
 {
@@ -65,11 +72,26 @@
         List<String> results = _monitor.findMatches(CONNECTION_PREFIX);
 
         // Validation
+        // We should have at least three messages when running InVM but when running External
+        // we will get 0-10 negotiation on con:0 whcih may close at some random point
+        // MESSAGE [con:0(/127.0.0.1:46926)] CON-1001 : Open
+        // MESSAGE [con:0(/127.0.0.1:46926)] CON-1001 : Open : Protocol Version : 0-10
+        // MESSAGE [con:1(/127.0.0.1:46927)] CON-1001 : Open
+        // MESSAGE [con:1(/127.0.0.1:46927)] CON-1001 : Open : Protocol Version : 0-9
+        // MESSAGE [con:0(/127.0.0.1:46926)] CON-1002 : Close
+        // MESSAGE [con:1(/127.0.0.1:46927)] CON-1001 : Open : Client ID : clientid : Protocol
Version : 0-9
+
+        //So check how many connections we have in the result set and extract the last one.
+        // When running InVM we will have con:0 and externally con:1
+
+        HashMap<Integer, List<String>> connectionData = splitResultsOnConnectionID(results);
+
+        // Get the last Integer from keySet of the ConnectionData
+        int connectionID = new TreeSet<Integer>(connectionData.keySet()).last();
+
+        //Use just the data from the last connection for the test
+        results = connectionData.get(connectionID);
 
-        // We should have at least three messages
-        //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open
-        //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open : Protocol Version : 0-9
-        //  MESSAGE [con:1(/127.0.0.1:52540)] CON-1001 : Open : Client ID : clientid : Protocol
Version : 0-9
         // If we are running inVM we will get three open messagse, if running externally
weN will also have
         // open and close messages from the failed 0-10 negotiation 
         assertTrue("CON messages not logged:" + results.size(), results.size() >= 3);



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message