Author: ritchiem Date: Tue Sep 1 14:30:33 2009 New Revision: 810072 URL: http://svn.apache.org/viewvc?rev=810072&view=rev Log: QPID-2059 : Updated SLT to ensure there is a gap between ACTIVE and SUSPENDING states so that the log can occur. As there are multiple threads editing the state of the subscripition it is possible that the state change does not result in a log message being produced.
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java?rev=810072&r1=810071&r2=810072&view=diff ============================================================================== --- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java (original) +++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/SubscriptionLoggingTest.java Tue Sep 1 14:30:33 2009 @@ -335,8 +335,12 @@ _connection.start(); //Fill the prefetch and two extra so that our receive bellow allows the - // subscription to become active then return to a suspended state. - int SEND_COUNT = 17; + // subscription to become active + // Previously we set this to 17 so that it would return to a suspended + // state. However, testing has shown that the state change can occur + // sufficiently quickly that logging does not occur consistently enough + // for testing. + int SEND_COUNT = 16; sendMessage(_session, _queue, SEND_COUNT); _session.commit(); // Retreive the first message, and start the flow of messages @@ -344,13 +348,7 @@ assertNotNull("First message not retreived", msg); _session.commit(); - - //Validate - List<String> results = _monitor.findMatches("SUB-1003"); - - // It has been seen on occasion that we do not get 3 messages logged. - // This could indicate that the broker has not received the above commit - + // Drain the queue to ensure there is time for the ACTIVE log message // Check that we can received all the messages int receivedCount = 0; while (msg != null) @@ -360,17 +358,24 @@ _session.commit(); } - System.err.println("All messasges received correctly."); + //Validate we received all the messages assertEquals("Not all sent messages received.", SEND_COUNT, receivedCount); + // Fill the queue again to suspend the consumer + sendMessage(_session, _queue, SEND_COUNT); + _session.commit(); + + //Validate + List<String> results = _monitor.findMatches("SUB-1003"); + try { // Validation expects three messages. // The first will be logged by the QueueActor as part of the processQueue thread -// INFO - MESSAGE [vh(/test)/qu(example.queue)] [sub:6(qu(example.queue))] SUB-1003 : State : SUSPENDED +// INFO - MESSAGE [vh(/test)/qu(example.queue)] [sub:6(qu(example.queue))] SUB-1003 : State : SUSPENDED // The second will be by the connnection as it acknowledges and activates the subscription // INFO - MESSAGE [con:6(gu...@anonymous(26562441)/test)/ch:3] [sub:6(qu(example.queue))] SUB-1003 : State : ACTIVE - // The final one can be the subscription suspending as part of the SubFlushRunner or the processQueue thread + // The final one can be either the connection or the subscription suspending as part of the SubFlushRunner or the processQueue thread // As a result validating the actor is more complicated and doesn't add anything. The goal of this test is // to ensure the State is correct not that a particular Actor performs the logging. // INFO - MESSAGE [sub:6(vh(test)/qu(example.queue))] [sub:6(qu(example.queue))] SUB-1003 : State : SUSPENDED @@ -414,6 +419,9 @@ } _connection.close(); + //Ensure the queue is drained before the test ends + drainQueue(_queue); + } /** --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscr...@qpid.apache.org