summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-08-03 13:34:33 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-08-03 13:34:33 +0000
commitd3f14331a2c3bbd889a19c42002ea01ddec6e3df (patch)
tree6418675b6b3da9c69b2675bac84fc3917693dfef
parentb8588d44be3e246706f22f356f4ca112f6197ff4 (diff)
downloadqpid-python-d3f14331a2c3bbd889a19c42002ea01ddec6e3df.tar.gz
QPID-2002 : Updated ConnectionLoggingTest to protect against message reordering of connection closure during negotiation.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@800376 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java42
-rw-r--r--java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java30
2 files changed, 67 insertions, 5 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java b/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
index 6cb2f5dfc3..47ae599d2b 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/logging/AbstractTestLogging.java
@@ -24,6 +24,9 @@ import org.apache.qpid.test.utils.QpidTestCase;
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 @@ public class AbstractTestLogging extends QpidTestCase
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 @@ public class AbstractTestLogging extends QpidTestCase
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;
+ }
}
diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
index 424e8e0cca..46f32b1414 100644
--- a/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/server/logging/ConnectionLoggingTest.java
@@ -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 @@ public class ConnectionLoggingTest extends AbstractTestLogging
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);