Author: aconway
Date: Mon Dec 15 16:07:10 2014
New Revision: 1645680

URL: http://svn.apache.org/r1645680
Log:
NO-JIRA: Fix inconsistent format of entity identifiers for router nodes.

Entity identities should be of the form <short-type-name>/<identifier>
routerNode entities were getting identifiers of the form "router.node:5"
Fixed this to be "router.node/5"

Modified:
    qpid/dispatch/trunk/src/router_agent.c
    qpid/dispatch/trunk/tests/system_test.py
    qpid/dispatch/trunk/tests/system_tests_management.py

Modified: qpid/dispatch/trunk/src/router_agent.c
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/router_agent.c?rev=1645680&r1=1645679&r2=1645680&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/router_agent.c (original)
+++ qpid/dispatch/trunk/src/router_agent.c Mon Dec 15 16:07:10 2014
@@ -82,7 +82,7 @@ qd_error_t qd_entity_refresh_router_node
     qd_router_node_t *rnode = (qd_router_node_t*) impl;
 
     if (!qd_entity_has(entity, "identity")) {
-        CHECK(qd_entity_set_stringf(entity, "identity", "%s:%d", 
QD_ROUTER_NODE_TYPE, rnode->mask_bit));
+        CHECK(qd_entity_set_stringf(entity, "identity", "%s/%d", 
QD_ROUTER_NODE_TYPE, rnode->mask_bit));
     }
     CHECK(qd_entity_set_string(entity, "addr", 
address_text(rnode->owning_addr)));
     long next_hop = rnode->next_hop ? rnode->next_hop->mask_bit : 0;

Modified: qpid/dispatch/trunk/tests/system_test.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_test.py?rev=1645680&r1=1645679&r2=1645680&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_test.py (original)
+++ qpid/dispatch/trunk/tests/system_test.py Mon Dec 15 16:07:10 2014
@@ -624,6 +624,11 @@ class TestCase(unittest.TestCase, Tester
     def assertIn(self, item, items):
         assert item in items, "%s not in %s" % (item, items)
 
+    if not getattr(unittest.TestCase, 'assertRegexpMatches'):
+        def assertRegexpMatches(self, text, regexp, msg=None):
+            """For python < 2.7: assert re.search(regexp, text)"""
+            assert re.search(regexp, text), msg or "Can't find %r in '%s'" 
%(regexp, text)
+
 def main_module():
     """
     Return the module name of the __main__ module - i.e. the filename with the

Modified: qpid/dispatch/trunk/tests/system_tests_management.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_management.py?rev=1645680&r1=1645679&r2=1645680&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_management.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_management.py Mon Dec 15 16:07:10 
2014
@@ -23,20 +23,26 @@ import unittest, system_test, re, os
 from qpid_dispatch.management import Node, ManagementError, Url, 
BadRequestStatus, NotImplementedStatus, NotFoundStatus, ForbiddenStatus
 from system_test import Qdrouterd, message, retry
 from proton import ConnectionException
+from itertools import chain
 
-DISPATCH = 'org.apache.qpid.dispatch'
-CONFIGURATION = DISPATCH + '.configurationEntity'
-OPERATIONAL = DISPATCH + '.operationalEntity'
-LISTENER = DISPATCH + '.listener'
-CONNECTOR = DISPATCH + '.connector'
-FIXED_ADDRESS = DISPATCH + '.fixedAddress'
-WAYPOINT = DISPATCH + '.waypoint'
-DUMMY = DISPATCH + '.dummy'
-ROUTER = DISPATCH + '.router'
+PREFIX = 'org.apache.qpid.dispatch.'
+CONFIGURATION = PREFIX + 'configurationEntity'
+OPERATIONAL = PREFIX + 'operationalEntity'
+LISTENER = PREFIX + 'listener'
+CONNECTOR = PREFIX + 'connector'
+FIXED_ADDRESS = PREFIX + 'fixedAddress'
+WAYPOINT = PREFIX + 'waypoint'
+DUMMY = PREFIX + 'dummy'
+ROUTER = PREFIX + 'router'
 LINK = ROUTER + '.link'
 ADDRESS = ROUTER + '.address'
 NODE = ROUTER + '.node'
 
+def short_name(name):
+    if name.startswith(PREFIX):
+        return name[len(PREFIX):]
+    return name
+
 
 class ManagementTest(system_test.TestCase): # pylint: 
disable=too-many-public-methods
 
@@ -325,6 +331,12 @@ class ManagementTest(system_test.TestCas
         self.assertEqual([u'amqp:/_topo/0/router2/$management', 
u'amqp:/_topo/0/router1/$management'],
                          sum([n.get_mgmt_nodes() for n in nodes], []))
 
+        # Test that all entities have a consitent identity format: type/name
+        entities = list(chain(
+            *[n.query(attribute_names=['type', 'identity', 
'name']).iter_entities() for n in nodes]))
+        for e in entities:
+            self.assertRegexpMatches(e.identity, "^%s/" % short_name(e.type))
+
     def test_get_types(self):
         types = self.node.get_types()
         self.assertIn(CONFIGURATION, types[LISTENER])



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to