diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json index 4b380925d6..e31f54c0e1 100644 --- a/python/qpid_dispatch/management/qdrouter.json +++ b/python/qpid_dispatch/management/qdrouter.json @@ -1423,6 +1423,10 @@ "ingressHistogram": { "type": "list", "description": "For outgoing links on connections with 'normal' role. This histogram shows the number of settled deliveries on the link that ingressed the network at each interior router node." + }, + "priority": { + "type": "integer", + "description": "For inter-router links, this is the message priority being handled." } } }, diff --git a/src/router_core/agent_link.c b/src/router_core/agent_link.c index b2d7dbfc75..5ca0f25ab1 100644 --- a/src/router_core/agent_link.c +++ b/src/router_core/agent_link.c @@ -43,6 +43,7 @@ #define QDR_LINK_RELEASED_COUNT 19 #define QDR_LINK_MODIFIED_COUNT 20 #define QDR_LINK_INGRESS_HISTOGRAM 21 +#define QDR_LINK_PRIORITY 22 const char *qdr_link_columns[] = {"name", @@ -67,6 +68,7 @@ const char *qdr_link_columns[] = "releasedCount", "modifiedCount", "ingressHistogram", + "priority", 0}; static const char *qd_link_type_name(qd_link_type_t lt) @@ -220,6 +222,10 @@ static void qdr_agent_write_column_CT(qd_composed_field_t *body, int col, qdr_li qd_compose_insert_null(body); break; + case QDR_LINK_PRIORITY: + qd_compose_insert_uint(body, link->priority); + break; + default: qd_compose_insert_null(body); break; diff --git a/src/router_core/agent_link.h b/src/router_core/agent_link.h index 64029496c0..cd92c1b7f7 100644 --- a/src/router_core/agent_link.h +++ b/src/router_core/agent_link.h @@ -29,7 +29,7 @@ void qdra_link_update_CT(qdr_core_t *core, qdr_query_t *query, qd_parsed_field_t *in_body); -#define QDR_LINK_COLUMN_COUNT 22 +#define QDR_LINK_COLUMN_COUNT 23 const char *qdr_link_columns[QDR_LINK_COLUMN_COUNT + 1]; diff --git a/tests/system_tests_qdstat.py b/tests/system_tests_qdstat.py index 45040f0a2e..2bd89d72c2 100644 --- a/tests/system_tests_qdstat.py +++ b/tests/system_tests_qdstat.py @@ -30,7 +30,6 @@ from proton import Url, SSLDomain, SSLUnavailable, SASL from system_test import main_module, SkipIfNeeded - class QdstatTest(system_test.TestCase): """Test qdstat tool output""" @classmethod @@ -104,6 +103,70 @@ def test_memory(self): def test_log(self): self.run_qdstat(['--log', '--limit=5'], r'AGENT \(debug\).*GET-LOG') +class QdstatLinkPriorityTest(system_test.TestCase): + """Need 2 routers to get inter-router links for the link priority test""" + @classmethod + def setUpClass(cls): + super(QdstatLinkPriorityTest, cls).setUpClass() + cls.inter_router_port = cls.tester.get_port() + config_1 = system_test.Qdrouterd.Config([ + ('router', {'mode': 'interior', 'id': 'R1'}), + ('listener', {'port': cls.tester.get_port()}), + ('connector', {'role': 'inter-router', 'port': cls.inter_router_port}) + ]) + + config_2 = system_test.Qdrouterd.Config([ + ('router', {'mode': 'interior', 'id': 'R2'}), + ('listener', {'role': 'inter-router', 'port': cls.inter_router_port}), + ]) + cls.router_2 = cls.tester.qdrouterd('test_router_2', config_2, wait=True) + cls.router_1 = cls.tester.qdrouterd('test_router_1', config_1, wait=True) + cls.router_1.wait_router_connected('R2') + + def address(self): + return self.router_1.addresses[0] + + def run_qdstat(self, args): + p = self.popen( + ['qdstat', '--bus', str(self.address()), '--timeout', str(system_test.TIMEOUT) ] + args, + name='qdstat-'+self.id(), stdout=PIPE, expect=None, + universal_newlines=True) + + out = p.communicate()[0] + assert p.returncode == 0, \ + "qdstat exit status %s, output:\n%s" % (p.returncode, out) + return out + + def test_link_priority(self): + out = self.run_qdstat(['--links']) + lines = out.split("\n") + + # make sure the output contains a header line + self.assertGreaterEqual(len(lines), 2) + + # see if the header line has the word priority in it + priorityregexp = r'priority' + priority_column = re.search(priorityregexp, lines[1]).start() + self.assertGreater(priority_column, -1) + + # extract the number in the priority column of every inter-router link + priorities = {} + for i in range(3, 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 + self.assertGreater(len(pri), 0, "Can not find numeric priority in '%s'" % lines[i]) + priority = int(pri[0]) + # make sure the priority is from 0 to 9 + self.assertGreaterEqual(priority, 0, "Priority was less than 0") + self.assertLessEqual(priority, 9, "Priority was greater than 9") + + # mark this priority as present + priorities[priority] = True + + # make sure that all priorities are present in the list (currently 0-9) + self.assertEqual(len(priorities.keys()), 10, "Not all priorities are present") + try: SSLDomain(SSLDomain.MODE_CLIENT) class QdstatSslTest(system_test.TestCase): diff --git a/tools/qdstat.in b/tools/qdstat.in index 2086310ef5..471b3c1b2a 100755 --- a/tools/qdstat.in +++ b/tools/qdstat.in @@ -293,7 +293,7 @@ class BusManager(Node): cols = ('linkType', 'linkDir', 'connectionId', 'identity', 'peer', 'owningAddr', 'capacity', 'undeliveredCount', 'unsettledCount', 'deliveryCount', 'presettledCount', 'droppedPresettledCount', 'acceptedCount', 'rejectedCount', 'releasedCount', - 'modifiedCount', 'adminStatus', 'operStatus', 'linkName') + 'modifiedCount', 'adminStatus', 'operStatus', 'linkName', 'priority') objects = self.query('org.apache.qpid.dispatch.router.link', cols, limit=self.opts.limit) @@ -314,6 +314,7 @@ class BusManager(Node): heads.append(Header("mod")) heads.append(Header("admin")) heads.append(Header("oper")) + heads.append(Header("priority")) if self.opts.verbose: heads.append(Header("name")) @@ -340,6 +341,7 @@ class BusManager(Node): row.append(link.modifiedCount) row.append(link.adminStatus) row.append(link.operStatus) + row.append(link.priority) if self.opts.verbose: row.append(link.linkName) rows.append(row)