DISPATCH-155 - From Jakub Scholz and Ganesh Murthy - Allow two connectors to the same host/port.
diff --git a/python/qpid_dispatch_internal/management/agent.py b/python/qpid_dispatch_internal/management/agent.py
index e6c664c..77e3416 100644
--- a/python/qpid_dispatch_internal/management/agent.py
+++ b/python/qpid_dispatch_internal/management/agent.py
@@ -319,11 +319,11 @@
return self.attributes.get('applicationName')
-def _host_port_identifier(entity):
- for attr in ['host', 'port']: # Set default values if need be
+def _host_port_name_identifier(entity):
+ for attr in ['host', 'port', 'name']: # Set default values if need be
entity.attributes.setdefault(
attr, entity.entity_type.attribute(attr).missing_value())
- return "%s:%s" % (entity.attributes['host'], entity.attributes['port'])
+ return "%s:%s:%s" % (entity.attributes['host'], entity.attributes['port'], entity.attributes['name'])
class ListenerEntity(EntityAdapter):
@@ -333,7 +333,7 @@
return config_listener
def _identifier(self):
- return _host_port_identifier(self)
+ return _host_port_name_identifier(self)
def __str__(self):
return super(ListenerEntity, self).__str__().replace("Entity(", "ListenerEntity(")
@@ -341,8 +341,6 @@
def _delete(self):
self._qd.qd_connection_manager_delete_listener(self._dispatch, self._implementations[0].key)
- def _identifier(self): return _host_port_identifier(self)
-
class ConnectorEntity(EntityAdapter):
def create(self):
config_connector = self._qd.qd_dispatch_configure_connector(self._dispatch, self)
@@ -353,7 +351,7 @@
self._qd.qd_connection_manager_delete_connector(self._dispatch, self._implementations[0].key)
def _identifier(self):
- return _host_port_identifier(self)
+ return _host_port_name_identifier(self)
def __str__(self):
return super(ConnectorEntity, self).__str__().replace("Entity(", "ConnectorEntity(")
@@ -469,7 +467,7 @@
class ConnectionEntity(EntityAdapter):
def _identifier(self):
- return self.attributes.get('host')
+ return self.attributes.get('host') + ":" + str(self.attributes.get('identity'))
def __str__(self):
return super(ConnectionEntity, self).__str__().replace("Entity(", "ConnectionEntity(")
diff --git a/tests/system_test.py b/tests/system_test.py
index f97b2bc..f4d070f 100755
--- a/tests/system_test.py
+++ b/tests/system_test.py
@@ -437,10 +437,18 @@
return address_list
def is_connected(self, port, host='127.0.0.1'):
- """If router has a connection to host:port return the management info.
+ """If router has a connection to host:port:identity return the management info.
Otherwise return None"""
try:
- return self.management.read(name="connection/%s:%s" % (host, port))
+ ret_val = False
+ response = self.management.query(type="org.apache.qpid.dispatch.connection")
+ index_name = response.attribute_names.index('name')
+ index_identity = response.attribute_names.index('identity')
+ for result in response.results:
+ outs = 'connection/%s:%s:%s' % (host, port, str(result[index_identity]))
+ if result[index_name] == outs:
+ ret_val = True
+ return ret_val
except:
return False
diff --git a/tests/system_tests_management.py b/tests/system_tests_management.py
index 1f6d486..662e11b 100644
--- a/tests/system_tests_management.py
+++ b/tests/system_tests_management.py
@@ -257,7 +257,7 @@
self.assertEqual(str(self.router.ports[0]), entity.port)
entity = self.node.read(
- type=LISTENER, identity='listener/0.0.0.0:%s' % self.router.ports[1])
+ type=LISTENER, identity='listener/0.0.0.0:%s:l1' % self.router.ports[1])
self.assertEqual('l1', entity.name)
self.assertEqual(str(self.router.ports[1]), entity.port)
diff --git a/tests/system_tests_qdmanage.py b/tests/system_tests_qdmanage.py
index 5621675..b8837b3 100644
--- a/tests/system_tests_qdmanage.py
+++ b/tests/system_tests_qdmanage.py
@@ -212,10 +212,15 @@
# Re-create the connector and then try wait_connectors
self.create(long_type, name, str(QdmanageTest.inter_router_port))
- full_name = 'connection/0.0.0.0:' + str(QdmanageTest.inter_router_port)
- output = json.loads(self.run_qdmanage('READ --type=org.apache.qpid.dispatch.connection --name ' + full_name))
- self.assertEquals(full_name, output['name'])
+ results = json.loads(self.run_qdmanage('QUERY --type=org.apache.qpid.dispatch.connection'))
+
+ created = False
+ for result in results:
+ name = result['name']
+ if 'connection/0.0.0.0:%s:' % QdmanageTest.inter_router_port in name:
+ created = True
+ self.assertTrue(created)
def test_zzz_add_connector(self):
port = self.get_port()