Loading src/tests/ecoc22/tests/Objects_DC_CSGW_TN.py +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ from common.tools.object_factory.Topology import json_topology, json_topology_id # if true, Device component is present and will infeer the endpoints from connect-rules # if false, Device component is not present and device objects must contain preconfigured endpoints ADD_CONNECT_RULES_TO_DEVICES = os.environ.get('ADD_CONNECT_RULES_TO_DEVICES', 'False') ADD_CONNECT_RULES_TO_DEVICES = os.environ.get('ADD_CONNECT_RULES_TO_DEVICES', 'True') ADD_CONNECT_RULES_TO_DEVICES = ADD_CONNECT_RULES_TO_DEVICES.upper() in {'T', 'TRUE', '1', 'Y', 'YES'} def compose_router(device_uuid, endpoint_uuids, topology_id=None): Loading src/tests/ecoc22/tests/test_functional_bootstrap.py +2 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from .Fixtures import context_client, device_client #from .Objects_BigNet import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES from .Objects_DC_CSGW_TN import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES from .Objects_DC_CSGW_TN import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES, OBJECTS_PER_TOPOLOGY #from .Objects_DC_CSGW_TN_OLS import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES Loading @@ -44,8 +44,8 @@ def test_prepare_environment( for context in CONTEXTS : context_client.SetContext (Context (**context )) for topology in TOPOLOGIES: context_client.SetTopology(Topology(**topology)) for device in DEVICES : device_client .AddDevice (Device (**device )) for device in DEVICES : device_client .AddDevice (Device (**device )) for topology_id, device_ids, _ in OBJECTS_PER_TOPOLOGY: topology = Topology() topology.CopyFrom(context_client.GetTopology(TopologyId(**topology_id))) Loading @@ -58,9 +58,7 @@ def test_prepare_environment( context_client.SetTopology(topology) for link in LINKS : context_client.SetLink (Link (**link )) for topology_id, _, link_ids in OBJECTS_PER_TOPOLOGY: topology = Topology() topology.CopyFrom(context_client.GetTopology(TopologyId(**topology_id))) Loading src/tests/ecoc22/tests/test_functional_cleanup.py +4 −28 Original line number Diff line number Diff line Loading @@ -48,34 +48,10 @@ def test_services_removed(context_client : ContextClient): # pylint: disable=re def test_scenario_cleanup( context_client : ContextClient, device_client : DeviceClient): # pylint: disable=redefined-outer-name # ----- Delete Links and Validate Collected Events ----------------------------------------------------------------- for link in LINKS: link_id = link['link_id'] link_uuid = link_id['link_uuid']['uuid'] LOGGER.info('Deleting Link {:s}'.format(link_uuid)) context_client.RemoveLink(LinkId(**link_id)) # ----- Delete Devices and Validate Collected Events --------------------------------------------------------------- for device, _ in DEVICES: device_id = device['device_id'] device_uuid = device_id['device_uuid']['uuid'] LOGGER.info('Deleting Device {:s}'.format(device_uuid)) device_client.DeleteDevice(DeviceId(**device_id)) # ----- Delete Topologies and Validate Collected Events ------------------------------------------------------------ for topology in TOPOLOGIES: topology_id = topology['topology_id'] context_uuid = topology_id['context_id']['context_uuid']['uuid'] topology_uuid = topology_id['topology_uuid']['uuid'] LOGGER.info('Deleting Topology {:s}/{:s}'.format(context_uuid, topology_uuid)) context_client.RemoveTopology(TopologyId(**topology_id)) # ----- Delete Contexts and Validate Collected Events -------------------------------------------------------------- for context in CONTEXTS: context_id = context['context_id'] context_uuid = context_id['context_uuid']['uuid'] LOGGER.info('Deleting Context {:s}'.format(context_uuid)) context_client.RemoveContext(ContextId(**context_id)) for link in LINKS : context_client.RemoveLink (LinkId (**link ['link_id' ])) for device in DEVICES : device_client .DeleteDevice (DeviceId (**device ['device_id' ])) for topology in TOPOLOGIES: context_client.RemoveTopology(TopologyId(**topology['topology_id'])) for context in CONTEXTS : context_client.RemoveContext (ContextId (**context ['context_id' ])) def test_scenario_empty_again(context_client : ContextClient): # pylint: disable=redefined-outer-name Loading src/tests/ecoc22/tests/test_functional_create_service.py +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ def test_scenario_service_created(context_client : ContextClient): # pylint: di response = context_client.ListServices(ContextId(**CONTEXT_ID)) LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response))) assert len(response.services) == 1 # L3NM assert len(response.services) == 1 # L2NM for service in response.services: service_id = service.service_id response = context_client.ListConnections(service_id) Loading src/tests/ecoc22/tests/test_functional_delete_service.py +9 −48 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import logging, pytest from common.DeviceTypes import DeviceTypeEnum from common.Settings import get_setting from common.proto.context_pb2 import ContextId, Empty from common.proto.context_pb2 import ContextId, Empty, ServiceTypeEnum from common.tests.EventTools import EVENT_REMOVE, EVENT_UPDATE, check_events from common.tools.object_factory.Connection import json_connection_id from common.tools.object_factory.Device import json_device_id Loading @@ -23,7 +23,7 @@ from common.tools.object_factory.Service import json_service_id from common.tools.grpc.Tools import grpc_message_to_json_string from compute.tests.mock_osm.MockOSM import MockOSM from context.client.ContextClient import ContextClient from context.client.EventsCollector import EventsCollector from .Fixtures import context_client, osm_wim #from .Objects_BigNet import ( # CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES, WIM_SERVICE_CONNECTION_POINTS, WIM_SERVICE_TYPE) from .Objects_DC_CSGW_TN import ( Loading @@ -31,28 +31,12 @@ from .Objects_DC_CSGW_TN import ( #from .Objects_DC_CSGW_TN_OLS import ( # CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES, WIM_SERVICE_CONNECTION_POINTS, WIM_SERVICE_TYPE) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) DEVTYPE_EMU_PR = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value @pytest.fixture(scope='session') def context_client(): _client = ContextClient(get_setting('CONTEXTSERVICE_SERVICE_HOST'), get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC')) yield _client _client.close() @pytest.fixture(scope='session') def osm_wim(): wim_url = 'http://{:s}:{:s}'.format( get_setting('COMPUTESERVICE_SERVICE_HOST'), str(get_setting('COMPUTESERVICE_SERVICE_PORT_HTTP'))) return MockOSM(wim_url, WIM_MAPPING, WIM_USERNAME, WIM_PASSWORD) def test_scenario_is_correct(context_client : ContextClient): # pylint: disable=redefined-outer-name # ----- List entities - Ensure service is created ------------------------------------------------------------------ response = context_client.ListContexts(Empty()) Loading @@ -69,27 +53,23 @@ def test_scenario_is_correct(context_client : ContextClient): # pylint: disable response = context_client.ListServices(ContextId(**CONTEXT_ID)) LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response))) assert len(response.services) == 2 # L3NM + TAPI assert len(response.services) == 1 # L2NM for service in response.services: service_id = service.service_id response = context_client.ListConnections(service_id) LOGGER.info(' ServiceId[{:s}] => Connections[{:d}] = {:s}'.format( grpc_message_to_json_string(service_id), len(response.connections), grpc_message_to_json_string(response))) assert len(response.connections) == 1 # one connection per service assert len(response.connections) == 2 # 2 connections per service def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name # ----- Start the EventsCollector ---------------------------------------------------------------------------------- events_collector = EventsCollector(context_client, log_events_received=True) events_collector.start() # ----- Delete Service --------------------------------------------------------------------------------------------- response = context_client.ListServiceIds(ContextId(**CONTEXT_ID)) LOGGER.info('Services[{:d}] = {:s}'.format(len(response.service_ids), grpc_message_to_json_string(response))) assert len(response.service_ids) == 2 # L3NM + TAPI response = context_client.ListServices(ContextId(**CONTEXT_ID)) LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response))) service_uuids = set() for service_id in response.service_ids: service_uuid = service_id.service_uuid.uuid for service in response.services: if service.service_type != ServiceTypeEnum.SERVICETYPE_L2NM: continue service_uuid = service.service_id.service_uuid.uuid if service_uuid.endswith(':optical'): continue service_uuids.add(service_uuid) osm_wim.conn_info[service_uuid] = {} Loading @@ -99,25 +79,6 @@ def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # p osm_wim.delete_connectivity_service(service_uuid) # ----- Validate collected events ---------------------------------------------------------------------------------- packet_connection_uuid = '{:s}:{:s}'.format(service_uuid, DEVTYPE_EMU_PR) optical_connection_uuid = '{:s}:optical:{:s}'.format(service_uuid, DEVTYPE_EMU_OLS) optical_service_uuid = '{:s}:optical'.format(service_uuid) expected_events = [ ('ConnectionEvent', EVENT_REMOVE, json_connection_id(packet_connection_uuid)), ('DeviceEvent', EVENT_UPDATE, json_device_id(DEVICE_R1_UUID)), ('DeviceEvent', EVENT_UPDATE, json_device_id(DEVICE_R3_UUID)), ('ServiceEvent', EVENT_REMOVE, json_service_id(service_uuid, context_id=CONTEXT_ID)), ('ConnectionEvent', EVENT_REMOVE, json_connection_id(optical_connection_uuid)), ('DeviceEvent', EVENT_UPDATE, json_device_id(DEVICE_O1_UUID)), ('ServiceEvent', EVENT_REMOVE, json_service_id(optical_service_uuid, context_id=CONTEXT_ID)), ] check_events(events_collector, expected_events) # ----- Stop the EventsCollector ----------------------------------------------------------------------------------- events_collector.stop() def test_services_removed(context_client : ContextClient): # pylint: disable=redefined-outer-name # ----- List entities - Ensure service is removed ------------------------------------------------------------------ Loading Loading
src/tests/ecoc22/tests/Objects_DC_CSGW_TN.py +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ from common.tools.object_factory.Topology import json_topology, json_topology_id # if true, Device component is present and will infeer the endpoints from connect-rules # if false, Device component is not present and device objects must contain preconfigured endpoints ADD_CONNECT_RULES_TO_DEVICES = os.environ.get('ADD_CONNECT_RULES_TO_DEVICES', 'False') ADD_CONNECT_RULES_TO_DEVICES = os.environ.get('ADD_CONNECT_RULES_TO_DEVICES', 'True') ADD_CONNECT_RULES_TO_DEVICES = ADD_CONNECT_RULES_TO_DEVICES.upper() in {'T', 'TRUE', '1', 'Y', 'YES'} def compose_router(device_uuid, endpoint_uuids, topology_id=None): Loading
src/tests/ecoc22/tests/test_functional_bootstrap.py +2 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from .Fixtures import context_client, device_client #from .Objects_BigNet import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES from .Objects_DC_CSGW_TN import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES from .Objects_DC_CSGW_TN import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES, OBJECTS_PER_TOPOLOGY #from .Objects_DC_CSGW_TN_OLS import CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES Loading @@ -44,8 +44,8 @@ def test_prepare_environment( for context in CONTEXTS : context_client.SetContext (Context (**context )) for topology in TOPOLOGIES: context_client.SetTopology(Topology(**topology)) for device in DEVICES : device_client .AddDevice (Device (**device )) for device in DEVICES : device_client .AddDevice (Device (**device )) for topology_id, device_ids, _ in OBJECTS_PER_TOPOLOGY: topology = Topology() topology.CopyFrom(context_client.GetTopology(TopologyId(**topology_id))) Loading @@ -58,9 +58,7 @@ def test_prepare_environment( context_client.SetTopology(topology) for link in LINKS : context_client.SetLink (Link (**link )) for topology_id, _, link_ids in OBJECTS_PER_TOPOLOGY: topology = Topology() topology.CopyFrom(context_client.GetTopology(TopologyId(**topology_id))) Loading
src/tests/ecoc22/tests/test_functional_cleanup.py +4 −28 Original line number Diff line number Diff line Loading @@ -48,34 +48,10 @@ def test_services_removed(context_client : ContextClient): # pylint: disable=re def test_scenario_cleanup( context_client : ContextClient, device_client : DeviceClient): # pylint: disable=redefined-outer-name # ----- Delete Links and Validate Collected Events ----------------------------------------------------------------- for link in LINKS: link_id = link['link_id'] link_uuid = link_id['link_uuid']['uuid'] LOGGER.info('Deleting Link {:s}'.format(link_uuid)) context_client.RemoveLink(LinkId(**link_id)) # ----- Delete Devices and Validate Collected Events --------------------------------------------------------------- for device, _ in DEVICES: device_id = device['device_id'] device_uuid = device_id['device_uuid']['uuid'] LOGGER.info('Deleting Device {:s}'.format(device_uuid)) device_client.DeleteDevice(DeviceId(**device_id)) # ----- Delete Topologies and Validate Collected Events ------------------------------------------------------------ for topology in TOPOLOGIES: topology_id = topology['topology_id'] context_uuid = topology_id['context_id']['context_uuid']['uuid'] topology_uuid = topology_id['topology_uuid']['uuid'] LOGGER.info('Deleting Topology {:s}/{:s}'.format(context_uuid, topology_uuid)) context_client.RemoveTopology(TopologyId(**topology_id)) # ----- Delete Contexts and Validate Collected Events -------------------------------------------------------------- for context in CONTEXTS: context_id = context['context_id'] context_uuid = context_id['context_uuid']['uuid'] LOGGER.info('Deleting Context {:s}'.format(context_uuid)) context_client.RemoveContext(ContextId(**context_id)) for link in LINKS : context_client.RemoveLink (LinkId (**link ['link_id' ])) for device in DEVICES : device_client .DeleteDevice (DeviceId (**device ['device_id' ])) for topology in TOPOLOGIES: context_client.RemoveTopology(TopologyId(**topology['topology_id'])) for context in CONTEXTS : context_client.RemoveContext (ContextId (**context ['context_id' ])) def test_scenario_empty_again(context_client : ContextClient): # pylint: disable=redefined-outer-name Loading
src/tests/ecoc22/tests/test_functional_create_service.py +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ def test_scenario_service_created(context_client : ContextClient): # pylint: di response = context_client.ListServices(ContextId(**CONTEXT_ID)) LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response))) assert len(response.services) == 1 # L3NM assert len(response.services) == 1 # L2NM for service in response.services: service_id = service.service_id response = context_client.ListConnections(service_id) Loading
src/tests/ecoc22/tests/test_functional_delete_service.py +9 −48 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import logging, pytest from common.DeviceTypes import DeviceTypeEnum from common.Settings import get_setting from common.proto.context_pb2 import ContextId, Empty from common.proto.context_pb2 import ContextId, Empty, ServiceTypeEnum from common.tests.EventTools import EVENT_REMOVE, EVENT_UPDATE, check_events from common.tools.object_factory.Connection import json_connection_id from common.tools.object_factory.Device import json_device_id Loading @@ -23,7 +23,7 @@ from common.tools.object_factory.Service import json_service_id from common.tools.grpc.Tools import grpc_message_to_json_string from compute.tests.mock_osm.MockOSM import MockOSM from context.client.ContextClient import ContextClient from context.client.EventsCollector import EventsCollector from .Fixtures import context_client, osm_wim #from .Objects_BigNet import ( # CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES, WIM_SERVICE_CONNECTION_POINTS, WIM_SERVICE_TYPE) from .Objects_DC_CSGW_TN import ( Loading @@ -31,28 +31,12 @@ from .Objects_DC_CSGW_TN import ( #from .Objects_DC_CSGW_TN_OLS import ( # CONTEXT_ID, CONTEXTS, DEVICES, LINKS, TOPOLOGIES, WIM_SERVICE_CONNECTION_POINTS, WIM_SERVICE_TYPE) LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) DEVTYPE_EMU_PR = DeviceTypeEnum.EMULATED_PACKET_ROUTER.value DEVTYPE_EMU_OLS = DeviceTypeEnum.EMULATED_OPEN_LINE_SYSTEM.value @pytest.fixture(scope='session') def context_client(): _client = ContextClient(get_setting('CONTEXTSERVICE_SERVICE_HOST'), get_setting('CONTEXTSERVICE_SERVICE_PORT_GRPC')) yield _client _client.close() @pytest.fixture(scope='session') def osm_wim(): wim_url = 'http://{:s}:{:s}'.format( get_setting('COMPUTESERVICE_SERVICE_HOST'), str(get_setting('COMPUTESERVICE_SERVICE_PORT_HTTP'))) return MockOSM(wim_url, WIM_MAPPING, WIM_USERNAME, WIM_PASSWORD) def test_scenario_is_correct(context_client : ContextClient): # pylint: disable=redefined-outer-name # ----- List entities - Ensure service is created ------------------------------------------------------------------ response = context_client.ListContexts(Empty()) Loading @@ -69,27 +53,23 @@ def test_scenario_is_correct(context_client : ContextClient): # pylint: disable response = context_client.ListServices(ContextId(**CONTEXT_ID)) LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response))) assert len(response.services) == 2 # L3NM + TAPI assert len(response.services) == 1 # L2NM for service in response.services: service_id = service.service_id response = context_client.ListConnections(service_id) LOGGER.info(' ServiceId[{:s}] => Connections[{:d}] = {:s}'.format( grpc_message_to_json_string(service_id), len(response.connections), grpc_message_to_json_string(response))) assert len(response.connections) == 1 # one connection per service assert len(response.connections) == 2 # 2 connections per service def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # pylint: disable=redefined-outer-name # ----- Start the EventsCollector ---------------------------------------------------------------------------------- events_collector = EventsCollector(context_client, log_events_received=True) events_collector.start() # ----- Delete Service --------------------------------------------------------------------------------------------- response = context_client.ListServiceIds(ContextId(**CONTEXT_ID)) LOGGER.info('Services[{:d}] = {:s}'.format(len(response.service_ids), grpc_message_to_json_string(response))) assert len(response.service_ids) == 2 # L3NM + TAPI response = context_client.ListServices(ContextId(**CONTEXT_ID)) LOGGER.info('Services[{:d}] = {:s}'.format(len(response.services), grpc_message_to_json_string(response))) service_uuids = set() for service_id in response.service_ids: service_uuid = service_id.service_uuid.uuid for service in response.services: if service.service_type != ServiceTypeEnum.SERVICETYPE_L2NM: continue service_uuid = service.service_id.service_uuid.uuid if service_uuid.endswith(':optical'): continue service_uuids.add(service_uuid) osm_wim.conn_info[service_uuid] = {} Loading @@ -99,25 +79,6 @@ def test_service_removal(context_client : ContextClient, osm_wim : MockOSM): # p osm_wim.delete_connectivity_service(service_uuid) # ----- Validate collected events ---------------------------------------------------------------------------------- packet_connection_uuid = '{:s}:{:s}'.format(service_uuid, DEVTYPE_EMU_PR) optical_connection_uuid = '{:s}:optical:{:s}'.format(service_uuid, DEVTYPE_EMU_OLS) optical_service_uuid = '{:s}:optical'.format(service_uuid) expected_events = [ ('ConnectionEvent', EVENT_REMOVE, json_connection_id(packet_connection_uuid)), ('DeviceEvent', EVENT_UPDATE, json_device_id(DEVICE_R1_UUID)), ('DeviceEvent', EVENT_UPDATE, json_device_id(DEVICE_R3_UUID)), ('ServiceEvent', EVENT_REMOVE, json_service_id(service_uuid, context_id=CONTEXT_ID)), ('ConnectionEvent', EVENT_REMOVE, json_connection_id(optical_connection_uuid)), ('DeviceEvent', EVENT_UPDATE, json_device_id(DEVICE_O1_UUID)), ('ServiceEvent', EVENT_REMOVE, json_service_id(optical_service_uuid, context_id=CONTEXT_ID)), ] check_events(events_collector, expected_events) # ----- Stop the EventsCollector ----------------------------------------------------------------------------------- events_collector.stop() def test_services_removed(context_client : ContextClient): # pylint: disable=redefined-outer-name # ----- List entities - Ensure service is removed ------------------------------------------------------------------ Loading