diff --git a/python/qpid_dispatch/management/client.py b/python/qpid_dispatch/management/client.py index a36d798d8b..9c81cd163b 100644 --- a/python/qpid_dispatch/management/client.py +++ b/python/qpid_dispatch/management/client.py @@ -122,8 +122,13 @@ def connect(url=None, router=None, timeout=10, ssl_domain=None, sasl=None, path = '_edge/%s/$management' % edge_router else: path = '$management' - return Node(Node.connection(url, router, timeout, ssl_domain, sasl, - edge_router=edge_router), path) + connection = Node.connection(url, router, timeout, ssl_domain, sasl, edge_router=edge_router) + try: + return Node(connection, path) + except Exception: + # ownership of connection has not been given to a new Node; close the connection + connection.close() + raise def __init__(self, connection, path, locales=None): """ diff --git a/tests/system_test.py b/tests/system_test.py index 5e7697eb09..08c96aec6c 100755 --- a/tests/system_test.py +++ b/tests/system_test.py @@ -51,13 +51,15 @@ import unittest +import proton +import proton.utils from proton import Message from proton import Delivery from proton.handlers import MessagingHandler from proton.reactor import AtLeastOnce, Container from proton.reactor import AtMostOnce from qpid_dispatch.management.client import Node - +from qpid_dispatch.management.error import NotFoundStatus # Optional modules MISSING_MODULES = [] @@ -704,7 +706,10 @@ def is_router_connected(self, router_id, **retry_kwargs): # Meantime the following actually tests send-thru to the router. node = Node.connect(self.addresses[0], router_id, timeout=1) return retry_exception(lambda: node.query('org.apache.qpid.dispatch.router')) - except: + except (proton.ConnectionException, NotFoundStatus, proton.utils.LinkDetached): + # proton.ConnectionException: the router is not yet accepting connections + # NotFoundStatus: the queried router is not yet connected + # TODO(DISPATCH-2119) proton.utils.LinkDetached: should be removed, currently needed for DISPATCH-2033 return False finally: if node: diff --git a/tests/system_tests_qdmanage.py b/tests/system_tests_qdmanage.py index 7dd0f8f211..28b412ed8f 100644 --- a/tests/system_tests_qdmanage.py +++ b/tests/system_tests_qdmanage.py @@ -100,7 +100,7 @@ def run_qdmanage(self, cmd, input=None, expect=Process.EXIT_OK, address=None): return out def assert_entity_equal(self, expect, actual, copy=None): - """Copy keys in copy from actual to identity, then assert maps equal.""" + """Copy keys in copy from actual to expect, then assert maps equal.""" if copy: for k in copy: expect[k] = actual[k]