diff options
| author | Aidan Skinner <aidan@apache.org> | 2009-05-28 10:46:37 +0000 |
|---|---|---|
| committer | Aidan Skinner <aidan@apache.org> | 2009-05-28 10:46:37 +0000 |
| commit | 380b37fe65b9426069e18895e2c6a1b89fa21184 (patch) | |
| tree | 43b75bd8d047a451c81ea175307c85343c2b07b8 /java | |
| parent | 0a3850a0c401d8d2e988b3fa86996813e788c829 (diff) | |
| download | qpid-python-380b37fe65b9426069e18895e2c6a1b89fa21184.tar.gz | |
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.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@779557 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
| -rw-r--r-- | java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java b/java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java index 5552355416..242efc2f5d 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/AlertingTest.java @@ -104,9 +104,14 @@ public class AlertingTest extends QpidTestCase _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 @@ public class AlertingTest extends QpidTestCase } } } - 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 @@ public class AlertingTest extends QpidTestCase 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 @@ public class AlertingTest extends QpidTestCase // Trigger the new value sendMessage(_session, _destination, 3); - boolean found = wasAlertFired(); - assertTrue("no alert generated in "+_logfile.getAbsolutePath(), found); + wasAlertFired(); } } |
