Adding upstream version 1.4.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
dc7df702ea
commit
7996c81031
166 changed files with 13787 additions and 11959 deletions
|
@ -5,196 +5,103 @@
|
|||
|
||||
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.mlag import VerifyMlagConfigSanity, VerifyMlagDualPrimary, VerifyMlagInterfaces, VerifyMlagPrimaryPriority, VerifyMlagReloadDelay, VerifyMlagStatus
|
||||
from tests.units.anta_tests import test
|
||||
|
||||
DATA: list[dict[str, Any]] = [
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyMlagStatus,
|
||||
if TYPE_CHECKING:
|
||||
from tests.units.anta_tests import AntaUnitTestDataDict
|
||||
|
||||
DATA: AntaUnitTestDataDict = {
|
||||
(VerifyMlagStatus, "success"): {
|
||||
"eos_data": [{"state": "active", "negStatus": "connected", "peerLinkStatus": "up", "localIntfStatus": "up"}],
|
||||
"inputs": None,
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "skipped",
|
||||
"test": VerifyMlagStatus,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "disabled",
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "skipped", "messages": ["MLAG is disabled"]},
|
||||
(VerifyMlagStatus, "skipped"): {
|
||||
"eos_data": [{"state": "disabled"}],
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["MLAG is disabled"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-negotiation-status",
|
||||
"test": VerifyMlagStatus,
|
||||
(VerifyMlagStatus, "failure-negotiation-status"): {
|
||||
"eos_data": [{"state": "active", "negStatus": "connecting", "peerLinkStatus": "up", "localIntfStatus": "up"}],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["MLAG negotiation status mismatch - Expected: connected Actual: connecting"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["MLAG negotiation status mismatch - Expected: connected Actual: connecting"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-local-interface",
|
||||
"test": VerifyMlagStatus,
|
||||
(VerifyMlagStatus, "failure-local-interface"): {
|
||||
"eos_data": [{"state": "active", "negStatus": "connected", "peerLinkStatus": "up", "localIntfStatus": "down"}],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["Operational state of the MLAG local interface is not correct - Expected: up Actual: down"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Operational state of the MLAG local interface is not correct - Expected: up Actual: down"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-peer-link",
|
||||
"test": VerifyMlagStatus,
|
||||
(VerifyMlagStatus, "failure-peer-link"): {
|
||||
"eos_data": [{"state": "active", "negStatus": "connected", "peerLinkStatus": "down", "localIntfStatus": "up"}],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["Operational state of the MLAG peer link is not correct - Expected: up Actual: down"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Operational state of the MLAG peer link is not correct - Expected: up Actual: down"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyMlagInterfaces,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
"mlagPorts": {"Disabled": 0, "Configured": 0, "Inactive": 0, "Active-partial": 0, "Active-full": 1},
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "success"},
|
||||
(VerifyMlagInterfaces, "success"): {
|
||||
"eos_data": [{"state": "active", "mlagPorts": {"Disabled": 0, "Configured": 0, "Inactive": 0, "Active-partial": 0, "Active-full": 1}}],
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "skipped",
|
||||
"test": VerifyMlagInterfaces,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "disabled",
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "skipped", "messages": ["MLAG is disabled"]},
|
||||
(VerifyMlagInterfaces, "skipped"): {
|
||||
"eos_data": [{"state": "disabled"}],
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["MLAG is disabled"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-active-partial",
|
||||
"test": VerifyMlagInterfaces,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
"mlagPorts": {"Disabled": 0, "Configured": 0, "Inactive": 0, "Active-partial": 1, "Active-full": 1},
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["MLAG status is not ok - Inactive Ports: 0 Partial Active Ports: 1"],
|
||||
},
|
||||
(VerifyMlagInterfaces, "failure-active-partial"): {
|
||||
"eos_data": [{"state": "active", "mlagPorts": {"Disabled": 0, "Configured": 0, "Inactive": 0, "Active-partial": 1, "Active-full": 1}}],
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["MLAG status is not ok - Inactive Ports: 0 Partial Active Ports: 1"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-inactive",
|
||||
"test": VerifyMlagInterfaces,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
"mlagPorts": {"Disabled": 0, "Configured": 0, "Inactive": 1, "Active-partial": 1, "Active-full": 1},
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["MLAG status is not ok - Inactive Ports: 1 Partial Active Ports: 1"],
|
||||
},
|
||||
(VerifyMlagInterfaces, "failure-inactive"): {
|
||||
"eos_data": [{"state": "active", "mlagPorts": {"Disabled": 0, "Configured": 0, "Inactive": 1, "Active-partial": 1, "Active-full": 1}}],
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["MLAG status is not ok - Inactive Ports: 1 Partial Active Ports: 1"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyMlagConfigSanity,
|
||||
(VerifyMlagConfigSanity, "success"): {
|
||||
"eos_data": [{"globalConfiguration": {}, "interfaceConfiguration": {}, "mlagActive": True, "mlagConnected": True}],
|
||||
"inputs": None,
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "skipped",
|
||||
"test": VerifyMlagConfigSanity,
|
||||
"eos_data": [
|
||||
{
|
||||
"mlagActive": False,
|
||||
},
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {"result": "skipped", "messages": ["MLAG is disabled"]},
|
||||
(VerifyMlagConfigSanity, "skipped"): {
|
||||
"eos_data": [{"mlagActive": False}],
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["MLAG is disabled"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-global",
|
||||
"test": VerifyMlagConfigSanity,
|
||||
(VerifyMlagConfigSanity, "failure-global"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"globalConfiguration": {"mlag": {"globalParameters": {"dual-primary-detection-delay": {"localValue": "0", "peerValue": "200"}}}},
|
||||
"interfaceConfiguration": {},
|
||||
"mlagActive": True,
|
||||
"mlagConnected": True,
|
||||
},
|
||||
}
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["MLAG config-sanity found in global configuration"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["MLAG config-sanity found in global configuration"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-interface",
|
||||
"test": VerifyMlagConfigSanity,
|
||||
(VerifyMlagConfigSanity, "failure-interface"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"globalConfiguration": {},
|
||||
"interfaceConfiguration": {"trunk-native-vlan mlag30": {"interface": {"Port-Channel30": {"localValue": "123", "peerValue": "3700"}}}},
|
||||
"mlagActive": True,
|
||||
"mlagConnected": True,
|
||||
},
|
||||
}
|
||||
],
|
||||
"inputs": None,
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["MLAG config-sanity found in interface configuration"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["MLAG config-sanity found in interface configuration"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyMlagReloadDelay,
|
||||
(VerifyMlagReloadDelay, "success"): {
|
||||
"eos_data": [{"state": "active", "reloadDelay": 300, "reloadDelayNonMlag": 330}],
|
||||
"inputs": {"reload_delay": 300, "reload_delay_non_mlag": 330},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "skipped-disabled",
|
||||
"test": VerifyMlagReloadDelay,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "disabled",
|
||||
},
|
||||
],
|
||||
(VerifyMlagReloadDelay, "skipped-disabled"): {
|
||||
"eos_data": [{"state": "disabled"}],
|
||||
"inputs": {"reload_delay": 300, "reload_delay_non_mlag": 330},
|
||||
"expected": {"result": "skipped", "messages": ["MLAG is disabled"]},
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["MLAG is disabled"]},
|
||||
},
|
||||
{
|
||||
"name": "failure",
|
||||
"test": VerifyMlagReloadDelay,
|
||||
(VerifyMlagReloadDelay, "failure"): {
|
||||
"eos_data": [{"state": "active", "reloadDelay": 400, "reloadDelayNonMlag": 430}],
|
||||
"inputs": {"reload_delay": 300, "reload_delay_non_mlag": 330},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": ["MLAG reload-delay mismatch - Expected: 300s Actual: 400s", "Delay for non-MLAG ports mismatch - Expected: 330s Actual: 430s"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyMlagDualPrimary,
|
||||
(VerifyMlagDualPrimary, "success"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
|
@ -203,38 +110,22 @@ DATA: list[dict[str, Any]] = [
|
|||
"dualPrimaryMlagRecoveryDelay": 60,
|
||||
"dualPrimaryNonMlagRecoveryDelay": 0,
|
||||
"detail": {"dualPrimaryDetectionDelay": 200, "dualPrimaryAction": "none"},
|
||||
},
|
||||
}
|
||||
],
|
||||
"inputs": {"detection_delay": 200, "errdisabled": False, "recovery_delay": 60, "recovery_delay_non_mlag": 0},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "skipped-disabled",
|
||||
"test": VerifyMlagDualPrimary,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "disabled",
|
||||
},
|
||||
],
|
||||
(VerifyMlagDualPrimary, "skipped-disabled"): {
|
||||
"eos_data": [{"state": "disabled"}],
|
||||
"inputs": {"detection_delay": 200, "errdisabled": False, "recovery_delay": 60, "recovery_delay_non_mlag": 0},
|
||||
"expected": {"result": "skipped", "messages": ["MLAG is disabled"]},
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["MLAG is disabled"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-disabled",
|
||||
"test": VerifyMlagDualPrimary,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
"dualPrimaryDetectionState": "disabled",
|
||||
"dualPrimaryPortsErrdisabled": False,
|
||||
},
|
||||
],
|
||||
(VerifyMlagDualPrimary, "failure-disabled"): {
|
||||
"eos_data": [{"state": "active", "dualPrimaryDetectionState": "disabled", "dualPrimaryPortsErrdisabled": False}],
|
||||
"inputs": {"detection_delay": 200, "errdisabled": False, "recovery_delay": 60, "recovery_delay_non_mlag": 0},
|
||||
"expected": {"result": "failure", "messages": ["Dual-primary detection is disabled"]},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Dual-primary detection is disabled"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-wrong-timers",
|
||||
"test": VerifyMlagDualPrimary,
|
||||
(VerifyMlagDualPrimary, "failure-wrong-timers"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
|
@ -243,20 +134,18 @@ DATA: list[dict[str, Any]] = [
|
|||
"dualPrimaryMlagRecoveryDelay": 160,
|
||||
"dualPrimaryNonMlagRecoveryDelay": 0,
|
||||
"detail": {"dualPrimaryDetectionDelay": 300, "dualPrimaryAction": "none"},
|
||||
},
|
||||
}
|
||||
],
|
||||
"inputs": {"detection_delay": 200, "errdisabled": False, "recovery_delay": 60, "recovery_delay_non_mlag": 0},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": [
|
||||
"Dual-primary detection delay mismatch - Expected: 200 Actual: 300",
|
||||
"Dual-primary MLAG recovery delay mismatch - Expected: 60 Actual: 160",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-wrong-action",
|
||||
"test": VerifyMlagDualPrimary,
|
||||
(VerifyMlagDualPrimary, "failure-wrong-action"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
|
@ -265,17 +154,12 @@ DATA: list[dict[str, Any]] = [
|
|||
"dualPrimaryMlagRecoveryDelay": 60,
|
||||
"dualPrimaryNonMlagRecoveryDelay": 0,
|
||||
"detail": {"dualPrimaryDetectionDelay": 200, "dualPrimaryAction": "none"},
|
||||
},
|
||||
}
|
||||
],
|
||||
"inputs": {"detection_delay": 200, "errdisabled": True, "recovery_delay": 60, "recovery_delay_non_mlag": 0},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["Dual-primary action mismatch - Expected: errdisableAllInterfaces Actual: none"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Dual-primary action mismatch - Expected: errdisableAllInterfaces Actual: none"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-wrong-non-mlag-delay",
|
||||
"test": VerifyMlagDualPrimary,
|
||||
(VerifyMlagDualPrimary, "failure-wrong-non-mlag-delay"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
|
@ -284,67 +168,32 @@ DATA: list[dict[str, Any]] = [
|
|||
"dualPrimaryMlagRecoveryDelay": 60,
|
||||
"dualPrimaryNonMlagRecoveryDelay": 120,
|
||||
"detail": {"dualPrimaryDetectionDelay": 200, "dualPrimaryAction": "errdisableAllInterfaces"},
|
||||
},
|
||||
}
|
||||
],
|
||||
"inputs": {"detection_delay": 200, "errdisabled": True, "recovery_delay": 60, "recovery_delay_non_mlag": 60},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["Dual-primary non MLAG recovery delay mismatch - Expected: 60 Actual: 120"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Dual-primary non MLAG recovery delay mismatch - Expected: 60 Actual: 120"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyMlagPrimaryPriority,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
"detail": {"mlagState": "primary", "primaryPriority": 32767},
|
||||
}
|
||||
],
|
||||
"inputs": {
|
||||
"primary_priority": 32767,
|
||||
},
|
||||
"expected": {"result": "success"},
|
||||
},
|
||||
{
|
||||
"name": "skipped-disabled",
|
||||
"test": VerifyMlagPrimaryPriority,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "disabled",
|
||||
}
|
||||
],
|
||||
(VerifyMlagPrimaryPriority, "success"): {
|
||||
"eos_data": [{"state": "active", "detail": {"mlagState": "primary", "primaryPriority": 32767}}],
|
||||
"inputs": {"primary_priority": 32767},
|
||||
"expected": {"result": "skipped", "messages": ["MLAG is disabled"]},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure-not-primary",
|
||||
"test": VerifyMlagPrimaryPriority,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
"detail": {"mlagState": "secondary", "primaryPriority": 32767},
|
||||
}
|
||||
],
|
||||
(VerifyMlagPrimaryPriority, "skipped-disabled"): {
|
||||
"eos_data": [{"state": "disabled"}],
|
||||
"inputs": {"primary_priority": 32767},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["The device is not set as MLAG primary"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.SKIPPED, "messages": ["MLAG is disabled"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-incorrect-priority",
|
||||
"test": VerifyMlagPrimaryPriority,
|
||||
"eos_data": [
|
||||
{
|
||||
"state": "active",
|
||||
"detail": {"mlagState": "secondary", "primaryPriority": 32767},
|
||||
}
|
||||
],
|
||||
(VerifyMlagPrimaryPriority, "failure-not-primary"): {
|
||||
"eos_data": [{"state": "active", "detail": {"mlagState": "secondary", "primaryPriority": 32767}}],
|
||||
"inputs": {"primary_priority": 32767},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["The device is not set as MLAG primary"]},
|
||||
},
|
||||
(VerifyMlagPrimaryPriority, "failure-incorrect-priority"): {
|
||||
"eos_data": [{"state": "active", "detail": {"mlagState": "secondary", "primaryPriority": 32767}}],
|
||||
"inputs": {"primary_priority": 1},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": ["The device is not set as MLAG primary", "MLAG primary priority mismatch - Expected: 1 Actual: 32767"],
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue