Skip to content

Commit

Permalink
Fixes skupperproject#1234: use common declaration of management type …
Browse files Browse the repository at this point in the history
…id in CI tests
  • Loading branch information
kgiusti committed Sep 26, 2023
1 parent 04d8712 commit eb7dea6
Show file tree
Hide file tree
Showing 28 changed files with 426 additions and 434 deletions.
27 changes: 12 additions & 15 deletions tests/http1_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand All @@ -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)


Expand All @@ -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)


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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'))

Expand All @@ -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):
Expand Down
58 changes: 39 additions & 19 deletions tests/system_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)]
Expand All @@ -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()
Expand Down Expand Up @@ -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:
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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"):
Expand All @@ -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)
Expand Down
19 changes: 7 additions & 12 deletions tests/system_tests_autolinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand All @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions tests/system_tests_connector_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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')
Expand All @@ -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'])
Expand Down
5 changes: 3 additions & 2 deletions tests/system_tests_delivery_abort.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)


Expand Down
Loading

0 comments on commit eb7dea6

Please sign in to comment.