diff options
author | Kenneth Anthony Giusti <kgiusti@apache.org> | 2013-04-19 17:59:28 +0000 |
---|---|---|
committer | Kenneth Anthony Giusti <kgiusti@apache.org> | 2013-04-19 17:59:28 +0000 |
commit | 4b59e2ce1f5f7f8e3171e19a04185f3b133a6b38 (patch) | |
tree | 58215f661184a4d906332cdf5c832487849cddbb | |
parent | 8735514651a4873dc0b9b0ea4cf0fc58267e6fb3 (diff) | |
download | qpid-python-4b59e2ce1f5f7f8e3171e19a04185f3b133a6b38.tar.gz |
QPID-4756: enable updateStats callback for QMFv2 object notifications
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1469974 13f79535-47bb-0310-9956-ffa450edef68
-rwxr-xr-x | qpid/cpp/src/tests/qpidd_qmfv2_tests.py | 46 | ||||
-rw-r--r-- | qpid/extras/qmf/src/py/qmf/console.py | 14 |
2 files changed, 39 insertions, 21 deletions
diff --git a/qpid/cpp/src/tests/qpidd_qmfv2_tests.py b/qpid/cpp/src/tests/qpidd_qmfv2_tests.py index d9a725fb23..8e32e466c5 100755 --- a/qpid/cpp/src/tests/qpidd_qmfv2_tests.py +++ b/qpid/cpp/src/tests/qpidd_qmfv2_tests.py @@ -88,8 +88,7 @@ class ConsoleTest(BrokerTest): self.newclass = [] self.agents = [] self.events = [] - self.props = [] - self.stats = [] + self.updates = {} # holds the objects by OID self.heartbeats = [] def brokerInfo(self, broker): @@ -111,17 +110,19 @@ class ConsoleTest(BrokerTest): #print "EVENT %s" % event self.events.append(event) def objectProps(self, broker, record): - #print "ObjProps PROPS=[%s]" % str(record.getProperties()) - #print "ObjProps STATS=[%s]" % str(record.getStatistics()) - # Both statistics and properties are available: - props = record.getProperties() - if props: - self.props.append(record) - stats = record.getStatistics() - if stats: - self.stats.append(record) + #print "ObjProps %s" % record + oid = record.getObjectId() + if oid not in self.updates: + self.updates[oid] = record + else: + self.updates[oid].mergeUpdate( record ) def objectStats(self, broker, record): - assert False, "objectStats() not called if QMFv2" + #print "ObjStats %s" % record + oid = record.getObjectId() + if oid not in self.updates: + self.updates[oid] = record + else: + self.updates[oid].mergeUpdate( record ) def heartbeat(self, agent, timestamp): #print "Heartbeat %s" % agent self.heartbeats.append( (agent, timestamp) ) @@ -133,7 +134,11 @@ class ConsoleTest(BrokerTest): # this should force objectStats callback self.broker.send_message( "fleabag", Message("Hi") ) # and we should get a few heartbeats - sleep(self.PUB_INTERVAL * 3) + sleep(self.PUB_INTERVAL) + self.broker.send_message( "fleabag", Message("Hi") ) + sleep(self.PUB_INTERVAL) + self.broker.send_message( "fleabag", Message("Hi") ) + sleep(self.PUB_INTERVAL * 2) assert handler.broker_info, "No BrokerInfo callbacks received" assert handler.broker_conn, "No BrokerConnected callbacks received" @@ -141,10 +146,21 @@ class ConsoleTest(BrokerTest): assert handler.newclass, "No NewClass callbacks received" assert handler.agents, "No NewAgent callbacks received" assert handler.events, "No event callbacks received" - assert handler.props, "No properties updates received" - assert handler.stats, "No statistics received" + assert handler.updates, "No updates received" assert handler.heartbeats, "No heartbeat callbacks received" + # now verify updates for queue "fleabag" were received, and the + # msgDepth statistic is correct + + msgs = 0 + for o in handler.updates.itervalues(): + key = o.getClassKey() + if key and key.getClassName() == "queue" and o.name == "fleabag": + assert o.msgDepth, "No update to msgDepth statistic!" + msgs = o.msgDepth + break + assert msgs == 3, "msgDepth statistics not accurate!" + def test_async_method(self): class Handler (qmf.console.Console): def __init__(self): diff --git a/qpid/extras/qmf/src/py/qmf/console.py b/qpid/extras/qmf/src/py/qmf/console.py index bd30730617..2d80bd26d2 100644 --- a/qpid/extras/qmf/src/py/qmf/console.py +++ b/qpid/extras/qmf/src/py/qmf/console.py @@ -3101,15 +3101,17 @@ class Agent: if 'qmf_object' in kwargs: if self.session.console: obj = kwargs['qmf_object'] - if len(self.session.class_filter) == 0: - self.session.console.objectProps(self.broker, obj) - elif obj.getClassKey(): + if self.session.class_filter and obj.getClassKey(): # slow path: check classKey against event_filter pname = obj.getClassKey().getPackageName() cname = obj.getClassKey().getClassName() - if ((pname, cname) in self.session.class_filter - or (pname, None) in self.session.class_filter): - self.session.console.objectProps(self.broker, obj) + if ((pname, cname) not in self.session.class_filter + and (pname, None) not in self.session.class_filter): + return + self.session.console.objectProps(self.broker, obj) + if obj.getStatistics(): + # QMFv2 objects may also contain statistic updates + self.session.console.objectStats(self.broker, obj) elif 'qmf_object_stats' in kwargs: if self.session.console: obj = kwargs['qmf_object_stats'] |