Merging upstream version 1.1.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
50f8dbf7e8
commit
2044ea6182
196 changed files with 10121 additions and 3780 deletions
|
@ -5,10 +5,14 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from anta.tests.routing.generic import VerifyRoutingProtocolModel, VerifyRoutingTableEntry, VerifyRoutingTableSize
|
||||
from tests.lib.anta import test # noqa: F401; pylint: disable=W0611
|
||||
from tests.units.anta_tests import test
|
||||
|
||||
DATA: list[dict[str, Any]] = [
|
||||
{
|
||||
|
@ -66,16 +70,6 @@ DATA: list[dict[str, Any]] = [
|
|||
"inputs": {"minimum": 42, "maximum": 666},
|
||||
"expected": {"result": "failure", "messages": ["routing-table has 1000 routes and not between min (42) and maximum (666)"]},
|
||||
},
|
||||
{
|
||||
"name": "error-max-smaller-than-min",
|
||||
"test": VerifyRoutingTableSize,
|
||||
"eos_data": [{}],
|
||||
"inputs": {"minimum": 666, "maximum": 42},
|
||||
"expected": {
|
||||
"result": "error",
|
||||
"messages": ["Minimum 666 is greater than maximum 42"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyRoutingTableEntry,
|
||||
|
@ -130,6 +124,48 @@ DATA: list[dict[str, Any]] = [
|
|||
"inputs": {"vrf": "default", "routes": ["10.1.0.1", "10.1.0.2"]},
|
||||
"expected": {"result": "success"},
|
||||
},
|
||||
{
|
||||
"name": "success-collect-all",
|
||||
"test": VerifyRoutingTableEntry,
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
"default": {
|
||||
"routingDisabled": False,
|
||||
"allRoutesProgrammedHardware": True,
|
||||
"allRoutesProgrammedKernel": True,
|
||||
"defaultRouteState": "notSet",
|
||||
"routes": {
|
||||
"10.1.0.1/32": {
|
||||
"hardwareProgrammed": True,
|
||||
"routeType": "eBGP",
|
||||
"routeLeaked": False,
|
||||
"kernelProgrammed": True,
|
||||
"routeAction": "forward",
|
||||
"directlyConnected": False,
|
||||
"preference": 20,
|
||||
"metric": 0,
|
||||
"vias": [{"nexthopAddr": "10.1.255.4", "interface": "Ethernet1"}],
|
||||
},
|
||||
"10.1.0.2/32": {
|
||||
"hardwareProgrammed": True,
|
||||
"routeType": "eBGP",
|
||||
"routeLeaked": False,
|
||||
"kernelProgrammed": True,
|
||||
"routeAction": "forward",
|
||||
"directlyConnected": False,
|
||||
"preference": 20,
|
||||
"metric": 0,
|
||||
"vias": [{"nexthopAddr": "10.1.255.6", "interface": "Ethernet2"}],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"inputs": {"vrf": "default", "routes": ["10.1.0.1", "10.1.0.2"], "collect": "all"},
|
||||
"expected": {"result": "success"},
|
||||
},
|
||||
{
|
||||
"name": "failure-missing-route",
|
||||
"test": VerifyRoutingTableEntry,
|
||||
|
@ -226,4 +262,75 @@ DATA: list[dict[str, Any]] = [
|
|||
"inputs": {"vrf": "default", "routes": ["10.1.0.1", "10.1.0.2"]},
|
||||
"expected": {"result": "failure", "messages": ["The following route(s) are missing from the routing table of VRF default: ['10.1.0.2']"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-wrong-route-collect-all",
|
||||
"test": VerifyRoutingTableEntry,
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
"default": {
|
||||
"routingDisabled": False,
|
||||
"allRoutesProgrammedHardware": True,
|
||||
"allRoutesProgrammedKernel": True,
|
||||
"defaultRouteState": "notSet",
|
||||
"routes": {
|
||||
"10.1.0.1/32": {
|
||||
"hardwareProgrammed": True,
|
||||
"routeType": "eBGP",
|
||||
"routeLeaked": False,
|
||||
"kernelProgrammed": True,
|
||||
"routeAction": "forward",
|
||||
"directlyConnected": False,
|
||||
"preference": 20,
|
||||
"metric": 0,
|
||||
"vias": [{"nexthopAddr": "10.1.255.4", "interface": "Ethernet1"}],
|
||||
},
|
||||
"10.1.0.55/32": {
|
||||
"hardwareProgrammed": True,
|
||||
"routeType": "eBGP",
|
||||
"routeLeaked": False,
|
||||
"kernelProgrammed": True,
|
||||
"routeAction": "forward",
|
||||
"directlyConnected": False,
|
||||
"preference": 20,
|
||||
"metric": 0,
|
||||
"vias": [{"nexthopAddr": "10.1.255.6", "interface": "Ethernet2"}],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"inputs": {"vrf": "default", "routes": ["10.1.0.1", "10.1.0.2"], "collect": "all"},
|
||||
"expected": {"result": "failure", "messages": ["The following route(s) are missing from the routing table of VRF default: ['10.1.0.2']"]},
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
class TestVerifyRoutingTableSizeInputs:
|
||||
"""Test anta.tests.routing.generic.VerifyRoutingTableSize.Input."""
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("minimum", "maximum"),
|
||||
[
|
||||
pytest.param(0, 0, id="zero"),
|
||||
pytest.param(1, 2, id="1<2"),
|
||||
pytest.param(0, sys.maxsize, id="max"),
|
||||
],
|
||||
)
|
||||
def test_valid(self, minimum: int, maximum: int) -> None:
|
||||
"""Test VerifyRoutingTableSize valid inputs."""
|
||||
VerifyRoutingTableSize.Input(minimum=minimum, maximum=maximum)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("minimum", "maximum"),
|
||||
[
|
||||
pytest.param(-2, -1, id="negative"),
|
||||
pytest.param(2, 1, id="2<1"),
|
||||
pytest.param(sys.maxsize, 0, id="max"),
|
||||
],
|
||||
)
|
||||
def test_invalid(self, minimum: int, maximum: int) -> None:
|
||||
"""Test VerifyRoutingTableSize invalid inputs."""
|
||||
with pytest.raises(ValidationError):
|
||||
VerifyRoutingTableSize.Input(minimum=minimum, maximum=maximum)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue