diff --git a/pyproject.toml b/pyproject.toml index c192eeff..a5adf262 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ dependencies = [ "prtpy", "pydot", "dataclasses-json", - "sdx-datamodel @ git+https://github.com/atlanticwave-sdx/datamodel@2.0.6.rc2" + "sdx-datamodel @ git+https://github.com/atlanticwave-sdx/datamodel@2.0.6.rc4", ] [project.urls] diff --git a/src/sdx_pce/topology/temanager.py b/src/sdx_pce/topology/temanager.py index 3fc533b3..edc08dd9 100644 --- a/src/sdx_pce/topology/temanager.py +++ b/src/sdx_pce/topology/temanager.py @@ -508,6 +508,9 @@ def generate_connection_breakdown( ) same_domain_port_flag = False if not request_format_is_tm: + connection_request = ( + ConnectionHandler().import_connection_data(connection_request).to_dict() + ) self._logger.info( f'connection_requst ingress_port: {connection_request["ingress_port"]["id"]}' ) diff --git a/tests/__init__.py b/tests/__init__.py index a52b551b..ccf66241 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -20,6 +20,9 @@ class TestData: REQUESTS_DIR = files("sdx_datamodel") / "data" / "requests" CONNECTION_REQ = REQUESTS_DIR / "test_request.json" + CONNECTION_REQ_AMLIGHT_ZAOXI_USER_PORT_v2 = ( + REQUESTS_DIR / "test_request-amlight_zaoxi-p2p-v2.json" + ) # Write test output files in OS temporary directory. TEST_OUTPUT_DIR = pathlib.Path(tempfile.gettempdir()) diff --git a/tests/test_te_manager.py b/tests/test_te_manager.py index 4e9f3965..075d9494 100644 --- a/tests/test_te_manager.py +++ b/tests/test_te_manager.py @@ -943,3 +943,94 @@ def _make_traffic_matrix_from_list(self, old_style_request: list) -> TrafficMatr ) return TrafficMatrix(connection_requests=new_requests, request_id=self.id()) + + def test_connection_amlight_to_zaoxi_user_port_v2(self): + """ + Exercise a connection request between Amlight and Zaoxi. + """ + temanager = TEManager(topology_data=None) + + for path in ( + TestData.TOPOLOGY_FILE_AMLIGHT_USER_PORT, + TestData.TOPOLOGY_FILE_SAX, + TestData.TOPOLOGY_FILE_ZAOXI, + ): + topology = json.loads(path.read_text()) + temanager.add_topology(topology) + + graph = temanager.generate_graph_te() + + connection_request = json.loads( + TestData.CONNECTION_REQ_AMLIGHT_ZAOXI_USER_PORT_v2.read_text() + ) + print(f"connection_request: {connection_request}") + traffic_matrix = temanager.generate_traffic_matrix(connection_request) + + print(f"Generated graph: '{graph}', traffic matrix: '{traffic_matrix}'") + + self.assertIsNotNone(graph) + self.assertIsNotNone(traffic_matrix) + + conn = temanager.requests_connectivity(traffic_matrix) + print(f"Graph connectivity: {conn}") + + solution = TESolver(graph, traffic_matrix).solve() + print(f"TESolver result: {solution}") + + self.assertIsNotNone(solution.connection_map) + + links = temanager.get_links_on_path(solution) + print(f"Links on path: {links}") + + # Make a flat list of links in connection solution dict, and + # check that we have the same number of links. + values = sum([v for v in solution.connection_map.values()], []) + self.assertEqual(len(links), len(values)) + + breakdown = temanager.generate_connection_breakdown( + solution, connection_request + ) + print(f"breakdown: {json.dumps(breakdown)}") + + # Note that the "domain" key is correct in the breakdown + # result when we initialize TEManager with None for topology, + # and later add individual topologies with add_topology(). + zaoxi = breakdown.get("urn:sdx:topology:zaoxi.net") + sax = breakdown.get("urn:sdx:topology:sax.net") + amlight = breakdown.get("urn:sdx:topology:amlight.net") + + # Per https://github.com/atlanticwave-sdx/pce/issues/101, each + # breakdown should be of the below form: + # + # { + # "name": "TENET_vlan_201_203_Ampath_Tenet", + # "dynamic_backup_path": true, + # "uni_a": { + # "tag": { + # "value": 203, + # "tag_type": 1 + # }, + # "interface_id": "cc:00:00:00:00:00:00:07:41" + # }, + # "uni_z": { + # "tag": { + # "value": 201, + # "tag_type": 1 + # }, + # "interface_id": "cc:00:00:00:00:00:00:08:50" + # } + # } + for segment in [zaoxi, sax, amlight]: + self.assertIsInstance(segment, dict) + self.assertIsInstance(segment.get("name"), str) + self.assertIsInstance(segment.get("dynamic_backup_path"), bool) + self.assertIsInstance(segment.get("uni_a"), dict) + self.assertIsInstance(segment.get("uni_a").get("tag"), dict) + self.assertIsInstance(segment.get("uni_a").get("tag").get("value"), int) + self.assertIsInstance(segment.get("uni_a").get("tag").get("tag_type"), int) + self.assertIsInstance(segment.get("uni_a").get("port_id"), str) + self.assertIsInstance(segment.get("uni_z"), dict) + self.assertIsInstance(segment.get("uni_z").get("tag"), dict) + self.assertIsInstance(segment.get("uni_z").get("tag").get("value"), int) + self.assertIsInstance(segment.get("uni_z").get("tag").get("tag_type"), int) + self.assertIsInstance(segment.get("uni_z").get("port_id"), str)