Loading src/integration_tester/Dockerfile +1 −1 Original line number Diff line number Diff line Loading @@ -30,5 +30,5 @@ COPY integration_tester/. integration_tester # Run integration tester ENTRYPOINT ["pytest", "-v", "--log-level=DEBUG", \ "integration_tester/test_context_device.py" \ "integration_tester/test_context_device_service.py" \ ] src/integration_tester/definitions.py +94 −38 Original line number Diff line number Diff line from common.database.api.context.OperationalStatus import OperationalStatus from common.database.api.context.Constants import DEFAULT_CONTEXT_ID, DEFAULT_TOPOLOGY_ID from common.database.api.context.service.ServiceState import ServiceState from common.database.api.context.service.ServiceType import ServiceType from common.database.api.context.topology.device.OperationalStatus import OperationalStatus TOPOLOGY_ID = { 'contextId': {'contextUuid': {'uuid': 'admin'}}, 'topoId': {'uuid': 'admin'} } CONTEXT_ID = {'contextUuid': {'uuid': DEFAULT_CONTEXT_ID}} TOPOLOGY_ID = {'contextId': CONTEXT_ID, 'topoId': {'uuid': DEFAULT_TOPOLOGY_ID}} DEVICE_ID_DEV1 = {'device_id': {'uuid': 'dev1'}} DEVICE_DEV1 = { 'device_id': {'device_id': {'uuid': 'dev1'}}, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'device_id': DEVICE_ID_DEV1, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'devOperationalStatus': OperationalStatus.ENABLED.value, 'endpointList' : [ {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev2'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev3'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port2'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port3'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port101'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port102'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port103'}}, 'port_type': 'OCH'}, ] } DEVICE_ID_DEV2 = {'device_id': {'uuid': 'dev2'}} DEVICE_DEV2 = { 'device_id': {'device_id': {'uuid': 'dev2'}}, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'device_id': DEVICE_ID_DEV2, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'devOperationalStatus': OperationalStatus.ENABLED.value, 'endpointList' : [ {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev1'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev3'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port1'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port3'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port101'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port102'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port103'}}, 'port_type': 'OCH'}, ] } DEVICE_ID_DEV3 = {'device_id': {'uuid': 'dev3'}} DEVICE_DEV3 = { 'device_id': {'device_id': {'uuid': 'dev3'}}, 'device_id': DEVICE_ID_DEV3, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'devOperationalStatus': OperationalStatus.ENABLED.value, 'endpointList' : [ {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev1'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev2'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port1'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port2'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port101'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port102'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port103'}}, 'port_type': 'OCH'}, ] } LINK_ID_DEV1_DEV2 = {'link_id': {'uuid': 'dev1/to-dev2 ==> dev2/to-dev1'}} LINK_ID_DEV1_DEV2 = {'link_id': {'uuid': 'dev1/port2 ==> dev2/port1'}} LINK_DEV1_DEV2 = { 'link_id': {'link_id': {'uuid': 'dev1/to-dev2 ==> dev2/to-dev1'}}, 'link_id': LINK_ID_DEV1_DEV2, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port1'}}, ] } LINK_ID_DEV1_DEV3 = {'link_id': {'uuid': 'dev1/to-dev3 ==> dev3/to-dev1'}} LINK_ID_DEV1_DEV3 = {'link_id': {'uuid': 'dev1/port3 ==> dev3/port1'}} LINK_DEV1_DEV3 = { 'link_id': {'link_id': {'uuid': 'dev1/to-dev3 ==> dev3/to-dev1'}}, 'link_id': LINK_ID_DEV1_DEV3, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port1'}}, ] } LINK_ID_DEV2_DEV1 = {'link_id': {'uuid': 'dev2/to-dev1 ==> dev1/to-dev2'}} LINK_ID_DEV2_DEV1 = {'link_id': {'uuid': 'dev2/port1 ==> dev1/port2'}} LINK_DEV2_DEV1 = { 'link_id': {'link_id': {'uuid': 'dev2/to-dev1 ==> dev1/to-dev2'}}, 'link_id': LINK_ID_DEV2_DEV1, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port2'}}, ] } LINK_ID_DEV2_DEV3 = {'link_id': {'uuid': 'dev2/to-dev3 ==> dev3/to-dev2'}} LINK_ID_DEV2_DEV3 = {'link_id': {'uuid': 'dev2/port3 ==> dev3/port2'}} LINK_DEV2_DEV3 = { 'link_id': {'link_id': {'uuid': 'dev2/to-dev3 ==> dev3/to-dev2'}}, 'link_id': LINK_ID_DEV2_DEV3, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port2'}}, ] } LINK_ID_DEV3_DEV1 = {'link_id': {'uuid': 'dev3/to-dev1 ==> dev1/to-dev3'}} LINK_ID_DEV3_DEV1 = {'link_id': {'uuid': 'dev3/port1 ==> dev1/port3'}} LINK_DEV3_DEV1 = { 'link_id': {'link_id': {'uuid': 'dev3/to-dev1 ==> dev1/to-dev3'}}, 'link_id': LINK_ID_DEV3_DEV1, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port3'}}, ] } LINK_ID_DEV3_DEV2 = {'link_id': {'uuid': 'dev3/to-dev2 ==> dev2/to-dev3'}} LINK_ID_DEV3_DEV2 = {'link_id': {'uuid': 'dev3/port2 ==> dev2/port3'}} LINK_DEV3_DEV2 = { 'link_id': {'link_id': {'uuid': 'dev3/to-dev2 ==> dev2/to-dev3'}}, 'link_id': LINK_ID_DEV3_DEV2, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port3'}}, ] } SERVICE_ID_SVC1 = {'contextId': CONTEXT_ID, 'cs_id': {'uuid': 'svc1'}} SERVICE_SVC1 = { 'cs_id': SERVICE_ID_SVC1, 'serviceType': ServiceType.L3NM.value, 'serviceConfig': {'serviceConfig': '<config/>'}, 'serviceState': {'serviceState': ServiceState.PLANNED.value}, 'constraint': [ {'constraint_type': 'latency_ms', 'constraint_value': '100'}, {'constraint_type': 'hops', 'constraint_value': '5'}, ], 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port101'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port101'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port101'}}, ] } SERVICE_ID_SVC2 = {'contextId': CONTEXT_ID, 'cs_id': {'uuid': 'svc2'}} SERVICE_SVC2 = { 'cs_id': SERVICE_ID_SVC2, 'serviceType': ServiceType.L3NM.value, 'serviceConfig': {'serviceConfig': '<config/>'}, 'serviceState': {'serviceState': ServiceState.PLANNED.value}, 'constraint': [ {'constraint_type': 'latency_ms', 'constraint_value': '100'}, {'constraint_type': 'hops', 'constraint_value': '5'}, ], 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port102'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port102'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port102'}}, ] } SERVICE_ID_SVC3 = {'contextId': CONTEXT_ID, 'cs_id': {'uuid': 'svc3'}} SERVICE_SVC3 = { 'cs_id': SERVICE_ID_SVC3, 'serviceType': ServiceType.L3NM.value, 'serviceConfig': {'serviceConfig': '<config/>'}, 'serviceState': {'serviceState': ServiceState.PLANNED.value}, 'constraint': [ {'constraint_type': 'latency_ms', 'constraint_value': '100'}, {'constraint_type': 'hops', 'constraint_value': '5'}, ], 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port103'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port103'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port103'}}, ] } src/integration_tester/test_context_device.py→src/integration_tester/test_context_device_service.py +31 −4 Original line number Diff line number Diff line Loading @@ -2,13 +2,18 @@ import logging, os, pytest from google.protobuf.json_format import MessageToDict from common.database.Factory import get_database, DatabaseEngineEnum from common.database.api.Database import Database from common.tests.Assertions import validate_device_id, validate_link_id, validate_topology_has_devices, \ validate_topology_has_links, validate_topology_is_empty from common.tests.Assertions import validate_device_id, validate_link_id, validate_service_id, \ validate_service_list_is_not_empty, validate_topology_has_devices, validate_topology_has_links, \ validate_topology_is_empty from context.client.ContextClient import ContextClient from context.proto.context_pb2 import Device, Empty, Link from device.client.DeviceClient import DeviceClient from .definitions import DEVICE_DEV1, DEVICE_DEV2, DEVICE_DEV3, LINK_DEV1_DEV2, LINK_DEV1_DEV3, LINK_DEV2_DEV1, \ LINK_DEV2_DEV3, LINK_DEV3_DEV1, LINK_DEV3_DEV2 from integration_tester.definitions import DEVICE_DEV1, DEVICE_DEV2, DEVICE_DEV3 from integration_tester.definitions import LINK_DEV1_DEV2, LINK_DEV1_DEV3, LINK_DEV2_DEV1, LINK_DEV2_DEV3, \ LINK_DEV3_DEV1, LINK_DEV3_DEV2 from integration_tester.definitions import SERVICE_SVC1, SERVICE_SVC2, SERVICE_SVC3 from service.client.ServiceClient import ServiceClient from service.proto.service_pb2 import Service LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) Loading Loading @@ -39,6 +44,14 @@ def device_client(): yield _client _client.close() @pytest.fixture(scope='session') def service_client(): service_host = get_setting('SERVICESERVICE_SERVICE_HOST') service_port = get_setting('SERVICESERVICE_SERVICE_PORT_GRPC') _client = ServiceClient(address=service_host, port=service_port) yield _client _client.close() def test_clean_database(redis_database : Database): # should work redis_database.clear_all() Loading Loading @@ -77,3 +90,17 @@ def test_add_links(context_client : ContextClient): context_client.GetTopology(Empty()), including_default_value_fields=True, preserving_proto_field_name=True, use_integers_for_enums=False)) def test_add_services(service_client : ServiceClient): # should work for service in [SERVICE_SVC1, SERVICE_SVC2, SERVICE_SVC3]: validate_service_id(MessageToDict( service_client.CreateService(Service(**service)), including_default_value_fields=True, preserving_proto_field_name=True, use_integers_for_enums=False)) # should work validate_service_list_is_not_empty(MessageToDict( service_client.GetServiceList(Empty()), including_default_value_fields=True, preserving_proto_field_name=True, use_integers_for_enums=False)) src/service/service/Tools.py +0 −2 Original line number Diff line number Diff line Loading @@ -156,8 +156,6 @@ def check_device_endpoint_exists( raise ServiceException(grpc.StatusCode.NOT_FOUND, msg) db_context = database.context(context_id) print('db_context.topologies', str(db_context.topologies.get())) if not db_context.topologies.contains(topology_id): msg = 'Context({})/Topology({}) in {} does not exist in the database.' msg = msg.format(context_id, topology_id, parent_name) Loading Loading
src/integration_tester/Dockerfile +1 −1 Original line number Diff line number Diff line Loading @@ -30,5 +30,5 @@ COPY integration_tester/. integration_tester # Run integration tester ENTRYPOINT ["pytest", "-v", "--log-level=DEBUG", \ "integration_tester/test_context_device.py" \ "integration_tester/test_context_device_service.py" \ ]
src/integration_tester/definitions.py +94 −38 Original line number Diff line number Diff line from common.database.api.context.OperationalStatus import OperationalStatus from common.database.api.context.Constants import DEFAULT_CONTEXT_ID, DEFAULT_TOPOLOGY_ID from common.database.api.context.service.ServiceState import ServiceState from common.database.api.context.service.ServiceType import ServiceType from common.database.api.context.topology.device.OperationalStatus import OperationalStatus TOPOLOGY_ID = { 'contextId': {'contextUuid': {'uuid': 'admin'}}, 'topoId': {'uuid': 'admin'} } CONTEXT_ID = {'contextUuid': {'uuid': DEFAULT_CONTEXT_ID}} TOPOLOGY_ID = {'contextId': CONTEXT_ID, 'topoId': {'uuid': DEFAULT_TOPOLOGY_ID}} DEVICE_ID_DEV1 = {'device_id': {'uuid': 'dev1'}} DEVICE_DEV1 = { 'device_id': {'device_id': {'uuid': 'dev1'}}, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'device_id': DEVICE_ID_DEV1, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'devOperationalStatus': OperationalStatus.ENABLED.value, 'endpointList' : [ {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev2'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev3'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port2'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port3'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port101'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port102'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port103'}}, 'port_type': 'OCH'}, ] } DEVICE_ID_DEV2 = {'device_id': {'uuid': 'dev2'}} DEVICE_DEV2 = { 'device_id': {'device_id': {'uuid': 'dev2'}}, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'device_id': DEVICE_ID_DEV2, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'devOperationalStatus': OperationalStatus.ENABLED.value, 'endpointList' : [ {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev1'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev3'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port1'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port3'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port101'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port102'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port103'}}, 'port_type': 'OCH'}, ] } DEVICE_ID_DEV3 = {'device_id': {'uuid': 'dev3'}} DEVICE_DEV3 = { 'device_id': {'device_id': {'uuid': 'dev3'}}, 'device_id': DEVICE_ID_DEV3, 'device_type': 'ROADM', 'device_config': {'device_config': '<config/>'}, 'devOperationalStatus': OperationalStatus.ENABLED.value, 'endpointList' : [ {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev1'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev2'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port1'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port2'}}, 'port_type': 'WDM'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port101'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port102'}}, 'port_type': 'OCH'}, {'port_id': {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port103'}}, 'port_type': 'OCH'}, ] } LINK_ID_DEV1_DEV2 = {'link_id': {'uuid': 'dev1/to-dev2 ==> dev2/to-dev1'}} LINK_ID_DEV1_DEV2 = {'link_id': {'uuid': 'dev1/port2 ==> dev2/port1'}} LINK_DEV1_DEV2 = { 'link_id': {'link_id': {'uuid': 'dev1/to-dev2 ==> dev2/to-dev1'}}, 'link_id': LINK_ID_DEV1_DEV2, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port1'}}, ] } LINK_ID_DEV1_DEV3 = {'link_id': {'uuid': 'dev1/to-dev3 ==> dev3/to-dev1'}} LINK_ID_DEV1_DEV3 = {'link_id': {'uuid': 'dev1/port3 ==> dev3/port1'}} LINK_DEV1_DEV3 = { 'link_id': {'link_id': {'uuid': 'dev1/to-dev3 ==> dev3/to-dev1'}}, 'link_id': LINK_ID_DEV1_DEV3, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port1'}}, ] } LINK_ID_DEV2_DEV1 = {'link_id': {'uuid': 'dev2/to-dev1 ==> dev1/to-dev2'}} LINK_ID_DEV2_DEV1 = {'link_id': {'uuid': 'dev2/port1 ==> dev1/port2'}} LINK_DEV2_DEV1 = { 'link_id': {'link_id': {'uuid': 'dev2/to-dev1 ==> dev1/to-dev2'}}, 'link_id': LINK_ID_DEV2_DEV1, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port2'}}, ] } LINK_ID_DEV2_DEV3 = {'link_id': {'uuid': 'dev2/to-dev3 ==> dev3/to-dev2'}} LINK_ID_DEV2_DEV3 = {'link_id': {'uuid': 'dev2/port3 ==> dev3/port2'}} LINK_DEV2_DEV3 = { 'link_id': {'link_id': {'uuid': 'dev2/to-dev3 ==> dev3/to-dev2'}}, 'link_id': LINK_ID_DEV2_DEV3, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port2'}}, ] } LINK_ID_DEV3_DEV1 = {'link_id': {'uuid': 'dev3/to-dev1 ==> dev1/to-dev3'}} LINK_ID_DEV3_DEV1 = {'link_id': {'uuid': 'dev3/port1 ==> dev1/port3'}} LINK_DEV3_DEV1 = { 'link_id': {'link_id': {'uuid': 'dev3/to-dev1 ==> dev1/to-dev3'}}, 'link_id': LINK_ID_DEV3_DEV1, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev1'}}, 'port_id': {'uuid' : 'to-dev3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port1'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port3'}}, ] } LINK_ID_DEV3_DEV2 = {'link_id': {'uuid': 'dev3/to-dev2 ==> dev2/to-dev3'}} LINK_ID_DEV3_DEV2 = {'link_id': {'uuid': 'dev3/port2 ==> dev2/port3'}} LINK_DEV3_DEV2 = { 'link_id': {'link_id': {'uuid': 'dev3/to-dev2 ==> dev2/to-dev3'}}, 'link_id': LINK_ID_DEV3_DEV2, 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port3'}}, ] } SERVICE_ID_SVC1 = {'contextId': CONTEXT_ID, 'cs_id': {'uuid': 'svc1'}} SERVICE_SVC1 = { 'cs_id': SERVICE_ID_SVC1, 'serviceType': ServiceType.L3NM.value, 'serviceConfig': {'serviceConfig': '<config/>'}, 'serviceState': {'serviceState': ServiceState.PLANNED.value}, 'constraint': [ {'constraint_type': 'latency_ms', 'constraint_value': '100'}, {'constraint_type': 'hops', 'constraint_value': '5'}, ], 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port101'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port101'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port101'}}, ] } SERVICE_ID_SVC2 = {'contextId': CONTEXT_ID, 'cs_id': {'uuid': 'svc2'}} SERVICE_SVC2 = { 'cs_id': SERVICE_ID_SVC2, 'serviceType': ServiceType.L3NM.value, 'serviceConfig': {'serviceConfig': '<config/>'}, 'serviceState': {'serviceState': ServiceState.PLANNED.value}, 'constraint': [ {'constraint_type': 'latency_ms', 'constraint_value': '100'}, {'constraint_type': 'hops', 'constraint_value': '5'}, ], 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port102'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port102'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port102'}}, ] } SERVICE_ID_SVC3 = {'contextId': CONTEXT_ID, 'cs_id': {'uuid': 'svc3'}} SERVICE_SVC3 = { 'cs_id': SERVICE_ID_SVC3, 'serviceType': ServiceType.L3NM.value, 'serviceConfig': {'serviceConfig': '<config/>'}, 'serviceState': {'serviceState': ServiceState.PLANNED.value}, 'constraint': [ {'constraint_type': 'latency_ms', 'constraint_value': '100'}, {'constraint_type': 'hops', 'constraint_value': '5'}, ], 'endpointList' : [ {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev3'}}, 'port_id': {'uuid' : 'to-dev2'}}, {'topoId': TOPOLOGY_ID, 'dev_id': {'device_id': {'uuid': 'dev2'}}, 'port_id': {'uuid' : 'to-dev3'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV1, 'port_id': {'uuid' : 'port103'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV2, 'port_id': {'uuid' : 'port103'}}, {'topoId': TOPOLOGY_ID, 'dev_id': DEVICE_ID_DEV3, 'port_id': {'uuid' : 'port103'}}, ] }
src/integration_tester/test_context_device.py→src/integration_tester/test_context_device_service.py +31 −4 Original line number Diff line number Diff line Loading @@ -2,13 +2,18 @@ import logging, os, pytest from google.protobuf.json_format import MessageToDict from common.database.Factory import get_database, DatabaseEngineEnum from common.database.api.Database import Database from common.tests.Assertions import validate_device_id, validate_link_id, validate_topology_has_devices, \ validate_topology_has_links, validate_topology_is_empty from common.tests.Assertions import validate_device_id, validate_link_id, validate_service_id, \ validate_service_list_is_not_empty, validate_topology_has_devices, validate_topology_has_links, \ validate_topology_is_empty from context.client.ContextClient import ContextClient from context.proto.context_pb2 import Device, Empty, Link from device.client.DeviceClient import DeviceClient from .definitions import DEVICE_DEV1, DEVICE_DEV2, DEVICE_DEV3, LINK_DEV1_DEV2, LINK_DEV1_DEV3, LINK_DEV2_DEV1, \ LINK_DEV2_DEV3, LINK_DEV3_DEV1, LINK_DEV3_DEV2 from integration_tester.definitions import DEVICE_DEV1, DEVICE_DEV2, DEVICE_DEV3 from integration_tester.definitions import LINK_DEV1_DEV2, LINK_DEV1_DEV3, LINK_DEV2_DEV1, LINK_DEV2_DEV3, \ LINK_DEV3_DEV1, LINK_DEV3_DEV2 from integration_tester.definitions import SERVICE_SVC1, SERVICE_SVC2, SERVICE_SVC3 from service.client.ServiceClient import ServiceClient from service.proto.service_pb2 import Service LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.DEBUG) Loading Loading @@ -39,6 +44,14 @@ def device_client(): yield _client _client.close() @pytest.fixture(scope='session') def service_client(): service_host = get_setting('SERVICESERVICE_SERVICE_HOST') service_port = get_setting('SERVICESERVICE_SERVICE_PORT_GRPC') _client = ServiceClient(address=service_host, port=service_port) yield _client _client.close() def test_clean_database(redis_database : Database): # should work redis_database.clear_all() Loading Loading @@ -77,3 +90,17 @@ def test_add_links(context_client : ContextClient): context_client.GetTopology(Empty()), including_default_value_fields=True, preserving_proto_field_name=True, use_integers_for_enums=False)) def test_add_services(service_client : ServiceClient): # should work for service in [SERVICE_SVC1, SERVICE_SVC2, SERVICE_SVC3]: validate_service_id(MessageToDict( service_client.CreateService(Service(**service)), including_default_value_fields=True, preserving_proto_field_name=True, use_integers_for_enums=False)) # should work validate_service_list_is_not_empty(MessageToDict( service_client.GetServiceList(Empty()), including_default_value_fields=True, preserving_proto_field_name=True, use_integers_for_enums=False))
src/service/service/Tools.py +0 −2 Original line number Diff line number Diff line Loading @@ -156,8 +156,6 @@ def check_device_endpoint_exists( raise ServiceException(grpc.StatusCode.NOT_FOUND, msg) db_context = database.context(context_id) print('db_context.topologies', str(db_context.topologies.get())) if not db_context.topologies.contains(topology_id): msg = 'Context({})/Topology({}) in {} does not exist in the database.' msg = msg.format(context_id, topology_id, parent_name) Loading