Skip to content

Commit

Permalink
Add a test for issue #356
Browse files Browse the repository at this point in the history
  • Loading branch information
sajith committed Nov 14, 2024
1 parent a6b251d commit 474f08a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
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 @@ -570,6 +585,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": "300"},
{"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, 200)


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

0 comments on commit 474f08a

Please sign in to comment.