Skip to content

Commit

Permalink
issue_782 Handling review comments: updated failure msg, unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VitthalMagadum committed Sep 26, 2024
1 parent 1235c8f commit cff8770
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 7 deletions.
6 changes: 2 additions & 4 deletions anta/tests/stp.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def test(self) -> None:

# Verify the STP topology(s).
if not stp_topologies:
self.result.is_failure("None of STP topology is configured.")
self.result.is_failure("STP is not configured.")
return

# Verifies the number of changes across all interfaces
Expand All @@ -317,8 +317,6 @@ def test(self) -> None:
failures["topologies"][topology] = interfaces

if failures["topologies"]:
self.result.is_failure(
f"The following Spanning Tree Protocol (STP) topology(s) are not configured or number of changes not within the threshold:{failures}"
)
self.result.is_failure(f"The following STP topologies are not configured or number of changes not within the threshold:\n{failures}")
else:
self.result.is_success()
74 changes: 71 additions & 3 deletions tests/units/anta_tests/test_stp.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,74 @@
"inputs": {"threshold": 10},
"expected": {"result": "success"},
},
{
"name": "success-rapid-pvst",
"test": VerifyStpTopologyChanges,
"eos_data": [
{
"unmappedVlans": [],
"topologies": {
"NoStp": {
"vlans": [4094, 4093, 1006],
"interfaces": {
"PeerEthernet2": {"state": "forwarding", "numChanges": 1, "lastChange": 1727151356.1330667},
},
},
"Vl1": {"vlans": [1], "interfaces": {"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0615358}}},
"Vl10": {
"vlans": [10],
"interfaces": {
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0673406},
"Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0677001},
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0728855},
"Ethernet3": {"state": "forwarding", "numChanges": 3, "lastChange": 1727326730.255137},
},
},
"Vl1198": {
"vlans": [1198],
"interfaces": {
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.074386},
"Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0743902},
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0743942},
},
},
"Vl1199": {
"vlans": [1199],
"interfaces": {
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0744},
"Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.07453},
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.074535},
},
},
"Vl20": {
"vlans": [20],
"interfaces": {
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.073489},
"Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0743747},
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0743794},
"Ethernet3": {"state": "forwarding", "numChanges": 3, "lastChange": 1727326730.2551405},
},
},
"Vl3009": {
"vlans": [3009],
"interfaces": {
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.074541},
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0745454},
},
},
"Vl3019": {
"vlans": [3019],
"interfaces": {
"Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0745502},
"Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1727326710.0745537},
},
},
},
},
],
"inputs": {"threshold": 10},
"expected": {"result": "success"},
},
{
"name": "failure-unstable-topology",
"test": VerifyStpTopologyChanges,
Expand All @@ -394,8 +462,8 @@
"expected": {
"result": "failure",
"messages": [
"The following Spanning Tree Protocol (STP) topology(s) are not configured or number of changes"
" not within the threshold:{'topologies': {'Cist': {'Cpu': {'Number of changes': 15}, 'Port-Channel5': {'Number of changes': 15}}}}"
"The following STP topologies are not configured or number of changes not within the threshold:\n"
"{'topologies': {'Cist': {'Cpu': {'Number of changes': 15}, 'Port-Channel5': {'Number of changes': 15}}}}"
],
},
},
Expand All @@ -416,6 +484,6 @@
},
],
"inputs": {"threshold": 10},
"expected": {"result": "failure", "messages": ["None of STP topology is configured."]},
"expected": {"result": "failure", "messages": ["STP is not configured."]},
},
]

0 comments on commit cff8770

Please sign in to comment.