Author: aidan
Date: Thu May 28 10:46:37 2009
New Revision: 779557

URL: http://svn.apache.org/viewvc?rev=779557&view=rev
Log:
Fail the test when we can't find the alert and surface the contents of the 
logfile. Ugly but effective for debugging occasional failures in CI.

Modified:
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java

Modified: 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java?rev=779557&r1=779556&r2=779557&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java
 (original)
+++ 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java
 Thu May 28 10:46:37 2009
@@ -104,9 +104,14 @@
         _consumer = _session.createConsumer(_destination);
     }
 
-    private boolean wasAlertFired() throws Exception
+    /**
+     * Checks the log file for MESSAGE_COUNT_ALERT, fails() the test if it's 
not found and
+     * places the entire contents in the message to help debug cruise control 
failures.
+     * @throws Exception
+     */
+    private void wasAlertFired() throws Exception
     {
-        // Loop throught alerts until we're done or 5 seconds have passed, 
+        // Loop through alerts until we're done or 5 seconds have passed, 
         // just in case the logfile takes a while to flush. 
         BufferedReader reader = new BufferedReader(new FileReader(_logfile));
         boolean found = false;
@@ -122,15 +127,26 @@
                 }
             }
         }
-        return found;
+        if (!found)
+        {
+            StringBuffer message = new StringBuffer("Could not find alert in 
log file: "+_logfile.getAbsolutePath());
+            message.append("\n");
+            reader = new BufferedReader(new FileReader(_logfile));
+            for (int i = 0; i < 79; i++) { message.append("-"); };
+            message.append("\n");
+            while (reader.ready()) { message.append(reader.readLine() + "\n");}
+            message.append("\n");
+            for (int i = 0; i < 79; i++) { message.append("-"); };
+            message.append("\n");
+            fail(message.toString());
+        }
     }
     
     public void testAlertingReallyWorks() throws Exception
     {
         // Send 5 messages, make sure that the alert was fired properly. 
         sendMessage(_session, _destination, _numMessages + 1);
-        boolean found = wasAlertFired();
-        assertTrue("no alert generated in "+_logfile.getAbsolutePath(), found);
+        wasAlertFired();
     }
 
     public void testAlertingReallyWorksWithRestart() throws Exception
@@ -139,8 +155,7 @@
         stopBroker();
         (new FileOutputStream(_logfile)).getChannel().truncate(0);
         startBroker();
-        boolean found = wasAlertFired();
-        assertTrue("no alert generated in "+_logfile.getAbsolutePath(), found);
+        wasAlertFired();
     }
     
     public void testAlertingReallyWorksWithChanges() throws Exception
@@ -158,7 +173,6 @@
         
         // Trigger the new value
         sendMessage(_session, _destination, 3);
-        boolean found = wasAlertFired();
-        assertTrue("no alert generated in "+_logfile.getAbsolutePath(), found);
+        wasAlertFired();
     }
 }



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

Reply via email to