From eb7dea6769266c79175689586ae8fef37791fe0d Mon Sep 17 00:00:00 2001 From: Kenneth Giusti Date: Tue, 26 Sep 2023 09:55:40 -0400 Subject: [PATCH] Fixes #1234: use common declaration of management type id in CI tests --- tests/http1_tests.py | 27 ++--- tests/system_test.py | 58 ++++++---- tests/system_tests_autolinks.py | 19 ++-- tests/system_tests_connector_status.py | 7 +- tests/system_tests_delivery_abort.py | 5 +- tests/system_tests_delivery_counts.py | 41 +++---- tests/system_tests_distribution.py | 6 +- tests/system_tests_edge_router.py | 17 ++- tests/system_tests_handle_failover.py | 14 +-- tests/system_tests_http.py | 12 +- tests/system_tests_http1_adaptor.py | 62 +++++------ tests/system_tests_http2.py | 39 ++++--- tests/system_tests_log_level_update.py | 35 +++--- tests/system_tests_management.py | 114 +++++++++---------- tests/system_tests_multicast.py | 10 +- tests/system_tests_one_router.py | 50 +++++---- tests/system_tests_open_properties.py | 3 +- tests/system_tests_panic_handler.py | 4 +- tests/system_tests_priority.py | 4 +- tests/system_tests_sasl_plain.py | 20 ++-- tests/system_tests_skmanage.py | 121 ++++++++++----------- tests/system_tests_ssl.py | 16 ++- tests/system_tests_tcp_adaptor.py | 98 ++++++++--------- tests/system_tests_tcp_half_close.py | 2 +- tests/system_tests_topology.py | 14 +-- tests/system_tests_topology_disposition.py | 9 +- tests/system_tests_two_routers.py | 23 ++-- tests/system_tests_user_id.py | 30 ++--- 28 files changed, 426 insertions(+), 434 deletions(-) diff --git a/tests/http1_tests.py b/tests/http1_tests.py index 0c7db383a..d439690b4 100644 --- a/tests/http1_tests.py +++ b/tests/http1_tests.py @@ -34,6 +34,8 @@ from system_test import TestCase, TIMEOUT, Logger, Qdrouterd, unittest from system_test import curl_available, run_curl, retry from system_test import retry_exception +from system_test import HTTP_CONNECTOR_TYPE, HTTP_LISTENER_TYPE +from system_test import TCP_LISTENER_TYPE CURL_VERSION = (7, 47, 0) # minimum required @@ -525,8 +527,7 @@ def wait_http_listeners_up(mgmt_address: str, Wait until the configured HTTP listener sockets have come up. Optionally filter the set of configured listeners using attribute names and values """ - LISTENER_TYPE = 'io.skupper.router.httpListener' - return _wait_adaptor_listeners_oper_status(LISTENER_TYPE, mgmt_address, + return _wait_adaptor_listeners_oper_status(HTTP_LISTENER_TYPE, mgmt_address, 'up', l_filter, timeout) @@ -538,8 +539,7 @@ def wait_http_listeners_down(mgmt_address: str, deactivated. Optionally filter the set of configured listeners using attribute names and values """ - LISTENER_TYPE = 'io.skupper.router.httpListener' - return _wait_adaptor_listeners_oper_status(LISTENER_TYPE, mgmt_address, + return _wait_adaptor_listeners_oper_status(HTTP_LISTENER_TYPE, mgmt_address, 'down', l_filter, timeout) @@ -550,8 +550,7 @@ def wait_tcp_listeners_up(mgmt_address: str, Wait until the configured TCP listener sockets have come up. Optionally filter the set of configured listeners using attribute names and values """ - LISTENER_TYPE = 'io.skupper.router.tcpListener' - return _wait_adaptor_listeners_oper_status(LISTENER_TYPE, mgmt_address, + return _wait_adaptor_listeners_oper_status(TCP_LISTENER_TYPE, mgmt_address, 'up', l_filter, timeout) @@ -1832,8 +1831,6 @@ class HttpAdaptorListenerConnectTestBase(TestCase): """ Test client connecting to adaptor listeners in various scenarios """ - LISTENER_TYPE = 'io.skupper.router.httpListener' - CONNECTOR_TYPE = 'io.skupper.router.httpConnector' PROTOCOL_VERSION = "HTTP1" @classmethod @@ -1934,14 +1931,14 @@ def _test_listener_socket_lifecycle(self, attributes = {'address': van_address, 'port': listener_port, 'protocolVersion': self.PROTOCOL_VERSION} - l_mgmt.create(type=self.LISTENER_TYPE, + l_mgmt.create(type=HTTP_LISTENER_TYPE, name=listener_name, attributes=attributes) # since there is no connector present, the operational state must be # down and connection attempts must be refused - listener = l_mgmt.read(type=self.LISTENER_TYPE, name=listener_name) + listener = l_mgmt.read(type=HTTP_LISTENER_TYPE, name=listener_name) self.assertEqual('down', listener['operStatus']) self.assertRaises(ConnectionRefusedError, self.client_connect, listener_port) @@ -1954,7 +1951,7 @@ def _test_listener_socket_lifecycle(self, 'host': '127.0.0.1', 'port': connector_port, 'protocolVersion': self.PROTOCOL_VERSION} - c_mgmt.create(type=self.CONNECTOR_TYPE, + c_mgmt.create(type=HTTP_CONNECTOR_TYPE, name=connector_name, attributes=attributes) @@ -1967,7 +1964,7 @@ def _test_listener_socket_lifecycle(self, # expect the listener socket to come up - self.assertTrue(retry(lambda: l_mgmt.read(type=self.LISTENER_TYPE, + self.assertTrue(retry(lambda: l_mgmt.read(type=HTTP_LISTENER_TYPE, name=listener_name)['operStatus'] == 'up')) # ensure clients can connect successfully. There may be a delay @@ -1980,10 +1977,10 @@ def _test_listener_socket_lifecycle(self, # Teardown the connector, expect listener admin state to go down - c_mgmt.delete(type=self.CONNECTOR_TYPE, name=connector_name) + c_mgmt.delete(type=HTTP_CONNECTOR_TYPE, name=connector_name) l_router.wait_address_unsubscribed(van_address) - self.assertTrue(retry(lambda: l_mgmt.read(type=self.LISTENER_TYPE, + self.assertTrue(retry(lambda: l_mgmt.read(type=HTTP_LISTENER_TYPE, name=listener_name)['operStatus'] == 'down')) @@ -1992,7 +1989,7 @@ def _func(): return self.client_connect(listener_port) != True self.assertRaises(ConnectionRefusedError, retry, _func) - l_mgmt.delete(type=self.LISTENER_TYPE, name=listener_name) + l_mgmt.delete(type=HTTP_LISTENER_TYPE, name=listener_name) class HttpTlsBadConfigTestsBase(TestCase): diff --git a/tests/system_test.py b/tests/system_test.py index 576546696..1852d7c54 100755 --- a/tests/system_test.py +++ b/tests/system_test.py @@ -74,11 +74,31 @@ # Optional modules MISSING_MODULES = [] -HTTP_LISTENER_TYPE = 'io.skupper.router.httpListener' -TCP_LISTENER_TYPE = 'io.skupper.router.tcpListener' + +# Management entity type names +ALLOCATOR_TYPE = 'io.skupper.router.allocator' +AMQP_CONNECTOR_TYPE = 'io.skupper.router.connector' +AMQP_LISTENER_TYPE = 'io.skupper.router.listener' +CONFIG_ADDRESS_TYPE = 'io.skupper.router.router.config.address' +CONFIG_AUTOLINK_TYPE = 'io.skupper.router.router.config.autoLink' +CONFIG_ENTITY_TYPE = 'io.skupper.router.configurationEntity' +CONNECTION_TYPE = 'io.skupper.router.connection' +DUMMY_TYPE = 'io.skupper.router.dummy' +ENTITY_TYPE = 'io.skupper.router.entity' HTTP_CONNECTOR_TYPE = 'io.skupper.router.httpConnector' +HTTP_LISTENER_TYPE = 'io.skupper.router.httpListener' +HTTP_REQ_INFO_TYPE = 'io.skupper.router.httpRequestInfo' +LOG_STATS_TYPE = 'io.skupper.router.logStats' +LOG_TYPE = 'io.skupper.router.log' +MANAGEMENT_TYPE = 'io.skupper.router.management' +OPER_ENTITY_TYPE = 'io.skupper.router.operationalEntity' +ROUTER_ADDRESS_TYPE = 'io.skupper.router.router.address' +ROUTER_LINK_TYPE = 'io.skupper.router.router.link' +ROUTER_NODE_TYPE = 'io.skupper.router.router.node' +ROUTER_TYPE = 'io.skupper.router.router' +SSL_PROFILE_TYPE = 'io.skupper.router.sslProfile' TCP_CONNECTOR_TYPE = 'io.skupper.router.tcpConnector' -CONNECTION_TYPE = 'io.skupper.router.connection' +TCP_LISTENER_TYPE = 'io.skupper.router.tcpListener' try: import qpidtoollibs # pylint: disable=unused-import @@ -901,7 +921,7 @@ def is_connected(self, port, host='127.0.0.1'): Otherwise return None""" try: ret_val = False - response = self.management.query(type="io.skupper.router.connection") + response = self.management.query(type=CONNECTION_TYPE) index_host = response.attribute_names.index('host') for result in response.results: outs = '%s:%s' % (host, port) @@ -925,7 +945,7 @@ def check(): # Need to rationalize addresses in management attributes. # endswith check is because of M/L/R prefixes addrs = self.management.query( - type='io.skupper.router.router.address', + type=ROUTER_ADDRESS_TYPE, attribute_names=['name', 'subscriberCount', 'remoteCount']).get_entities() addrs = [a for a in addrs if a['name'].endswith(address)] @@ -939,7 +959,7 @@ def wait_address_unsubscribed(self, address, **retry_kwargs): """ Block until address has no subscribers """ - a_type = 'io.skupper.router.router.address' + a_type = ROUTER_ADDRESS_TYPE def check(): addrs = self.management.query(a_type).get_dicts() @@ -1023,7 +1043,7 @@ def is_router_connected(self, router_id, **retry_kwargs): # Meantime the following actually tests send-thru to the router. try: with Node.connect(self.addresses[0], router_id) as node: - return node.query('io.skupper.router.router') + return node.query(ROUTER_TYPE) except (proton.ConnectionException, proton.Timeout, NotFoundStatus, proton.utils.LinkDetached, proton.utils.SendException) as exc: @@ -1044,7 +1064,7 @@ def is_edges_connected(edges=num_edges, meshes=num_meshes): node = None try: node = Node.connect(self.addresses[0], timeout=1) - out = retry_exception(lambda: node.query('io.skupper.router.connection'), delay=1) + out = retry_exception(lambda: node.query(CONNECTION_TYPE), delay=1) if out: role_index = out.attribute_names.index("role") dir_index = out.attribute_names.index("dir") @@ -1078,7 +1098,7 @@ def is_server_connected(check_tls=is_tls): node = None try: node = Node.connect(self.addresses[0], timeout=1) - out = retry_exception(lambda: node.query('io.skupper.router.connection')) + out = retry_exception(lambda: node.query(CONNECTION_TYPE)) if out: role_index = out.attribute_names.index("role") dir_index = out.attribute_names.index("dir") @@ -1782,32 +1802,32 @@ def response(self, msg): return self._Response(ap['statusCode'], ap['statusDescription'], msg.body) def query_router(self): - ap = {'operation': 'QUERY', 'type': 'io.skupper.router.router'} + ap = {'operation': 'QUERY', 'type': ROUTER_TYPE} return Message(properties=ap, reply_to=self.reply_addr) def query_connections(self): - ap = {'operation': 'QUERY', 'type': 'io.skupper.router.connection'} + ap = {'operation': 'QUERY', 'type': CONNECTION_TYPE} return Message(properties=ap, reply_to=self.reply_addr) def query_links(self): - ap = {'operation': 'QUERY', 'type': 'io.skupper.router.router.link'} + ap = {'operation': 'QUERY', 'type': ROUTER_LINK_TYPE} return Message(properties=ap, reply_to=self.reply_addr) def query_addresses(self): ap = {'operation': 'QUERY', - 'type': 'io.skupper.router.router.address'} + 'type': ROUTER_ADDRESS_TYPE} return Message(properties=ap, reply_to=self.reply_addr) def create_connector(self, name, **kwargs): ap = {'operation': 'CREATE', - 'type': 'io.skupper.router.connector', + 'type': AMQP_CONNECTOR_TYPE, 'name': name} return Message(properties=ap, reply_to=self.reply_addr, body=kwargs) def delete_connector(self, name): ap = {'operation': 'DELETE', - 'type': 'io.skupper.router.connector', + 'type': AMQP_CONNECTOR_TYPE, 'name': name} return Message(properties=ap, reply_to=self.reply_addr) @@ -1844,7 +1864,7 @@ def get_link_info(name, address): Query the router at address for the status and statistics of the named link """ qdm = QdManager(address=address) - rc = qdm.query('io.skupper.router.router.link') + rc = qdm.query(ROUTER_LINK_TYPE) for item in rc: if item.get('name') == name: return item @@ -1853,7 +1873,7 @@ def get_link_info(name, address): def has_mobile_dest_in_address_table(address, dest): qdm = QdManager(address=address) - rc = qdm.query('io.skupper.router.router.address') + rc = qdm.query(ROUTER_ADDRESS_TYPE) has_dest = False for item in rc: if dest in item.get("name"): @@ -1870,11 +1890,11 @@ def get_inter_router_links(address): inter_router_links = [] inter_router_data_ids = [] qdm = QdManager(address=address) - conns = qdm.query('io.skupper.router.connection') + conns = qdm.query(CONNECTION_TYPE) for item in conns: if item.get("role") == "inter-router-data": inter_router_data_ids.append(item.get("identity")) - rc = qdm.query('io.skupper.router.router.link') + rc = qdm.query(ROUTER_LINK_TYPE) for item in rc: if item.get("linkType") == "inter-router" or item.get("connectionId") in inter_router_data_ids: inter_router_links.append(item) diff --git a/tests/system_tests_autolinks.py b/tests/system_tests_autolinks.py index 9ca3a7913..c7a8202c3 100644 --- a/tests/system_tests_autolinks.py +++ b/tests/system_tests_autolinks.py @@ -28,7 +28,7 @@ from system_test import TestCase, Qdrouterd, main_module, TIMEOUT, Process, TestTimeout from system_test import unittest from system_test import QdManager -from system_test import retry_assertion +from system_test import retry_assertion, CONFIG_AUTOLINK_TYPE, ROUTER_TYPE CONNECTION_PROPERTIES = {'connection': 'properties', 'int_property': 6451} @@ -115,12 +115,10 @@ def setUpClass(cls): def test_name_collision(self): args = {"name": "autoLink", "address": "autoLink1", "connection": "broker", "direction": "in"} # Add autoLink with the same name as the one already present. - al_long_type = 'io.skupper.router.router.config.autoLink' - addr_long_type = 'io.skupper.router.router.config.address' mgmt = QdManager(address=self.router.addresses[0]) test_pass = False try: - mgmt.create(al_long_type, args) + mgmt.create(CONFIG_AUTOLINK_TYPE, args) except Exception as e: if "BadRequestStatus: Name conflicts with an existing entity" in str(e): test_pass = True @@ -217,8 +215,7 @@ def address(self): return self.routers[1].addresses[0] def check_auto_link(self): - long_type = 'io.skupper.router.router.config.autoLink' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + CONFIG_AUTOLINK_TYPE output = json.loads(self.run_skmanage(query_command)) if output[0].get('operStatus') == "active": @@ -256,8 +253,7 @@ def schedule_auto_link_reconnect_test(self): def test_auto_link_reattach(self): def check_autolink_status(): - long_type = 'io.skupper.router.router.config.autoLink' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + CONFIG_AUTOLINK_TYPE output = json.loads(self.run_skmanage(query_command)) # Since the distribution of the autoLinked address 'examples' @@ -367,8 +363,7 @@ def test_03_autolink_sender(self): test.run() self.assertIsNone(test.error) - long_type = 'io.skupper.router.router' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + ROUTER_TYPE output = json.loads(self.run_skmanage(query_command)) self.assertEqual(output[0]['deliveriesEgressRouteContainer'], 275) self.assertEqual(output[0]['deliveriesIngressRouteContainer'], 0) @@ -740,7 +735,7 @@ def send_ops(self): if self.n_created < self.count: while self.n_created < self.count and self.agent.credit > 0: props = {'operation': 'CREATE', - 'type': 'io.skupper.router.router.config.autoLink', + 'type': CONFIG_AUTOLINK_TYPE, 'name': 'AL.%d' % self.n_created} body = {'direction': 'out', 'containerId': 'container.new', @@ -751,7 +746,7 @@ def send_ops(self): elif self.n_attached == self.count and self.n_deleted < self.count: while self.n_deleted < self.count and self.agent.credit > 0: props = {'operation': 'DELETE', - 'type': 'io.skupper.router.router.config.autoLink', + 'type': CONFIG_AUTOLINK_TYPE, 'name': 'AL.%d' % self.n_deleted} body = {} msg = Message(properties=props, body=body, reply_to=self.reply_to) diff --git a/tests/system_tests_connector_status.py b/tests/system_tests_connector_status.py index 82d8eb661..873eee921 100644 --- a/tests/system_tests_connector_status.py +++ b/tests/system_tests_connector_status.py @@ -21,6 +21,7 @@ from threading import Timer from system_test import TestCase, Process, Qdrouterd, TIMEOUT +from system_test import AMQP_CONNECTOR_TYPE class ConnectorStatusTest(TestCase): @@ -101,8 +102,7 @@ def schedule_B_connector_test(self): def check_B_connector(self): # Router A should now try to connect to Router B again since we killed Router C. - long_type = 'io.skupper.router.connector' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + AMQP_CONNECTOR_TYPE output = json.loads(self.run_skmanage(query_command, address=self.address())) conn_status = output[0].get('connectionStatus') @@ -117,8 +117,7 @@ def test_conn_status_before_connect(self): # The routers have connected and begun talking to each other # Verify that the connectionStatus field of the connector is set to SUCCESS. # Also make sure that the connectionMsg field of the connector has "Connection opened" in it. - long_type = 'io.skupper.router.connector' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + AMQP_CONNECTOR_TYPE output = json.loads(self.run_skmanage(query_command)) connection_msg = output[0]['connectionMsg'] self.assertEqual('SUCCESS', output[0]['connectionStatus']) diff --git a/tests/system_tests_delivery_abort.py b/tests/system_tests_delivery_abort.py index b677e0b08..44fe9c3b4 100644 --- a/tests/system_tests_delivery_abort.py +++ b/tests/system_tests_delivery_abort.py @@ -24,6 +24,7 @@ from skupper_router_internal.compat import BINARY from system_test import Logger, TestCase, Qdrouterd, main_module, unittest, TIMEOUT, TestTimeout +from system_test import ROUTER_ADDRESS_TYPE class RouterTest(TestCase): @@ -121,11 +122,11 @@ def response(self, msg): return Entity(ap['statusCode'], ap['statusDescription'], msg.body) def read_address(self, name): - ap = {'operation': 'READ', 'type': 'io.skupper.router.router.address', 'name': name} + ap = {'operation': 'READ', 'type': ROUTER_ADDRESS_TYPE, 'name': name} return Message(properties=ap, reply_to=self.reply_addr) def query_addresses(self): - ap = {'operation': 'QUERY', 'type': 'io.skupper.router.router.address'} + ap = {'operation': 'QUERY', 'type': ROUTER_ADDRESS_TYPE} return Message(properties=ap, reply_to=self.reply_addr) diff --git a/tests/system_tests_delivery_counts.py b/tests/system_tests_delivery_counts.py index e133635e0..33e7f7685 100644 --- a/tests/system_tests_delivery_counts.py +++ b/tests/system_tests_delivery_counts.py @@ -23,8 +23,11 @@ from skupper_router.management.client import Node -from system_test import TestCase, Qdrouterd, TIMEOUT, get_link_info, \ - get_inter_router_links, has_mobile_dest_in_address_table, PollTimeout, TestTimeout +from system_test import TestCase, Qdrouterd, TIMEOUT, get_link_info +from system_test import get_inter_router_links +from system_test import has_mobile_dest_in_address_table, PollTimeout +from system_test import TestTimeout, ROUTER_TYPE + LARGE_PAYLOAD = ("X" * 1024) * 30 @@ -73,7 +76,7 @@ def router_modified_counts(self, large_message=False): address = self.router.addresses[0] local_node = Node.connect(address, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_modified_index = outs.attribute_names.index('modifiedDeliveries') results = outs.results[0] num_modified_deliveries_pre_test = results[deliveries_modified_index] @@ -82,7 +85,7 @@ def router_modified_counts(self, large_message=False): test = ModifiedDeliveriesTest(address, num_messages, large_message) test.run() - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) results = outs.results[0] self.assertEqual(results[deliveries_modified_index] - num_modified_deliveries_pre_test, num_messages) @@ -126,7 +129,7 @@ def one_router_rejected_counts(self, large_message=False): address = self.router.addresses[0] local_node = Node.connect(address, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_rejected_index = outs.attribute_names.index('rejectedDeliveries') results = outs.results[0] deliveries_rejected_pre_test = results[deliveries_rejected_index] @@ -135,7 +138,7 @@ def one_router_rejected_counts(self, large_message=False): test = RejectedDeliveriesTest(address, num_messages, large_message) test.run() - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) results = outs.results[0] self.assertEqual(results[deliveries_rejected_index] - deliveries_rejected_pre_test, num_messages) @@ -178,7 +181,7 @@ def one_router_released_dropped_count(self, large_message=False): address = self.router.addresses[0] local_node = Node.connect(address, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_dropped_presettled_index = outs.attribute_names.index('droppedPresettledDeliveries') deliveries_released_index = outs.attribute_names.index('releasedDeliveries') @@ -192,7 +195,7 @@ def one_router_released_dropped_count(self, large_message=False): test = ReleasedDroppedPresettledCountTest(address, num_messages, large_message) test.run() - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) results = outs.results[0] @@ -252,7 +255,7 @@ def two_router_released_dropped_counts(self, large_message=False): # Make sure the hello messages (which are presettled dont show up in the counts local_node = Node.connect(address, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_dropped_presettled_index = outs.attribute_names.index('droppedPresettledDeliveries') deliveries_released_index = outs.attribute_names.index('releasedDeliveries') deliveries_presettled_index = outs.attribute_names.index('presettledDeliveries') @@ -264,7 +267,7 @@ def two_router_released_dropped_counts(self, large_message=False): test = ReleasedDroppedPresettledCountTest(address, num_messages, large_message) test.run() - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) results = outs.results[0] self.assertEqual(results[deliveries_dropped_presettled_index] - deliveries_dropped_presettled_pre_test, 10) @@ -620,14 +623,14 @@ def two_router_ingress_egress_counts(self, large_message=False): # Gather the values for deliveries_ingress and deliveries_egress before running the test. local_node = Node.connect(in_router_addr, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_ingress_index = outs.attribute_names.index('deliveriesIngress') results = outs.results[0] pre_deliveries_ingresss = results[deliveries_ingress_index] local_node = Node.connect(out_router_addr, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_egress_index = outs.attribute_names.index('deliveriesEgress') deliveries_accepted_index = outs.attribute_names.index('acceptedDeliveries') results = outs.results[0] @@ -643,13 +646,13 @@ def two_router_ingress_egress_counts(self, large_message=False): # Gather the values for deliveries_ingress and deliveries_egress after running the test. local_node = Node.connect(in_router_addr, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) results = outs.results[0] post_deliveries_ingresss = results[deliveries_ingress_index] local_node = Node.connect(out_router_addr, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) results = outs.results[0] post_deliveries_egress = results[deliveries_egress_index] @@ -704,7 +707,7 @@ def one_router_ingress_egress_counts(self, large_message=False): address = self.router.addresses[0] local_node = Node.connect(address, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_ingress_index = outs.attribute_names.index('deliveriesIngress') deliveries_egress_index = outs.attribute_names.index('deliveriesEgress') @@ -716,7 +719,7 @@ def one_router_ingress_egress_counts(self, large_message=False): test = IngressEgressOneRouterTest(address, num_messages, large_message=large_message) test.run() - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) results = outs.results[0] @@ -776,7 +779,7 @@ def route_container_egress(self , large_message=False): route_container_addr = self.router.addresses[1] num_messages = 10 local_node = Node.connect(regular_addr, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_egress_route_container_index = outs.attribute_names.index('deliveriesEgressRouteContainer') results = outs.results[0] @@ -785,7 +788,7 @@ def route_container_egress(self , large_message=False): test = RouteContainerEgressTest(route_container_addr, regular_addr, num_messages, large_message=large_message) test.run() - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_egress_route_container_index = outs.attribute_names.index('deliveriesEgressRouteContainer') results = outs.results[0] @@ -1144,7 +1147,7 @@ def test_route_container_ingress(self): test.run() local_node = Node.connect(regular_addr, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) deliveries_ingress_route_container_index = outs.attribute_names.index('deliveriesIngressRouteContainer') diff --git a/tests/system_tests_distribution.py b/tests/system_tests_distribution.py index 506c82047..17ac8b34a 100644 --- a/tests/system_tests_distribution.py +++ b/tests/system_tests_distribution.py @@ -24,7 +24,7 @@ from proton.reactor import Container, LinkOption from system_test import TestCase, Qdrouterd, main_module, TIMEOUT, TestTimeout -from system_test import unittest, Logger +from system_test import unittest, Logger, ROUTER_ADDRESS_TYPE # ------------------------------------------------ @@ -63,11 +63,11 @@ def parse_address_query_response(self, msg): return AddressCheckResponse(ap['statusCode'], ap['statusDescription'], msg.body) def make_address_query(self, name): - ap = {'operation': 'READ', 'type': 'io.skupper.router.router.address', 'name': name} + ap = {'operation': 'READ', 'type': ROUTER_ADDRESS_TYPE, 'name': name} return Message(properties=ap, reply_to=self.reply_addr) def make_addresses_query(self): - ap = {'operation': 'QUERY', 'type': 'io.skupper.router.router.address'} + ap = {'operation': 'QUERY', 'type': ROUTER_ADDRESS_TYPE} return Message(properties=ap, reply_to=self.reply_addr) diff --git a/tests/system_tests_edge_router.py b/tests/system_tests_edge_router.py index 215a25991..8ea9a7129 100644 --- a/tests/system_tests_edge_router.py +++ b/tests/system_tests_edge_router.py @@ -35,7 +35,7 @@ from system_test import QdManager from system_test import unittest from system_test import Process -from system_test import CONNECTION_TYPE +from system_test import CONNECTION_TYPE, ROUTER_ADDRESS_TYPE from test_broker import FakeBroker from message_tests import DynamicAddressTest, MobileAddressAnonymousTest, MobileAddressTest @@ -1404,7 +1404,7 @@ def test_71_skmanage_edge_router_option(self): mgmt = QdManager(address=self.routers[0].addresses[0], edge_router_id='EA1') conn_found = False - outs = mgmt.query('io.skupper.router.connection') + outs = mgmt.query(CONNECTION_TYPE) for out in outs: if out['container'] == 'INT.A' and out['dir'] == "out" and out['role'] == "edge": conn_found = True @@ -1416,7 +1416,7 @@ def test_71_skmanage_edge_router_option(self): mgmt = QdManager(address=self.routers[2].addresses[0], edge_router_id='EA1') conn_found = False - outs = mgmt.query('io.skupper.router.connection') + outs = mgmt.query(CONNECTION_TYPE) for out in outs: if out['container'] == 'INT.A' and out['dir'] == "out" and out['role'] == "edge": @@ -1431,7 +1431,7 @@ def test_71_skmanage_edge_router_option(self): mgmt = QdManager(address=self.routers[1].addresses[0], edge_router_id='EA1') conn_found = False - outs = mgmt.query('io.skupper.router.connection') + outs = mgmt.query(CONNECTION_TYPE) for out in outs: if out['container'] == 'INT.A' and out['dir'] == "out" and out['role'] == "edge": @@ -1492,7 +1492,7 @@ def test_73_skmanage_query_interior_from_edge(self): # uplink to INT.A) and query for connections on INT.A mgmt = QdManager(address=self.routers[2].addresses[0], router_id='INT.A') - outs = mgmt.query('io.skupper.router.connection') + outs = mgmt.query(CONNECTION_TYPE) ea1_conn_found = False ea2_conn_found = False int_b_inter_router_conn_found = False @@ -1512,7 +1512,7 @@ def test_73_skmanage_query_interior_from_edge(self): # uplink to INT.A) and query for connections on INT.B mgmt = QdManager(address=self.routers[2].addresses[0], router_id='INT.B') - outs = mgmt.query('io.skupper.router.connection') + outs = mgmt.query(CONNECTION_TYPE) eb1_conn_found = False eb2_conn_found = False int_a_inter_router_conn_found = False @@ -1650,7 +1650,7 @@ def on_link_opened(self, event): def check_address(self): local_node = Node.connect(self.interior_host, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router.address') + outs = local_node.query(type=ROUTER_ADDRESS_TYPE) remote_count = outs.attribute_names.index("remoteCount") subs_count = outs.attribute_names.index("subscriberCount") found = False @@ -1895,8 +1895,7 @@ def router(name, mode, extra): def _get_address(self, router, address): """Lookup address in route table""" - a_type = 'io.skupper.router.router.address' - addrs = router.management.query(a_type).get_dicts() + addrs = router.management.query(ROUTER_ADDRESS_TYPE).get_dicts() return [a for a in addrs if address in a['name']] def _wait_address_gone(self, router, address): diff --git a/tests/system_tests_handle_failover.py b/tests/system_tests_handle_failover.py index 6621baa36..fc40b2ac6 100644 --- a/tests/system_tests_handle_failover.py +++ b/tests/system_tests_handle_failover.py @@ -25,7 +25,7 @@ from threading import Timer from system_test import TestCase, Qdrouterd, Process, TIMEOUT -from system_test import main_module +from system_test import main_module, AMQP_CONNECTOR_TYPE from system_test import unittest @@ -134,8 +134,7 @@ def test_1_connector_has_failover_list(self): followed by the two items sent by the Router B (stored in cls.failover_list) The 'failoverUrls' is comma separated. """ - long_type = 'io.skupper.router.connector' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + AMQP_CONNECTOR_TYPE output = json.loads(self.run_skmanage(query_command)) expected = "amqp://127.0.0.1:" + str(FailoverTest.inter_router_port) + ", " + FailoverTest.failover_list @@ -148,8 +147,7 @@ def schedule_B_to_C_failover_test(self): self.attempts += 1 def check_C_connector(self): - long_type = 'io.skupper.router.connector' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + AMQP_CONNECTOR_TYPE output = json.loads(self.run_skmanage(query_command, address=self.routers[1].addresses[0])) expected = FailoverTest.backup_url + ", " + "amqp://127.0.0.1:" + str(FailoverTest.inter_router_port) \ @@ -203,8 +201,7 @@ def schedule_C_to_B_failover_test(self): def check_B_connector(self): # Router A should now try to connect to Router B again since we killed Router C. - long_type = 'io.skupper.router.connector' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + AMQP_CONNECTOR_TYPE output = json.loads(self.run_skmanage(query_command, address=self.routers[1].addresses[0])) # The order that the URLs appear in the failoverUrls is important. This is the order in which the router @@ -256,8 +253,7 @@ def test_3_reinstate_router_B(self): def check_A_connector(self): # Router A should now try to connect to Router B again since we killed Router C. - long_type = 'io.skupper.router.connector' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + AMQP_CONNECTOR_TYPE output = json.loads(self.run_skmanage(query_command, address=self.routers[1].addresses[0])) # The order that the URLs appear in the failoverUrls is important. This is the order in which the router diff --git a/tests/system_tests_http.py b/tests/system_tests_http.py index 9d862bbc9..af8a21c20 100644 --- a/tests/system_tests_http.py +++ b/tests/system_tests_http.py @@ -27,7 +27,7 @@ import skupper_router_site from system_test import Process, QdManager, retry from system_test import TestCase, Qdrouterd, main_module, DIR -from system_test import unittest +from system_test import unittest, AMQP_LISTENER_TYPE, ALLOCATOR_TYPE # # Note: these tests exercise the management interface accessed via HTTP. These @@ -129,7 +129,6 @@ def address(): # are working. # Delete the listener on port http_delete_listen_port_1 - long_type = 'io.skupper.router.listener' mgmt = QdManager(address=address()) if self.skip_delete_http_listener_test: @@ -137,13 +136,13 @@ def address(): # Try deleting it and make sure you get an exception. exception_raised = False try: - mgmt.delete(long_type, name=name) + mgmt.delete(AMQP_LISTENER_TYPE, name=name) except Exception as e: if "BadRequestStatus: HTTP listeners cannot be deleted" in str(e): exception_raised = True self.assertTrue(exception_raised) else: - mgmt.delete(long_type, name=name) + mgmt.delete(AMQP_LISTENER_TYPE, name=name) # Once again try to perform a GET request. Now since the listener # is gone, the GET will fail. @@ -221,7 +220,7 @@ def test_http_metrics(self): "qdr_deliveries_delayed_10sec_total", "qdr_deliveries_stuck_total", "qdr_links_blocked_total"] - for stat in r.management.query(type="io.skupper.router.allocator").get_dicts(): + for stat in r.management.query(type=ALLOCATOR_TYPE).get_dicts(): stat_names.append(stat['typeName']) def _test(stat_names, port): @@ -359,9 +358,8 @@ def address(): if not self.skip_delete_http_listener_test: # Delete the listener with name 'delete-me' - long_type = 'io.skupper.router.listener' mgmt = QdManager(address=address()) - mgmt.delete(long_type, name=name) + mgmt.delete(AMQP_LISTENER_TYPE, name=name) # Make sure that the listener got deleted. ret_val = retry(lambda: self.is_get_request_failing("https://localhost:%s/system_tests_http.txt" % r.ports[3], use_get_cert=True), timeout=10, delay=2) diff --git a/tests/system_tests_http1_adaptor.py b/tests/system_tests_http1_adaptor.py index f0b199a06..dd5a1bfd6 100644 --- a/tests/system_tests_http1_adaptor.py +++ b/tests/system_tests_http1_adaptor.py @@ -39,6 +39,8 @@ from system_test import retry_exception, curl_available, run_curl, retry from system_test import nginx_available, get_digest, NginxServer, Process from system_test import openssl_available, is_pattern_present +from system_test import HTTP_CONNECTOR_TYPE, HTTP_LISTENER_TYPE +from system_test import CONNECTION_TYPE, HTTP_REQ_INFO_TYPE, ROUTER_LINK_TYPE from http1_tests import http1_ping, TestServer, RequestHandler10 from http1_tests import RequestMsg, ResponseMsg, ResponseValidator from http1_tests import ThreadedTestClient, Http1OneRouterTestBase @@ -120,10 +122,6 @@ class Http1AdaptorManagementTest(TestCase): def setUpClass(cls): super(Http1AdaptorManagementTest, cls).setUpClass() - cls.LISTENER_TYPE = 'io.skupper.router.httpListener' - cls.CONNECTOR_TYPE = 'io.skupper.router.httpConnector' - cls.CONNECTION_TYPE = 'io.skupper.router.connection' - cls.interior_edge_port = cls.tester.get_port() cls.interior_mgmt_port = cls.tester.get_port() cls.edge_mgmt_port = cls.tester.get_port() @@ -166,16 +164,16 @@ def test_01_create_delete(self): adaptor properly notifies the interior of the subscribers/producers. """ e_mgmt = self.e_router.management - self.assertEqual(0, len(e_mgmt.query(type=self.LISTENER_TYPE).results)) - self.assertEqual(0, len(e_mgmt.query(type=self.CONNECTOR_TYPE).results)) + self.assertEqual(0, len(e_mgmt.query(type=HTTP_LISTENER_TYPE).results)) + self.assertEqual(0, len(e_mgmt.query(type=HTTP_CONNECTOR_TYPE).results)) - e_mgmt.create(type=self.CONNECTOR_TYPE, + e_mgmt.create(type=HTTP_CONNECTOR_TYPE, name="ServerConnector", attributes={'address': 'closest/http1Service', 'port': self.http_server_port, 'protocolVersion': 'HTTP1'}) - e_mgmt.create(type=self.LISTENER_TYPE, + e_mgmt.create(type=HTTP_LISTENER_TYPE, name="ClientListener", attributes={'address': 'closest/http1Service', 'port': self.http_listener_port, @@ -183,8 +181,8 @@ def test_01_create_delete(self): # verify the entities have been created and http traffic works - self.assertEqual(1, len(e_mgmt.query(type=self.LISTENER_TYPE).results)) - self.assertEqual(1, len(e_mgmt.query(type=self.CONNECTOR_TYPE).results)) + self.assertEqual(1, len(e_mgmt.query(type=HTTP_LISTENER_TYPE).results)) + self.assertEqual(1, len(e_mgmt.query(type=HTTP_CONNECTOR_TYPE).results)) http1_ping(sport=self.http_server_port, cport=self.http_listener_port) @@ -195,15 +193,15 @@ def test_01_create_delete(self): # delete the connector and listener; wait for the associated connection # to be removed # - e_mgmt.delete(type=self.CONNECTOR_TYPE, name="ServerConnector") - self.assertEqual(0, len(e_mgmt.query(type=self.CONNECTOR_TYPE).results)) - e_mgmt.delete(type=self.LISTENER_TYPE, name="ClientListener") - self.assertEqual(0, len(e_mgmt.query(type=self.LISTENER_TYPE).results)) + e_mgmt.delete(type=HTTP_CONNECTOR_TYPE, name="ServerConnector") + self.assertEqual(0, len(e_mgmt.query(type=HTTP_CONNECTOR_TYPE).results)) + e_mgmt.delete(type=HTTP_LISTENER_TYPE, name="ClientListener") + self.assertEqual(0, len(e_mgmt.query(type=HTTP_LISTENER_TYPE).results)) # will hit test timeout on failure: while True: hconns = 0 - obj = e_mgmt.query(type=self.CONNECTION_TYPE, + obj = e_mgmt.query(type=CONNECTION_TYPE, attribute_names=["protocol"]) for item in obj.get_dicts(): if "http/1.x" in item["protocol"]: @@ -240,45 +238,45 @@ def test_01_create_delete(self): # # re-create the connector and listener; verify it works # - e_mgmt.create(type=self.CONNECTOR_TYPE, + e_mgmt.create(type=HTTP_CONNECTOR_TYPE, name="ServerConnector", attributes={'address': 'closest/http1Service', 'port': self.http_server_port, 'protocolVersion': 'HTTP1'}) - e_mgmt.create(type=self.LISTENER_TYPE, + e_mgmt.create(type=HTTP_LISTENER_TYPE, name="ClientListener", attributes={'address': 'closest/http1Service', 'port': self.http_listener_port, 'protocolVersion': 'HTTP1'}) - self.assertEqual(1, len(e_mgmt.query(type=self.LISTENER_TYPE).results)) - self.assertEqual(1, len(e_mgmt.query(type=self.CONNECTOR_TYPE).results)) + self.assertEqual(1, len(e_mgmt.query(type=HTTP_LISTENER_TYPE).results)) + self.assertEqual(1, len(e_mgmt.query(type=HTTP_CONNECTOR_TYPE).results)) http1_ping(sport=self.http_server_port, cport=self.http_listener_port) self.i_router.wait_address("closest/http1Service", subscribers=1) - e_mgmt.delete(type=self.CONNECTOR_TYPE, name="ServerConnector") - self.assertEqual(0, len(e_mgmt.query(type=self.CONNECTOR_TYPE).results)) - e_mgmt.delete(type=self.LISTENER_TYPE, name="ClientListener") - self.assertEqual(0, len(e_mgmt.query(type=self.LISTENER_TYPE).results)) + e_mgmt.delete(type=HTTP_CONNECTOR_TYPE, name="ServerConnector") + self.assertEqual(0, len(e_mgmt.query(type=HTTP_CONNECTOR_TYPE).results)) + e_mgmt.delete(type=HTTP_LISTENER_TYPE, name="ClientListener") + self.assertEqual(0, len(e_mgmt.query(type=HTTP_LISTENER_TYPE).results)) def test_01_delete_active_connector(self): """Delete an HTTP1 connector that is currently connected to a server. Verify the connection is dropped. """ e_mgmt = self.e_router.management - self.assertEqual(0, len(e_mgmt.query(type=self.CONNECTOR_TYPE).results)) + self.assertEqual(0, len(e_mgmt.query(type=HTTP_CONNECTOR_TYPE).results)) - e_mgmt.create(type=self.CONNECTOR_TYPE, + e_mgmt.create(type=HTTP_CONNECTOR_TYPE, name="ServerConnector", attributes={'address': 'closest/http1Service', 'port': self.http_server_port, 'protocolVersion': 'HTTP1'}) # verify the connector has been created and attach a dummy server - self.assertEqual(1, len(e_mgmt.query(type=self.CONNECTOR_TYPE).results)) + self.assertEqual(1, len(e_mgmt.query(type=HTTP_CONNECTOR_TYPE).results)) server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: @@ -295,8 +293,8 @@ def test_01_delete_active_connector(self): self.i_router.wait_address("closest/http1Service", subscribers=1) # delete the connector - e_mgmt.delete(type=self.CONNECTOR_TYPE, name="ServerConnector") - self.assertEqual(0, len(e_mgmt.query(type=self.CONNECTOR_TYPE).results)) + e_mgmt.delete(type=HTTP_CONNECTOR_TYPE, name="ServerConnector") + self.assertEqual(0, len(e_mgmt.query(type=HTTP_CONNECTOR_TYPE).results)) # expect socket to close while True: @@ -428,7 +426,7 @@ def test_000_stats(self): client.close() qd_manager = QdManager(address=self.INT_A.listener) - stats = qd_manager.query('io.skupper.router.httpRequestInfo') + stats = qd_manager.query(HTTP_REQ_INFO_TYPE) self.assertEqual(len(stats), 2) for s in stats: self.assertEqual(s.get('requests'), 10) @@ -625,7 +623,7 @@ def _server_get_undelivered_out(mgmt, service_address): # Return the total count of outgoing undelivered deliveries to # service_address count = 0 - links = mgmt.query('io.skupper.router.router.link') + links = mgmt.query(ROUTER_LINK_TYPE) for link in filter(lambda link: link['linkName'] == 'http1.server.out' and link['owningAddr'].endswith(service_address), links): @@ -637,7 +635,7 @@ def _server_get_unsettled_out(mgmt, service_address): # Return the total count of outgoing unsettled deliveries to # service_address count = 0 - links = mgmt.query('io.skupper.router.router.link') + links = mgmt.query(ROUTER_LINK_TYPE) for link in filter(lambda link: link['linkName'] == 'http1.server.out' and link['owningAddr'].endswith(service_address), links): @@ -648,7 +646,7 @@ def _server_get_unsettled_out(mgmt, service_address): def _client_in_link_count(mgmt, service_address): # get the total number of active HTTP1 client in-links for the given # service address - links = mgmt.query('io.skupper.router.router.link') + links = mgmt.query(ROUTER_LINK_TYPE) count = len(list(filter(lambda link: link['linkName'] == 'http1.client.in' and link['owningAddr'].endswith(service_address), diff --git a/tests/system_tests_http2.py b/tests/system_tests_http2.py index 5236b897a..ad9bf84bf 100644 --- a/tests/system_tests_http2.py +++ b/tests/system_tests_http2.py @@ -28,7 +28,10 @@ from http1_tests import wait_http_listeners_up, HttpAdaptorListenerConnectTestBase, wait_tcp_listeners_up from system_test import TestCase, Qdrouterd, QdManager, Process, retry_assertion from system_test import curl_available, nginx_available, TIMEOUT, Http2Server -from system_test import get_digest +from system_test import get_digest, TCP_LISTENER_TYPE, TCP_CONNECTOR_TYPE +from system_test import HTTP_LISTENER_TYPE, HTTP_CONNECTOR_TYPE +from system_test import CONNECTION_TYPE, HTTP_REQ_INFO_TYPE + h2hyper_installed = True try: @@ -260,9 +263,9 @@ def check_listener_delete(self, client_addr, server_addr, tcp_listener=False): qd_manager = QdManager(address=server_addr) if tcp_listener: - entity_name = 'io.skupper.router.tcpListener' + entity_name = TCP_LISTENER_TYPE else: - entity_name = 'io.skupper.router.httpListener' + entity_name = HTTP_LISTENER_TYPE listeners = qd_manager.query(entity_name) self.assertEqual(len(listeners), 1) @@ -306,7 +309,7 @@ def check_connector_delete(self, client_addr, server_addr, server_port, # Run a skmanage query on connections to see how many qdr_connections are # there on the egress router qd_manager = QdManager(address=server_addr) - connections = qd_manager.query('io.skupper.router.connection') + connections = qd_manager.query(CONNECTION_TYPE) self.assertGreaterEqual(len(connections), 2) if not tcp_connector: @@ -319,9 +322,9 @@ def check_connector_delete(self, client_addr, server_addr, server_port, # Run a skmanage DELETE on the httpConnector if tcp_connector: - connector_type = 'io.skupper.router.tcpConnector' + connector_type = TCP_CONNECTOR_TYPE else: - connector_type = 'io.skupper.router.httpConnector' + connector_type = HTTP_CONNECTOR_TYPE connectors = qd_manager.query(connector_type) self.assertEqual(len(connectors), 1) @@ -333,7 +336,7 @@ def check_connector_delete(self, client_addr, server_addr, server_port, self.assertEqual(len(connectors), 0) # Deleting the connector must have taken out the connection to the server. - connections = qd_manager.query('io.skupper.router.connection') + connections = qd_manager.query(CONNECTION_TYPE) server_conn_found = False for conn in connections: if str(server_port) in conn['name']: @@ -360,7 +363,7 @@ def check_connector_delete(self, client_addr, server_addr, server_port, tries = 0 conn_present = False while tries < num_tries: - connections = qd_manager.query('io.skupper.router.connection') + connections = qd_manager.query(CONNECTION_TYPE) tries += 1 if len(connections) < 2: sleep(2) @@ -546,11 +549,11 @@ def test_000_stats(self): _, out, _ = self.run_curl(address, args=self.get_all_curl_args(['-d', 'fname=Mickey&lname=Mouse', '-X', 'POST'])) self.assertIn('Success! Your first name is Mickey, last name is Mouse', out) - stats = qd_manager.query('io.skupper.router.httpRequestInfo') + stats = qd_manager.query(HTTP_REQ_INFO_TYPE) self.assertEqual(len(stats), 2) def check_num_requests(): - statistics = qd_manager.query('io.skupper.router.httpRequestInfo') + statistics = qd_manager.query(HTTP_REQ_INFO_TYPE) for stat in statistics: self.assertEqual(stat.get('requests'), 2) @@ -562,7 +565,7 @@ def check_num_requests(): # in more detail. retry_assertion(check_num_requests) - stats = qd_manager.query('io.skupper.router.httpRequestInfo') + stats = qd_manager.query(HTTP_REQ_INFO_TYPE) for s in stats: self.assertEqual(s.get('requests'), 2) @@ -734,7 +737,7 @@ def test_000_stats(self): address = self.router_qdra.http_addresses[0] qd_manager_a = QdManager(address=self.router_qdra.addresses[0]) qd_manager_b = QdManager(address=self.router_qdrb.addresses[0]) - stats_a = qd_manager_a.query('io.skupper.router.httpRequestInfo') + stats_a = qd_manager_a.query(HTTP_REQ_INFO_TYPE) # First request self.run_curl(address, args=self.get_all_curl_args()) @@ -745,9 +748,9 @@ def test_000_stats(self): self.assertIn('Success! Your first name is Mickey, last name is Mouse', out) def check_num_requests(): - stats = qd_manager_a.query('io.skupper.router.httpRequestInfo') + stats = qd_manager_a.query(HTTP_REQ_INFO_TYPE) self.assertEqual(stats[0].get('requests'), 2) - stats = qd_manager_b.query('io.skupper.router.httpRequestInfo') + stats = qd_manager_b.query(HTTP_REQ_INFO_TYPE) self.assertEqual(stats[0].get('requests'), 2) # This test intermittently fails with the following error - @@ -758,7 +761,7 @@ def check_num_requests(): # in more detail. retry_assertion(check_num_requests) - stats_a = qd_manager_a.query('io.skupper.router.httpRequestInfo') + stats_a = qd_manager_a.query(HTTP_REQ_INFO_TYPE) self.assertEqual(len(stats_a), 1) self.assertEqual(stats_a[0].get('requests'), 2) @@ -766,7 +769,7 @@ def check_num_requests(): self.assertEqual(stats_a[0].get('bytesOut'), 3944) self.assertEqual(stats_a[0].get('bytesIn'), 24) - stats_b = qd_manager_b.query('io.skupper.router.httpRequestInfo') + stats_b = qd_manager_b.query(HTTP_REQ_INFO_TYPE) self.assertEqual(len(stats_b), 1) self.assertEqual(stats_b[0].get('requests'), 2) @@ -974,7 +977,7 @@ def test_check_connector_delete(self): # Now delete the httpConnector on the edge router config_edgea qd_manager = QdManager(address=self.router_qdra.addresses[0]) - qd_manager.delete("io.skupper.router.httpConnector", name=self.edge_a_http_connector_name) + qd_manager.delete(HTTP_CONNECTOR_TYPE, name=self.edge_a_http_connector_name) sleep(2) # now check the interior router for the examples address. Since the httpConnector on one of the @@ -992,7 +995,7 @@ def test_check_connector_delete(self): # Now delete the httpConnector on the edge router config_edgeb qd_manager = QdManager(address=self.router_qdrb.addresses[0]) - qd_manager.delete("io.skupper.router.httpConnector", name=self.edge_b_http_connector_name) + qd_manager.delete(HTTP_CONNECTOR_TYPE, name=self.edge_b_http_connector_name) sleep(2) # Now, run a curl client GET request with a timeout. diff --git a/tests/system_tests_log_level_update.py b/tests/system_tests_log_level_update.py index e8587533c..ae9d40335 100644 --- a/tests/system_tests_log_level_update.py +++ b/tests/system_tests_log_level_update.py @@ -25,7 +25,8 @@ from proton.reactor import Container from system_test import TestCase, Qdrouterd -from system_test import QdManager +from system_test import QdManager, LOG_TYPE +from system_test import CONNECTION_TYPE apply_options = AtMostOnce() @@ -173,13 +174,13 @@ def test_turn_on_protocol_trace(self): self.assertTrue(num_attaches == 4) # Turn off trace logging using skmanage - qd_manager.update("io.skupper.router.log", {"enable": "info+"}, name="log/DEFAULT") + qd_manager.update(LOG_TYPE, {"enable": "info+"}, name="log/DEFAULT") # Turn on trace (not debug+) level logging for the PROTOCOL module. After doing # this we will create a sender and a receiver and make sure that the PROTOCOL module # is emitting proton frame trace messages. - qd_manager.update("io.skupper.router.log", {"enable": "debug+"}, name="log/PROTOCOL") + qd_manager.update(LOG_TYPE, {"enable": "debug+"}, name="log/PROTOCOL") TEST_ADDR = "moduletest1" hello_world_1 = "Hello World_1!" @@ -197,7 +198,7 @@ def test_turn_on_protocol_trace(self): # Now turn off trace logging for the PROTOCOL module and make sure # that there is no more proton frame trace messages appearing in the log - qd_manager.update("io.skupper.router.log", + qd_manager.update(LOG_TYPE, {"enable": "info+"}, name="log/PROTOCOL") TEST_ADDR = "moduletest2" @@ -266,7 +267,7 @@ def test_inter_router_protocol_trace(self): # The router already has trace logging turned on for all connections. # Get the connection id of the inter-router connection - results = qd_manager.query("io.skupper.router.connection") + results = qd_manager.query(CONNECTION_TYPE) conn_id = None for result in results: if result['role'] == 'inter-router': @@ -274,7 +275,7 @@ def test_inter_router_protocol_trace(self): # Turn off trace logging for the inter-router connection. This update command is run async by the router # so we need to sleep a bit before the operation is actually completed. - qd_manager.update("io.skupper.router.connection", {"enableProtocolTrace": "false"}, identity=conn_id) + qd_manager.update(CONNECTION_TYPE, {"enableProtocolTrace": "false"}, identity=conn_id) time.sleep(1) num_transfers = self._get_transfer_frame_count(conn_id) @@ -293,7 +294,7 @@ def test_inter_router_protocol_trace(self): self.assertEqual(num_transfers_after_update, num_transfers) # Turn on trace logging for the inter-router connection - qd_manager.update("io.skupper.router.connection", {"enableProtocolTrace": "yes"}, identity=conn_id) + qd_manager.update(CONNECTION_TYPE, {"enableProtocolTrace": "yes"}, identity=conn_id) # Create a receiver and make sure the MAU update is NOT seen on the inter-router connection log TEST_ADDR_2 = "EnableConnectionLevelProtocolTraceTest2" @@ -333,7 +334,7 @@ def test_enable_protocol_trace_on_non_existent_connection(self): try: # Turn on trace logging for connection with invalid or non-existent identity - outs = qd_manager.update("io.skupper.router.connection", {"enableProtocolTrace": "true"}, identity='G10000') + outs = qd_manager.update(CONNECTION_TYPE, {"enableProtocolTrace": "true"}, identity='G10000') except Exception as e: if "BadRequestStatus" in str(e): bad_request = True @@ -344,7 +345,7 @@ def test_single_connection_protocol_trace(self): qd_manager = QdManager(self.address) # Turn off trace logging on all connections. - qd_manager.update("io.skupper.router.log", {"enable": "info+"}, + qd_manager.update(LOG_TYPE, {"enable": "info+"}, name="log/DEFAULT") TEST_ADDR_1 = "EnableConnectionLevelProtocolTraceTest1" @@ -360,14 +361,14 @@ def test_single_connection_protocol_trace(self): container_2.container_id = CONTAINER_ID_2 conn_2 = BlockingConnection(self.address, container=container_2) - results = qd_manager.query("io.skupper.router.connection") + results = qd_manager.query(CONNECTION_TYPE) conn_id = None for result in results: if result['container'] == CONTAINER_ID_1: conn_id = result['identity'] # Turn on trace logging for connection with identity conn_id - qd_manager.update("io.skupper.router.connection", {"enableProtocolTrace": "true"}, identity=conn_id) + qd_manager.update(CONNECTION_TYPE, {"enableProtocolTrace": "true"}, identity=conn_id) blocking_receiver_1 = conn_1.create_receiver(address=TEST_ADDR_1) blocking_sender_1 = conn_1.create_sender(address=TEST_ADDR_1, options=apply_options) @@ -393,7 +394,7 @@ def test_single_connection_protocol_trace(self): self.assertTrue(num_attaches_2 == 0) # Now turn off the connection tracing on that connection - qd_manager.update("io.skupper.router.connection", + qd_manager.update(CONNECTION_TYPE, {"enableProtocolTrace": "off"}, identity=conn_id) blocking_receiver_1.close() @@ -465,7 +466,7 @@ def test_01_toggle_default_trace_logging(self): self.assertTrue(num_attaches == 4) # STEP 2: Turn off trace logging using skmanage - qd_manager.update("io.skupper.router.log", {"enable": "info+"}, name="log/DEFAULT") + qd_manager.update(LOG_TYPE, {"enable": "info+"}, name="log/DEFAULT") # Step 3: Now, router trace logging is turned off (has been set to info+) # Create the sender and receiver again on a different address and make @@ -487,7 +488,7 @@ def test_01_toggle_default_trace_logging(self): # STEP 4: Tuen trace logging back on again and make sure num_attaches = 4 TEST_ADDR = "apachetest3" - qd_manager.update("io.skupper.router.log", {"enable": "debug+"}, name="log/DEFAULT") + qd_manager.update(LOG_TYPE, {"enable": "debug+"}, name="log/DEFAULT") self.create_sender_receiver(TEST_ADDR, hello_world_3, blocking_connection) # STEP 3: Count the number of attaches for address TEST_ADDR, there should be 4 @@ -529,9 +530,9 @@ def test_02_toggle_server_trace_logging(self): # for the PROTOCOL module and make sure it works. qd_manager = QdManager(self.address) # Set log level to info+ on the DEFAULT module - qd_manager.update("io.skupper.router.log", {"enable": "info+"}, name="log/DEFAULT") + qd_manager.update(LOG_TYPE, {"enable": "info+"}, name="log/DEFAULT") # Set log level to debug+ on the PROTOCOL module - qd_manager.update("io.skupper.router.log", {"enable": "debug+"}, name="log/PROTOCOL") + qd_manager.update(LOG_TYPE, {"enable": "debug+"}, name="log/PROTOCOL") blocking_connection = BlockingConnection(self.address) self.create_sender_receiver(TEST_ADDR, hello_world_5, @@ -548,7 +549,7 @@ def test_02_toggle_server_trace_logging(self): self.assertTrue(num_attaches == 4) TEST_ADDR = "apachetest6" - qd_manager.update("io.skupper.router.log", {"enable": "info+"}, name="log/PROTOCOL") + qd_manager.update(LOG_TYPE, {"enable": "info+"}, name="log/PROTOCOL") self.create_sender_receiver(TEST_ADDR, hello_world_6, blocking_connection) diff --git a/tests/system_tests_management.py b/tests/system_tests_management.py index 8f629cb8c..b29a7e004 100644 --- a/tests/system_tests_management.py +++ b/tests/system_tests_management.py @@ -37,22 +37,14 @@ import system_test from system_test import Qdrouterd, Process from system_test import unittest - -PREFIX = 'io.skupper.router.' -MANAGEMENT = PREFIX + 'management' -CONFIGURATION = PREFIX + 'configurationEntity' -OPERATIONAL = PREFIX + 'operationalEntity' -LISTENER = PREFIX + 'listener' -CONNECTOR = PREFIX + 'connector' -DUMMY = PREFIX + 'dummy' -ROUTER = PREFIX + 'router' -LINK = ROUTER + '.link' -ADDRESS = ROUTER + '.address' -NODE = ROUTER + '.node' -CONFIG_ADDRESS = ROUTER + '.config.address' +from system_test import MANAGEMENT_TYPE, CONFIG_ENTITY_TYPE, OPER_ENTITY_TYPE +from system_test import AMQP_LISTENER_TYPE, AMQP_CONNECTOR_TYPE, DUMMY_TYPE +from system_test import ROUTER_TYPE, ROUTER_LINK_TYPE, ROUTER_ADDRESS_TYPE +from system_test import ROUTER_NODE_TYPE, CONFIG_ADDRESS_TYPE def short_name(name): + PREFIX = 'io.skupper.router.' if name.startswith(PREFIX): return name[len(PREFIX):] return name @@ -133,28 +125,28 @@ def test_bad_query(self): def test_metadata(self): """Query with type only""" - response = self.node.query(type=ROUTER) + response = self.node.query(type=ROUTER_TYPE) for attr in ['type', 'metadata']: self.assertIn(attr, response.attribute_names) self.assertEqual(response.get_entities()[0]['metadata'], 'selftest;solo') def test_query_type(self): """Query with type only""" - response = self.node.query(type=LISTENER) + response = self.node.query(type=AMQP_LISTENER_TYPE) for attr in ['type', 'name', 'identity', 'host', 'port']: self.assertIn(attr, response.attribute_names) for r in response.get_dicts(): self.assertEqual(len(response.attribute_names), len(r)) - self.assertEqual(r['type'], LISTENER) + self.assertEqual(r['type'], AMQP_LISTENER_TYPE) self.assertTrue( {'l0', 'l1', 'l2'} <= set(r['name'] for r in response.get_entities())) def test_query_type_attributes(self): """Query with type and attribute names""" attribute_names = ['type', 'name', 'port'] - response = self.node.query(type=LISTENER, attribute_names=attribute_names) + response = self.node.query(type=AMQP_LISTENER_TYPE, attribute_names=attribute_names) self.assertEqual(attribute_names, response.attribute_names) - expect = [[LISTENER, 'l%s' % i, str(self.router.ports[i])] for i in range(3)] + expect = [[AMQP_LISTENER_TYPE, 'l%s' % i, str(self.router.ports[i])] for i in range(3)] for r in expect: # We might have extras in results due to create tests self.assertIn(r, response.results) self.assertIn(dict(zip(attribute_names, r)), response.get_dicts()) @@ -164,7 +156,7 @@ def test_query_attributes(self): attribute_names = ['type', 'name', 'port'] response = self.node.query(attribute_names=attribute_names) self.assertEqual(attribute_names, response.attribute_names) - expect = [[LISTENER, 'l%s' % i, str(self.router.ports[i])] for i in range(3)] + expect = [[AMQP_LISTENER_TYPE, 'l%s' % i, str(self.router.ports[i])] for i in range(3)] for r in expect: # We might have extras in results due to create tests self.assertIn(r, response.results) for name in ['router/' + self.router.name, 'log/DEFAULT']: @@ -192,18 +184,18 @@ def test_create_listener(self): port = self.get_port() # Note qdrouter schema defines port as string not int, since it can be a service name. attributes = {'name': 'foo', 'port': str(port), 'role': 'normal', 'saslMechanisms': 'ANONYMOUS', 'authenticatePeer': False} - entity = self.assert_create_ok(LISTENER, 'foo', attributes) + entity = self.assert_create_ok(AMQP_LISTENER_TYPE, 'foo', attributes) self.assertEqual(entity['name'], 'foo') self.assertEqual(entity['host'], '') # Connect via the new listener node3 = self.cleanup(Node.connect(Url(port=port))) - router = node3.query(type=ROUTER).get_entities() + router = node3.query(type=ROUTER_TYPE).get_entities() self.assertEqual(self.router.name, router[0]['id']) # Delete the listener entity.delete() - response = self.node.query(type=LISTENER, attribute_names=['name']) + response = self.node.query(type=AMQP_LISTENER_TYPE, attribute_names=['name']) for l in response.get_dicts(): self.assertNotEqual(l['name'], 'foo') @@ -278,45 +270,45 @@ def update_check_log(attributes, error=True, debug=False): dict(identity="BOGUS", enable="default")) def test_create_config_address(self): - self.assert_create_ok(CONFIG_ADDRESS, 'myConfigAddr', dict(prefix='prefixA')) - self.assert_read_ok(CONFIG_ADDRESS, 'myConfigAddr', + self.assert_create_ok(CONFIG_ADDRESS_TYPE, 'myConfigAddr', dict(prefix='prefixA')) + self.assert_read_ok(CONFIG_ADDRESS_TYPE, 'myConfigAddr', dict(prefix='prefixA', pattern=None)) simple_send_receive_test = SimpleSndRecv(self.router.addresses[0], '/prefixA/other') simple_send_receive_test.run() self.assertTrue(simple_send_receive_test.message_received) - self.node.delete(CONFIG_ADDRESS, name='myConfigAddr') + self.node.delete(CONFIG_ADDRESS_TYPE, name='myConfigAddr') self.assertRaises(NotFoundStatus, self.node.read, - type=CONFIG_ADDRESS, name='myConfigAddr') + type=CONFIG_ADDRESS_TYPE, name='myConfigAddr') def test_create_config_address_pattern(self): - self.assert_create_ok(CONFIG_ADDRESS, 'patternAddr', dict(pattern='a.*.b')) - self.assert_read_ok(CONFIG_ADDRESS, 'patternAddr', + self.assert_create_ok(CONFIG_ADDRESS_TYPE, 'patternAddr', dict(pattern='a.*.b')) + self.assert_read_ok(CONFIG_ADDRESS_TYPE, 'patternAddr', dict(prefix=None, pattern='a.*.b')) simple_send_receive_test = SimpleSndRecv(self.router.addresses[0], '/a.HITHERE.b') simple_send_receive_test.run() self.assertTrue(simple_send_receive_test.message_received) - self.node.delete(CONFIG_ADDRESS, name='patternAddr') + self.node.delete(CONFIG_ADDRESS_TYPE, name='patternAddr') self.assertRaises(NotFoundStatus, self.node.read, - type=CONFIG_ADDRESS, name='patternAddr') + type=CONFIG_ADDRESS_TYPE, name='patternAddr') def test_dummy(self): """Test all operations on the dummy test entity""" - entity = self.node.read(type=LISTENER, name='l0') + entity = self.node.read(type=AMQP_LISTENER_TYPE, name='l0') self.assertEqual('l0', entity.name) self.assertEqual(str(self.router.ports[0]), entity.port) entity = self.node.read( - type=LISTENER, identity='listener/0.0.0.0:%s:l1' % self.router.ports[1]) + type=AMQP_LISTENER_TYPE, 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) # Bad type - self.assertRaises(BadRequestStatus, self.node.read, type=CONNECTOR, name='l0') + self.assertRaises(BadRequestStatus, self.node.read, type=AMQP_CONNECTOR_TYPE, name='l0') # Unknown entity - self.assertRaises(NotFoundStatus, self.node.read, type=LISTENER, name='nosuch') + self.assertRaises(NotFoundStatus, self.node.read, type=AMQP_LISTENER_TYPE, name='nosuch') # Update is not allowed by the schema self.assertRaises(NotImplementedStatus, entity.update) @@ -325,29 +317,29 @@ def test_dummy(self): self.assertRaises(NotImplementedStatus, entity.call, 'nosuchop', foo="bar") # Dummy entity supports all CRUD operations - dummy = self.node.create({'arg1': 'START'}, type=DUMMY, name='MyDummy', ) - self.assertEqual(dummy.type, DUMMY) + dummy = self.node.create({'arg1': 'START'}, type=DUMMY_TYPE, name='MyDummy', ) + self.assertEqual(dummy.type, DUMMY_TYPE) self.assertEqual(dummy.name, 'MyDummy') self.assertEqual(dummy.arg1, 'START') identity = dummy.identity self.assertEqual( - dict(type=DUMMY, identity=identity, name='MyDummy', arg1='START'), + dict(type=DUMMY_TYPE, identity=identity, name='MyDummy', arg1='START'), dummy.attributes) dummy.attributes['num1'] = 42 dummy.arg1 = 'one' self.assertEqual( - dict(type=DUMMY, identity=identity, name='MyDummy', arg1='one', num1=42), + dict(type=DUMMY_TYPE, identity=identity, name='MyDummy', arg1='one', num1=42), dummy.attributes) dummy.update() dummy.attributes.update(dict(arg1='x', num1=0)) dummy.read() self.assertEqual( - dict(type=DUMMY, name='MyDummy', identity=identity, arg1='one', num1=42), + dict(type=DUMMY_TYPE, name='MyDummy', identity=identity, arg1='one', num1=42), dummy.attributes) - dummy2 = self.node.read(type=DUMMY, name='MyDummy') + dummy2 = self.node.read(type=DUMMY_TYPE, name='MyDummy') self.assertEqual(dummy.attributes, dummy2.attributes) integers = [0, 1, 42, (2**63) - 1, -1, -42, -(2**63)] @@ -355,7 +347,7 @@ def test_dummy(self): for data in test_data: try: self.assertEqual( - {'operation': 'callme', 'type': DUMMY, 'identity': identity, 'data': data}, + {'operation': 'callme', 'type': DUMMY_TYPE, 'identity': identity, 'data': data}, dummy.call('callme', data=data)) except TypeError as exc: raise TypeError("data=%r: %s" % (data, exc)) @@ -364,11 +356,11 @@ def test_dummy(self): self.assertRaises(BadRequestStatus, dummy.update) dummy.delete() - self.assertRaises(NotFoundStatus, self.node.read, type=DUMMY, name='MyDummy') + self.assertRaises(NotFoundStatus, self.node.read, type=DUMMY_TYPE, name='MyDummy') def test_link(self): """Verify we can find our own reply-to address in links""" - response = self.node.query(type=LINK) + response = self.node.query(type=ROUTER_LINK_TYPE) path = self.node.reply_to.split('/')[-1] mylink = [l for l in response.get_dicts() if l['owningAddr'] and l['owningAddr'].endswith(path)] @@ -382,16 +374,16 @@ def test_connection(self): def test_router(self): """Verify router counts match entity counts""" entities = self.node.query().get_entities() - routers = [e for e in entities if e.type == ROUTER] + routers = [e for e in entities if e.type == ROUTER_TYPE] self.assertEqual(1, len(routers)) router = routers[0] - self.assertEqual(router.linkCount, len([e for e in entities if e.type == LINK])) - self.assertEqual(router.addrCount, len([e for e in entities if e.type == ADDRESS])) + self.assertEqual(router.linkCount, len([e for e in entities if e.type == ROUTER_LINK_TYPE])) + self.assertEqual(router.addrCount, len([e for e in entities if e.type == ROUTER_ADDRESS_TYPE])) def test_router_node(self): """Test node entity in a trio of linked routers""" nodes = [self.cleanup(Node.connect(Url(r.addresses[0]))) for r in self.routers] - rnode_lists = [n.query(type=NODE).get_dicts() for n in nodes] + rnode_lists = [n.query(type=ROUTER_NODE_TYPE).get_dicts() for n in nodes] def check(attrs): name = attrs['id'] @@ -411,7 +403,7 @@ def test_entity_names(self): entities = list(chain( *[n.query(attribute_names=['type', 'identity', 'name']).iter_entities() for n in nodes])) for e in entities: - if e.type == MANAGEMENT: + if e.type == MANAGEMENT_TYPE: self.assertEqual(e.identity, "self") else: if e.type == 'io.skupper.router.connection': @@ -432,30 +424,30 @@ def test_remote_node(self): remote = self.cleanup(Node.connect(remote_url)) router_id = remotes[0].split("/")[3] assert router_id in ['router0', 'router1', 'router2'] - self.assertEqual([router_id], [r.id for r in remote.query(type=ROUTER).get_entities()]) + self.assertEqual([router_id], [r.id for r in remote.query(type=ROUTER_TYPE).get_entities()]) def test_get_types(self): types = self.node.get_types() - self.assertIn(CONFIGURATION, types[LISTENER]) - self.assertIn(OPERATIONAL, types[LINK]) + self.assertIn(CONFIG_ENTITY_TYPE, types[AMQP_LISTENER_TYPE]) + self.assertIn(OPER_ENTITY_TYPE, types[ROUTER_LINK_TYPE]) def test_get_operations(self): - result = self.node.get_operations(type=DUMMY) - self.assertEqual({DUMMY: ["CREATE", "READ", "UPDATE", "DELETE", "CALLME"]}, result) + result = self.node.get_operations(type=DUMMY_TYPE) + self.assertEqual({DUMMY_TYPE: ["CREATE", "READ", "UPDATE", "DELETE", "CALLME"]}, result) result = self.node.get_operations() - for type in LISTENER, LINK: + for type in AMQP_LISTENER_TYPE, ROUTER_LINK_TYPE: self.assertIn(type, result) - self.assertEqual(["UPDATE", "READ"], result[LINK]) + self.assertEqual(["UPDATE", "READ"], result[ROUTER_LINK_TYPE]) def test_get_attributes(self): - result = self.node.get_attributes(type=DUMMY) + result = self.node.get_attributes(type=DUMMY_TYPE) self.assertEqual({'arg1', 'arg2', 'num1', 'num2', 'name', 'identity', 'type'}, - set(result[DUMMY])) + set(result[DUMMY_TYPE])) result = self.node.get_attributes() - for type in LISTENER, LINK: + for type in AMQP_LISTENER_TYPE, ROUTER_LINK_TYPE: self.assertIn(type, result) for a in ['linkType', 'linkDir', 'owningAddr']: - self.assertIn(a, result[LINK]) + self.assertIn(a, result[ROUTER_LINK_TYPE]) def test_standalone_no_inter_router(self): """Verify that we do not allow inter-router connectors or listeners in standalone mode""" @@ -463,11 +455,11 @@ def test_standalone_no_inter_router(self): attrs = dict(role="inter-router", saslMechanisms="ANONYMOUS") self.assertRaises( BadRequestStatus, - self.node.create, dict(attrs, type=LISTENER, name="bad1", port=str(self.get_port()))) + self.node.create, dict(attrs, type=AMQP_LISTENER_TYPE, name="bad1", port=str(self.get_port()))) self.assertRaises( BadRequestStatus, - self.node.create, dict(attrs, type=CONNECTOR, name="bad2", port=str(self.get_port()))) + self.node.create, dict(attrs, type=AMQP_CONNECTOR_TYPE, name="bad2", port=str(self.get_port()))) conf = Qdrouterd.Config([ ('router', {'mode': 'standalone', 'id': 'all_by_myself1'}), diff --git a/tests/system_tests_multicast.py b/tests/system_tests_multicast.py index ec69e552b..179325881 100644 --- a/tests/system_tests_multicast.py +++ b/tests/system_tests_multicast.py @@ -32,7 +32,9 @@ from proton import Link from proton import Message from proton import Delivery -from system_test import AsyncTestSender, AsyncTestReceiver, TestCase, Qdrouterd, main_module, TIMEOUT, TestTimeout, unittest +from system_test import AsyncTestSender, AsyncTestReceiver, TestCase +from system_test import Qdrouterd, main_module, TIMEOUT, TestTimeout, unittest +from system_test import ALLOCATOR_TYPE, ROUTER_ADDRESS_TYPE MAX_FRAME = 1023 @@ -183,8 +185,7 @@ def _get_alloc_stats(self, router, stats): d = dict() mgmt = router.management - atype = 'io.skupper.router.allocator' - q = mgmt.query(type=atype).get_dicts() + q = mgmt.query(type=ALLOCATOR_TYPE).get_dicts() for name in stats: d[name] = next(a for a in q if a['typeName'] == name) return d @@ -621,8 +622,7 @@ def run(self): clean = True for cfg in self.config: mgmt = cfg['router'].management - atype = 'io.skupper.router.router.address' - addrs = mgmt.query(type=atype).get_dicts() + addrs = mgmt.query(type=ROUTER_ADDRESS_TYPE).get_dicts() if any(self.topic in a['name'] for a in addrs): clean = False break diff --git a/tests/system_tests_one_router.py b/tests/system_tests_one_router.py index 5d7125a98..5bac62338 100644 --- a/tests/system_tests_one_router.py +++ b/tests/system_tests_one_router.py @@ -30,7 +30,12 @@ from skupper_router.management.client import Node -from system_test import TestCase, Qdrouterd, main_module, TIMEOUT, DIR, Process, unittest, QdManager, TestTimeout +from system_test import TestCase, Qdrouterd, main_module, TIMEOUT, DIR +from system_test import Process, unittest, QdManager, TestTimeout +from system_test import AMQP_CONNECTOR_TYPE, AMQP_LISTENER_TYPE +from system_test import CONNECTION_TYPE, ROUTER_ADDRESS_TYPE, ROUTER_LINK_TYPE +from system_test import ROUTER_TYPE + from system_tests_ssl import RouterTestSslBase as SSL_TEST CONNECTION_PROPERTIES_UNICODE_STRING = {'connection': 'properties', 'int_property': 6451} @@ -60,7 +65,7 @@ def test_49_add_interrouter_connector_to_standalone_router(self): mgmt = QdManager(address=self.router.addresses[0]) test_pass = False try: - out = mgmt.create("io.skupper.router.connector", + out = mgmt.create(AMQP_CONNECTOR_TYPE, {"host": "0.0.0.0", "port": "77777", "role": "inter-router"}) @@ -79,7 +84,7 @@ def test_50_add_edge_listener_to_standalone_router(self): mgmt = QdManager(address=self.router.addresses[0]) test_pass = False try: - out = mgmt.create("io.skupper.router.listener", + out = mgmt.create(AMQP_LISTENER_TYPE, {"host": "0.0.0.0", "port": "77777", "role": "edge", @@ -99,7 +104,7 @@ def test_51_add_interrouter_listener_to_standalone_router(self): mgmt = QdManager(address=self.router.addresses[0]) test_pass = False try: - out = mgmt.create("io.skupper.router.listener", + out = mgmt.create(AMQP_LISTENER_TYPE, {"host": "0.0.0.0", "port": "77777", "role": "inter-router", @@ -132,7 +137,7 @@ def test_52_add_interrouter_connector_to_edge_router(self): mgmt = QdManager(address=self.router.addresses[0]) test_pass = False try: - out = mgmt.create("io.skupper.router.connector", + out = mgmt.create(AMQP_CONNECTOR_TYPE, {"host": "0.0.0.0", "port": "77777", "role": "inter-router"}) @@ -151,7 +156,7 @@ def test_53_add_edge_listener_to_edge_router(self): mgmt = QdManager(address=self.router.addresses[0]) test_pass = False try: - out = mgmt.create("io.skupper.router.listener", + out = mgmt.create(AMQP_LISTENER_TYPE, {"host": "0.0.0.0", "port": "77777", "role": "edge", @@ -171,7 +176,7 @@ def test_54_add_interrouter_listener_to_edge_router(self): mgmt = QdManager(address=self.router.addresses[0]) test_pass = False try: - out = mgmt.create("io.skupper.router.listener", + out = mgmt.create(AMQP_LISTENER_TYPE, {"host": "0.0.0.0", "port": "77777", "role": "inter-router", @@ -849,7 +854,7 @@ def test_37_connection_properties_unicode_string(self): node = Node.connect(self.router.addresses[0]) - results = node.query(type='io.skupper.router.connection', attribute_names=['properties']).results + results = node.query(type=CONNECTION_TYPE, attribute_names=['properties']).results found = False for result in results: @@ -872,7 +877,7 @@ def test_38_connection_properties_symbols(self): node = Node.connect(self.router.addresses[0]) - results = node.query(type='io.skupper.router.connection', attribute_names=['properties']).results + results = node.query(type=CONNECTION_TYPE, attribute_names=['properties']).results found = False for result in results: @@ -902,7 +907,7 @@ def test_42_unsettled_large_message_test(self): def test_43_dropped_presettled_receiver_stops(self): local_node = Node.connect(self.address, timeout=TIMEOUT) - res = local_node.query('io.skupper.router.router') + res = local_node.query(ROUTER_TYPE) presettled_dropped_count_index = res.attribute_names.index('droppedPresettledDeliveries') presettled_dropped_count = res.results[0][presettled_dropped_count_index] test = DroppedPresettledTest(self.address, 200, presettled_dropped_count) @@ -1027,15 +1032,15 @@ def response(self, msg): return Entity(ap['statusCode'], ap['statusDescription'], msg.body) def read_address(self, name): - ap = {'operation': 'READ', 'type': 'io.skupper.router.router.address', 'name': name} + ap = {'operation': 'READ', 'type': ROUTER_ADDRESS_TYPE, 'name': name} return Message(properties=ap, reply_to=self.reply_addr) def query_addresses(self): - ap = {'operation': 'QUERY', 'type': 'io.skupper.router.router.address'} + ap = {'operation': 'QUERY', 'type': ROUTER_ADDRESS_TYPE} return Message(properties=ap, reply_to=self.reply_addr) def query_links(self): - ap = {'operation': 'QUERY', 'type': 'io.skupper.router.router.link'} + ap = {'operation': 'QUERY', 'type': ROUTER_LINK_TYPE} return Message(properties=ap, reply_to=self.reply_addr) @@ -1412,7 +1417,7 @@ def run(self): def on_message(self, event): if event.receiver == self.receiver: if event.message.properties['statusCode'] == 200: - if 'io.skupper.router.router' in event.message.body.keys(): + if ROUTER_TYPE in event.message.body.keys(): if len(event.message.body.keys()) > 2: self.bail(None) else: @@ -1502,7 +1507,7 @@ def addr_text(self, addr): def on_timer_task(self, event): local_node = Node.connect(self.parent.address, timeout=TIMEOUT) - res = local_node.query('io.skupper.router.router.address') + res = local_node.query(ROUTER_ADDRESS_TYPE) name = res.attribute_names.index('name') found = False for results in res.results: @@ -1661,7 +1666,7 @@ def __init__(self, parent): def on_timer_task(self, event): self.num_tries += 1 local_node = Node.connect(self.parent.addr, timeout=TIMEOUT) - res = local_node.query('io.skupper.router.router.link') + res = local_node.query(ROUTER_LINK_TYPE) owning_addr_index = res.attribute_names.index('owningAddr') has_address = False for out in res.results: @@ -1693,7 +1698,7 @@ def __init__(self, parent): def on_timer_task(self, event): self.num_tries += 1 local_node = Node.connect(self.parent.addr, timeout=TIMEOUT) - res = local_node.query('io.skupper.router.router') + res = local_node.query(ROUTER_TYPE) presettled_deliveries_dropped_index = res.attribute_names.index('droppedPresettledDeliveries') presettled_dropped_count = res.results[0][presettled_deliveries_dropped_index] @@ -2612,7 +2617,7 @@ def __init__(self, parent, lastDlv=None, uptime=0): def on_timer_task(self, event): local_node = Node.connect(self.parent.address, timeout=TIMEOUT) - result = local_node.query('io.skupper.router.connection') + result = local_node.query(CONNECTION_TYPE) container_id_index = result.attribute_names.index('container') uptime_seconds_index = result.attribute_names.index('uptimeSeconds') last_dlv_seconds_index = result.attribute_names.index('lastDlvSeconds') @@ -2778,7 +2783,7 @@ def __init__(self, address): def get_modified_deliveries(self) : local_node = Node.connect(self.address, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) pos = outs.attribute_names.index("modifiedDeliveries") results = outs.results[0] n_modified_deliveries = results[pos] @@ -2902,7 +2907,7 @@ def __init__(self, address): def check_if_done(self): if self.n_settled == self.count: local_node = Node.connect(self.address, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) pos = outs.attribute_names.index("acceptedDeliveries") results = outs.results[0] if results[pos] >= self.count: @@ -2962,7 +2967,7 @@ def __init__(self, address): def count_rejects(self) : local_node = Node.connect(self.address, timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) pos = outs.attribute_names.index("rejectedDeliveries") results = outs.results[0] return results[pos] @@ -3206,8 +3211,7 @@ def run(self): clean = False while not clean: clean = True - atype = 'io.skupper.router.router.address' - addrs = self.router.management.query(type=atype).get_dicts() + addrs = self.router.management.query(type=ROUTER_ADDRESS_TYPE).get_dicts() if any("dispatch-1330" in a['name'] for a in addrs): clean = False break diff --git a/tests/system_tests_open_properties.py b/tests/system_tests_open_properties.py index 07d8ffe23..e171203fb 100644 --- a/tests/system_tests_open_properties.py +++ b/tests/system_tests_open_properties.py @@ -24,6 +24,7 @@ from test_broker import FakeBroker from system_test import TestCase, unittest, main_module, Qdrouterd from system_test import retry, TIMEOUT, wait_port, QdManager, Process +from system_test import CONNECTION_TYPE def strip_default_options(options): @@ -476,7 +477,7 @@ def setUpClass(cls): cls.RouterA.wait_ready() mgmt = cls.RouterA.management while True: - results = mgmt.query(type='io.skupper.router.connection', + results = mgmt.query(type=CONNECTION_TYPE, attribute_names=['container']).get_dicts() if any(c['container'] == 'RouterB' for c in results): break diff --git a/tests/system_tests_panic_handler.py b/tests/system_tests_panic_handler.py index ca7295d8f..659375867 100644 --- a/tests/system_tests_panic_handler.py +++ b/tests/system_tests_panic_handler.py @@ -23,7 +23,7 @@ import re from system_test import TestCase, unittest, main_module, Process -from system_test import retry, Qdrouterd, QdManager +from system_test import retry, Qdrouterd, QdManager, HTTP_LISTENER_TYPE @unittest.skipIf(os.environ.get("QPID_RUNTIME_CHECK", None) != "OFF", @@ -63,7 +63,7 @@ def test_01_panic_handler(self): mgmt = QdManager(address=self.router.addresses[0], timeout=1) # this call will crash the router try: - mgmt.create('io.skupper.router.httpListener', + mgmt.create(HTTP_LISTENER_TYPE, {'address': 'closest/panic', 'port': self.tester.get_port(), 'protocolVersion': 'HTTP1', diff --git a/tests/system_tests_priority.py b/tests/system_tests_priority.py index 87155b772..22c779e47 100644 --- a/tests/system_tests_priority.py +++ b/tests/system_tests_priority.py @@ -25,6 +25,8 @@ from skupper_router_internal.compat import UNICODE from system_test import TestCase, Qdrouterd, main_module, unittest +from system_test import ROUTER_LINK_TYPE + # ------------------------------------------------ # Helper classes for all tests. @@ -56,7 +58,7 @@ def __init__(self, reply_addr): def make_router_link_query(self) : props = {'count': '100', 'operation': 'QUERY', - 'entityType': 'io.skupper.router.router.link', + 'entityType': ROUTER_LINK_TYPE, 'name': 'self', 'type': 'org.amqp.management' } diff --git a/tests/system_tests_sasl_plain.py b/tests/system_tests_sasl_plain.py index b32fd8606..b06a3531f 100644 --- a/tests/system_tests_sasl_plain.py +++ b/tests/system_tests_sasl_plain.py @@ -21,7 +21,7 @@ import os from subprocess import PIPE, Popen from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, retry_assertion -from system_test import unittest, QdManager, Process +from system_test import unittest, QdManager, Process, CONNECTION_TYPE from skupper_router.management.client import Node from proton import SASL @@ -139,9 +139,8 @@ def setUpClass(cls): @unittest.skipIf(not SASL.extended(), "Cyrus library not available. skipping test") def test_inter_router_sasl_fail(self): passed = False - long_type = 'io.skupper.router.connection' qd_manager = QdManager(address=self.routers[1].addresses[0]) - connections = qd_manager.query(long_type) + connections = qd_manager.query(CONNECTION_TYPE) for connection in connections: if connection['role'] == 'inter-router': passed = True @@ -234,10 +233,9 @@ def setUpClass(cls): @unittest.skipIf(not SASL.extended(), "Cyrus library not available. skipping test") def test_inter_router_sasl_fail(self): passed = False - long_type = 'io.skupper.router.connection' qd_manager = QdManager(address=self.routers[1].addresses[0]) - connections = qd_manager.query(long_type) + connections = qd_manager.query(CONNECTION_TYPE) for connection in connections: if connection['role'] == 'inter-router': @@ -517,7 +515,7 @@ def test_inter_router_plain_over_ssl_exists(self): """ local_node = Node.connect(self.routers[0].addresses[1], timeout=TIMEOUT) - results = local_node.query(type='io.skupper.router.connection').get_entities() + results = local_node.query(type=CONNECTION_TYPE).get_entities() # sslProto should be TLSv1.x self.assertIn('TLSv1', results[0].sslProto) @@ -612,7 +610,7 @@ def test_no_inter_router_connection(self): due to setting 'verifyHostname': 'yes' """ local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT) - results = local_node.query(type='io.skupper.router.connection').get_entities() + results = local_node.query(type=CONNECTION_TYPE).get_entities() # There should be only two connections. # There will be no inter-router connection @@ -727,7 +725,7 @@ def test_inter_router_plain_over_ssl_exists(self): """ local_node = Node.connect(self.routers[1].addresses[0], timeout=TIMEOUT) - results = local_node.query(type='io.skupper.router.connection').get_entities() + results = local_node.query(type=CONNECTION_TYPE).get_entities() self.common_asserts(results) @@ -738,13 +736,13 @@ def test_zzz_delete_create_ssl_profile(self): """ local_node = self.routers[1].management - connections = local_node.query(type='io.skupper.router.connection').get_entities() + connections = local_node.query(type=CONNECTION_TYPE).get_entities() self.assertIn("QDR.X", [c.container for c in connections]) # We can find the connection before local_node.delete(type='connector', name='connectorToX') local_node.delete(type='sslProfile', name='client-ssl-profile') def check_connections(): - conns = local_node.query(type='io.skupper.router.connection').get_entities() + conns = local_node.query(type=CONNECTION_TYPE).get_entities() is_qdr_x = "QDR.X" in [c.container for c in conns] self.assertFalse(is_qdr_x) # Should not be present now @@ -772,7 +770,7 @@ def check_connections(): 'saslUsername': 'test@domain.com', 'saslPassword': 'password'}) self.routers[1].wait_connectors() - results = local_node.query(type='io.skupper.router.connection').get_entities() + results = local_node.query(type=CONNECTION_TYPE).get_entities() self.common_asserts(results) diff --git a/tests/system_tests_skmanage.py b/tests/system_tests_skmanage.py index 93cdbbb25..21e086504 100644 --- a/tests/system_tests_skmanage.py +++ b/tests/system_tests_skmanage.py @@ -30,9 +30,11 @@ from system_test import unittest, retry_assertion from system_test import Logger, TestCase, Process, Qdrouterd, main_module, TIMEOUT, DIR -from system_test import QdManager - -DUMMY = "io.skupper.router.dummy" +from system_test import QdManager, DUMMY_TYPE, SSL_PROFILE_TYPE, LOG_STATS_TYPE +from system_test import CONFIG_ADDRESS_TYPE, ROUTER_ADDRESS_TYPE +from system_test import AMQP_LISTENER_TYPE, LOG_TYPE, ROUTER_TYPE +from system_test import CONFIG_ENTITY_TYPE, ENTITY_TYPE, CONFIG_AUTOLINK_TYPE +from system_test import AMQP_CONNECTOR_TYPE, ROUTER_LINK_TYPE, CONNECTION_TYPE CONNECTION_PROPERTIES_UNICODE_STRING = {'connection': 'properties', 'int_property': 6451} @@ -119,7 +121,7 @@ def check(cmd, expect, copy=None, **kwargs): actual = json.loads(self.run_skmanage(cmd)) self.assert_entity_equal(expect, actual, copy=copy) - expect = {'arg1': 'foo', 'type': DUMMY, 'name': 'mydummy2'} + expect = {'arg1': 'foo', 'type': DUMMY_TYPE, 'name': 'mydummy2'} # create with type, name in attributes check('create arg1=foo type=dummy name=mydummy2', expect, copy=['identity'], attributes=json.dumps(expect)) # create with type, name as arguments @@ -147,10 +149,10 @@ def check_list(cmd, expect_list, input, copy=None): actual = json.loads(self.run_skmanage(cmd + " --stdin", input=input)) self.assert_entities_equal(expect_list, actual, copy=copy) - expect = {'type': DUMMY, 'name': 'mydummyx', 'arg1': 'foo'} + expect = {'type': DUMMY_TYPE, 'name': 'mydummyx', 'arg1': 'foo'} check('create', expect, json.dumps(expect), copy=['identity']) - expect_list = [{'type': DUMMY, 'name': 'mydummyx%s' % i} for i in range(3)] + expect_list = [{'type': DUMMY_TYPE, 'name': 'mydummyx%s' % i} for i in range(3)] check_list('create', expect_list, json.dumps(expect_list), copy=['identity']) expect['arg1'] = 'bar' @@ -165,7 +167,13 @@ def check_list(cmd, expect_list, input, copy=None): def test_query(self): def long_type(name): - return 'io.skupper.router.' + name + long_names = {'listener': AMQP_LISTENER_TYPE, + 'log': LOG_TYPE, + 'router': ROUTER_TYPE, + 'router.link': ROUTER_LINK_TYPE, + 'connection': CONNECTION_TYPE, + 'router.address': ROUTER_ADDRESS_TYPE} + return long_names[name] types = ['listener', 'log', 'router'] long_types = [long_type(name) for name in types] @@ -175,7 +183,7 @@ def long_type(name): for t in long_types: self.assertIn(t, qall_types) - qlistener = json.loads(self.run_skmanage('query --type=listener')) + qlistener = json.loads(self.run_skmanage(f'query --type={AMQP_LISTENER_TYPE}')) self.assertEqual([long_type('listener')] * 4, [e['type'] for e in qlistener]) self.assertEqual(self.router_1.ports[0], int(qlistener[0]['port'])) @@ -217,31 +225,31 @@ def test_get_attributes(self): def test_get_operations(self): out = json.loads(self.run_skmanage("get-operations")) self.assertEqual(len(out), TOTAL_ENTITIES) - self.assertEqual(out['io.skupper.router.sslProfile'], ['CREATE', 'DELETE', 'READ']) + self.assertEqual(out[SSL_PROFILE_TYPE], ['CREATE', 'DELETE', 'READ']) def test_get_types_with_ssl_profile_type(self): - out = json.loads(self.run_skmanage("get-types --type=io.skupper.router.sslProfile")) - self.assertEqual(out['io.skupper.router.sslProfile'], ['io.skupper.router.configurationEntity', 'io.skupper.router.entity']) + out = json.loads(self.run_skmanage(f"get-types --type={SSL_PROFILE_TYPE}")) + self.assertEqual(out[SSL_PROFILE_TYPE], [CONFIG_ENTITY_TYPE, ENTITY_TYPE]) def test_get_ssl_profile_type_attributes(self): - out = json.loads(self.run_skmanage('get-attributes --type=io.skupper.router.sslProfile')) + out = json.loads(self.run_skmanage(f'get-attributes --type={SSL_PROFILE_TYPE}')) self.assertEqual(len(out), 1) - self.assertEqual(len(out['io.skupper.router.sslProfile']), 11) + self.assertEqual(len(out[SSL_PROFILE_TYPE]), 11) def test_get_ssl_profile_attributes(self): - out = json.loads(self.run_skmanage('get-attributes io.skupper.router.sslProfile')) + out = json.loads(self.run_skmanage(f'get-attributes {SSL_PROFILE_TYPE}')) self.assertEqual(len(out), 1) - self.assertEqual(len(out['io.skupper.router.sslProfile']), 11) + self.assertEqual(len(out[SSL_PROFILE_TYPE]), 11) def test_get_ssl_profile_type_operations(self): - out = json.loads(self.run_skmanage('get-operations --type=io.skupper.router.sslProfile')) + out = json.loads(self.run_skmanage(f'get-operations --type={SSL_PROFILE_TYPE}')) self.assertEqual(len(out), 1) - self.assertEqual(len(out['io.skupper.router.sslProfile']), 3) + self.assertEqual(len(out[SSL_PROFILE_TYPE]), 3) def test_get_ssl_profile_operations(self): - out = json.loads(self.run_skmanage('get-operations io.skupper.router.sslProfile')) + out = json.loads(self.run_skmanage(f'get-operations {SSL_PROFILE_TYPE}')) self.assertEqual(len(out), 1) - self.assertEqual(len(out['io.skupper.router.sslProfile']), 3) + self.assertEqual(len(out[SSL_PROFILE_TYPE]), 3) def test_get_log(self): logs = json.loads(self.run_skmanage("get-log limit=20")) @@ -252,7 +260,7 @@ def test_get_log(self): self.assertTrue(found) def test_get_logstats(self): - query_command = 'QUERY --type=logStats' + query_command = f'QUERY --type={LOG_STATS_TYPE}' logs = json.loads(self.run_skmanage(query_command)) # Each value returned by the above query should be # a log, and each log should contain an entry for each @@ -284,14 +292,14 @@ def test_update(self): exception = False try: # Try to not set 'output' - json.loads(self.run_skmanage("UPDATE --type io.skupper.router.log --name log/DEFAULT outputFile=")) + json.loads(self.run_skmanage(f"UPDATE --type {LOG_TYPE} --name log/DEFAULT outputFile=")) except Exception as e: exception = True self.assertIn("InternalServerErrorStatus: CError: Configuration: Failed to open log file ''", str(e)) self.assertTrue(exception) # Set a valid 'output' - output = json.loads(self.run_skmanage("UPDATE --type io.skupper.router.log --name log/DEFAULT " + output = json.loads(self.run_skmanage(f"UPDATE --type {LOG_TYPE} --name log/DEFAULT " "enable=debug+ outputFile=A.log")) self.assertEqual("A.log", output['outputFile']) self.assertEqual("debug+", output['enable']) @@ -304,8 +312,7 @@ def create(self, type, name, port, role=None): return ret_entity def test_check_address_name(self): - long_type = 'io.skupper.router.router.config.address' - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + CONFIG_ADDRESS_TYPE output = json.loads(self.run_skmanage(query_command)) self.assertEqual(len(output), 2) self.assertEqual(output[0]['name'], "test-address") @@ -318,22 +325,19 @@ def test_check_address_name(self): self.assertNotIn('prefix', output[1]) def test_create_address(self): - long_type = 'io.skupper.router.router.config.address' - create_command = 'CREATE --type=' + long_type + ' pattern="a.b.#"' + create_command = f'CREATE --type={CONFIG_ADDRESS_TYPE} pattern="a.b.#"' output = json.loads(self.run_skmanage(create_command)) self.assertEqual(output['pattern'], '"a.b.#"') def test_check_auto_link_name(self): - long_type = 'io.skupper.router.router.config.autoLink' - query_command = 'QUERY --type=' + long_type + query_command = f'QUERY --type={CONFIG_AUTOLINK_TYPE}' output = json.loads(self.run_skmanage(query_command)) self.assertEqual(output[0]['name'], "test-auto-link") self.assertEqual(output[0]['direction'], "out") self.assertEqual(output[0]['addr'], "mnop") def test_specify_container_id_connection_auto_link(self): - long_type = 'io.skupper.router.router.config.autoLink' - create_command = 'CREATE --type=' + long_type + ' address=abc containerId=id1 connection=conn1 direction=out' + create_command = f'CREATE --type={CONFIG_AUTOLINK_TYPE} address=abc containerId=id1 connection=conn1 direction=out' output = self.run_skmanage(create_command, expect=Process.EXIT_FAIL) self.assertIn("Both connection and containerId cannot be specified", output) @@ -343,19 +347,18 @@ def test_yyy_delete_create_connector(self): It then adds back the connector and make sure that there is at least one inter-router connection. The test name starts with a yyy so that it runs towards the end. """ - long_type = 'io.skupper.router.connector' - query_command = 'QUERY --type=' + long_type + query_command = f'QUERY --type={AMQP_CONNECTOR_TYPE}' output = json.loads(self.run_skmanage(query_command)) name = output[0]['name'] # Delete an existing connector - delete_command = 'DELETE --type=' + long_type + ' --name=' + name + delete_command = 'DELETE --type=' + AMQP_CONNECTOR_TYPE + ' --name=' + name self.run_skmanage(delete_command) output = json.loads(self.run_skmanage(query_command)) self.assertEqual(output, []) def query_inter_router_connector(check_inter_router_present=False): - outs = json.loads(self.run_skmanage('query --type=connection')) + outs = json.loads(self.run_skmanage(f'query --type={CONNECTION_TYPE}')) inter_router_present = False for out in outs: if check_inter_router_present: @@ -371,7 +374,7 @@ def query_inter_router_connector(check_inter_router_present=False): retry_assertion(query_inter_router_connector, delay=2) # Create back the connector with role="inter-router" - self.create(long_type, name, str(SkmanageTest.inter_router_port), role="inter-router") + self.create(AMQP_CONNECTOR_TYPE, name, str(SkmanageTest.inter_router_port), role="inter-router") outputs = json.loads(self.run_skmanage(query_command)) created = False for output in outputs: @@ -390,31 +393,30 @@ def query_inter_router_connector(check_inter_router_present=False): def test_zzz_add_connector(self): port = self.get_port() # dont provide role and make sure that role is defaulted to 'normal' - command = "CREATE --type=connector --name=eaconn1 port=" + str(port) + " host=0.0.0.0" + command = f"CREATE --type={AMQP_CONNECTOR_TYPE} --name=eaconn1 port=" + str(port) + " host=0.0.0.0" output = json.loads(self.run_skmanage(command)) self.assertEqual("normal", output['role']) # provide the same connector name (eaconn1), expect duplicate value failure self.assertRaises(Exception, self.run_skmanage, - "CREATE --type=connector --name=eaconn1 port=12345 host=0.0.0.0") + f"CREATE --type={AMQP_CONNECTOR_TYPE} --name=eaconn1 port=12345 host=0.0.0.0") port = self.get_port() # provide role as 'normal' and make sure that it is preserved - command = "CREATE --type=connector --name=eaconn2 port=" + str(port) + " host=0.0.0.0 role=normal" + command = f"CREATE --type={AMQP_CONNECTOR_TYPE} --name=eaconn2 port=" + str(port) + " host=0.0.0.0 role=normal" output = json.loads(self.run_skmanage(command)) self.assertEqual("normal", output['role']) def test_zzz_create_delete_listener(self): - long_type = 'io.skupper.router.listener' name = 'ealistener' listener_port = self.get_port() - listener = self.create(long_type, name, str(listener_port)) - self.assertEqual(listener['type'], long_type) + listener = self.create(AMQP_LISTENER_TYPE, name, str(listener_port)) + self.assertEqual(listener['type'], AMQP_LISTENER_TYPE) self.assertEqual(listener['name'], name) exception_occurred = False - delete_command = 'DELETE --type=' + long_type + ' --name=' + name + delete_command = 'DELETE --type=' + AMQP_LISTENER_TYPE + ' --name=' + name self.run_skmanage(delete_command) exception_occurred = False @@ -429,12 +431,12 @@ def test_zzz_create_delete_listener(self): def test_create_delete_ssl_profile(self): ssl_profile_name = 'ssl-profile-test' - ssl_create_command = 'CREATE --type=sslProfile certFile=' + self.ssl_file('server-certificate.pem') + \ + ssl_create_command = f'CREATE --type={SSL_PROFILE_TYPE} certFile=' + self.ssl_file('server-certificate.pem') + \ ' privateKeyFile=' + self.ssl_file('server-private-key.pem') + ' password=server-password' + \ ' name=' + ssl_profile_name + ' caCertFile=' + self.ssl_file('ca-certificate.pem') output = json.loads(self.run_skmanage(ssl_create_command)) self.assertEqual(output['name'], ssl_profile_name) - self.run_skmanage('DELETE --type=sslProfile --name=' + + self.run_skmanage(f'DELETE --type={SSL_PROFILE_TYPE} --name=' + ssl_profile_name) def test_delete_connection(self): @@ -445,7 +447,7 @@ def test_delete_connection(self): :return: """ connection = BlockingConnection(self.address(), properties=CONNECTION_PROPERTIES_UNICODE_STRING) - query_command = 'QUERY --type=connection' + query_command = f'QUERY --type={CONNECTION_TYPE}' outputs = json.loads(self.run_skmanage(query_command)) identity = None passed = False @@ -471,12 +473,11 @@ def test_create_delete_address_pattern(self): ('*/mars/*/#', 'multicast'), ('*.mercury', 'closest'), ('*/#/pluto', 'multicast')] - long_type = 'io.skupper.router.router.config.address' # add patterns: pcount = 0 for p in config: - query_command = 'CREATE --type=' + long_type + \ + query_command = 'CREATE --type=' + CONFIG_ADDRESS_TYPE + \ ' pattern=' + p[0] + \ ' distribution=' + p[1] + \ ' name=Pattern' + str(pcount) @@ -484,7 +485,7 @@ def test_create_delete_address_pattern(self): pcount += 1 # verify correctly added: - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + CONFIG_ADDRESS_TYPE output = json.loads(self.run_skmanage(query_command)) total = len(output) @@ -501,13 +502,13 @@ def test_create_delete_address_pattern(self): # delete pcount = 0 for p in config: - query_command = 'DELETE --type=' + long_type + \ + query_command = 'DELETE --type=' + CONFIG_ADDRESS_TYPE + \ ' --name=Pattern' + str(pcount) self.run_skmanage(query_command) pcount += 1 # verify deleted: - query_command = 'QUERY --type=' + long_type + query_command = 'QUERY --type=' + CONFIG_ADDRESS_TYPE output = json.loads(self.run_skmanage(query_command)) self.assertEqual(len(output), total - len(config)) for o in output: @@ -536,7 +537,7 @@ def test_yy_query_many_links(self): # Try fetching all 10,000 addresses # This skmanage query command would fail without the fix # for DISPATCH-974 - query_command = 'QUERY --type=io.skupper.router.router.address' + query_command = f'QUERY --type={ROUTER_ADDRESS_TYPE}' for i in range(3): sender_addresses = 0 receiver_addresses = 0 @@ -586,9 +587,8 @@ def test_yy_query_many_links(self): self.assertEqual(in_links, COUNT) def test_worker_threads(self): - long_type = 'io.skupper.router.router' qd_manager = QdManager(address=self.address()) - output = qd_manager.query('io.skupper.router.router') + output = qd_manager.query(ROUTER_TYPE) self.assertEqual(output[0]['workerThreads'], 4) def test_check_memory_usage(self): @@ -596,8 +596,7 @@ def test_check_memory_usage(self): Verify that the process memory usage is present. Non-Linux platforms may return zero, so accept that as a valid value. """ - long_type = 'io.skupper.router.router' - query_command = 'QUERY --type=' + long_type + query_command = f'QUERY --type={ROUTER_TYPE}' output = json.loads(self.run_skmanage(query_command)) self.assertEqual(len(output), 1) mem = output[0].get('memoryUsage') @@ -615,7 +614,7 @@ def test_ssl_connection(self): """Verify skmanage can securely connect via SSL""" ssl_address = "amqps://localhost:%s" % self.secure_port ssl_user_address = "amqps://localhost:%s" % self.secure_user_port - query = 'QUERY --type io.skupper.router.router' + query = f'QUERY --type {ROUTER_TYPE}' # this should fail: no trustfile with self.assertRaises(RuntimeError, @@ -666,8 +665,7 @@ def test_ssl_connection(self): def test_listener_connector_cost(self): # Try creating a connector and listener with negative cost - connector_long_type = 'io.skupper.router.connector' - create_command = 'CREATE --type=' + connector_long_type + ' port=' + \ + create_command = 'CREATE --type=' + AMQP_CONNECTOR_TYPE + ' port=' + \ str(self.get_port()) + ' cost=-1 role=normal' error_string = "Configuration: Invalid cost (-1) specified. Minimum value for cost is " \ "1 and maximum value is 2147483647" @@ -679,8 +677,7 @@ def test_listener_connector_cost(self): passed = True self.assertTrue(passed) - listener_long_type = 'io.skupper.router.listener' - create_command = 'CREATE --type=' + listener_long_type + ' port=' + \ + create_command = 'CREATE --type=' + AMQP_LISTENER_TYPE + ' port=' + \ str(self.get_port()) + ' cost=-1 role=normal' error_string = "Configuration: Invalid cost (-1) specified. Minimum value for cost is " \ "1 and maximum value is 2147483647" @@ -693,7 +690,7 @@ def test_listener_connector_cost(self): self.assertTrue(passed) # Try creating a connector and listener with cost past the int range. - create_command = 'CREATE --type=' + connector_long_type + ' port=' + \ + create_command = 'CREATE --type=' + AMQP_CONNECTOR_TYPE + ' port=' + \ str(self.get_port()) + ' cost=2147483648 role=normal' error_string = "Configuration: Invalid cost (2147483648) specified. Minimum value for cost is " \ "1 and maximum value is 2147483647" @@ -705,7 +702,7 @@ def test_listener_connector_cost(self): passed = True self.assertTrue(passed) - create_command = 'CREATE --type=' + listener_long_type + ' port=' + \ + create_command = 'CREATE --type=' + AMQP_LISTENER_TYPE + ' port=' + \ str(self.get_port()) + ' cost=2147483648 role=normal' passed = False try: diff --git a/tests/system_tests_ssl.py b/tests/system_tests_ssl.py index 48abf642e..6bea7229d 100644 --- a/tests/system_tests_ssl.py +++ b/tests/system_tests_ssl.py @@ -31,7 +31,7 @@ from skupper_router.management.client import Node from system_test import TIMEOUT, TestCase, main_module, Qdrouterd, DIR -from system_test import unittest, retry +from system_test import unittest, retry, CONNECTION_TYPE, ROUTER_NODE_TYPE def protocol_name(proto): @@ -213,8 +213,6 @@ def check_tls_protocol(self, mgmt, listener_port, tls_protocol, ATTR_NAMES = ['ssl', 'sslProto', 'sasl', 'isAuthenticated', 'isEncrypted', 'user'] - CONN_TYPE = 'io.skupper.router.connection' - # Management address to connect using the given TLS protocol url = Url("amqps://0.0.0.0:%d/$management" % listener_port) @@ -250,7 +248,7 @@ def check_tls_protocol(self, mgmt, listener_port, tls_protocol, # router! def _get_tls_conn(): - conns = mgmt.query(type=CONN_TYPE, + conns = mgmt.query(type=CONNECTION_TYPE, attribute_names=ATTR_NAMES).get_entities() ssl_conns = [c for c in conns if c['ssl']] if ssl_conns: @@ -267,7 +265,7 @@ def _get_tls_conn(): # not interfere with other tests def _wait_conn_gone(): - conns = mgmt.query(type=CONN_TYPE, + conns = mgmt.query(type=CONNECTION_TYPE, attribute_names=ATTR_NAMES).get_entities() if len([c for c in conns if c['ssl']]) == 0: return True @@ -535,7 +533,7 @@ def get_router_nodes(self): url = Url("amqp://0.0.0.0:%d/$management" % self.PORT_NO_SSL) node = Node.connect(url) - response = node.query(type="io.skupper.router.router.node", attribute_names=["id"]) + response = node.query(type=ROUTER_NODE_TYPE, attribute_names=["id"]) router_nodes = [] for resp in response.get_dicts(): router_nodes.append(resp['id']) @@ -556,7 +554,7 @@ def test_connected_tls_sasl_routers(self): def _get_ssl_conns(mgmt): # query all inter-router connections, wait until all expected # connections have come up - conns = mgmt.query(type='io.skupper.router.connection', + conns = mgmt.query(type=CONNECTION_TYPE, attribute_names=['role', 'ssl', 'sslProto', @@ -728,7 +726,7 @@ def get_router_nodes(self): url = Url("amqp://0.0.0.0:%d/$management" % self.PORT_NO_SSL) node = Node.connect(url) - response = node.query(type="io.skupper.router.router.node", attribute_names=["id"]) + response = node.query(type=ROUTER_NODE_TYPE, attribute_names=["id"]) router_nodes = [] for resp in response.get_dicts(): router_nodes.append(resp['id']) @@ -881,7 +879,7 @@ def get_router_nodes(self): url = Url("amqp://0.0.0.0:%d/$management" % self.PORT_NO_SSL) node = Node.connect(url) - response = node.query(type="io.skupper.router.router.node", attribute_names=["id"]) + response = node.query(type=ROUTER_NODE_TYPE, attribute_names=["id"]) router_nodes = [] for resp in response.get_dicts(): router_nodes.append(resp['id']) diff --git a/tests/system_tests_tcp_adaptor.py b/tests/system_tests_tcp_adaptor.py index 70d0ebc5d..9f4b16808 100644 --- a/tests/system_tests_tcp_adaptor.py +++ b/tests/system_tests_tcp_adaptor.py @@ -44,7 +44,8 @@ from system_test import main_module from system_test import unittest from system_test import retry -from system_test import CONNECTION_TYPE +from system_test import CONNECTION_TYPE, TCP_CONNECTOR_TYPE, TCP_LISTENER_TYPE +from system_test import ROUTER_LINK_TYPE from system_test import retry_assertion from system_tests_ssl import RouterTestSslBase from http1_tests import wait_tcp_listeners_up @@ -683,12 +684,11 @@ def router(name, mode, connection, extra=None, ssl=False, encapsulation="legacy" cls.logger.log("TCP_TEST waiting for all tcpListeners to activate...") - LISTENER_TYPE = 'io.skupper.router.tcpListener' for rtr in cls.routers: mgmt = rtr.management listeners_ready = False while not listeners_ready: - listeners = mgmt.query(type=LISTENER_TYPE, + listeners = mgmt.query(type=TCP_LISTENER_TYPE, attribute_names=["operStatus", "name", "address"]).get_dicts() listeners_ready = True @@ -1536,11 +1536,10 @@ def setUpClass(cls): cls.e_router.wait_ready() def _query_links_by_addr(self, router_mgmt, owning_addr): - oid = 'io.skupper.router.router.link' attrs = ['owningAddr', 'linkDir'] links = [] - rc = router_mgmt.query(type=oid, attribute_names=attrs).results + rc = router_mgmt.query(type=ROUTER_LINK_TYPE, attribute_names=attrs).results for link in rc: if link[0] is not None and link[0].endswith(owning_addr): links.append(link) @@ -1552,33 +1551,30 @@ def test_01_mgmt(self): Create and delete TCP connectors and listeners. Ensure that the service address is properly removed on the interior router. """ - LISTENER_TYPE = 'io.skupper.router.tcpListener' - CONNECTOR_TYPE = 'io.skupper.router.tcpConnector' - mgmt = self.e_router.management van_address = self.test_name + "/test_01_mgmt" # When starting out, there should be no tcpListeners or tcpConnectors. - self.assertEqual(0, len(mgmt.query(type=LISTENER_TYPE).results)) - self.assertEqual(0, len(mgmt.query(type=CONNECTOR_TYPE).results)) + self.assertEqual(0, len(mgmt.query(type=TCP_LISTENER_TYPE).results)) + self.assertEqual(0, len(mgmt.query(type=TCP_CONNECTOR_TYPE).results)) connector_name = "ServerConnector" listener_name = "ClientListener" - mgmt.create(type=LISTENER_TYPE, + mgmt.create(type=TCP_LISTENER_TYPE, name=listener_name, attributes={'address': van_address, 'port': self.tcp_listener_port, 'host': '127.0.0.1'}) - mgmt.create(type=CONNECTOR_TYPE, + mgmt.create(type=TCP_CONNECTOR_TYPE, name=connector_name, attributes={'address': van_address, 'port': self.tcp_server_port, 'host': '127.0.0.1'}) # verify the entities have been created and tcp traffic works - self.assertEqual(1, len(mgmt.query(type=LISTENER_TYPE).results)) - self.assertEqual(1, len(mgmt.query(type=CONNECTOR_TYPE).results)) + self.assertEqual(1, len(mgmt.query(type=TCP_LISTENER_TYPE).results)) + self.assertEqual(1, len(mgmt.query(type=TCP_CONNECTOR_TYPE).results)) # now verify that the interior router sees the service address # and two proxy links are created: one outgoing for the connector and @@ -1594,12 +1590,12 @@ def test_01_mgmt(self): time.sleep(0.25) # Delete the connector and listener - out = mgmt.delete(type=CONNECTOR_TYPE, name=connector_name) # pylint: disable=assignment-from-no-return + out = mgmt.delete(type=TCP_CONNECTOR_TYPE, name=connector_name) # pylint: disable=assignment-from-no-return self.assertIsNone(out) - self.assertEqual(0, len(mgmt.query(type=CONNECTOR_TYPE).results)) - out = mgmt.delete(type=LISTENER_TYPE, name=listener_name) # pylint: disable=assignment-from-no-return + self.assertEqual(0, len(mgmt.query(type=TCP_CONNECTOR_TYPE).results)) + out = mgmt.delete(type=TCP_LISTENER_TYPE, name=listener_name) # pylint: disable=assignment-from-no-return self.assertIsNone(out) - self.assertEqual(0, len(mgmt.query(type=LISTENER_TYPE).results)) + self.assertEqual(0, len(mgmt.query(type=TCP_LISTENER_TYPE).results)) # verify the service address and proxy links are no longer active on # the interior router @@ -1624,27 +1620,24 @@ def test_02_mgmt_recreate(self): """ Verify that deleting then re-creating listeners and connectors works """ - LISTENER_TYPE = 'io.skupper.router.tcpListener' - CONNECTOR_TYPE = 'io.skupper.router.tcpConnector' - mgmt = self.e_router.management van_address = self.test_name + "/test_02_mgmt_recreate" # When starting out, there should be no tcpListeners or tcpConnectors. - self.assertEqual(0, len(mgmt.query(type=LISTENER_TYPE).results)) - self.assertEqual(0, len(mgmt.query(type=CONNECTOR_TYPE).results)) + self.assertEqual(0, len(mgmt.query(type=TCP_LISTENER_TYPE).results)) + self.assertEqual(0, len(mgmt.query(type=TCP_CONNECTOR_TYPE).results)) connector_name = "ServerConnector" listener_name = "ClientListener" for i in range(2): - mgmt.create(type=LISTENER_TYPE, + mgmt.create(type=TCP_LISTENER_TYPE, name=listener_name, attributes={'address': van_address, 'port': self.tcp_listener_port, 'host': '127.0.0.1'}) - mgmt.create(type=CONNECTOR_TYPE, + mgmt.create(type=TCP_CONNECTOR_TYPE, name=connector_name, attributes={'address': van_address, 'port': self.tcp_server_port, @@ -1653,7 +1646,7 @@ def test_02_mgmt_recreate(self): # wait until the listener has initialized def _wait_for_listener_up(): - li = mgmt.read(type=LISTENER_TYPE, name=listener_name) + li = mgmt.read(type=TCP_LISTENER_TYPE, name=listener_name) if li['operStatus'] == 'up': return True return False @@ -1661,13 +1654,13 @@ def _wait_for_listener_up(): # verify initial statistics - l_stats = mgmt.read(type=LISTENER_TYPE, name=listener_name) + l_stats = mgmt.read(type=TCP_LISTENER_TYPE, name=listener_name) self.assertEqual(0, l_stats['bytesIn']) self.assertEqual(0, l_stats['bytesOut']) self.assertEqual(0, l_stats['connectionsOpened']) self.assertEqual(0, l_stats['connectionsClosed']) - c_stats = mgmt.read(type=CONNECTOR_TYPE, name=connector_name) + c_stats = mgmt.read(type=TCP_CONNECTOR_TYPE, name=connector_name) self.assertEqual(0, c_stats['bytesIn']) self.assertEqual(0, c_stats['bytesOut']) self.assertEqual(1, c_stats['connectionsOpened']) # dispatcher @@ -1682,7 +1675,7 @@ def _wait_for_listener_up(): server.listen(1) self.assertTrue(retry(lambda: - mgmt.read(type=LISTENER_TYPE, + mgmt.read(type=TCP_LISTENER_TYPE, name=listener_name)['operStatus'] == 'up')) @@ -1712,10 +1705,10 @@ def _wait_for_listener_up(): # Wait until the test clients have closed def _wait_for_close(): - if 0 == mgmt.read(type=LISTENER_TYPE, + if 0 == mgmt.read(type=TCP_LISTENER_TYPE, name=listener_name)['connectionsClosed']: return False - if 0 == mgmt.read(type=CONNECTOR_TYPE, + if 0 == mgmt.read(type=TCP_CONNECTOR_TYPE, name=connector_name)['connectionsClosed']: return False return True @@ -1723,13 +1716,13 @@ def _wait_for_close(): # Verify updated statistics. - l_stats = mgmt.read(type=LISTENER_TYPE, name=listener_name) + l_stats = mgmt.read(type=TCP_LISTENER_TYPE, name=listener_name) self.assertEqual(10, l_stats['bytesIn']) self.assertEqual(4, l_stats['bytesOut']) self.assertEqual(1, l_stats['connectionsOpened']) self.assertEqual(1, l_stats['connectionsClosed']) - c_stats = mgmt.read(type=CONNECTOR_TYPE, name=connector_name) + c_stats = mgmt.read(type=TCP_CONNECTOR_TYPE, name=connector_name) self.assertEqual(4, c_stats['bytesIn']) self.assertEqual(10, c_stats['bytesOut']) self.assertEqual(2, c_stats['connectionsOpened']) @@ -1748,11 +1741,11 @@ def _wait_for_close(): # splendid! Not delete all the things - mgmt.delete(type=LISTENER_TYPE, name=listener_name) - self.assertEqual(0, len(mgmt.query(type=LISTENER_TYPE).results)) + mgmt.delete(type=TCP_LISTENER_TYPE, name=listener_name) + self.assertEqual(0, len(mgmt.query(type=TCP_LISTENER_TYPE).results)) - mgmt.delete(type=CONNECTOR_TYPE, name=connector_name) - self.assertEqual(0, len(mgmt.query(type=CONNECTOR_TYPE).results)) + mgmt.delete(type=TCP_CONNECTOR_TYPE, name=connector_name) + self.assertEqual(0, len(mgmt.query(type=TCP_CONNECTOR_TYPE).results)) # attempting to connect should fail once the listener socket has # been closed @@ -1771,9 +1764,6 @@ class TcpAdaptorListenerConnectTest(TestCase): """ Test client connecting to TcpListeners in various scenarios """ - LISTENER_TYPE = 'io.skupper.router.tcpListener' - CONNECTOR_TYPE = 'io.skupper.router.tcpConnector' - @classmethod def setUpClass(cls): super(TcpAdaptorListenerConnectTest, cls).setUpClass() @@ -1843,13 +1833,13 @@ def test_01_no_service(self): connector_port = self.tester.get_port() a_mgmt = self.INTA.management - a_mgmt.create(type=self.LISTENER_TYPE, + a_mgmt.create(type=TCP_LISTENER_TYPE, name="ClientListener01", attributes={'address': van_address, 'port': listener_port}) b_mgmt = self.INTB.management - b_mgmt.create(type=self.CONNECTOR_TYPE, + b_mgmt.create(type=TCP_CONNECTOR_TYPE, name="ServerConnector01", attributes={'address': van_address, 'host': '127.0.0.1', @@ -1863,7 +1853,7 @@ def test_01_no_service(self): # connect to. while True: - listener = a_mgmt.read(type=self.LISTENER_TYPE, + listener = a_mgmt.read(type=TCP_LISTENER_TYPE, name='ClientListener01') if listener['operStatus'] != 'up': time.sleep(0.1) @@ -1896,8 +1886,8 @@ def test_01_no_service(self): # Yay we did not hang! Test passed break - a_mgmt.delete(type=self.LISTENER_TYPE, name="ClientListener01") - b_mgmt.delete(type=self.CONNECTOR_TYPE, name="ServerConnector01") + a_mgmt.delete(type=TCP_LISTENER_TYPE, name="ClientListener01") + b_mgmt.delete(type=TCP_CONNECTOR_TYPE, name="ServerConnector01") self.INTA.wait_address_unsubscribed(van_address) @@ -1916,7 +1906,7 @@ def _test_listener_socket_lifecycle(self, connector_port = self.tester.get_port() l_mgmt = l_router.management - l_mgmt.create(type=self.LISTENER_TYPE, + l_mgmt.create(type=TCP_LISTENER_TYPE, name=listener_name, attributes={'address': van_address, 'port': listener_port}) @@ -1924,7 +1914,7 @@ def _test_listener_socket_lifecycle(self, # since there is no connector present, the operational state must be # down and connection attempts must be refused - listener = l_mgmt.read(type=self.LISTENER_TYPE, name=listener_name) + listener = l_mgmt.read(type=TCP_LISTENER_TYPE, name=listener_name) self.assertEqual('down', listener['operStatus']) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_conn: @@ -1942,7 +1932,7 @@ def _test_listener_socket_lifecycle(self, server.bind(("", connector_port)) server.listen(1) - c_mgmt.create(type=self.CONNECTOR_TYPE, + c_mgmt.create(type=TCP_CONNECTOR_TYPE, name=connector_name, attributes={'address': van_address, 'host': '127.0.0.1', @@ -1958,7 +1948,7 @@ def _test_listener_socket_lifecycle(self, # expect the listener socket to come up while True: - listener = l_mgmt.read(type=self.LISTENER_TYPE, name=listener_name) + listener = l_mgmt.read(type=TCP_LISTENER_TYPE, name=listener_name) if listener['operStatus'] != 'up': time.sleep(0.1) continue @@ -1984,11 +1974,11 @@ def _test_listener_socket_lifecycle(self, # Teardown the connector, expect listener admin state to go down # and connections be refused - c_mgmt.delete(type=self.CONNECTOR_TYPE, name=connector_name) + c_mgmt.delete(type=TCP_CONNECTOR_TYPE, name=connector_name) l_router.wait_address_unsubscribed(van_address) while True: - listener = l_mgmt.read(type=self.LISTENER_TYPE, name=listener_name) + listener = l_mgmt.read(type=TCP_LISTENER_TYPE, name=listener_name) if listener['operStatus'] != 'down': time.sleep(0.1) continue @@ -2005,7 +1995,7 @@ def _test_listener_socket_lifecycle(self, # Test successful break - l_mgmt.delete(type=self.LISTENER_TYPE, name=listener_name) + l_mgmt.delete(type=TCP_LISTENER_TYPE, name=listener_name) def test_02_listener_interior(self): """ @@ -2082,7 +2072,7 @@ def test_delete_tcp_connection(self): client_conn.connect(('127.0.0.1', self.good_listener_port)) qd_manager = QdManager(self.address) conn_id = None - results = qd_manager.query("io.skupper.router.connection") + results = qd_manager.query(CONNECTION_TYPE) for result in results: conn_direction = result['dir'] # Find the id of the tcp connection we want to delete. @@ -2094,7 +2084,7 @@ def test_delete_tcp_connection(self): self.assertIsNotNone(conn_id, "Expected connection id to be not None") def check_connection_deleted(): - outs = qd_manager.query("io.skupper.router.connection") + outs = qd_manager.query(CONNECTION_TYPE) is_conn_present = False for out in outs: if out['identity'] == conn_id: diff --git a/tests/system_tests_tcp_half_close.py b/tests/system_tests_tcp_half_close.py index 6100ed841..198b7b26d 100644 --- a/tests/system_tests_tcp_half_close.py +++ b/tests/system_tests_tcp_half_close.py @@ -23,6 +23,7 @@ from system_test import Qdrouterd, TIMEOUT, TestCase, unittest from system_test import main_module, retry_exception, retry +from system_test import CONNECTION_TYPE class TcpAdaptorIdleHalfClosedTest(TestCase): @@ -64,7 +65,6 @@ def _get_tcp_conn_count(self): """ Return the number of currently active TCP connections """ - CONNECTION_TYPE = 'io.skupper.router.connection' mgmt = self.router.management conns = mgmt.query(type=CONNECTION_TYPE, attribute_names=['protocol', 'container', diff --git a/tests/system_tests_topology.py b/tests/system_tests_topology.py index b75085156..30bfa0d84 100644 --- a/tests/system_tests_topology.py +++ b/tests/system_tests_topology.py @@ -30,8 +30,8 @@ from system_test import AsyncTestReceiver from system_test import TestCase, Qdrouterd, main_module -from system_test import TIMEOUT -from system_test import unittest +from system_test import TIMEOUT, AMQP_CONNECTOR_TYPE, ROUTER_ADDRESS_TYPE +from system_test import unittest, CONNECTION_TYPE # ------------------------------------------------ # Helper classes for all tests. @@ -61,17 +61,17 @@ def __init__(self, reply_addr): self.reply_addr = reply_addr def make_connection_query(self): - props = {'operation': 'QUERY', 'type': 'io.skupper.router.connection'} + props = {'operation': 'QUERY', 'type': CONNECTION_TYPE} msg = Message(properties=props, reply_to=self.reply_addr) return msg def make_connector_query(self, connector_name): - props = {'operation': 'READ', 'type': 'io.skupper.router.connector', 'name' : connector_name} + props = {'operation': 'READ', 'type': AMQP_CONNECTOR_TYPE, 'name' : connector_name} msg = Message(properties=props, reply_to=self.reply_addr) return msg def make_connector_delete_command(self, connector_name): - props = {'operation': 'DELETE', 'type': 'io.skupper.router.connector', 'name' : connector_name} + props = {'operation': 'DELETE', 'type': AMQP_CONNECTOR_TYPE, 'name' : connector_name} msg = Message(properties=props, reply_to=self.reply_addr) return msg @@ -778,7 +778,7 @@ def test_01_reboot_INT_A(self): # immediately rather than waiting for the remoteLsMaxAgeSeconds timeout mgmt = INT_C.management - a_type = 'io.skupper.router.router.address' + a_type = ROUTER_ADDRESS_TYPE rsp = mgmt.query(a_type).get_dicts() while any('closest/on_A' in a['name'] for a in rsp): time.sleep(0.25) @@ -813,7 +813,7 @@ def test_02_shutdown_INT_A(self): # wait for INT_A mobile addresses to be removed from INT_C, this # should happen after ra_stale seconds mgmt = INT_C.management - a_type = 'io.skupper.router.router.address' + a_type = ROUTER_ADDRESS_TYPE rsp = mgmt.query(a_type).get_dicts() while any('closest/on_A' in a['name'] for a in rsp): time.sleep(0.25) diff --git a/tests/system_tests_topology_disposition.py b/tests/system_tests_topology_disposition.py index b5d8eaaaa..da108607c 100644 --- a/tests/system_tests_topology_disposition.py +++ b/tests/system_tests_topology_disposition.py @@ -29,6 +29,7 @@ from skupper_router_internal.compat import UNICODE from system_test import TestCase, Qdrouterd, main_module, Logger, TIMEOUT +from system_test import CONNECTION_TYPE, AMQP_CONNECTOR_TYPE, ROUTER_LINK_TYPE # ================================================ @@ -67,23 +68,23 @@ def __init__(self, reply_addr) : self.reply_addr = reply_addr def make_connection_query(self): - ap = {'operation': 'QUERY', 'type': 'io.skupper.router.connection'} + ap = {'operation': 'QUERY', 'type': CONNECTION_TYPE} return Message(properties=ap, reply_to=self.reply_addr) def make_connector_query(self, connector_name) : - props = {'operation': 'READ', 'type': 'io.skupper.router.connector', 'name' : connector_name} + props = {'operation': 'READ', 'type': AMQP_CONNECTOR_TYPE, 'name' : connector_name} msg = Message(properties=props, reply_to=self.reply_addr) return msg def make_connector_delete_command(self, connector_name) : - props = {'operation': 'DELETE', 'type': 'io.skupper.router.connector', 'name' : connector_name} + props = {'operation': 'DELETE', 'type': AMQP_CONNECTOR_TYPE, 'name' : connector_name} msg = Message(properties=props, reply_to=self.reply_addr) return msg def make_router_link_query(self) : props = {'count': '100', 'operation': 'QUERY', - 'entityType': 'io.skupper.router.router.link', + 'entityType': ROUTER_LINK_TYPE, 'name': 'self', 'type': 'org.amqp.management' } diff --git a/tests/system_tests_two_routers.py b/tests/system_tests_two_routers.py index d3985debe..7ffcfadb3 100644 --- a/tests/system_tests_two_routers.py +++ b/tests/system_tests_two_routers.py @@ -35,7 +35,8 @@ from system_test import AsyncTestReceiver, retry from system_test import AsyncTestSender from system_test import get_inter_router_links -from system_test import unittest +from system_test import unittest, ROUTER_TYPE, CONNECTION_TYPE +from system_test import ROUTER_ADDRESS_TYPE, AMQP_CONNECTOR_TYPE CONNECTION_PROPERTIES_UNICODE_STRING = {'connection': 'properties', 'int_property': 6451} @@ -116,7 +117,7 @@ def test_01_pre_settled(self): self.assertIsNone(test.error) local_node = Node.connect(self.routers[0].addresses[0], timeout=TIMEOUT) - outs = local_node.query(type='io.skupper.router.router') + outs = local_node.query(type=ROUTER_TYPE) # deliveriesTransit must most surely be greater than num_msgs pos = outs.attribute_names.index("deliveriesTransit") @@ -426,7 +427,7 @@ def on_link_opened(self, event): request = Message() request.address = "amqp:/_local/$management" request.properties = { - 'type': 'io.skupper.router.connection', + 'type': CONNECTION_TYPE, 'operation': 'QUERY'} request.reply_to = self.mgmt_receiver.remote_source.address self.mgmt_sender.send(request) @@ -435,7 +436,7 @@ def on_link_opened(self, event): def poll_timeout(self): request = Message() request.address = "amqp:/_local/$management" - request.properties = {'type': 'io.skupper.router.connection', + request.properties = {'type': CONNECTION_TYPE, 'operation': 'QUERY'} request.reply_to = self.mgmt_receiver_2.remote_source.address self.mgmt_sender.send(request) @@ -458,7 +459,7 @@ def on_message(self, event): request.address = "amqp:/_local/$management" request.properties = { 'identity': identity, - 'type': 'io.skupper.router.connection', + 'type': CONNECTION_TYPE, 'operation': 'UPDATE' } request.body = { @@ -1077,7 +1078,7 @@ def addr_text(self, addr): def on_timer_task(self, event): local_node = Node.connect(self.parent.address1, timeout=TIMEOUT) - res = local_node.query('io.skupper.router.router.address') + res = local_node.query(ROUTER_ADDRESS_TYPE) name = res.attribute_names.index('name') found = False for results in res.results: @@ -1439,7 +1440,7 @@ def can_terminate(self): return False def check_connections(self): - res = self.local_node.query(type='io.skupper.router.connection') + res = self.local_node.query(type=CONNECTION_TYPE) results = res.results # If DISPATCH-1093 was not fixed, there would be an additional @@ -1462,17 +1463,15 @@ def test_create_connectors(self): self.local_node = Node.connect(self.routers[0].addresses[0], timeout=TIMEOUT) - res = self.local_node.query(type='io.skupper.router.connection') + res = self.local_node.query(type=CONNECTION_TYPE) results = res.results self.assertEqual(1, len(results)) - long_type = 'io.skupper.router.connector' - - create_command = 'CREATE --type=' + long_type + ' --name=foo' + ' host=0.0.0.0 port=' + str(TwoRouterConnection.B_normal_port_1) + create_command = 'CREATE --type=' + AMQP_CONNECTOR_TYPE + ' --name=foo' + ' host=0.0.0.0 port=' + str(TwoRouterConnection.B_normal_port_1) self.run_skmanage(create_command) - create_command = 'CREATE --type=' + long_type + ' --name=bar' + ' host=0.0.0.0 port=' + str(TwoRouterConnection.B_normal_port_2) + create_command = 'CREATE --type=' + AMQP_CONNECTOR_TYPE + ' --name=bar' + ' host=0.0.0.0 port=' + str(TwoRouterConnection.B_normal_port_2) self.run_skmanage(create_command) diff --git a/tests/system_tests_user_id.py b/tests/system_tests_user_id.py index 90667d47a..a876a6d7a 100644 --- a/tests/system_tests_user_id.py +++ b/tests/system_tests_user_id.py @@ -19,7 +19,7 @@ import os from system_test import TestCase, Qdrouterd, DIR, main_module, TIMEOUT -from system_test import unittest +from system_test import unittest, CONNECTION_TYPE from skupper_router.management.client import Node from proton import SSLDomain @@ -249,73 +249,73 @@ def test_ssl_user_id(self): addr = self.address(0).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) - user_id = node.query(type='io.skupper.router.connection', attribute_names=['user']).results[0][0] + user_id = node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[0][0] self.assertEqual("3eccbf1a2f3e46da823c63a9da9158983cb495a3", user_id) addr = self.address(1).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) self.assertEqual("72d543690cb0a8fc2d0f4c704c65411b9ee8ad53839fced4c720d73e58e4f0d7", - node.query(type='io.skupper.router.connection', attribute_names=['user']).results[1][0]) + node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[1][0]) addr = self.address(2).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) self.assertEqual("c6de3a340014b0f8a1d2b41d22e414fc5756494ffa3c8760bbff56f3aa9f179a5a6eae09413fd7a6afbf36b5fb4bad8795c2836774acfe00a701797cc2a3a9ab", - node.query(type='io.skupper.router.connection', attribute_names=['user']).results[2][0]) + node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[2][0]) addr = self.address(3).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) self.assertEqual("72d543690cb0a8fc2d0f4c704c65411b9ee8ad53839fced4c720d73e58e4f0d7;127.0.0.1;Client;Dev;US;NC", - node.query(type='io.skupper.router.connection', attribute_names=['user']).results[3][0]) + node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[3][0]) addr = self.address(4).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) self.assertEqual("3eccbf1a2f3e46da823c63a9da9158983cb495a3;US;NC", - node.query(type='io.skupper.router.connection', attribute_names=['user']).results[4][0]) + node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[4][0]) addr = self.address(5).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) self.assertEqual("US;NC;c6de3a340014b0f8a1d2b41d22e414fc5756494ffa3c8760bbff56f3aa9f179a5a6eae09413fd7a6afbf36b5fb4bad8795c2836774acfe00a701797cc2a3a9ab", - node.query(type='io.skupper.router.connection', attribute_names=['user']).results[5][0]) + node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[5][0]) addr = self.address(6).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) self.assertEqual("127.0.0.1;NC;Dev;US;Client", - node.query(type='io.skupper.router.connection', attribute_names=['user']).results[6][0]) + node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[6][0]) addr = self.address(7).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) self.assertEqual("NC;US;Client;Dev;127.0.0.1;Raleigh", - node.query(type='io.skupper.router.connection', attribute_names=['user']).results[7][0]) + node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[7][0]) addr = self.address(8).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) self.assertEqual("C=US,ST=NC,L=Raleigh,OU=Dev,O=Client,CN=127.0.0.1", - node.query(type='io.skupper.router.connection', attribute_names=['user']).results[8][0]) + node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[8][0]) addr = self.address(9).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) self.assertEqual("C=US,ST=NC,L=Raleigh,OU=Dev,O=Client,CN=127.0.0.1", - node.query(type='io.skupper.router.connection', attribute_names=['user']).results[9][0]) + node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[9][0]) addr = self.address(10).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) - user = node.query(type='io.skupper.router.connection', attribute_names=['user']).results[10][0] + user = node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[10][0] self.assertEqual("C=US,ST=NC,L=Raleigh,OU=Dev,O=Client,CN=127.0.0.1", str(user)) # authenticatePeer is set to 'no' in this listener, the user should anonymous on the connection. addr = self.address(11).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) - user = node.query(type='io.skupper.router.connection', attribute_names=['user']).results[11][0] + user = node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[11][0] self.assertEqual("anonymous", user) addr = self.address(12).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) - user = node.query(type='io.skupper.router.connection', attribute_names=['user']).results[12][0] + user = node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[12][0] self.assertEqual("user12", str(user)) addr = self.address(13).replace("amqp", "amqps") node = Node.connect(addr, timeout=TIMEOUT, ssl_domain=domain) - user_id = node.query(type='io.skupper.router.connection', attribute_names=['user']).results[13][0] + user_id = node.query(type=CONNECTION_TYPE, attribute_names=['user']).results[13][0] self.assertEqual("user13", user_id) node.close()