diff options
19 files changed, 207 insertions, 97 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java index 2e107ada34..51076fe358 100644 --- a/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/management/jmx/ManagementActorLoggingTest.java @@ -88,7 +88,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging */ public void testJMXManagementConsoleConnection() throws IOException { - List<String> results = _monitor.findMatches("MNG-1007"); + List<String> results = _monitor.waitAndFindMatches("MNG-1007", DEFAULT_LOG_WAIT); assertEquals("Unexpected Management Connection count", 1, results.size()); @@ -107,7 +107,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging _jmxUtils.close(); - results = _monitor.findMatches("MNG-1008"); + results = _monitor.waitAndFindMatches("MNG-1008", DEFAULT_LOG_WAIT); assertEquals("Unexpected Management Connection count", 1, results.size()); @@ -168,7 +168,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging exceptionReceived.await(2, TimeUnit.SECONDS)); //Validate results - List<String> results = _monitor.findMatches("CON-1002"); + List<String> results = _monitor.waitAndFindMatches("CON-1002", DEFAULT_LOG_WAIT); assertEquals("Unexpected Connection Close count", 1, results.size()); } @@ -203,7 +203,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging // Validate //1 - ID is correct - List<String> results = _monitor.findMatches("EXH-1001"); + List<String> results = _monitor.waitAndFindMatches("EXH-1001", DEFAULT_LOG_WAIT); assertEquals("More than one exchange creation found", 1, results.size()); @@ -227,7 +227,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging // Validate //1 - ID is correct - List<String> results = _monitor.findMatches("EXH-1001"); + List<String> results = _monitor.waitAndFindMatches("EXH-1001", DEFAULT_LOG_WAIT); assertEquals("More than one exchange creation found", 1, results.size()); @@ -252,7 +252,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging // Validate //1 - ID is correct - List<String> results = _monitor.findMatches("EXH-1001"); + List<String> results = _monitor.waitAndFindMatches("EXH-1001", DEFAULT_LOG_WAIT); assertEquals("More than one exchange creation found", 1, results.size()); @@ -277,7 +277,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging // Validate //1 - ID is correct - List<String> results = _monitor.findMatches("EXH-1001"); + List<String> results = _monitor.waitAndFindMatches("EXH-1001", DEFAULT_LOG_WAIT); assertEquals("More than one exchange creation found", 1, results.size()); @@ -320,7 +320,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging // Validate - List<String> results = _monitor.findMatches("QUE-1001"); + List<String> results = _monitor.waitAndFindMatches("QUE-1001", DEFAULT_LOG_WAIT); assertEquals("More than one queue creation found", 1, results.size()); @@ -365,7 +365,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging managedBroker.deleteQueue(getName()); - List<String> results = _monitor.findMatches("QUE-1002"); + List<String> results = _monitor.waitAndFindMatches("QUE-1002", DEFAULT_LOG_WAIT); assertEquals("More than one queue deletion found", 1, results.size()); @@ -411,7 +411,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging managedExchange.createNewBinding(getName(), getName()); - List<String> results = _monitor.findMatches("BND-1001"); + List<String> results = _monitor.waitAndFindMatches("BND-1001", DEFAULT_LOG_WAIT); assertEquals("More than one bind creation found", 1, results.size()); @@ -438,7 +438,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging managedExchange.createNewBinding(getName(), getName()); - List<String> results = _monitor.findMatches("BND-1001"); + List<String> results = _monitor.waitAndFindMatches("BND-1001", DEFAULT_LOG_WAIT); assertEquals("More than one bind creation found", 1, results.size()); @@ -465,7 +465,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging managedExchange.createNewBinding(getName(), getName()); - List<String> results = _monitor.findMatches("BND-1001"); + List<String> results = _monitor.waitAndFindMatches("BND-1001", DEFAULT_LOG_WAIT); assertEquals("More than one bind creation found", 1, results.size()); @@ -512,7 +512,7 @@ public class ManagementActorLoggingTest extends AbstractTestLogging managedBroker.unregisterExchange(getName()); - List<String> results = _monitor.findMatches("EXH-1002"); + List<String> results = _monitor.waitAndFindMatches("EXH-1002", DEFAULT_LOG_WAIT); assertEquals("More than one exchange deletion found", 1, results.size()); diff --git a/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java b/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java index e7975f8d24..ca20efd2a9 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/BrokerStartupTest.java @@ -102,7 +102,7 @@ public class BrokerStartupTest extends AbstractTestLogging 0, _monitor.findMatches("log4j:ERROR Could not read configuration file from URL").size()); assertEquals("Logging did not error as expected", - 1, _monitor.findMatches("Logging configuration error: unable to read file ").size()); + 1, _monitor.waitAndFindMatches("Logging configuration error: unable to read file ", DEFAULT_LOG_WAIT).size()); // Perfom some action on the broker to ensure that we hit the DEBUG @@ -120,7 +120,7 @@ public class BrokerStartupTest extends AbstractTestLogging assertEquals(COUNT,drainQueue(queue)); - List<String> results = _monitor.findMatches("DEBUG"); + List<String> results = _monitor.waitAndFindMatches("DEBUG", DEFAULT_LOG_WAIT); try { // Validation 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 e7d1c8b896..ce05c95473 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 @@ -32,6 +32,7 @@ import java.util.List; public class AbstractTestLogging extends QpidTestCase { + public static final long DEFAULT_LOG_WAIT = 2000; protected LogMonitor _monitor; @Override diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java index 683abee4da..3429edd6bc 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/AlertingTest.java @@ -47,13 +47,6 @@ public class AlertingTest extends AbstractTestLogging public void setUp() throws Exception { - // set QPID_WORK to be [QPID_WORK|io.tmpdir]/<testName> - // This ensures that each of these tests operate independantly. - setSystemProperty("QPID_WORK", - System.getProperty("QPID_WORK", - System.getProperty("java.io.tmpdir")) - + File.separator + getName()); - // Update the configuration to make our virtualhost Persistent. makeVirtualHostPersistent(VIRTUALHOST); diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java index 266cb42ad7..db8d1ae36c 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/BindingLoggingTest.java @@ -104,7 +104,7 @@ public class BindingLoggingTest extends AbstractTestLogging { _session.createConsumer(_queue).close(); - List<String> results = _monitor.findMatches(BND_PREFIX); + List<String> results = _monitor.waitAndFindMatches(BND_PREFIX, DEFAULT_LOG_WAIT); // We will have two binds as we bind all queues to the default exchange assertEquals("Result set larger than expected.", 2, results.size()); @@ -141,7 +141,7 @@ public class BindingLoggingTest extends AbstractTestLogging _session.createDurableSubscriber(_topic, getName(), SELECTOR, false).close(); - List<String> results = _monitor.findMatches(BND_PREFIX); + List<String> results = _monitor.waitAndFindMatches(BND_PREFIX, DEFAULT_LOG_WAIT); // We will have two binds as we bind all queues to the default exchange assertEquals("Result set larger than expected.", 2, results.size()); @@ -212,7 +212,7 @@ public class BindingLoggingTest extends AbstractTestLogging // and so unbind. _session.createConsumer(_session.createTemporaryQueue()).close(); - List<String> results = _monitor.findMatches(BND_PREFIX); + List<String> results = _monitor.waitAndFindMatches(BND_PREFIX, DEFAULT_LOG_WAIT); // We will have two binds as we bind all queues to the default exchange assertEquals("Result not as expected." + results, 4, results.size()); diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java index b00a71315e..b5203742bd 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/BrokerLoggingTest.java @@ -47,6 +47,8 @@ import java.util.List; */ public class BrokerLoggingTest extends AbstractTestLogging { + private static final String BRK_LOG_PREFIX = "BRK-"; + public void setUp() throws Exception { // We either do this here or have a null check in tearDown. @@ -79,6 +81,8 @@ public class BrokerLoggingTest extends AbstractTestLogging */ public void testBrokerStartupConfiguration() throws Exception { + String TESTID="BRK-1006"; + // This logging startup code only occurs when you run a Java broker, // that broker must be started via Main so not an InVM broker. if (isJavaBroker() && isExternalBroker()) @@ -91,7 +95,10 @@ public class BrokerLoggingTest extends AbstractTestLogging String configFilePath = _configFile.toString(); - List<String> results = _monitor.findMatches("BRK-"); + // Ensure we wait for TESTID to be logged + _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT); + + List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT); try { // Validation @@ -101,10 +108,10 @@ public class BrokerLoggingTest extends AbstractTestLogging String log = getLog(results.get(0)); //1 - validateMessageID("BRK-1006", log); + validateMessageID(TESTID, log); //2 - results = _monitor.findMatches("BRK-1006"); + results = _monitor.findMatches(TESTID); assertEquals("More than one configuration message found.", 1, results.size()); @@ -170,7 +177,10 @@ public class BrokerLoggingTest extends AbstractTestLogging // Ensure broker has fully started up. getConnection(); - List<String> results = _monitor.findMatches("BRK-"); + // Ensure we wait for TESTID to be logged + _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT); + + List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT); try { // Validation @@ -268,7 +278,10 @@ public class BrokerLoggingTest extends AbstractTestLogging // Ensure broker has fully started up. getConnection(); - List<String> results = _monitor.findMatches("BRK-"); + // Ensure we wait for TESTID to be logged + _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT); + + List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT); try { // Validation @@ -353,8 +366,14 @@ public class BrokerLoggingTest extends AbstractTestLogging // Now we can create the monitor as _outputFile will now be defined _monitor = new LogMonitor(_outputFile); + + // Ensure we wait for TESTID to be logged + _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT); + + // Retrieve all BRK- log messages so we can check for an erroneous + // BRK-1002 message. + List<String> results = _monitor.findMatches(BRK_LOG_PREFIX); - List<String> results = _monitor.findMatches("BRK-"); try { // Validation @@ -437,7 +456,12 @@ public class BrokerLoggingTest extends AbstractTestLogging // Ensure broker has fully started up. getConnection(); - List<String> results = _monitor.findMatches("BRK-"); + // Ensure we wait for TESTID to be logged + _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT); + + // Retrieve all BRK- log messages so we can check for an erroneous + // BRK-1002 message. + List<String> results = _monitor.findMatches(BRK_LOG_PREFIX); try { // Validation @@ -537,7 +561,12 @@ public class BrokerLoggingTest extends AbstractTestLogging // Ensure broker has fully started up. getConnection(); - List<String> results = _monitor.findMatches("BRK-"); + // Ensure we wait for TESTID to be logged + _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT); + + // Retrieve all BRK- log messages so we can check for an erroneous + // BRK-1002 message. + List<String> results = _monitor.findMatches(BRK_LOG_PREFIX); try { // Validation @@ -630,8 +659,12 @@ public class BrokerLoggingTest extends AbstractTestLogging //Ensure the broker has fully started up. getConnection(); + // Ensure we wait for TESTID to be logged + _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT); - List<String> results = _monitor.findMatches("BRK-"); + // Retrieve all BRK- log messages so we can check for an erroneous + // BRK-1001 message. + List<String> results = _monitor.findMatches(BRK_LOG_PREFIX); try { // Validation @@ -645,7 +678,7 @@ public class BrokerLoggingTest extends AbstractTestLogging assertFalse("More broker log statements present after ready message", validation); String log = getLog(rawLog); - // Ensure we do not have a BRK-1002 message + // Ensure we do not have a BRK-1001 message if (!getMessageID(log).equals(TESTID)) { if (getMessageID(log).equals("BRK-1001")) @@ -720,7 +753,7 @@ public class BrokerLoggingTest extends AbstractTestLogging //Give broker time to shutdown and flush log checkSocketClosed(getPort()); - List<String> results = _monitor.findMatches("BRK-"); + List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT); try { // Validation @@ -828,7 +861,7 @@ public class BrokerLoggingTest extends AbstractTestLogging //Give broker time to shutdown and flush log checkSocketClosed(getPort()); - List<String> results = _monitor.findMatches(TESTID); + List<String> results = _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT); try { // Validation @@ -910,7 +943,9 @@ public class BrokerLoggingTest extends AbstractTestLogging // Ensure the broker has shutdown before retreving results checkSocketClosed(getPort()); - List<String> results = _monitor.findMatches("BRK-"); + _monitor.waitAndFindMatches(TESTID, DEFAULT_LOG_WAIT); + + List<String> results = _monitor.waitAndFindMatches(BRK_LOG_PREFIX, DEFAULT_LOG_WAIT); try { // Validation diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java index ea0199570c..2d1a204ce4 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/ChannelLoggingTest.java @@ -26,24 +26,14 @@ import javax.jms.Connection; import javax.jms.MessageConsumer; import javax.jms.Queue; import javax.jms.Session; -import java.io.File; import java.util.List; public class ChannelLoggingTest extends AbstractTestLogging { private static final String CHANNEL_PREFIX = "CHN-"; - public void setUp() throws Exception - { - // set QPID_WORK to be [QPID_WORK|io.tmpdir]/<testName> - setSystemProperty("QPID_WORK", - System.getProperty("QPID_WORK", - System.getProperty("java.io.tmpdir")) - + File.separator + getName()); - - //Start the broker - super.setUp(); - } + // No explicit startup configuration is required for this test + // so no setUp() method /** * Description: @@ -74,6 +64,9 @@ public class ChannelLoggingTest extends AbstractTestLogging // Test that calling session.close gives us the expected output ((AMQConnection)connection).createSession(false, Session.AUTO_ACKNOWLEDGE,PREFETCH); + // Wait to ensure that the CHN-1004 message is logged + _monitor.waitForMessage("CHN-1004", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(CHANNEL_PREFIX); // Validation @@ -129,13 +122,16 @@ public class ChannelLoggingTest extends AbstractTestLogging connection.start(); + // Wait to ensure that the CHN-1002 message is logged + _monitor.waitForMessage("CHN-1002", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(CHANNEL_PREFIX); assertTrue("No CHN messages logged", results.size() > 0); // The last channel message should be: // - // INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow Off + // INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow Stopped // Verify int resultSize = results.size(); @@ -183,22 +179,30 @@ public class ChannelLoggingTest extends AbstractTestLogging //Call receive to send the Flow On message consumer.receiveNoWait(); + //Wait for up to 2 seconds for message to appear + // ignore response as we will use the findMatches afterwards just + // incase it did take more than 2 seconds to log. + _monitor.waitForMessage(CHANNEL_PREFIX, 2000); + + // Wait to ensure that the CHN-1002 message is logged + _monitor.waitForMessage("CHN-1002", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(CHANNEL_PREFIX); assertTrue("No CHN messages logged", results.size() > 0); - // The last two channel messages should be: + // The last two channel messages(before the close) should be: // - // INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow On + // INFO [qpid.message] MESSAGE [con:1(guest@/127.0.0.1:49869/test)/ch:1] [con:1(guest@/127.0.0.1:49869/test)/ch:1] CHN-1002 : Flow Stopped + // INFO [qpid.message] MESSAGE [con:1(guest@/127.0.0.1:49869/test)/ch:1] [con:1(guest@/127.0.0.1:49869/test)/ch:1] CHN-1002 : Flow Started - // Verify + // Verify the last channel msg is Started. int resultSize = results.size(); String log = getLog(results.get(resultSize - 1)); validateMessageID("CHN-1002", log); assertEquals("Message should be Flow Started", "Flow Started", getMessageString(fromMessage(log))); - } /** @@ -232,6 +236,9 @@ public class ChannelLoggingTest extends AbstractTestLogging // Close the connection to verify the created session closing is logged. connection.close(); + // Wait to ensure that the CHN-1003 message is logged + _monitor.waitForMessage("CHN-1003", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(CHANNEL_PREFIX); assertTrue("No CHN messages logged", results.size() > 0); @@ -279,16 +286,14 @@ public class ChannelLoggingTest extends AbstractTestLogging // Create a session and then close it connection.createSession(false, Session.AUTO_ACKNOWLEDGE).close(); + // Wait to ensure that the CHN-1003 message is logged + _monitor.waitForMessage("CHN-1003", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(CHANNEL_PREFIX); assertTrue("No CHN messages logged", results.size() > 0); - // The last two channel messages should be: - // - // INFO - MESSAGE [con:0(guest@anonymous(4205299)/test)/ch:1] [con:0(guest@anonymous(4205299)/test)/ch:1] CHN-1002 : Flow On - // Verify - int resultSize = results.size(); String log = getLog(results.get(resultSize - 1)); 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 503129072b..9bdf2bb7a3 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 @@ -30,17 +30,8 @@ public class ConnectionLoggingTest extends AbstractTestLogging { private static final String CONNECTION_PREFIX = "CON-"; - public void setUp() throws Exception - { - // set QPID_WORK to be [QPID_WORK|io.tmpdir]/<testName> - setSystemProperty("QPID_WORK", - System.getProperty("QPID_WORK", - System.getProperty("java.io.tmpdir")) - + File.separator + getName()); - - //Start the broker - super.setUp(); - } + // No explicit startup configuration is required for this test + // so no setUp() method /** * Description: @@ -64,7 +55,7 @@ public class ConnectionLoggingTest extends AbstractTestLogging Connection connection = getConnection(); - List<String> results = _monitor.findMatches(CONNECTION_PREFIX); + List<String> results = _monitor.waitAndFindMatches(CONNECTION_PREFIX, DEFAULT_LOG_WAIT); assertTrue("No CON messages logged", results.size() > 0); @@ -155,6 +146,9 @@ public class ConnectionLoggingTest extends AbstractTestLogging // Open and then close the conneciton getConnection().close(); + // Wait to ensure that the desired message is logged + _monitor.waitForMessage("CON-1002", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(CONNECTION_PREFIX); // Validation diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java index cc3993249c..5b2fc4cdcb 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/DerbyMessageStoreLoggingTest.java @@ -91,7 +91,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest startBroker(); - List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX); + List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT); // Validation @@ -102,7 +102,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation - results = _monitor.findMatches("MST-1002"); + results = _monitor.waitAndFindMatches("MST-1002", DEFAULT_LOG_WAIT); assertEquals("Each vhost did not close its store.", vhosts.size(), results.size()); @@ -154,7 +154,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest startBroker(); - List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX); + List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT); // Validation @@ -165,7 +165,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation - results = _monitor.findMatches("MST-1004"); + results = _monitor.waitAndFindMatches("MST-1004", DEFAULT_LOG_WAIT); assertTrue("Each vhost did not close its store.", vhosts.size() <= results.size()); @@ -221,7 +221,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest startBroker(); - List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX); + List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT); // Validation @@ -232,7 +232,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation - results = _monitor.findMatches("MST-1006"); + results = _monitor.waitAndFindMatches("MST-1006", DEFAULT_LOG_WAIT); assertTrue("Each vhost did not close its store.", vhosts.size() <= results.size()); @@ -287,7 +287,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest startBroker(); - List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX); + List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT); // Validation @@ -298,7 +298,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation - results = _monitor.findMatches("MST-1004 : Recovery Start :"); + results = _monitor.waitAndFindMatches("MST-1004 : Recovery Start :", DEFAULT_LOG_WAIT); // We are only looking for the default queue defined in local host being // recovered. If other tests have made queues in test then we want to @@ -352,7 +352,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest startBroker(); - List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX); + List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT); // Validation @@ -363,7 +363,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation - results = _monitor.findMatches("MST-1006 : Recovery Complete :"); + results = _monitor.waitAndFindMatches("MST-1006 : Recovery Complete :", DEFAULT_LOG_WAIT); // We are only looking for the default queue defined in local host being // recovered. If other tests have made queues in test then we want to @@ -494,7 +494,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest startBroker(); - List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX); + List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT); // Validation @@ -505,7 +505,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation - results = _monitor.findMatches("MST-1004 : Recovery Start : " + queueName); + results = _monitor.waitAndFindMatches("MST-1004 : Recovery Start : " + queueName, DEFAULT_LOG_WAIT); assertEquals("Recovered test queue not found.", 1, results.size()); @@ -516,7 +516,7 @@ public class DerbyMessageStoreLoggingTest extends MemoryMessageStoreLoggingTest assertTrue("MST-1004 does end with queue '" + queueName + "':" + getMessageString(result), getMessageString(result).endsWith(queueName)); - results = _monitor.findMatches("MST-1005"); + results = _monitor.waitAndFindMatches("MST-1005", DEFAULT_LOG_WAIT); assertTrue("Insufficient MST-1005 logged.", results.size()>0); diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java index 6a4292ec2e..c43915be35 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/DurableQueueLoggingTest.java @@ -94,6 +94,9 @@ public class DurableQueueLoggingTest extends AbstractTestLogging _session.createConsumer(queue); // Validation + // Ensure we have received the QUE log msg. + _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(QUEUE_PREFIX); // Only 1 Queue message should hav been logged @@ -145,6 +148,9 @@ public class DurableQueueLoggingTest extends AbstractTestLogging _session.createConsumer(queue); // Validation + // Ensure we have received the QUE log msg. + _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(QUEUE_PREFIX); // Only 1 Queue message should hav been logged @@ -196,6 +202,9 @@ public class DurableQueueLoggingTest extends AbstractTestLogging _session.createConsumer(queue); // Validation + // Ensure we have received the QUE log msg. + _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(QUEUE_PREFIX); // Only 1 Queue message should hav been logged @@ -260,6 +269,9 @@ public class DurableQueueLoggingTest extends AbstractTestLogging _session.createConsumer(queue); // Validation + // Ensure we have received the QUE log msg. + _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(QUEUE_PREFIX); // Only 1 Queue message should hav been logged @@ -325,6 +337,9 @@ public class DurableQueueLoggingTest extends AbstractTestLogging _session.createConsumer(queue); // Validation + // Ensure we have received the QUE log msg. + _monitor.waitForMessage("QUE-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(QUEUE_PREFIX); // Only 1 Queue message should hav been logged diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java index 778201e3e4..5facafe6aa 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/ExchangeLoggingTest.java @@ -94,6 +94,9 @@ public class ExchangeLoggingTest extends AbstractTestLogging // They should all be durable + // Ensure we have received the EXH log msg. + _monitor.waitForMessage("EXH-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(EXH_PREFIX); assertTrue("No Results found for Exchange.", results.size()>0); @@ -131,6 +134,8 @@ public class ExchangeLoggingTest extends AbstractTestLogging _monitor.reset(); _session.createConsumer(_queue); + // Ensure we have received the EXH log msg. + _monitor.waitForMessage("EXH-1001", DEFAULT_LOG_WAIT); List<String> results = _monitor.findMatches(EXH_PREFIX); @@ -180,6 +185,9 @@ public class ExchangeLoggingTest extends AbstractTestLogging ((AMQConnection) _connection).getProtocolHandler().syncWrite(exchangeDeclare, ExchangeDeleteOkBody.class); + //Wait and ensure we get our last EXH-1002 msg + _monitor.waitForMessage("EXH-1002", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(EXH_PREFIX); assertEquals("Result set larger than expected.", 2, results.size()); diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java index 8b7c881a32..9ec223f694 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java @@ -85,7 +85,11 @@ public class ManagementLoggingTest extends AbstractTestLogging // Now we can create the monitor as _outputFile will now be defined _monitor = new LogMonitor(_outputFile); + // Ensure we have received the MNG log msg. + _monitor.waitForMessage("MNG-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(MNG_PREFIX); + try { // Validation @@ -215,7 +219,7 @@ public class ManagementLoggingTest extends AbstractTestLogging // Now we can create the monitor as _outputFile will now be defined _monitor = new LogMonitor(_outputFile); - List<String> results = _monitor.findMatches("MNG-1002"); + List<String> results = _monitor.waitAndFindMatches("MNG-1002", DEFAULT_LOG_WAIT); try { // Validation @@ -290,7 +294,7 @@ public class ManagementLoggingTest extends AbstractTestLogging // Now we can create the monitor as _outputFile will now be defined _monitor = new LogMonitor(_outputFile); - List<String> results = _monitor.findMatches("MNG-1006"); + List<String> results = _monitor.waitAndFindMatches("MNG-1006", DEFAULT_LOG_WAIT); try { // Validation diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java index 2298ba4da0..1bcef1dbb0 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/MemoryMessageStoreLoggingTest.java @@ -78,7 +78,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging startBroker(); - List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX); + List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT); // Validation @@ -93,7 +93,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation - results = _monitor.findMatches("MST-1001"); + results = _monitor.waitAndFindMatches("MST-1001", DEFAULT_LOG_WAIT); assertEquals("Each vhost did not create a store.", vhosts.size(), results.size()); @@ -149,7 +149,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging //Stop the broker so we get the close messages. stopBroker(); - List<String> results = _monitor.findMatches(MESSAGES_STORE_PREFIX); + List<String> results = _monitor.waitAndFindMatches(MESSAGES_STORE_PREFIX, DEFAULT_LOG_WAIT); // Validation @@ -160,7 +160,7 @@ public class MemoryMessageStoreLoggingTest extends AbstractTestLogging List<String> vhosts = configuration.getConfig().getList("virtualhosts.virtualhost.name"); //Validate each vhost logs a creation - results = _monitor.findMatches("MST-1003"); + results = _monitor.waitAndFindMatches("MST-1003", DEFAULT_LOG_WAIT); assertEquals("Each vhost did not close its store.", vhosts.size(), results.size()); diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java index 150f462d0f..0637271c0c 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/QueueLoggingTest.java @@ -94,6 +94,9 @@ public class QueueLoggingTest extends AbstractTestLogging _session.close(); // Validation + //Ensure that we wait for the QUE log message + _monitor.waitAndFindMatches("QUE-1002", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(QUEUE_PREFIX); // Only 1 Queue message should hav been logged @@ -145,6 +148,9 @@ public class QueueLoggingTest extends AbstractTestLogging _session.createConsumer(_session.createTemporaryQueue()).close(); // Validation + //Ensure that we wait for the QUE log message + _monitor.waitAndFindMatches("QUE-1002", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(QUEUE_PREFIX); // Only 1 Queue message should hav been logged diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java index 5dd56fb0f9..6a0e2f1e86 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java @@ -91,6 +91,9 @@ public class SubscriptionLoggingTest extends AbstractTestLogging //Validate + //Ensure that we wait for the SUB log message + _monitor.waitAndFindMatches("SUB-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(SUB_PREFIX); assertEquals("Result set larger than expected.", 1, results.size()); @@ -126,10 +129,12 @@ public class SubscriptionLoggingTest extends AbstractTestLogging _session.createDurableSubscriber(_topic, getName()); //Validate + //Ensure that we wait for the SUB log message + _monitor.waitAndFindMatches("SUB-1001", DEFAULT_LOG_WAIT); List<String> results = _monitor.findMatches(SUB_PREFIX); - assertEquals("Result set larger than expected.", 1, results.size()); + assertEquals("Result set not as expected.", 1, results.size()); String log = getLog(results.get(0)); @@ -163,6 +168,9 @@ public class SubscriptionLoggingTest extends AbstractTestLogging _session.createBrowser(_queue); //Validate + //Ensure that we wait for the SUB log message + _monitor.waitAndFindMatches("SUB-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(SUB_PREFIX); assertEquals("Result set larger than expected.", 2, results.size()); @@ -207,6 +215,9 @@ public class SubscriptionLoggingTest extends AbstractTestLogging //Validate + //Ensure that we wait for the SUB log message + _monitor.waitAndFindMatches("SUB-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(SUB_PREFIX); assertEquals("Result set larger than expected.", 1, results.size()); @@ -245,6 +256,9 @@ public class SubscriptionLoggingTest extends AbstractTestLogging //Validate + //Ensure that we wait for the SUB log message + _monitor.waitAndFindMatches("SUB-1001", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(SUB_PREFIX); assertEquals("Result set larger than expected.", 1, results.size()); @@ -283,6 +297,9 @@ public class SubscriptionLoggingTest extends AbstractTestLogging _session.createConsumer(_queue).close(); //Validate + //Ensure that we wait for the SUB log message + _monitor.waitAndFindMatches("SUB-1002", DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(SUB_PREFIX); //3 @@ -369,7 +386,7 @@ public class SubscriptionLoggingTest extends AbstractTestLogging _session.commit(); //Validate - List<String> results = _monitor.findMatches("SUB-1003"); + List<String> results = _monitor.waitAndFindMatches("SUB-1003", DEFAULT_LOG_WAIT); try { diff --git a/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java b/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java index f4a0c8b27d..b97bd64a55 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/logging/VirtualHostLoggingTest.java @@ -59,6 +59,8 @@ public class VirtualHostLoggingTest extends AbstractTestLogging */ public void testVirtualhostCreation() throws Exception { + //Wait for the correct VHT message to arrive. + _monitor.waitForMessage("VHT-1001",DEFAULT_LOG_WAIT); List<String> results = _monitor.findMatches(VHT_PREFIX); try @@ -112,6 +114,9 @@ public class VirtualHostLoggingTest extends AbstractTestLogging { stopBroker(); + //Wait for the correct VHT message to arrive. + _monitor.waitForMessage("VHT-1002",DEFAULT_LOG_WAIT); + List<String> results = _monitor.findMatches(VHT_PREFIX); try { diff --git a/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java b/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java index aead8eda53..cd0de76981 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/queue/ProducerFlowControlTest.java @@ -160,7 +160,7 @@ public class ProducerFlowControlTest extends AbstractTestLogging sendMessagesAsync(producer, producerSession, 5, 50L); Thread.sleep(5000); - List<String> results = _monitor.findMatches("QUE-1003"); + List<String> results = _monitor.waitAndFindMatches("QUE-1003", DEFAULT_LOG_WAIT); assertEquals("Did not find correct number of QUE-1003 queue overfull messages", 1, results.size()); @@ -170,7 +170,7 @@ public class ProducerFlowControlTest extends AbstractTestLogging while(consumer.receive(1000) != null); - results = _monitor.findMatches("QUE-1004"); + results = _monitor.waitAndFindMatches("QUE-1004", DEFAULT_LOG_WAIT); assertEquals("Did not find correct number of QUE_UNDERFULL queue underfull messages", 1, results.size()); @@ -205,7 +205,7 @@ public class ProducerFlowControlTest extends AbstractTestLogging MessageSender sender = sendMessagesAsync(producer, producerSession, 5, 50L); Thread.sleep(10000); - List<String> results = _monitor.findMatches("Message send delayed by"); + List<String> results = _monitor.waitAndFindMatches("Message send delayed by", 10000); assertTrue("No delay messages logged by client",results.size()!=0); results = _monitor.findMatches("Message send failed due to timeout waiting on broker enforced flow control"); assertEquals("Incorrect number of send failure messages logged by client",1,results.size()); diff --git a/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java b/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java index 7d55c68b75..a5e2b80f64 100644 --- a/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java +++ b/java/systests/src/main/java/org/apache/qpid/util/LogMonitor.java @@ -33,6 +33,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.List; +import java.util.LinkedList; /** * Utility to simplify the monitoring of Log4j file output @@ -91,6 +92,30 @@ public class LogMonitor } /** + * Checks the log file for a given message to appear and returns all + * instances of that appearance. + * + * @param message the message to wait for in the log + * @param wait the time in ms to wait for the message to occur + * @return true if the message was found + * + * @throws java.io.FileNotFoundException if the Log file can nolonger be found + * @throws IOException thrown when reading the log file + */ + public List<String> waitAndFindMatches(String message, long wait) + throws FileNotFoundException, IOException + { + if (waitForMessage(message, wait, true)) + { + return findMatches(message); + } + else + { + return new LinkedList<String>(); + } + } + + /** * Checks the log for instances of the search string. * * The pattern parameter can take any valid argument used in String.contains() @@ -114,6 +139,8 @@ public class LogMonitor * @param message the message to wait for in the log * @param wait the time in ms to wait for the message to occur * + * @param printFileOnFailure should we print the contents that have been + * read if we fail ot find the message. * @return true if the message was found * * @throws java.io.FileNotFoundException if the Log file can nolonger be found diff --git a/java/systests/src/main/java/org/apache/qpid/util/LogMonitorTest.java b/java/systests/src/main/java/org/apache/qpid/util/LogMonitorTest.java index 2b9fe8e039..a99abe4b94 100644 --- a/java/systests/src/main/java/org/apache/qpid/util/LogMonitorTest.java +++ b/java/systests/src/main/java/org/apache/qpid/util/LogMonitorTest.java @@ -224,7 +224,7 @@ public class LogMonitorTest extends TestCase assertEquals("Incorrect result set size", 0, results.size()); } - /** + /** * Validate that the LogMonitor can match the given string in the log * * @param log The LogMonitor to check |