You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2016/11/25 11:08:01 UTC
svn commit: r1771283 - in /qpid/java/trunk:
systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
systests/src/test/java/org/apache/qpid/server/logging/AlertingTest.java
test-profiles/Java10UninvestigatedTestsExcludes
Author: rgodfrey
Date: Fri Nov 25 11:08:01 2016
New Revision: 1771283
URL: http://svn.apache.org/viewvc?rev=1771283&view=rev
Log:
QPID-7546 : Add a mechanism to get queue depth using AMQP management, enable AlertingTest
Modified:
qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/logging/AlertingTest.java
qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes
Modified: qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1771283&r1=1771282&r2=1771283&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java (original)
+++ qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java Fri Nov 25 11:08:01 2016
@@ -44,7 +44,9 @@ import org.slf4j.MDC;
import org.apache.qpid.QpidException;
import org.apache.qpid.client.AMQConnectionFactory;
import org.apache.qpid.client.AMQConnectionURL;
+import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.BrokerDetails;
import org.apache.qpid.exchange.ExchangeDefaults;
@@ -501,6 +503,70 @@ public class QpidBrokerTestCase extends
}
}
+ public long getQueueDepth(final Connection con, final Queue destination) throws JMSException, QpidException
+ {
+ if(isBroker10())
+ {
+ Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try
+ {
+
+ MessageProducer producer = session.createProducer(session.createQueue("$management"));
+ final TemporaryQueue responseQ = session.createTemporaryQueue();
+ MessageConsumer consumer = session.createConsumer(responseQ);
+ MapMessage message = session.createMapMessage();
+ message.setStringProperty("index", "object-path");
+ message.setStringProperty("key", destination.getQueueName());
+ message.setStringProperty("type", "org.apache.qpid.Queue");
+ message.setStringProperty("operation", "getStatistics");
+ message.setStringProperty("statistics", "[\"queueDepthMessages\"]");
+
+ message.setJMSReplyTo(responseQ);
+
+ producer.send(message);
+
+ Message response = consumer.receive();
+ try
+ {
+ if (response instanceof MapMessage)
+ {
+ return ((MapMessage) response).getLong("queueDepthMessages");
+ }
+ else if (response instanceof ObjectMessage)
+ {
+ Object body = ((ObjectMessage) response).getObject();
+ if (body instanceof Map)
+ {
+ return Long.valueOf(((Map) body).get("queueDepthMessages").toString());
+ }
+ }
+ throw new IllegalArgumentException("Cannot parse the results from a management operation");
+ }
+ finally
+ {
+ consumer.close();
+ responseQ.delete();
+ }
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+ else
+ {
+ Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try
+ {
+ return ((AMQSession<?, ?>) session).getQueueDepth((AMQDestination) destination);
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+ }
+
/**
* Send messages to the given destination.
Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/logging/AlertingTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/logging/AlertingTest.java?rev=1771283&r1=1771282&r2=1771283&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/logging/AlertingTest.java (original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/logging/AlertingTest.java Fri Nov 25 11:08:01 2016
@@ -26,8 +26,6 @@ import javax.jms.Connection;
import javax.jms.Queue;
import javax.jms.Session;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQSession;
import org.apache.qpid.systest.rest.RestTestHelper;
import org.apache.qpid.test.utils.TestBrokerConfiguration;
@@ -74,7 +72,7 @@ public class AlertingTest extends Abstra
{
_connection = getConnection();
_session = _connection.createSession(true, Session.SESSION_TRANSACTED);
- _destination = _session.createQueue(getTestQueueName());
+ _destination = createTestQueue(_session);
// Consumer is only used to actually create the destination
_session.createConsumer(_destination).close();
@@ -148,7 +146,7 @@ public class AlertingTest extends Abstra
setupConnection();
// Validate the queue depth is as expected
- long messageCount = ((AMQSession<?, ?>) _session).getQueueDepth((AMQDestination) _destination);
+ long messageCount = getQueueDepth(_connection, _destination);
assertEquals("Broker has invalid message count for test", 2, messageCount);
// Ensure the alert has not occurred yet
Modified: qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes
URL: http://svn.apache.org/viewvc/qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes?rev=1771283&r1=1771282&r2=1771283&view=diff
==============================================================================
--- qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes (original)
+++ qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes Fri Nov 25 11:08:01 2016
@@ -21,7 +21,6 @@
// working, defined as broken, or excluded as they test version specific functionality
org.apache.qpid.server.AbruptClientDisconnectTest#*
-org.apache.qpid.server.logging.AlertingTest#*
org.apache.qpid.server.logging.BindingLoggingTest#*
org.apache.qpid.server.logging.ChannelLoggingTest#*
org.apache.qpid.server.logging.ConnectionLoggingTest#*
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org