This is an automated email from the ASF dual-hosted git repository. gmurthy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push: new b6d8bae DISPATCH-1411 - Added UTC datetime and router id to all options of qdstat b6d8bae is described below commit b6d8bae8f8ee1337a32a5a720adc0a6def29349c Author: Ganesh Murthy <gmur...@apache.org> AuthorDate: Fri Oct 11 10:22:44 2019 -0400 DISPATCH-1411 - Added UTC datetime and router id to all options of qdstat --- pom.xml | 1 + tests/system_tests_link_routes.py | 4 +- ...system_tests_link_routes_add_external_prefix.py | 6 +- tests/system_tests_qdstat.py | 24 ++-- tools/qdstat.in | 123 +++++++++++++++++---- 5 files changed, 124 insertions(+), 34 deletions(-) diff --git a/pom.xml b/pom.xml index 3769861..375a479 100644 --- a/pom.xml +++ b/pom.xml @@ -107,6 +107,7 @@ <exclude>**/server-password-file.txt</exclude> <exclude>**/server-password-file-bad.txt</exclude> <exclude>**/client-password-file.txt</exclude> + <exclude>**/password.txt</exclude> <exclude>**/*.pkcs12</exclude> <exclude>**/.idea/**</exclude> <!-- This is for ignoring the intellij idea project files --> <exclude>**/*~</exclude> <!-- This is for files created by emacs --> diff --git a/tests/system_tests_link_routes.py b/tests/system_tests_link_routes.py index 7d4dc1f..22ceeaf 100644 --- a/tests/system_tests_link_routes.py +++ b/tests/system_tests_link_routes.py @@ -272,11 +272,11 @@ class LinkRouteTest(TestCase): self.assertEqual(out_list.count('out'), 4) parts = out.split("\n") - self.assertEqual(len(parts), 12) + self.assertEqual(len(parts), 15) out = self.run_qdstat_linkRoute(self.routers[1].addresses[0], args=['--limit=1']) parts = out.split("\n") - self.assertEqual(len(parts), 5) + self.assertEqual(len(parts), 8) def test_ccc_qdstat_link_routes_routerC(self): """ diff --git a/tests/system_tests_link_routes_add_external_prefix.py b/tests/system_tests_link_routes_add_external_prefix.py index 27383ac..85f8309 100644 --- a/tests/system_tests_link_routes_add_external_prefix.py +++ b/tests/system_tests_link_routes_add_external_prefix.py @@ -143,13 +143,13 @@ class LinkRouteTest(TestCase): def test_qdstat_link_routes_on_B(self): output = self.run_qdstat_linkRoute(self.routers[1].addresses[0]) lines = output.split("\n") - self.assertEqual(len(lines), 8) # 4 links, 3 lines of header and an empty line at the end - header = lines[1] + self.assertEqual(len(lines), 11) # 4 links, 3 lines of header and an empty line at the end + header = lines[4] columns = header.split() self.assertEqual(len(columns), 6) self.assertEqual(columns[4], "add-ext-prefix") self.assertEqual(columns[5], "del-ext-prefix") - linkroutes = parse_fields(header, lines[3:7]) + linkroutes = parse_fields(header, lines[6:10]) self.assertEqual(linkroutes[0][0], "foo") self.assertEqual(linkroutes[0][1], "in") self.assertEqual(linkroutes[0][4], "bar.") diff --git a/tests/system_tests_qdstat.py b/tests/system_tests_qdstat.py index 816747d..2147263 100644 --- a/tests/system_tests_qdstat.py +++ b/tests/system_tests_qdstat.py @@ -71,28 +71,32 @@ class QdstatTest(system_test.TestCase): self.assertTrue("Link Routes 0" in out) self.assertTrue("Router Id QDR.A" in out) self.assertTrue("Mode standalone" in out) + self.assertEqual(out.count("QDR.A"), 2) def test_connections(self): self.run_qdstat(['--connections'], r'host.*container.*role') - self.run_qdstat(['--connections'], 'no-auth') + outs = self.run_qdstat(['--connections'], 'no-auth') + outs = self.run_qdstat(['--connections'], 'QDR.A') def test_links(self): + self.run_qdstat(['--links'], r'QDR.A') out = self.run_qdstat(['--links'], r'endpoint.*out.*local.*temp.') parts = out.split("\n") - self.assertEqual(len(parts), 6) + self.assertEqual(len(parts), 9) def test_links_with_limit(self): out = self.run_qdstat(['--links', '--limit=1']) parts = out.split("\n") - self.assertEqual(len(parts), 5) + self.assertEqual(len(parts), 8) def test_nodes(self): self.run_qdstat(['--nodes'], r'No Router List') def test_address(self): + out = self.run_qdstat(['--address'], r'QDR.A') out = self.run_qdstat(['--address'], r'\$management') parts = out.split("\n") - self.assertEqual(len(parts), 8) + self.assertEqual(len(parts), 11) def test_qdstat_no_args(self): outs = self.run_qdstat(args=None) @@ -115,11 +119,11 @@ class QdstatTest(system_test.TestCase): # see if the header line has the word priority in it priorityregexp = r'pri' - priority_column = re.search(priorityregexp, lines[1]).start() + priority_column = re.search(priorityregexp, lines[4]).start() self.assertTrue(priority_column > -1) # extract the number in the priority column of every address - for i in range(3, len(lines) - 1): + for i in range(6, len(lines) - 1): pri = re.findall('\d+', lines[i][priority_column:]) # make sure the priority found is a number self.assertTrue(len(pri) > 0, "Can not find numeric priority in '%s'" % lines[i]) @@ -131,13 +135,15 @@ class QdstatTest(system_test.TestCase): def test_address_with_limit(self): out = self.run_qdstat(['--address', '--limit=1']) parts = out.split("\n") - self.assertEqual(len(parts), 5) + self.assertEqual(len(parts), 8) def test_memory(self): out = self.run_qdstat(['--memory']) if out.strip() == "No memory statistics available": # router built w/o memory pools enabled] return self.skipTest("Router's memory pools disabled") + self.assertTrue("QDR.A" in out) + self.assertTrue("UTC" in out) regexp = r'qdr_address_t\s+[0-9]+' assert re.search(regexp, out, re.I), "Can't find '%s' in '%s'" % (regexp, out) @@ -296,12 +302,12 @@ class QdstatLinkPriorityTest(system_test.TestCase): # see if the header line has the word priority in it priorityregexp = r'pri' - priority_column = re.search(priorityregexp, lines[1]).start() + priority_column = re.search(priorityregexp, lines[4]).start() self.assertTrue(priority_column > -1) # extract the number in the priority column of every inter-router link priorities = {} - for i in range(3, len(lines) - 1): + for i in range(6, len(lines) - 1): if re.search(r'inter-router', lines[i]): pri = re.findall('\d+', lines[i][priority_column:]) # make sure the priority found is a number diff --git a/tools/qdstat.in b/tools/qdstat.in index 02b61a8..c7399df 100755 --- a/tools/qdstat.in +++ b/tools/qdstat.in @@ -107,7 +107,19 @@ class BusManager(Node): return text[:-1] return text - def displayEdges(self): + def displayRouterId(self): + objects = self.query('org.apache.qpid.dispatch.router') + router = objects[0] + if router: + print(router.id) + + def display_datetime_router_id(self): + print(str(datetime.utcnow()) + " UTC") + self.displayRouterId() + print("") + + + def displayEdges(self, show_date_id=True): disp = Display(prefix=" ") heads = [] heads.append(Header("id")) @@ -123,8 +135,14 @@ class BusManager(Node): objects = self.query('org.apache.qpid.dispatch.connection', limit=self.opts.limit) if not objects: + if show_date_id: + self.display_datetime_router_id() print("No Edge Router Connections") return + + if show_date_id: + self.display_datetime_router_id() + has_active = False first = objects[0] @@ -139,7 +157,6 @@ class BusManager(Node): heads.append(Header("active")) for conn in objects: - #print (conn) if conn.role == "edge": row = [] row.append(conn.identity) @@ -165,7 +182,7 @@ class BusManager(Node): dispRows = rows disp.formattedTable(title, heads, dispRows) - def displayConnections(self): + def displayConnections(self, show_date_id=True): disp = Display(prefix=" ") heads = [] heads.append(Header("id")) @@ -180,6 +197,9 @@ class BusManager(Node): rows = [] objects = self.query('org.apache.qpid.dispatch.connection', limit=self.opts.limit) + if show_date_id: + self.display_datetime_router_id() + for conn in objects: row = [] row.append(conn.identity) @@ -255,7 +275,7 @@ class BusManager(Node): outlist.append(str(i)) return outlist - def displayGeneral(self): + def displayGeneral(self, show_date_id=True): disp = Display(prefix=" ") heads = [] heads.append(Header("attr")) @@ -265,6 +285,9 @@ class BusManager(Node): objects = self.query('org.apache.qpid.dispatch.router') router = objects[0] + if show_date_id: + self.display_datetime_router_id() + rows.append(('Version', router.version)) rows.append(('Mode', router.mode)) rows.append(('Router Id', router.id)) @@ -304,7 +327,7 @@ class BusManager(Node): dispRows = rows disp.formattedTable(title, heads, dispRows) - def displayRouterLinks(self): + def displayRouterLinks(self, show_date_id=True): disp = Display(prefix=" ") heads = [] heads.append(Header("type")) @@ -331,6 +354,9 @@ class BusManager(Node): has_priority = False has_delayed = False + if show_date_id: + self.display_datetime_router_id() + if objects: first_row = objects[0] if first_row: @@ -398,7 +424,7 @@ class BusManager(Node): dispRows = rows disp.formattedTable(title, heads, dispRows) - def displayRouterNodes(self): + def displayRouterNodes(self, show_date_id=True): disp = Display(prefix=" ") heads = [] heads.append(Header("router-id")) @@ -415,6 +441,9 @@ class BusManager(Node): # Find the most recent topo change in this neighborhood. lastTopoChange = 0.0 + if show_date_id: + self.display_datetime_router_id() + for node in objects: row = [] if node.lastTopoChange: @@ -446,7 +475,7 @@ class BusManager(Node): else: print("Router is Standalone - No Router List") - def displayAddresses(self): + def displayAddresses(self, show_date_id=True): disp = Display(prefix=" ") heads = [] heads.append(Header("class")) @@ -463,6 +492,9 @@ class BusManager(Node): has_priority = False + if show_date_id: + self.display_datetime_router_id() + if objects: first_row = objects[0] if first_row: @@ -511,7 +543,7 @@ class BusManager(Node): dispRows = sorter.getSorted() disp.formattedTable(title, heads, dispRows) - def displayAutolinks(self): + def displayAutolinks(self, show_date_id=True): disp = Display(prefix=" ") heads = [] heads.append(Header("addr")) @@ -526,6 +558,14 @@ class BusManager(Node): objects = self.query('org.apache.qpid.dispatch.router.config.autoLink', cols, limit=self.opts.limit) + if show_date_id: + self.display_datetime_router_id() + + if not objects: + print("AutoLinks") + print("No AutoLinks found") + return + for al in objects: row = [] row.append(al.address) @@ -536,12 +576,13 @@ class BusManager(Node): row.append(al.operStatus) row.append(al.lastError) rows.append(row) + title = "AutoLinks" sorter = Sorter(heads, rows, 'addr', 0, True) dispRows = sorter.getSorted() disp.formattedTable(title, heads, dispRows) - def displayLinkRoutes(self): + def displayLinkRoutes(self, show_date_id=True): disp = Display(prefix=" ") heads = [] heads.append(Header("address")) @@ -554,6 +595,17 @@ class BusManager(Node): link_routes = self.query('org.apache.qpid.dispatch.router.config.linkRoute', cols, limit=self.opts.limit) have_add_del_prefix = False + + if not link_routes: + if show_date_id: + self.display_datetime_router_id() + print("Link Routes") + print("No Link Routes found") + return + + if show_date_id: + self.display_datetime_router_id() + for link_route in link_routes: row = [] row.append(link_route.prefix if link_route.prefix else link_route.pattern) @@ -576,7 +628,7 @@ class BusManager(Node): dispRows = sorter.getSorted() disp.formattedTable(title, heads, dispRows) - def displayMemory(self): + def displayMemory(self, show_date_id=True): disp = Display(prefix=" ") heads = [] heads.append(Header("type")) @@ -594,6 +646,9 @@ class BusManager(Node): objects = self.query('org.apache.qpid.dispatch.allocator', cols) + if show_date_id: + self.display_datetime_router_id() + for t in objects: row = [] row.append(self._identity_clean(t.identity)) @@ -619,14 +674,38 @@ class BusManager(Node): for line in log: print("%s %s (%s) %s" % (ctime(line[5]), line[0], line[1], line[2])) - def show_all(self): - self.displayRouterLinks() - self.displayAddresses() - self.displayConnections() - self.displayAutolinks() - self.displayLinkRoutes() - self.displayGeneral() - self.displayMemory() + def show_all(self, show_summary=True): + if show_summary: + # print the datetime and router id + print(str(datetime.utcnow()) + " UTC") + self.displayRouterId() + print("") + + self.displayRouterLinks(show_date_id=False) + print("") + self.displayAddresses(show_date_id=False) + print("") + self.displayConnections(show_date_id=False) + print("") + self.displayAutolinks(show_date_id=False) + print("") + self.displayLinkRoutes(show_date_id=False) + print("") + self.displayGeneral(show_date_id=False) + print("") + self.displayMemory(show_date_id=False) + print("") + + def has_nodes(self): + all_nodes = super(BusManager, self).get_mgmt_nodes() + has_nodes = True + if all_nodes: + if len(all_nodes) < 2: + has_nodes = False + else: + has_nodes = False + + return has_nodes, all_nodes def has_nodes(self): all_nodes = super(BusManager, self).get_mgmt_nodes() @@ -642,12 +721,16 @@ class BusManager(Node): def display(self): has_nodes, nodes = self.has_nodes() if self.opts.all_routers and has_nodes: - print (str(datetime.now())) + print(str(datetime.utcnow()) + " UTC") for node in nodes: super(BusManager, self).set_client(node[6:]) parts = node.split("/") print ("Router ", parts[3]) - self.show() + print("") + if self.show.__name__ == 'show_all': + self.show(show_summary=False) + else: + self.show(show_date_id=False) print("") else: self.show() --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org