Repository: qpid-dispatch Updated Branches: refs/heads/master b794973eb -> 07eb9c404
DISPATCH-556 - Default limit of rows obtained by qdstat to 1000 (cherry picked from commit 37f0b705f65c8f6d6074a7be101f857c49f8d7e8) Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/07eb9c40 Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/07eb9c40 Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/07eb9c40 Branch: refs/heads/master Commit: 07eb9c404bd3375c95993c0ddb7cec4bf1d33dd9 Parents: b794973 Author: Ganesh Murthy <[email protected]> Authored: Wed Dec 7 16:33:44 2016 -0500 Committer: Ganesh Murthy <[email protected]> Committed: Thu Dec 8 09:12:32 2016 -0500 ---------------------------------------------------------------------- tests/system_tests_link_routes.py | 17 ++++++++++++----- tests/system_tests_qdstat.py | 18 ++++++++++++++++-- tools/qdstat | 27 ++++++++++++++++++--------- 3 files changed, 46 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/07eb9c40/tests/system_tests_link_routes.py ---------------------------------------------------------------------- diff --git a/tests/system_tests_link_routes.py b/tests/system_tests_link_routes.py index ada1795..15749dc 100644 --- a/tests/system_tests_link_routes.py +++ b/tests/system_tests_link_routes.py @@ -119,9 +119,12 @@ class LinkRouteTest(TestCase): # bit more time for the routers to stabilize. sleep(2) - def run_qdstat_linkRoute(self, address): + def run_qdstat_linkRoute(self, address, args=None): + cmd = ['qdstat', '--bus', str(address), '--timeout', str(TIMEOUT) ] + ['--linkroute'] + if args: + cmd = cmd + args p = self.popen( - ['qdstat', '--bus', str(address), '--timeout', str(TIMEOUT) ] + ['--linkroute'], + cmd, name='qdstat-'+self.id(), stdout=PIPE, expect=None) out = p.communicate()[0] @@ -196,9 +199,6 @@ class LinkRouteTest(TestCase): out = self.run_qdmanage(cmd=cmd, address=self.routers[1].addresses[0]) self.assertTrue(identity in out) - - - def test_bbb_qdstat_link_routes_routerB(self): """ Runs qdstat on router B to make sure that router B has two link routes, one 'in' and one 'out' @@ -209,6 +209,13 @@ class LinkRouteTest(TestCase): self.assertEqual(out_list.count('in'), 2) self.assertEqual(out_list.count('out'), 2) + parts = out.split("\n") + self.assertEqual(len(parts), 8) + + out = self.run_qdstat_linkRoute(self.routers[1].addresses[0], args=['--limit=1']) + parts = out.split("\n") + self.assertEqual(len(parts), 5) + def test_ccc_qdstat_link_routes_routerC(self): """ Runs qdstat on router C to make sure that router C has two link routes, one 'in' and one 'out' http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/07eb9c40/tests/system_tests_qdstat.py ---------------------------------------------------------------------- diff --git a/tests/system_tests_qdstat.py b/tests/system_tests_qdstat.py index 016acae..d54f7df 100644 --- a/tests/system_tests_qdstat.py +++ b/tests/system_tests_qdstat.py @@ -62,13 +62,27 @@ class QdstatTest(system_test.TestCase): self.run_qdstat(['--connections'], r'host.*container.*role') def test_links(self): - self.run_qdstat(['--links'], r'endpoint.*out.*local.*temp.') + out = self.run_qdstat(['--links'], r'endpoint.*out.*local.*temp.') + parts = out.split("\n") + self.assertEqual(len(parts), 6) + + def test_links_with_limit(self): + out = self.run_qdstat(['--links', '--limit=1']) + parts = out.split("\n") + self.assertEqual(len(parts), 5) def test_nodes(self): self.run_qdstat(['--nodes'], r'No Router List') def test_address(self): - self.run_qdstat(['--address'], r'\$management') + out = self.run_qdstat(['--address'], r'\$management') + parts = out.split("\n") + self.assertEqual(len(parts), 8) + + def test_address_with_limit(self): + out = self.run_qdstat(['--address', '--limit=1']) + parts = out.split("\n") + self.assertEqual(len(parts), 5) def test_memory(self): out = self.run_qdstat(['--memory']) http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/07eb9c40/tools/qdstat ---------------------------------------------------------------------- diff --git a/tools/qdstat b/tools/qdstat index 5bd076f..a6c98e0 100755 --- a/tools/qdstat +++ b/tools/qdstat @@ -52,7 +52,11 @@ def parse_args(argv): parser.add_option("--linkroutes", help="Show Link Routes", action="store_const", const="linkroutes", dest="show") parser.add_option("-v", "--verbose", help="Show maximum detail", action="store_true", dest="verbose") parser.add_option("--log", help="Show recent log entries", action="store_const", const="log", dest="show") - parser.add_option("--limit", help="Limit number of log entries", type="int") + + # This limit can be used to limit the number of output rows and can be used in conjunction with options + # like -c, -l, -a, --autolinks, --linkroutes and --log. + # By default, the limit is set to 1000 rows. + parser.add_option("--limit", help="Limit number of output rows", type="int", default=1000) opts, args = parser.parse_args(args=argv) @@ -74,13 +78,13 @@ class BusManager(Node): ssl_domain=opts_ssl_domain(opts), sasl=opts_sasl(self.opts))) - def query(self, entity_type, attribute_names=None): + def query(self, entity_type, attribute_names=None, limit=None): if attribute_names: unames = [] for a in attribute_names: unames.append(unicode(a)) attribute_names = unames - return super(BusManager, self).query(entity_type, attribute_names).get_entities() + return super(BusManager, self).query(entity_type, attribute_names, count=limit).get_entities() def connAuth(self, conn): ## @@ -127,7 +131,7 @@ class BusManager(Node): rows = [] - objects = self.query('org.apache.qpid.dispatch.connection') + objects = self.query('org.apache.qpid.dispatch.connection', limit=self.opts.limit) for conn in objects: row = [] @@ -255,7 +259,8 @@ class BusManager(Node): 'capacity', 'undeliveredCount', 'unsettledCount', 'deliveryCount', 'presettledCount', 'acceptedCount', 'rejectedCount', 'releasedCount', 'modifiedCount', 'adminStatus', 'operStatus', 'linkName') - objects = self.query('org.apache.qpid.dispatch.router.link', cols) + + objects = self.query('org.apache.qpid.dispatch.router.link', cols, limit=self.opts.limit) for link in objects: row = [] @@ -300,7 +305,7 @@ class BusManager(Node): cols = ('id', 'nextHop', 'routerLink', 'lastTopoChange') if self.opts.verbose: cols += ('cost', 'linkState', 'validOrigins') - objects = self.query('org.apache.qpid.dispatch.router.node', cols) + objects = self.query('org.apache.qpid.dispatch.router.node', cols, limit=self.opts.limit) # Find the most recent topo change in this neighborhood. lastTopoChange = 0.0 @@ -356,7 +361,8 @@ class BusManager(Node): cols = ('distribution', 'inProcess', 'subscriberCount', 'remoteCount', 'containerCount', 'deliveriesIngress', 'deliveriesEgress', 'deliveriesTransit', 'deliveriesToContainer', 'deliveriesFromContainer') - objects = self.query('org.apache.qpid.dispatch.router.address', cols) + + objects = self.query('org.apache.qpid.dispatch.router.address', cols, limit=self.opts.limit) for addr in objects: row = [] @@ -392,7 +398,8 @@ class BusManager(Node): rows = [] cols = ('addr', 'dir', 'phase', 'externalAddr', 'linkRef', 'operStatus', 'lastError') - objects = self.query('org.apache.qpid.dispatch.router.config.autoLink', cols) + + objects = self.query('org.apache.qpid.dispatch.router.config.autoLink', cols, limit=self.opts.limit) for al in objects: row = [] @@ -419,7 +426,8 @@ class BusManager(Node): rows = [] cols = ('prefix', 'dir', 'distribution', 'operStatus') - link_routes = self.query('org.apache.qpid.dispatch.router.config.linkRoute', cols) + + link_routes = self.query('org.apache.qpid.dispatch.router.config.linkRoute', cols, limit=self.opts.limit) for link_route in link_routes: row = [] @@ -449,6 +457,7 @@ class BusManager(Node): cols = ('identity', 'typeSize', 'transferBatchSize', 'localFreeListMax', 'totalAllocFromHeap', 'heldByThreads', 'batchesRebalancedToThreads', 'batchesRebalancedToGlobal') + objects = self.query('org.apache.qpid.dispatch.allocator', cols) for t in objects: --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
