summaryrefslogtreecommitdiffstats
path: root/tests/units/anta_tests/test_stp.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-10-15 20:30:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-10-15 20:32:01 +0000
commite45744e7c5b9916c398fe41273194ffb671fcdac (patch)
tree620ad07a959cf23c8fef76d2967d31eb9c29e6ec /tests/units/anta_tests/test_stp.py
parentReleasing debian version 1.0.0-1. (diff)
downloadanta-e45744e7c5b9916c398fe41273194ffb671fcdac.tar.xz
anta-e45744e7c5b9916c398fe41273194ffb671fcdac.zip
Merging upstream version 1.1.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/units/anta_tests/test_stp.py')
-rw-r--r--tests/units/anta_tests/test_stp.py166
1 files changed, 164 insertions, 2 deletions
diff --git a/tests/units/anta_tests/test_stp.py b/tests/units/anta_tests/test_stp.py
index 64a1168..3742210 100644
--- a/tests/units/anta_tests/test_stp.py
+++ b/tests/units/anta_tests/test_stp.py
@@ -7,8 +7,8 @@ from __future__ import annotations
from typing import Any
-from anta.tests.stp import VerifySTPBlockedPorts, VerifySTPCounters, VerifySTPForwardingPorts, VerifySTPMode, VerifySTPRootPriority
-from tests.lib.anta import test # noqa: F401; pylint: disable=W0611
+from anta.tests.stp import VerifySTPBlockedPorts, VerifySTPCounters, VerifySTPForwardingPorts, VerifySTPMode, VerifySTPRootPriority, VerifyStpTopologyChanges
+from tests.units.anta_tests import test
DATA: list[dict[str, Any]] = [
{
@@ -324,4 +324,166 @@ DATA: list[dict[str, Any]] = [
"inputs": {"priority": 32768, "instances": [10, 20, 30]},
"expected": {"result": "failure", "messages": ["The following instance(s) have the wrong STP root priority configured: ['VL20', 'VL30']"]},
},
+ {
+ "name": "success-mstp",
+ "test": VerifyStpTopologyChanges,
+ "eos_data": [
+ {
+ "unmappedVlans": [],
+ "topologies": {
+ "Cist": {
+ "interfaces": {
+ "Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365},
+ "Port-Channel5": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.7353542},
+ }
+ },
+ "NoStp": {
+ "interfaces": {
+ "Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365},
+ "Ethernet1": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.7353542},
+ }
+ },
+ },
+ },
+ ],
+ "inputs": {"threshold": 10},
+ "expected": {"result": "success"},
+ },
+ {
+ "name": "success-rstp",
+ "test": VerifyStpTopologyChanges,
+ "eos_data": [
+ {
+ "unmappedVlans": [],
+ "topologies": {
+ "Cist": {
+ "interfaces": {
+ "Vxlan1": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365},
+ "PeerEthernet3": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.7353542},
+ }
+ },
+ "NoStp": {
+ "interfaces": {
+ "Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365},
+ "Ethernet1": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.7353542},
+ }
+ },
+ },
+ },
+ ],
+ "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,
+ "eos_data": [
+ {
+ "unmappedVlans": [],
+ "topologies": {
+ "Cist": {
+ "interfaces": {
+ "Cpu": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.735365},
+ "Port-Channel5": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.7353542},
+ }
+ },
+ },
+ },
+ ],
+ "inputs": {"threshold": 10},
+ "expected": {
+ "result": "failure",
+ "messages": [
+ "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}}}}"
+ ],
+ },
+ },
+ {
+ "name": "failure-topologies-not-configured",
+ "test": VerifyStpTopologyChanges,
+ "eos_data": [
+ {
+ "unmappedVlans": [],
+ "topologies": {
+ "NoStp": {
+ "interfaces": {
+ "Cpu": {"state": "forwarding", "numChanges": 1, "lastChange": 1723990624.735365},
+ "Ethernet1": {"state": "forwarding", "numChanges": 15, "lastChange": 1723990624.7353542},
+ }
+ }
+ },
+ },
+ ],
+ "inputs": {"threshold": 10},
+ "expected": {"result": "failure", "messages": ["STP is not configured."]},
+ },
]