Merging upstream version 1.3.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
5b922100c9
commit
8a6a3342fc
337 changed files with 16571 additions and 4891 deletions
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2023-2024 Arista Networks, Inc.
|
||||
# Copyright (c) 2023-2025 Arista Networks, Inc.
|
||||
# Use of this source code is governed by the Apache License 2.0
|
||||
# that can be found in the LICENSE file.
|
||||
"""Tests for anta.tests.stp.py."""
|
||||
|
@ -7,7 +7,15 @@ from __future__ import annotations
|
|||
|
||||
from typing import Any
|
||||
|
||||
from anta.tests.stp import VerifySTPBlockedPorts, VerifySTPCounters, VerifySTPForwardingPorts, VerifySTPMode, VerifySTPRootPriority, VerifyStpTopologyChanges
|
||||
from anta.tests.stp import (
|
||||
VerifySTPBlockedPorts,
|
||||
VerifySTPCounters,
|
||||
VerifySTPDisabledVlans,
|
||||
VerifySTPForwardingPorts,
|
||||
VerifySTPMode,
|
||||
VerifySTPRootPriority,
|
||||
VerifyStpTopologyChanges,
|
||||
)
|
||||
from tests.units.anta_tests import test
|
||||
|
||||
DATA: list[dict[str, Any]] = [
|
||||
|
@ -29,7 +37,7 @@ DATA: list[dict[str, Any]] = [
|
|||
{"spanningTreeVlanInstances": {}},
|
||||
],
|
||||
"inputs": {"mode": "rstp", "vlans": [10, 20]},
|
||||
"expected": {"result": "failure", "messages": ["STP mode 'rstp' not configured for the following VLAN(s): [10, 20]"]},
|
||||
"expected": {"result": "failure", "messages": ["VLAN 10 STP mode: rstp - Not configured", "VLAN 20 STP mode: rstp - Not configured"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-wrong-mode",
|
||||
|
@ -39,7 +47,10 @@ DATA: list[dict[str, Any]] = [
|
|||
{"spanningTreeVlanInstances": {"20": {"spanningTreeVlanInstance": {"protocol": "mstp"}}}},
|
||||
],
|
||||
"inputs": {"mode": "rstp", "vlans": [10, 20]},
|
||||
"expected": {"result": "failure", "messages": ["Wrong STP mode configured for the following VLAN(s): [10, 20]"]},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["VLAN 10 - Incorrect STP mode - Expected: rstp Actual: mstp", "VLAN 20 - Incorrect STP mode - Expected: rstp Actual: mstp"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-both",
|
||||
|
@ -51,7 +62,7 @@ DATA: list[dict[str, Any]] = [
|
|||
"inputs": {"mode": "rstp", "vlans": [10, 20]},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["STP mode 'rstp' not configured for the following VLAN(s): [10]", "Wrong STP mode configured for the following VLAN(s): [20]"],
|
||||
"messages": ["VLAN 10 STP mode: rstp - Not configured", "VLAN 20 - Incorrect STP mode - Expected: rstp Actual: mstp"],
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -66,7 +77,7 @@ DATA: list[dict[str, Any]] = [
|
|||
"test": VerifySTPBlockedPorts,
|
||||
"eos_data": [{"spanningTreeInstances": {"MST0": {"spanningTreeBlockedPorts": ["Ethernet10"]}, "MST10": {"spanningTreeBlockedPorts": ["Ethernet10"]}}}],
|
||||
"inputs": None,
|
||||
"expected": {"result": "failure", "messages": ["The following ports are blocked by STP: {'MST0': ['Ethernet10'], 'MST10': ['Ethernet10']}"]},
|
||||
"expected": {"result": "failure", "messages": ["STP Instance: MST0 - Blocked ports - Ethernet10", "STP Instance: MST10 - Blocked ports - Ethernet10"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
|
@ -76,18 +87,44 @@ DATA: list[dict[str, Any]] = [
|
|||
"expected": {"result": "success"},
|
||||
},
|
||||
{
|
||||
"name": "failure",
|
||||
"name": "failure-bpdu-tagged-error-mismatch",
|
||||
"test": VerifySTPCounters,
|
||||
"eos_data": [
|
||||
{
|
||||
"interfaces": {
|
||||
"Ethernet10": {"bpduSent": 201, "bpduReceived": 0, "bpduTaggedError": 3, "bpduOtherError": 0, "bpduRateLimitCount": 0},
|
||||
"Ethernet11": {"bpduSent": 99, "bpduReceived": 0, "bpduTaggedError": 3, "bpduOtherError": 0, "bpduRateLimitCount": 0},
|
||||
},
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": [
|
||||
"Interface Ethernet10 - STP BPDU packet tagged errors count mismatch - Expected: 0 Actual: 3",
|
||||
"Interface Ethernet11 - STP BPDU packet tagged errors count mismatch - Expected: 0 Actual: 3",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-bpdu-other-error-mismatch",
|
||||
"test": VerifySTPCounters,
|
||||
"eos_data": [
|
||||
{
|
||||
"interfaces": {
|
||||
"Ethernet10": {"bpduSent": 201, "bpduReceived": 0, "bpduTaggedError": 0, "bpduOtherError": 3, "bpduRateLimitCount": 0},
|
||||
"Ethernet11": {"bpduSent": 99, "bpduReceived": 0, "bpduTaggedError": 0, "bpduOtherError": 6, "bpduRateLimitCount": 0},
|
||||
},
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "failure", "messages": ["The following interfaces have STP BPDU packet errors: ['Ethernet10', 'Ethernet11']"]},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": [
|
||||
"Interface Ethernet10 - STP BPDU packet other errors count mismatch - Expected: 0 Actual: 3",
|
||||
"Interface Ethernet11 - STP BPDU packet other errors count mismatch - Expected: 0 Actual: 6",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
|
@ -126,7 +163,7 @@ DATA: list[dict[str, Any]] = [
|
|||
"test": VerifySTPForwardingPorts,
|
||||
"eos_data": [{"unmappedVlans": [], "topologies": {}}, {"unmappedVlans": [], "topologies": {}}],
|
||||
"inputs": {"vlans": [10, 20]},
|
||||
"expected": {"result": "failure", "messages": ["STP instance is not configured for the following VLAN(s): [10, 20]"]},
|
||||
"expected": {"result": "failure", "messages": ["VLAN 10 - STP instance is not configured", "VLAN 20 - STP instance is not configured"]},
|
||||
},
|
||||
{
|
||||
"name": "failure",
|
||||
|
@ -144,7 +181,10 @@ DATA: list[dict[str, Any]] = [
|
|||
"inputs": {"vlans": [10, 20]},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["The following VLAN(s) have interface(s) that are not in a forwarding state: [{'VLAN 10': ['Ethernet10']}, {'VLAN 20': ['Ethernet10']}]"],
|
||||
"messages": [
|
||||
"VLAN 10 Interface: Ethernet10 - Invalid state - Expected: forwarding Actual: discarding",
|
||||
"VLAN 20 Interface: Ethernet10 - Invalid state - Expected: forwarding Actual: discarding",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -253,6 +293,28 @@ DATA: list[dict[str, Any]] = [
|
|||
"inputs": {"priority": 16384, "instances": [0]},
|
||||
"expected": {"result": "success"},
|
||||
},
|
||||
{
|
||||
"name": "success-input-instance-none",
|
||||
"test": VerifySTPRootPriority,
|
||||
"eos_data": [
|
||||
{
|
||||
"instances": {
|
||||
"MST0": {
|
||||
"rootBridge": {
|
||||
"priority": 16384,
|
||||
"systemIdExtension": 0,
|
||||
"macAddress": "02:1c:73:8b:93:ac",
|
||||
"helloTime": 2.0,
|
||||
"maxAge": 20,
|
||||
"forwardDelay": 15,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"inputs": {"priority": 16384},
|
||||
"expected": {"result": "success"},
|
||||
},
|
||||
{
|
||||
"name": "failure-no-instances",
|
||||
"test": VerifySTPRootPriority,
|
||||
|
@ -273,7 +335,7 @@ DATA: list[dict[str, Any]] = [
|
|||
},
|
||||
],
|
||||
"inputs": {"priority": 32768, "instances": [0]},
|
||||
"expected": {"result": "failure", "messages": ["Unsupported STP instance type: WRONG0"]},
|
||||
"expected": {"result": "failure", "messages": ["STP Instance: WRONG0 - Unsupported STP instance type"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-wrong-instance-type",
|
||||
|
@ -282,6 +344,28 @@ DATA: list[dict[str, Any]] = [
|
|||
"inputs": {"priority": 32768, "instances": [10, 20]},
|
||||
"expected": {"result": "failure", "messages": ["No STP instances configured"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-instance-not-found",
|
||||
"test": VerifySTPRootPriority,
|
||||
"eos_data": [
|
||||
{
|
||||
"instances": {
|
||||
"VL10": {
|
||||
"rootBridge": {
|
||||
"priority": 32768,
|
||||
"systemIdExtension": 10,
|
||||
"macAddress": "00:1c:73:27:95:a2",
|
||||
"helloTime": 2.0,
|
||||
"maxAge": 20,
|
||||
"forwardDelay": 15,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": {"priority": 32768, "instances": [11, 20]},
|
||||
"expected": {"result": "failure", "messages": ["Instance: VL11 - Not configured", "Instance: VL20 - Not configured"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-wrong-priority",
|
||||
"test": VerifySTPRootPriority,
|
||||
|
@ -322,7 +406,13 @@ 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']"]},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": [
|
||||
"STP Instance: VL20 - Incorrect root priority - Expected: 32768 Actual: 8196",
|
||||
"STP Instance: VL30 - Incorrect root priority - Expected: 32768 Actual: 8196",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "success-mstp",
|
||||
|
@ -462,8 +552,8 @@ DATA: list[dict[str, Any]] = [
|
|||
"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}}}}"
|
||||
"Topology: Cist Interface: Cpu - Number of changes not within the threshold - Expected: 10 Actual: 15",
|
||||
"Topology: Cist Interface: Port-Channel5 - Number of changes not within the threshold - Expected: 10 Actual: 15",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -484,6 +574,50 @@ DATA: list[dict[str, Any]] = [
|
|||
},
|
||||
],
|
||||
"inputs": {"threshold": 10},
|
||||
"expected": {"result": "failure", "messages": ["STP is not configured."]},
|
||||
"expected": {"result": "failure", "messages": ["STP is not configured"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifySTPDisabledVlans,
|
||||
"eos_data": [{"spanningTreeVlanInstances": {"1": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {"priority": 32768}}}, "6": {}, "4094": {}}}],
|
||||
"inputs": {"vlans": ["6", "4094"]},
|
||||
"expected": {"result": "success"},
|
||||
},
|
||||
{
|
||||
"name": "failure-stp-not-configured",
|
||||
"test": VerifySTPDisabledVlans,
|
||||
"eos_data": [{"spanningTreeVlanInstances": {}}],
|
||||
"inputs": {"vlans": ["6", "4094"]},
|
||||
"expected": {"result": "failure", "messages": ["STP is not configured"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-vlans-not-found",
|
||||
"test": VerifySTPDisabledVlans,
|
||||
"eos_data": [
|
||||
{
|
||||
"spanningTreeVlanInstances": {
|
||||
"1": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}},
|
||||
"6": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}},
|
||||
"4094": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}},
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": {"vlans": ["16", "4093"]},
|
||||
"expected": {"result": "failure", "messages": ["VLAN: 16 - Not configured", "VLAN: 4093 - Not configured"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-vlans-enabled",
|
||||
"test": VerifySTPDisabledVlans,
|
||||
"eos_data": [
|
||||
{
|
||||
"spanningTreeVlanInstances": {
|
||||
"1": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}},
|
||||
"6": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}},
|
||||
"4094": {"spanningTreeVlanInstance": {"protocol": "mstp", "bridge": {}}},
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": {"vlans": ["6", "4094"]},
|
||||
"expected": {"result": "failure", "messages": ["VLAN: 6 - STP is enabled", "VLAN: 4094 - STP is enabled"]},
|
||||
},
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue