Skip to content

Commit

Permalink
Addressed review comments: updated the failure msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
VitthalMagadum committed Nov 8, 2024
1 parent c589ee9 commit 2eff367
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions anta/input_models/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __str__(self) -> str:
Examples
--------
Port Ethernet1 (Neighbor: DC1-SPINE2, Neighbor port: Ethernet2)
Port Ethernet1 (Neighbor: DC1-SPINE2, Neighbor Port: Ethernet2)
"""
return f"Port {self.port} (Neighbor: {self.neighbor_device}, Neighbor port: {self.neighbor_port})"
return f"Port {self.port} (Neighbor: {self.neighbor_device}, Neighbor Port: {self.neighbor_port})"
5 changes: 3 additions & 2 deletions anta/tests/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class Input(AntaTest.Input):

neighbors: list[Neighbor]
"""List of LLDP neighbors."""
Neighbor: ClassVar[type[Neighbor]] = Neighbor

@AntaTest.anta_test
def test(self) -> None:
Expand All @@ -125,7 +126,7 @@ def test(self) -> None:
continue

if len(lldp_neighbor_info := output[neighbor.port]["lldpNeighborInfo"]) == 0:
self.result.is_failure(f"{neighbor} - No LLDP neighbors on the port")
self.result.is_failure(f"{neighbor} - No LLDP neighbors")
continue

# Check if the system name and neighbor port matches
Expand All @@ -135,4 +136,4 @@ def test(self) -> None:
)
if not match_found:
failure_msg = [f"{info['systemName']}/{info['neighborInterfaceInfo']['interfaceId_v2']}" for info in lldp_neighbor_info]
self.result.is_failure(f"{neighbor} - Wrong LLDP neighbors on the ports; {', '.join(failure_msg)}")
self.result.is_failure(f"{neighbor} - Wrong LLDP neighbors; {', '.join(failure_msg)}")
16 changes: 7 additions & 9 deletions tests/units/anta_tests/test_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
{"port": "Ethernet2", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"},
],
},
"expected": {"result": "failure", "messages": ["Port Ethernet2 (Neighbor: DC1-SPINE2, Neighbor port: Ethernet1) - Port not found"]},
"expected": {"result": "failure", "messages": ["Port Ethernet2 (Neighbor: DC1-SPINE2, Neighbor Port: Ethernet1) - Port not found"]},
},
{
"name": "failure-no-neighbor",
Expand Down Expand Up @@ -363,7 +363,7 @@
{"port": "Ethernet2", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"},
],
},
"expected": {"result": "failure", "messages": ["Port Ethernet2 (Neighbor: DC1-SPINE2, Neighbor port: Ethernet1) - No LLDP neighbors on the port"]},
"expected": {"result": "failure", "messages": ["Port Ethernet2 (Neighbor: DC1-SPINE2, Neighbor Port: Ethernet1) - No LLDP neighbors"]},
},
{
"name": "failure-wrong-neighbor",
Expand Down Expand Up @@ -412,7 +412,7 @@
},
"expected": {
"result": "failure",
"messages": ["Port Ethernet2 (Neighbor: DC1-SPINE2, Neighbor port: Ethernet1) - Wrong LLDP neighbors on the ports; DC1-SPINE2/Ethernet2"],
"messages": ["Port Ethernet2 (Neighbor: DC1-SPINE2, Neighbor Port: Ethernet1) - Wrong LLDP neighbors; DC1-SPINE2/Ethernet2"],
},
},
{
Expand Down Expand Up @@ -450,9 +450,9 @@
"expected": {
"result": "failure",
"messages": [
"Port Ethernet1 (Neighbor: DC1-SPINE1, Neighbor port: Ethernet1) - Wrong LLDP neighbors on the ports; DC1-SPINE1/Ethernet2",
"Port Ethernet2 (Neighbor: DC1-SPINE2, Neighbor port: Ethernet1) - No LLDP neighbors on the port",
"Port Ethernet3 (Neighbor: DC1-SPINE3, Neighbor port: Ethernet1) - Port not found",
"Port Ethernet1 (Neighbor: DC1-SPINE1, Neighbor Port: Ethernet1) - Wrong LLDP neighbors; DC1-SPINE1/Ethernet2",
"Port Ethernet2 (Neighbor: DC1-SPINE2, Neighbor Port: Ethernet1) - No LLDP neighbors",
"Port Ethernet3 (Neighbor: DC1-SPINE3, Neighbor Port: Ethernet1) - Port not found",
],
},
},
Expand Down Expand Up @@ -498,9 +498,7 @@
},
"expected": {
"result": "failure",
"messages": [
"Port Ethernet1 (Neighbor: DC1-SPINE3, Neighbor port: Ethernet1) - Wrong LLDP neighbors on the ports; DC1-SPINE1/Ethernet1, DC1-SPINE2/Ethernet1"
],
"messages": ["Port Ethernet1 (Neighbor: DC1-SPINE3, Neighbor Port: Ethernet1) - Wrong LLDP neighbors; DC1-SPINE1/Ethernet1, DC1-SPINE2/Ethernet1"],
},
},
]

0 comments on commit 2eff367

Please sign in to comment.