Skip to content

Commit

Permalink
Merge branch 'main' into roll-back-patch-when-fail
Browse files Browse the repository at this point in the history
  • Loading branch information
congwang09 authored Dec 4, 2024
2 parents 25e38cf + cb02301 commit ad16eba
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [
"pika >= 1.2.0",
"dataset",
"pymongo > 3.0",
"sdx-pce @ git+https://github.com/atlanticwave-sdx/[email protected].dev4",
"sdx-pce @ git+https://github.com/atlanticwave-sdx/[email protected].dev5",
]

[project.optional-dependencies]
Expand Down
7 changes: 5 additions & 2 deletions sdx_controller/handlers/connection_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ def place_connection(
logger.debug(f"Breakdown sent to LC, status: {status}, code: {code}")
return status, code
except TEError as te_err:
return te_err
# We could probably return te_err.te_code instead of 400,
# but I don't think PCE should use HTTP error codes,
# because that violates abstraction boundaries.
return f"PCE error: {te_err}", 400
except Exception as e:
err = traceback.format_exc().replace("\n", ", ")
logger.error(f"Error when generating/publishing breakdown: {e} - {err}")
Expand Down Expand Up @@ -274,7 +277,7 @@ def handle_link_failure(self, te_manager, failed_links):
logger.debug(connection)
_reason, code = self.place_connection(te_manager, connection)
if code // 100 == 2:
self.db_instance.add_key(
self.db_instance.add_key_value_pair_to_db(
"connections", connection["id"], json.dumps(connection)
)

Expand Down
4 changes: 4 additions & 0 deletions sdx_controller/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ class TestData:
CONNECTION_REQ_V2_AMLIGHT_ZAOXI = (
REQUESTS_DIR / "test_request-amlight_zaoxi-p2p-v2.json"
)

TOPOLOGY_FILE_AMLIGHT_v2 = TOPOLOGY_DIR / "ampath_v2.json"
TOPOLOGY_FILE_SAX_v2 = TOPOLOGY_DIR / "sax_v2.json"
TOPOLOGY_FILE_ZAOXI_v2 = TOPOLOGY_DIR / "zaoxi_v2.json"
42 changes: 42 additions & 0 deletions sdx_controller/test/test_l2vpn_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ def __add_the_three_topologies(self):
print(f"Adding topology: {topology.get('id')}")
self.te_manager.add_topology(topology)

def __add_the_three_v2_topologies(self):
"""
A helper to add the three known topologies.
"""
for idx, topology_file in enumerate(
[
TestData.TOPOLOGY_FILE_AMLIGHT_v2,
TestData.TOPOLOGY_FILE_SAX_v2,
TestData.TOPOLOGY_FILE_ZAOXI_v2,
]
):
topology = json.loads(topology_file.read_text())
print(f"Adding topology: {topology.get('id')}")
self.te_manager.add_topology(topology)

def test_delete_connection_with_setup(self):
"""
Test case for delete_connection()
Expand Down Expand Up @@ -569,6 +584,33 @@ def test_z105_getconnections_success(self):

assert len(response.get_json()) != 0

def test_issue_356(self):
"""
See https://github.com/atlanticwave-sdx/sdx-controller/issues/356
"""

self.__add_the_three_v2_topologies()

connection_request = {
"name": "VLAN between AMPATH/300 and TENET/300",
"endpoints": [
{"port_id": "urn:sdx:port:ampath.net:Ampath3:50", "vlan": "30000"},
{"port_id": "urn:sdx:port:tenet.ac.za:Tenet03:50", "vlan": "any"},
],
}

response = self.client.open(
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=json.dumps(connection_request),
content_type="application/json",
)

print(f"POST response body is : {response.data.decode('utf-8')}")
print(f"POST Response JSON is : {response.get_json()}")

self.assertStatus(response, 400)


if __name__ == "__main__":
unittest.main()

0 comments on commit ad16eba

Please sign in to comment.