Merging upstream version 1.4.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
a6f5a146cb
commit
3254dea030
166 changed files with 13787 additions and 11959 deletions
|
@ -5,15 +5,24 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from anta.models import AntaTest
|
||||
from anta.result_manager.models import AntaTestStatus
|
||||
from anta.tests.routing.ospf import VerifyOSPFMaxLSA, VerifyOSPFNeighborCount, VerifyOSPFNeighborState
|
||||
from tests.units.anta_tests import test
|
||||
from tests.units.anta_tests import AntaUnitTest, test
|
||||
|
||||
DATA: list[dict[str, Any]] = [
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyOSPFNeighborState,
|
||||
if sys.version_info >= (3, 10):
|
||||
from typing import TypeAlias
|
||||
else:
|
||||
TypeAlias = type
|
||||
|
||||
|
||||
AntaUnitTestDataDict: TypeAlias = dict[tuple[type[AntaTest], str], AntaUnitTest]
|
||||
|
||||
DATA: AntaUnitTestDataDict = {
|
||||
(VerifyOSPFNeighborState, "success"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
|
@ -39,9 +48,9 @@ DATA: list[dict[str, Any]] = [
|
|||
"inactivity": 1683298014.844345,
|
||||
"interfaceAddress": "10.3.0.1",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"BLAH": {
|
||||
"instList": {
|
||||
|
@ -55,20 +64,17 @@ DATA: list[dict[str, Any]] = [
|
|||
"adjacencyState": "full",
|
||||
"inactivity": 1683298014.844345,
|
||||
"interfaceAddress": "10.3.0.1",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure",
|
||||
"test": VerifyOSPFNeighborState,
|
||||
(VerifyOSPFNeighborState, "failure"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
|
@ -94,9 +100,9 @@ DATA: list[dict[str, Any]] = [
|
|||
"inactivity": 1683298014.844345,
|
||||
"interfaceAddress": "10.3.0.1",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"BLAH": {
|
||||
"instList": {
|
||||
|
@ -110,63 +116,31 @@ DATA: list[dict[str, Any]] = [
|
|||
"adjacencyState": "down",
|
||||
"inactivity": 1683298014.844345,
|
||||
"interfaceAddress": "10.3.0.1",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": [
|
||||
"Instance: 666 VRF: default Interface: 7.7.7.7 - Incorrect adjacency state - Expected: Full Actual: 2-way",
|
||||
"Instance: 777 VRF: BLAH Interface: 8.8.8.8 - Incorrect adjacency state - Expected: Full Actual: down",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "skipped-ospf-not-configured",
|
||||
"test": VerifyOSPFNeighborState,
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {},
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "skipped", "messages": ["OSPF not configured"]},
|
||||
(VerifyOSPFNeighborState, "skipped-ospf-not-configured"): {
|
||||
"eos_data": [{"vrfs": {}}],
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["OSPF not configured"]},
|
||||
},
|
||||
{
|
||||
"name": "skipped-neighbor-not-found",
|
||||
"test": VerifyOSPFNeighborState,
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
"default": {
|
||||
"instList": {
|
||||
"666": {
|
||||
"ospfNeighborEntries": [],
|
||||
},
|
||||
},
|
||||
},
|
||||
"BLAH": {
|
||||
"instList": {
|
||||
"777": {
|
||||
"ospfNeighborEntries": [],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "skipped", "messages": ["No OSPF neighbor detected"]},
|
||||
(VerifyOSPFNeighborState, "skipped-neighbor-not-found"): {
|
||||
"eos_data": [{"vrfs": {"default": {"instList": {"666": {"ospfNeighborEntries": []}}}, "BLAH": {"instList": {"777": {"ospfNeighborEntries": []}}}}}],
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["No OSPF neighbor detected"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyOSPFNeighborCount,
|
||||
(VerifyOSPFNeighborCount, "success"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
|
@ -192,9 +166,9 @@ DATA: list[dict[str, Any]] = [
|
|||
"inactivity": 1683298014.844345,
|
||||
"interfaceAddress": "10.3.0.1",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"BLAH": {
|
||||
"instList": {
|
||||
|
@ -208,20 +182,18 @@ DATA: list[dict[str, Any]] = [
|
|||
"adjacencyState": "full",
|
||||
"inactivity": 1683298014.844345,
|
||||
"interfaceAddress": "10.3.0.1",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": {"number": 3},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure-good-number-wrong-state",
|
||||
"test": VerifyOSPFNeighborCount,
|
||||
(VerifyOSPFNeighborCount, "failure-good-number-wrong-state"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
|
@ -247,9 +219,9 @@ DATA: list[dict[str, Any]] = [
|
|||
"inactivity": 1683298014.844345,
|
||||
"interfaceAddress": "10.3.0.1",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"BLAH": {
|
||||
"instList": {
|
||||
|
@ -263,65 +235,28 @@ DATA: list[dict[str, Any]] = [
|
|||
"adjacencyState": "down",
|
||||
"inactivity": 1683298014.844345,
|
||||
"interfaceAddress": "10.3.0.1",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": {"number": 3},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["Neighbor count mismatch - Expected: 3 Actual: 1"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Neighbor count mismatch - Expected: 3 Actual: 1"]},
|
||||
},
|
||||
{
|
||||
"name": "skipped-ospf-not-configured",
|
||||
"test": VerifyOSPFNeighborCount,
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {},
|
||||
},
|
||||
],
|
||||
(VerifyOSPFNeighborCount, "skipped-ospf-not-configured"): {
|
||||
"eos_data": [{"vrfs": {}}],
|
||||
"inputs": {"number": 3},
|
||||
"expected": {"result": "skipped", "messages": ["OSPF not configured"]},
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["OSPF not configured"]},
|
||||
},
|
||||
{
|
||||
"name": "skipped-no-neighbor-detected",
|
||||
"test": VerifyOSPFNeighborCount,
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
"default": {
|
||||
"instList": {
|
||||
"666": {
|
||||
"ospfNeighborEntries": [],
|
||||
},
|
||||
},
|
||||
},
|
||||
"BLAH": {
|
||||
"instList": {
|
||||
"777": {
|
||||
"ospfNeighborEntries": [],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
(VerifyOSPFNeighborCount, "skipped-no-neighbor-detected"): {
|
||||
"eos_data": [{"vrfs": {"default": {"instList": {"666": {"ospfNeighborEntries": []}}}, "BLAH": {"instList": {"777": {"ospfNeighborEntries": []}}}}}],
|
||||
"inputs": {"number": 3},
|
||||
"expected": {
|
||||
"result": "skipped",
|
||||
"messages": [
|
||||
"No OSPF neighbor detected",
|
||||
],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["No OSPF neighbor detected"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyOSPFMaxLSA,
|
||||
(VerifyOSPFMaxLSA, "success"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
|
@ -329,10 +264,7 @@ DATA: list[dict[str, Any]] = [
|
|||
"instList": {
|
||||
"1": {
|
||||
"instanceId": 1,
|
||||
"maxLsaInformation": {
|
||||
"maxLsa": 12000,
|
||||
"maxLsaThreshold": 75,
|
||||
},
|
||||
"maxLsaInformation": {"maxLsa": 12000, "maxLsaThreshold": 75},
|
||||
"routerId": "1.1.1.1",
|
||||
"lsaInformation": {
|
||||
"lsaArrivalInterval": 1000,
|
||||
|
@ -341,17 +273,14 @@ DATA: list[dict[str, Any]] = [
|
|||
"lsaMaxWaitInterval": 5000,
|
||||
"numLsa": 9,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"TEST": {
|
||||
"instList": {
|
||||
"10": {
|
||||
"instanceId": 10,
|
||||
"maxLsaInformation": {
|
||||
"maxLsa": 1000,
|
||||
"maxLsaThreshold": 75,
|
||||
},
|
||||
"maxLsaInformation": {"maxLsa": 1000, "maxLsaThreshold": 75},
|
||||
"routerId": "20.20.20.20",
|
||||
"lsaInformation": {
|
||||
"lsaArrivalInterval": 1000,
|
||||
|
@ -360,18 +289,15 @@ DATA: list[dict[str, Any]] = [
|
|||
"lsaMaxWaitInterval": 5000,
|
||||
"numLsa": 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure",
|
||||
"test": VerifyOSPFMaxLSA,
|
||||
(VerifyOSPFMaxLSA, "failure"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {
|
||||
|
@ -379,10 +305,7 @@ DATA: list[dict[str, Any]] = [
|
|||
"instList": {
|
||||
"1": {
|
||||
"instanceId": 1,
|
||||
"maxLsaInformation": {
|
||||
"maxLsa": 12000,
|
||||
"maxLsaThreshold": 75,
|
||||
},
|
||||
"maxLsaInformation": {"maxLsa": 12000, "maxLsaThreshold": 75},
|
||||
"routerId": "1.1.1.1",
|
||||
"lsaInformation": {
|
||||
"lsaArrivalInterval": 1000,
|
||||
|
@ -391,17 +314,14 @@ DATA: list[dict[str, Any]] = [
|
|||
"lsaMaxWaitInterval": 5000,
|
||||
"numLsa": 11500,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"TEST": {
|
||||
"instList": {
|
||||
"10": {
|
||||
"instanceId": 10,
|
||||
"maxLsaInformation": {
|
||||
"maxLsa": 1000,
|
||||
"maxLsaThreshold": 75,
|
||||
},
|
||||
"maxLsaInformation": {"maxLsa": 1000, "maxLsaThreshold": 75},
|
||||
"routerId": "20.20.20.20",
|
||||
"lsaInformation": {
|
||||
"lsaArrivalInterval": 1000,
|
||||
|
@ -410,30 +330,19 @@ DATA: list[dict[str, Any]] = [
|
|||
"lsaMaxWaitInterval": 5000,
|
||||
"numLsa": 1500,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": [
|
||||
"Instance: 1 - Crossed the maximum LSA threshold - Expected: < 9000 Actual: 11500",
|
||||
"Instance: 10 - Crossed the maximum LSA threshold - Expected: < 750 Actual: 1500",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "skipped",
|
||||
"test": VerifyOSPFMaxLSA,
|
||||
"eos_data": [
|
||||
{
|
||||
"vrfs": {},
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "skipped", "messages": ["OSPF not configured"]},
|
||||
},
|
||||
]
|
||||
(VerifyOSPFMaxLSA, "skipped"): {"eos_data": [{"vrfs": {}}], "expected": {"result": AntaTestStatus.SKIPPED, "messages": ["OSPF not configured"]}},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue