diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 08:35:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 08:35:51 +0000 |
commit | 641d0d615623d4818993e1967fc96af1eefc4605 (patch) | |
tree | c40f205eb559c8a495489262190a0be4f1829740 /tests/units/anta_tests | |
parent | Adding upstream version 0.13.0. (diff) | |
download | anta-641d0d615623d4818993e1967fc96af1eefc4605.tar.xz anta-641d0d615623d4818993e1967fc96af1eefc4605.zip |
Adding upstream version 0.14.0.upstream/0.14.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/units/anta_tests')
28 files changed, 3384 insertions, 1286 deletions
diff --git a/tests/units/anta_tests/__init__.py b/tests/units/anta_tests/__init__.py index e772bee..8ca0e8c 100644 --- a/tests/units/anta_tests/__init__.py +++ b/tests/units/anta_tests/__init__.py @@ -1,3 +1,4 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. +"""Test for anta.tests submodule.""" diff --git a/tests/units/anta_tests/routing/__init__.py b/tests/units/anta_tests/routing/__init__.py index e772bee..aef1274 100644 --- a/tests/units/anta_tests/routing/__init__.py +++ b/tests/units/anta_tests/routing/__init__.py @@ -1,3 +1,4 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. +"""Test for anta.tests.routing submodule.""" diff --git a/tests/units/anta_tests/routing/test_bgp.py b/tests/units/anta_tests/routing/test_bgp.py index 799f058..31006c5 100644 --- a/tests/units/anta_tests/routing/test_bgp.py +++ b/tests/units/anta_tests/routing/test_bgp.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.routing.bgp.py -""" +"""Tests for anta.tests.routing.bgp.py.""" + # pylint: disable=C0302 from __future__ import annotations @@ -11,7 +10,7 @@ from typing import Any # pylint: disable=C0413 # because of the patch above -from anta.tests.routing.bgp import ( # noqa: E402 +from anta.tests.routing.bgp import ( VerifyBGPAdvCommunities, VerifyBGPExchangedRoutes, VerifyBGPPeerASNCap, @@ -34,44 +33,100 @@ DATA: list[dict[str, Any]] = [ { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, "peerState": "Established", }, "10.1.255.2": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, + { + "vrfs": { + "MGMT": { + "peers": { + "10.255.0.21": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, + { + "vrfs": { + "default": { + "peers": { + "10.255.0.1": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.255.0.2": { "description": "DC1-SPINE2_Ethernet1", - "version": 4, - "msgReceived": 3759, - "msgSent": 3757, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 14, - "prefixReceived": 14, - "upDownTime": 1694266296.367261, - "underMaintenance": False, "peerState": "Established", }, }, - } - } - } + }, + }, + }, + { + "vrfs": { + "default": { + "peers": { + "10.255.0.11": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.255.0.12": { + "description": "DC1-SPINE2_Ethernet1", + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, + { + "vrfs": { + "default": { + "peers": { + "10.255.0.21": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.255.0.22": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "default", "num_peers": 2}]}, + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "unicast", "vrf": "default", "num_peers": 2}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "MGMT", "num_peers": 1}, + {"afi": "evpn", "num_peers": 2}, + {"afi": "link-state", "num_peers": 2}, + {"afi": "path-selection", "num_peers": 2}, + ] + }, "expected": {"result": "success"}, }, { @@ -81,59 +136,189 @@ DATA: list[dict[str, Any]] = [ { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, "peerState": "Established", }, "10.1.255.2": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, + { + "vrfs": { + "MGMT": { + "peers": { + "10.255.0.21": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, + { + "vrfs": { + "default": { + "peers": { + "10.255.0.1": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.255.0.2": { "description": "DC1-SPINE2_Ethernet1", - "version": 4, - "msgReceived": 3759, - "msgSent": 3757, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 14, - "prefixReceived": 14, - "upDownTime": 1694266296.367261, - "underMaintenance": False, "peerState": "Established", }, }, - } - } - } + }, + }, + }, + { + "vrfs": { + "default": { + "peers": { + "10.255.0.11": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.255.0.12": { + "description": "DC1-SPINE2_Ethernet1", + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, + { + "vrfs": { + "default": { + "peers": { + "10.255.0.21": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "default", "num_peers": 3}]}, - "expected": {"result": "failure", "messages": ["Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'default': 'Expected: 3, Actual: 2'}}]"]}, + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "unicast", "vrf": "default", "num_peers": 3}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "MGMT", "num_peers": 2}, + {"afi": "evpn", "num_peers": 1}, + {"afi": "link-state", "num_peers": 3}, + {"afi": "path-selection", "num_peers": 3}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'default': 'Expected: 3, Actual: 2'}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': 'Expected: 2, Actual: 1'}}, " + "{'afi': 'evpn', 'vrfs': {'default': 'Expected: 1, Actual: 2'}}, " + "{'afi': 'link-state', 'vrfs': {'default': 'Expected: 3, Actual: 2'}}, " + "{'afi': 'path-selection', 'vrfs': {'default': 'Expected: 3, Actual: 1'}}]" + ], + }, }, { "name": "failure-no-peers", "test": VerifyBGPPeerCount, - "eos_data": [{"vrfs": {"default": {"vrf": "default", "routerId": "10.1.0.3", "asn": "65120", "peers": {}}}}], - "inputs": {"address_families": [{"afi": "ipv6", "safi": "unicast", "vrf": "default", "num_peers": 3}]}, - "expected": {"result": "failure", "messages": ["Failures: [{'afi': 'ipv6', 'safi': 'unicast', 'vrfs': {'default': 'Expected: 3, Actual: 0'}}]"]}, + "eos_data": [ + { + "vrfs": { + "default": { + "peers": {}, + } + } + }, + { + "vrfs": { + "MGMT": { + "peers": {}, + } + } + }, + { + "vrfs": { + "default": { + "peers": {}, + } + } + }, + { + "vrfs": { + "default": { + "peers": {}, + } + } + }, + { + "vrfs": { + "default": { + "peers": {}, + } + } + }, + ], + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "unicast", "vrf": "default", "num_peers": 2}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "MGMT", "num_peers": 1}, + {"afi": "evpn", "num_peers": 2}, + {"afi": "link-state", "num_peers": 2}, + {"afi": "path-selection", "num_peers": 2}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'default': 'Expected: 2, Actual: 0'}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': 'Expected: 1, Actual: 0'}}, " + "{'afi': 'evpn', 'vrfs': {'default': 'Expected: 2, Actual: 0'}}, " + "{'afi': 'link-state', 'vrfs': {'default': 'Expected: 2, Actual: 0'}}, " + "{'afi': 'path-selection', 'vrfs': {'default': 'Expected: 2, Actual: 0'}}]" + ], + }, }, { "name": "failure-not-configured", "test": VerifyBGPPeerCount, - "eos_data": [{"vrfs": {}}], - "inputs": {"address_families": [{"afi": "ipv6", "safi": "multicast", "vrf": "DEV", "num_peers": 3}]}, - "expected": {"result": "failure", "messages": ["Failures: [{'afi': 'ipv6', 'safi': 'multicast', 'vrfs': {'DEV': 'Not Configured'}}]"]}, + "eos_data": [{"vrfs": {}}, {"vrfs": {}}, {"vrfs": {}}, {"vrfs": {}}, {"vrfs": {}}], + "inputs": { + "address_families": [ + {"afi": "ipv6", "safi": "multicast", "vrf": "DEV", "num_peers": 3}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "MGMT", "num_peers": 1}, + {"afi": "evpn", "num_peers": 2}, + {"afi": "link-state", "num_peers": 2}, + {"afi": "path-selection", "num_peers": 2}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "Failures: [{'afi': 'ipv6', 'safi': 'multicast', 'vrfs': {'DEV': 'Not Configured'}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': 'Not Configured'}}, " + "{'afi': 'evpn', 'vrfs': {'default': 'Not Configured'}}, " + "{'afi': 'link-state', 'vrfs': {'default': 'Not Configured'}}, " + "{'afi': 'path-selection', 'vrfs': {'default': 'Not Configured'}}]" + ], + }, }, { "name": "success-vrf-all", @@ -142,226 +327,132 @@ DATA: list[dict[str, Any]] = [ { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, "peerState": "Established", }, }, }, "PROD": { - "vrf": "PROD", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, "peerState": "Established", }, "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, "peerState": "Established", }, }, }, - } - } - ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "all", "num_peers": 3}]}, - "expected": {"result": "success"}, - }, - { - "name": "failure-vrf-all", - "test": VerifyBGPPeerCount, - "eos_data": [ + }, + }, { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { - "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, + "10.1.255.10": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, "peerState": "Established", }, }, }, "PROD": { - "vrf": "PROD", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { - "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, - "inMsgQueue": 0, - "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, - "peerState": "Established", - }, - "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, + "10.1.254.11": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, "peerState": "Established", }, }, }, - } - } + }, + }, ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "all", "num_peers": 5}]}, - "expected": {"result": "failure", "messages": ["Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'all': 'Expected: 5, Actual: 3'}}]"]}, + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "unicast", "vrf": "all", "num_peers": 3}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "all", "num_peers": 2}, + ] + }, + "expected": {"result": "success"}, }, { - "name": "success-multiple-afi", + "name": "failure-vrf-all", "test": VerifyBGPPeerCount, "eos_data": [ { "vrfs": { + "default": { + "peers": { + "10.1.255.0": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, "PROD": { - "vrf": "PROD", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, "peerState": "Established", }, "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, "peerState": "Established", }, }, - } - } + }, + }, }, { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { - "10.1.0.1": { - "description": "DC1-SPINE1", - "version": 4, - "msgReceived": 3894, - "msgSent": 3897, + "10.1.255.10": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266296.584472, - "underMaintenance": False, "peerState": "Established", }, - "10.1.0.2": { - "description": "DC1-SPINE2", - "version": 4, - "msgReceived": 3893, - "msgSent": 3902, + }, + }, + "PROD": { + "peers": { + "10.1.254.1": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "192.168.1.12": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266297.433896, - "underMaintenance": False, "peerState": "Established", }, }, - } - } + }, + }, }, ], "inputs": { "address_families": [ - {"afi": "ipv4", "safi": "unicast", "vrf": "PROD", "num_peers": 2}, - {"afi": "evpn", "num_peers": 2}, + {"afi": "ipv4", "safi": "unicast", "vrf": "all", "num_peers": 5}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "all", "num_peers": 2}, ] }, "expected": { - "result": "success", + "result": "failure", + "messages": [ + "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'all': 'Expected: 5, Actual: 3'}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'all': 'Expected: 2, Actual: 3'}}]" + ], }, }, { @@ -371,96 +462,114 @@ DATA: list[dict[str, Any]] = [ { "vrfs": { "PROD": { - "vrf": "PROD", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, "peerState": "Established", }, "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, "peerState": "Established", }, }, - } - } + }, + }, }, {"vrfs": {}}, { "vrfs": { + "MGMT": { + "peers": { + "10.1.254.11": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "192.168.1.21": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, + { + "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.0.1": { - "description": "DC1-SPINE1", - "version": 4, - "msgReceived": 3894, - "msgSent": 3897, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266296.584472, - "underMaintenance": False, "peerState": "Established", }, "10.1.0.2": { - "description": "DC1-SPINE2", - "version": 4, - "msgReceived": 3893, - "msgSent": 3902, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266297.433896, - "underMaintenance": False, "peerState": "Established", }, }, - } - } + }, + }, + }, + { + "vrfs": { + "default": { + "peers": { + "10.1.0.11": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.1.0.21": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, + }, + { + "vrfs": { + "default": { + "peers": { + "10.1.0.2": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.1.0.22": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + }, }, ], "inputs": { "address_families": [ {"afi": "ipv4", "safi": "unicast", "vrf": "PROD", "num_peers": 3}, - {"afi": "evpn", "num_peers": 3}, {"afi": "ipv6", "safi": "unicast", "vrf": "default", "num_peers": 3}, - ] + {"afi": "ipv4", "safi": "sr-te", "vrf": "MGMT", "num_peers": 3}, + {"afi": "evpn", "num_peers": 3}, + {"afi": "link-state", "num_peers": 4}, + {"afi": "path-selection", "num_peers": 1}, + ], }, "expected": { "result": "failure", "messages": [ "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'PROD': 'Expected: 3, Actual: 2'}}, " "{'afi': 'ipv6', 'safi': 'unicast', 'vrfs': {'default': 'Not Configured'}}, " - "{'afi': 'evpn', 'vrfs': {'default': 'Expected: 3, Actual: 2'}}" + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': 'Expected: 3, Actual: 2'}}, " + "{'afi': 'evpn', 'vrfs': {'default': 'Expected: 3, Actual: 2'}}, " + "{'afi': 'link-state', 'vrfs': {'default': 'Expected: 4, Actual: 2'}}, " + "{'afi': 'path-selection', 'vrfs': {'default': 'Expected: 1, Actual: 2'}}]", ], }, }, @@ -471,44 +580,84 @@ DATA: list[dict[str, Any]] = [ { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, "peerState": "Established", }, "10.1.255.2": { - "description": "DC1-SPINE2_Ethernet1", - "version": 4, - "msgReceived": 3759, - "msgSent": 3757, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 14, - "prefixReceived": 14, - "upDownTime": 1694266296.367261, - "underMaintenance": False, "peerState": "Established", }, }, } } - } + }, + { + "vrfs": { + "MGMT": { + "peers": { + "10.1.255.10": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.1.255.12": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + } + } + }, + { + "vrfs": { + "default": { + "peers": { + "10.1.255.20": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.1.255.22": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + } + } + }, + { + "vrfs": { + "default": { + "peers": { + "10.1.255.30": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.1.255.32": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + } + } + }, ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "default"}]}, + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "unicast", "vrf": "default"}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "MGMT"}, + {"afi": "path-selection"}, + {"afi": "link-state"}, + ] + }, "expected": {"result": "success"}, }, { @@ -518,48 +667,91 @@ DATA: list[dict[str, Any]] = [ { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, "peerState": "Idle", }, "10.1.255.2": { - "description": "DC1-SPINE2_Ethernet1", - "version": 4, - "msgReceived": 3759, - "msgSent": 3757, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 14, - "prefixReceived": 14, - "upDownTime": 1694266296.367261, - "underMaintenance": False, "peerState": "Established", }, }, } } - } + }, + { + "vrfs": { + "MGMT": { + "peers": { + "10.1.255.10": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.1.255.12": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Idle", + }, + }, + } + } + }, + { + "vrfs": { + "default": { + "peers": { + "10.1.255.20": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Idle", + }, + "10.1.255.22": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + } + } + }, + { + "vrfs": { + "default": { + "peers": { + "10.1.255.30": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.1.255.32": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Idle", + }, + }, + } + } + }, ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "default"}]}, + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "unicast", "vrf": "default"}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "MGMT"}, + {"afi": "path-selection"}, + {"afi": "link-state"}, + ] + }, "expected": { "result": "failure", "messages": [ - "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'default': {'10.1.255.0': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}]" + "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'default': {'10.1.255.0': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': {'10.1.255.12': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}, " + "{'afi': 'path-selection', 'vrfs': {'default': {'10.1.255.20': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}, " + "{'afi': 'link-state', 'vrfs': {'default': {'10.1.255.32': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}]" ], }, }, @@ -570,79 +762,74 @@ DATA: list[dict[str, Any]] = [ { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, "peerState": "Established", }, "10.1.255.2": { - "description": "DC1-SPINE2_Ethernet1", - "version": 4, - "msgReceived": 3759, - "msgSent": 3757, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 14, - "prefixReceived": 14, - "upDownTime": 1694266296.367261, - "underMaintenance": False, "peerState": "Established", }, }, }, "PROD": { - "vrf": "PROD", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, "peerState": "Established", }, "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, "peerState": "Established", }, }, }, } - } + }, + { + "vrfs": { + "default": { + "peers": { + "10.1.255.10": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "10.1.255.12": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + "PROD": { + "peers": { + "10.1.254.11": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "192.168.1.111": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + } + }, ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "all"}]}, + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "unicast", "vrf": "all"}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "all"}, + ] + }, "expected": { "result": "success", }, @@ -654,138 +841,183 @@ DATA: list[dict[str, Any]] = [ { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, "peerState": "Idle", }, "10.1.255.2": { - "description": "DC1-SPINE2_Ethernet1", - "version": 4, - "msgReceived": 3759, - "msgSent": 3757, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 14, - "prefixReceived": 14, - "upDownTime": 1694266296.367261, - "underMaintenance": False, "peerState": "Established", }, }, }, "PROD": { - "vrf": "PROD", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, "peerState": "Established", }, "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, "inMsgQueue": 100, "outMsgQueue": 200, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, "peerState": "Established", }, }, }, } - } + }, + { + "vrfs": { + "default": { + "peers": { + "10.1.255.10": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Idle", + }, + "10.1.255.12": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + }, + }, + "PROD": { + "peers": { + "10.1.254.11": { + "inMsgQueue": 0, + "outMsgQueue": 0, + "peerState": "Established", + }, + "192.168.1.111": { + "inMsgQueue": 100, + "outMsgQueue": 200, + "peerState": "Established", + }, + }, + }, + } + }, ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "all"}]}, + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "unicast", "vrf": "all"}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "all"}, + ] + }, "expected": { "result": "failure", "messages": [ "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'default': {'10.1.255.0': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}, " - "'PROD': {'192.168.1.11': {'peerState': 'Established', 'inMsgQueue': 100, 'outMsgQueue': 200}}}}]" + "'PROD': {'192.168.1.11': {'peerState': 'Established', 'inMsgQueue': 100, 'outMsgQueue': 200}}}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'default': {'10.1.255.10': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}, " + "'PROD': {'192.168.1.111': {'peerState': 'Established', 'inMsgQueue': 100, 'outMsgQueue': 200}}}}]" ], }, }, { "name": "failure-not-configured", "test": VerifyBGPPeersHealth, - "eos_data": [{"vrfs": {}}], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "DEV"}]}, - "expected": {"result": "failure", "messages": ["Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'DEV': 'Not Configured'}}]"]}, + "eos_data": [{"vrfs": {}}, {"vrfs": {}}, {"vrfs": {}}, {"vrfs": {}}], + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "unicast", "vrf": "DEV"}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "MGMT"}, + {"afi": "link-state"}, + {"afi": "path-selection"}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'DEV': 'Not Configured'}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': 'Not Configured'}}, " + "{'afi': 'link-state', 'vrfs': {'default': 'Not Configured'}}, " + "{'afi': 'path-selection', 'vrfs': {'default': 'Not Configured'}}]" + ], + }, }, { "name": "failure-no-peers", "test": VerifyBGPPeersHealth, - "eos_data": [{"vrfs": {"default": {"vrf": "default", "routerId": "10.1.0.3", "asn": "65120", "peers": {}}}}], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "multicast"}]}, - "expected": {"result": "failure", "messages": ["Failures: [{'afi': 'ipv4', 'safi': 'multicast', 'vrfs': {'default': 'No Peers'}}]"]}, - }, - { - "name": "success-multiple-afi", - "test": VerifyBGPPeersHealth, "eos_data": [ { "vrfs": { - "PROD": { - "vrf": "PROD", + "default": { + "vrf": "default", "routerId": "10.1.0.3", "asn": "65120", + "peers": {}, + } + } + }, + { + "vrfs": { + "MGMT": { + "vrf": "MGMT", + "routerId": "10.1.0.3", + "asn": "65120", + "peers": {}, + } + } + }, + { + "vrfs": { + "default": { + "vrf": "default", + "routerId": "10.1.0.3", + "asn": "65120", + "peers": {}, + } + } + }, + { + "vrfs": { + "default": { + "vrf": "default", + "routerId": "10.1.0.3", + "asn": "65120", + "peers": {}, + } + } + }, + ], + "inputs": { + "address_families": [ + {"afi": "ipv4", "safi": "multicast"}, + {"afi": "ipv4", "safi": "sr-te", "vrf": "MGMT"}, + {"afi": "link-state"}, + {"afi": "path-selection"}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "Failures: [{'afi': 'ipv4', 'safi': 'multicast', 'vrfs': {'default': 'No Peers'}}, {'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': 'No Peers'}}, " + "{'afi': 'link-state', 'vrfs': {'default': 'No Peers'}}, {'afi': 'path-selection', 'vrfs': {'default': 'No Peers'}}]" + ], + }, + }, + { + "name": "success", + "test": VerifyBGPSpecificPeers, + "eos_data": [ + { + "vrfs": { + "default": { "peers": { - "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, + "10.1.255.0": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, "peerState": "Established", }, - "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, + "10.1.255.2": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, "peerState": "Established", }, }, @@ -794,132 +1026,53 @@ DATA: list[dict[str, Any]] = [ }, { "vrfs": { - "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", + "MGMT": { "peers": { - "10.1.0.1": { - "description": "DC1-SPINE1", - "version": 4, - "msgReceived": 3894, - "msgSent": 3897, + "10.1.255.10": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266296.584472, - "underMaintenance": False, "peerState": "Established", }, - "10.1.0.2": { - "description": "DC1-SPINE2", - "version": 4, - "msgReceived": 3893, - "msgSent": 3902, + "10.1.255.12": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266297.433896, - "underMaintenance": False, "peerState": "Established", }, }, } } }, - ], - "inputs": { - "address_families": [ - {"afi": "ipv4", "safi": "unicast", "vrf": "PROD"}, - {"afi": "evpn"}, - ] - }, - "expected": { - "result": "success", - }, - }, - { - "name": "failure-multiple-afi", - "test": VerifyBGPPeersHealth, - "eos_data": [ { "vrfs": { - "PROD": { - "vrf": "PROD", - "routerId": "10.1.0.3", - "asn": "65120", + "default": { "peers": { - "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, + "10.1.255.20": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, "peerState": "Established", }, - "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, - "inMsgQueue": 10, + "10.1.255.22": { + "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, "peerState": "Established", }, }, } } }, - {"vrfs": {}}, { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { - "10.1.0.1": { - "description": "DC1-SPINE1", - "version": 4, - "msgReceived": 3894, - "msgSent": 3897, + "10.1.255.30": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266296.584472, - "underMaintenance": False, "peerState": "Established", }, - "10.1.0.2": { - "description": "DC1-SPINE2", - "version": 4, - "msgReceived": 3893, - "msgSent": 3902, + "10.1.255.32": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266297.433896, - "underMaintenance": False, - "peerState": "Idle", + "peerState": "Established", }, }, } @@ -928,174 +1081,76 @@ DATA: list[dict[str, Any]] = [ ], "inputs": { "address_families": [ - {"afi": "ipv4", "safi": "unicast", "vrf": "PROD"}, - {"afi": "evpn"}, - {"afi": "ipv6", "safi": "unicast", "vrf": "default"}, + { + "afi": "ipv4", + "safi": "unicast", + "vrf": "default", + "peers": ["10.1.255.0", "10.1.255.2"], + }, + { + "afi": "ipv4", + "safi": "sr-te", + "vrf": "MGMT", + "peers": ["10.1.255.10", "10.1.255.12"], + }, + {"afi": "path-selection", "peers": ["10.1.255.20", "10.1.255.22"]}, + {"afi": "link-state", "peers": ["10.1.255.30", "10.1.255.32"]}, ] }, - "expected": { - "result": "failure", - "messages": [ - "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': " - "{'PROD': {'192.168.1.11': {'peerState': 'Established', 'inMsgQueue': 10, 'outMsgQueue': 0}}}}, " - "{'afi': 'ipv6', 'safi': 'unicast', 'vrfs': {'default': 'Not Configured'}}, " - "{'afi': 'evpn', 'vrfs': {'default': {'10.1.0.2': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}" - ], - }, + "expected": {"result": "success"}, }, { - "name": "success", + "name": "failure-issues", "test": VerifyBGPSpecificPeers, "eos_data": [ { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, - "peerState": "Established", + "peerState": "Idle", }, "10.1.255.2": { - "description": "DC1-SPINE2_Ethernet1", - "version": 4, - "msgReceived": 3759, - "msgSent": 3757, "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 14, - "prefixReceived": 14, - "upDownTime": 1694266296.367261, - "underMaintenance": False, "peerState": "Established", }, }, } } - } - ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "default", "peers": ["10.1.255.0", "10.1.255.2"]}]}, - "expected": {"result": "success"}, - }, - { - "name": "failure-issues", - "test": VerifyBGPSpecificPeers, - "eos_data": [ + }, { "vrfs": { - "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", + "MGMT": { "peers": { - "10.1.255.0": { - "description": "DC1-SPINE1_Ethernet1", - "version": 4, - "msgReceived": 0, - "msgSent": 0, + "10.1.255.10": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266295.098931, - "underMaintenance": False, - "peerState": "Idle", + "peerState": "Established", }, - "10.1.255.2": { - "description": "DC1-SPINE2_Ethernet1", - "version": 4, - "msgReceived": 3759, - "msgSent": 3757, + "10.1.255.12": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 14, - "prefixReceived": 14, - "upDownTime": 1694266296.367261, - "underMaintenance": False, - "peerState": "Established", + "peerState": "Idle", }, }, } } - } - ], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "default", "peers": ["10.1.255.0", "10.1.255.2"]}]}, - "expected": { - "result": "failure", - "messages": [ - "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'default': {'10.1.255.0': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}]" - ], - }, - }, - { - "name": "failure-not-configured", - "test": VerifyBGPSpecificPeers, - "eos_data": [{"vrfs": {}}], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "unicast", "vrf": "DEV", "peers": ["10.1.255.0"]}]}, - "expected": {"result": "failure", "messages": ["Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'DEV': 'Not Configured'}}]"]}, - }, - { - "name": "failure-no-peers", - "test": VerifyBGPSpecificPeers, - "eos_data": [{"vrfs": {"default": {"vrf": "default", "routerId": "10.1.0.3", "asn": "65120", "peers": {}}}}], - "inputs": {"address_families": [{"afi": "ipv4", "safi": "multicast", "peers": ["10.1.255.0"]}]}, - "expected": { - "result": "failure", - "messages": ["Failures: [{'afi': 'ipv4', 'safi': 'multicast', 'vrfs': {'default': {'10.1.255.0': {'peerNotFound': True}}}}]"], - }, - }, - { - "name": "success-multiple-afi", - "test": VerifyBGPSpecificPeers, - "eos_data": [ + }, { "vrfs": { - "PROD": { - "vrf": "PROD", - "routerId": "10.1.0.3", - "asn": "65120", + "default": { "peers": { - "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, + "10.1.255.20": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, - "peerState": "Established", + "peerState": "Idle", }, - "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, + "10.1.255.22": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, "peerState": "Established", }, }, @@ -1105,37 +1160,16 @@ DATA: list[dict[str, Any]] = [ { "vrfs": { "default": { - "vrf": "default", - "routerId": "10.1.0.3", - "asn": "65120", "peers": { - "10.1.0.1": { - "description": "DC1-SPINE1", - "version": 4, - "msgReceived": 3894, - "msgSent": 3897, + "10.1.255.30": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266296.584472, - "underMaintenance": False, "peerState": "Established", }, - "10.1.0.2": { - "description": "DC1-SPINE2", - "version": 4, - "msgReceived": 3893, - "msgSent": 3902, + "10.1.255.32": { "inMsgQueue": 0, "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266297.433896, - "underMaintenance": False, - "peerState": "Established", + "peerState": "Idle", }, }, } @@ -1144,110 +1178,128 @@ DATA: list[dict[str, Any]] = [ ], "inputs": { "address_families": [ - {"afi": "ipv4", "safi": "unicast", "vrf": "PROD", "peers": ["10.1.254.1", "192.168.1.11"]}, - {"afi": "evpn", "peers": ["10.1.0.1", "10.1.0.2"]}, + { + "afi": "ipv4", + "safi": "unicast", + "vrf": "default", + "peers": ["10.1.255.0", "10.1.255.2"], + }, + { + "afi": "ipv4", + "safi": "sr-te", + "vrf": "MGMT", + "peers": ["10.1.255.10", "10.1.255.12"], + }, + {"afi": "path-selection", "peers": ["10.1.255.20", "10.1.255.22"]}, + {"afi": "link-state", "peers": ["10.1.255.30", "10.1.255.32"]}, ] }, - "expected": {"result": "success"}, + "expected": { + "result": "failure", + "messages": [ + "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'default': {'10.1.255.0': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': {'10.1.255.12': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}, " + "{'afi': 'path-selection', 'vrfs': {'default': {'10.1.255.20': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}, " + "{'afi': 'link-state', 'vrfs': {'default': {'10.1.255.32': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}}]" + ], + }, }, { - "name": "failure-multiple-afi", + "name": "failure-not-configured", + "test": VerifyBGPSpecificPeers, + "eos_data": [{"vrfs": {}}, {"vrfs": {}}, {"vrfs": {}}, {"vrfs": {}}], + "inputs": { + "address_families": [ + { + "afi": "ipv4", + "safi": "unicast", + "vrf": "DEV", + "peers": ["10.1.255.0"], + }, + { + "afi": "ipv4", + "safi": "sr-te", + "vrf": "MGMT", + "peers": ["10.1.255.10"], + }, + {"afi": "link-state", "peers": ["10.1.255.20"]}, + {"afi": "path-selection", "peers": ["10.1.255.30"]}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': {'DEV': 'Not Configured'}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': 'Not Configured'}}, {'afi': 'link-state', 'vrfs': {'default': 'Not Configured'}}, " + "{'afi': 'path-selection', 'vrfs': {'default': 'Not Configured'}}]" + ], + }, + }, + { + "name": "failure-no-peers", "test": VerifyBGPSpecificPeers, "eos_data": [ { "vrfs": { - "PROD": { - "vrf": "PROD", + "default": { + "vrf": "default", "routerId": "10.1.0.3", "asn": "65120", - "peers": { - "10.1.254.1": { - "description": "DC1-LEAF1B", - "version": 4, - "msgReceived": 3777, - "msgSent": 3764, - "inMsgQueue": 0, - "outMsgQueue": 0, - "asn": "65120", - "prefixAccepted": 2, - "prefixReceived": 2, - "upDownTime": 1694266296.659891, - "underMaintenance": False, - "peerState": "Established", - }, - "192.168.1.11": { - "description": "K8S-CLUSTER1", - "version": 4, - "msgReceived": 6417, - "msgSent": 7546, - "inMsgQueue": 10, - "outMsgQueue": 0, - "asn": "65000", - "prefixAccepted": 1, - "prefixReceived": 1, - "upDownTime": 1694266329.978035, - "underMaintenance": False, - "peerState": "Established", - }, - }, + "peers": {}, + } + } + }, + { + "vrfs": { + "MGMT": { + "vrf": "MGMT", + "routerId": "10.1.0.3", + "asn": "65120", + "peers": {}, } } }, - {"vrfs": {}}, { "vrfs": { "default": { "vrf": "default", "routerId": "10.1.0.3", "asn": "65120", - "peers": { - "10.1.0.1": { - "description": "DC1-SPINE1", - "version": 4, - "msgReceived": 3894, - "msgSent": 3897, - "inMsgQueue": 0, - "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266296.584472, - "underMaintenance": False, - "peerState": "Established", - }, - "10.1.0.2": { - "description": "DC1-SPINE2", - "version": 4, - "msgReceived": 3893, - "msgSent": 3902, - "inMsgQueue": 0, - "outMsgQueue": 0, - "asn": "65100", - "prefixAccepted": 0, - "prefixReceived": 0, - "upDownTime": 1694266297.433896, - "underMaintenance": False, - "peerState": "Idle", - }, - }, + "peers": {}, + } + } + }, + { + "vrfs": { + "default": { + "vrf": "default", + "routerId": "10.1.0.3", + "asn": "65120", + "peers": {}, } } }, ], "inputs": { "address_families": [ - {"afi": "ipv4", "safi": "unicast", "vrf": "PROD", "peers": ["10.1.254.1", "192.168.1.11"]}, - {"afi": "evpn", "peers": ["10.1.0.1", "10.1.0.2"]}, - {"afi": "ipv6", "safi": "unicast", "vrf": "default", "peers": ["10.1.0.1", "10.1.0.2"]}, + {"afi": "ipv4", "safi": "multicast", "peers": ["10.1.255.0"]}, + { + "afi": "ipv4", + "safi": "sr-te", + "vrf": "MGMT", + "peers": ["10.1.255.10"], + }, + {"afi": "link-state", "peers": ["10.1.255.20"]}, + {"afi": "path-selection", "peers": ["10.1.255.30"]}, ] }, "expected": { "result": "failure", "messages": [ - "Failures: [{'afi': 'ipv4', 'safi': 'unicast', 'vrfs': " - "{'PROD': {'192.168.1.11': {'peerState': 'Established', 'inMsgQueue': 10, 'outMsgQueue': 0}}}}, " - "{'afi': 'ipv6', 'safi': 'unicast', 'vrfs': {'default': 'Not Configured'}}, " - "{'afi': 'evpn', 'vrfs': {'default': {'10.1.0.2': {'peerState': 'Idle', 'inMsgQueue': 0, 'outMsgQueue': 0}}}" + "Failures: [{'afi': 'ipv4', 'safi': 'multicast', 'vrfs': {'default': {'10.1.255.0': {'peerNotFound': True}}}}, " + "{'afi': 'ipv4', 'safi': 'sr-te', 'vrfs': {'MGMT': {'10.1.255.10': {'peerNotFound': True}}}}, " + "{'afi': 'link-state', 'vrfs': {'default': {'10.1.255.20': {'peerNotFound': True}}}}, " + "{'afi': 'path-selection', 'vrfs': {'default': {'10.1.255.30': {'peerNotFound': True}}}}]" ], }, }, @@ -1390,10 +1442,46 @@ DATA: list[dict[str, Any]] = [ "name": "failure-no-routes", "test": VerifyBGPExchangedRoutes, "eos_data": [ - {"vrfs": {"default": {"vrf": "default", "routerId": "192.0.255.1", "asn": "65001", "bgpRouteEntries": {}}}}, - {"vrfs": {"default": {"vrf": "default", "routerId": "192.0.255.1", "asn": "65001", "bgpRouteEntries": {}}}}, - {"vrfs": {"default": {"vrf": "default", "routerId": "192.0.255.1", "asn": "65001", "bgpRouteEntries": {}}}}, - {"vrfs": {"default": {"vrf": "default", "routerId": "192.0.255.1", "asn": "65001", "bgpRouteEntries": {}}}}, + { + "vrfs": { + "default": { + "vrf": "default", + "routerId": "192.0.255.1", + "asn": "65001", + "bgpRouteEntries": {}, + } + } + }, + { + "vrfs": { + "default": { + "vrf": "default", + "routerId": "192.0.255.1", + "asn": "65001", + "bgpRouteEntries": {}, + } + } + }, + { + "vrfs": { + "default": { + "vrf": "default", + "routerId": "192.0.255.1", + "asn": "65001", + "bgpRouteEntries": {}, + } + } + }, + { + "vrfs": { + "default": { + "vrf": "default", + "routerId": "192.0.255.1", + "asn": "65001", + "bgpRouteEntries": {}, + } + } + }, ], "inputs": { "bgp_peers": [ @@ -1801,8 +1889,16 @@ DATA: list[dict[str, Any]] = [ "peerAddress": "172.30.11.1", "neighborCapabilities": { "multiprotocolCaps": { - "ipv4Unicast": {"advertised": True, "received": True, "enabled": True}, - "ipv4MplsLabels": {"advertised": True, "received": True, "enabled": True}, + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + }, + "ipv4MplsLabels": { + "advertised": True, + "received": True, + "enabled": True, + }, } }, } @@ -1814,8 +1910,16 @@ DATA: list[dict[str, Any]] = [ "peerAddress": "172.30.11.10", "neighborCapabilities": { "multiprotocolCaps": { - "ipv4Unicast": {"advertised": True, "received": True, "enabled": True}, - "ipv4MplsVpn": {"advertised": True, "received": True, "enabled": True}, + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + }, + "ipv4MplsVpn": { + "advertised": True, + "received": True, + "enabled": True, + }, } }, } @@ -1852,8 +1956,16 @@ DATA: list[dict[str, Any]] = [ "peerAddress": "172.30.11.1", "neighborCapabilities": { "multiprotocolCaps": { - "ipv4Unicast": {"advertised": True, "received": True, "enabled": True}, - "ipv4MplsVpn": {"advertised": True, "received": True, "enabled": True}, + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + }, + "ipv4MplsVpn": { + "advertised": True, + "received": True, + "enabled": True, + }, } }, } @@ -1889,7 +2001,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "multiprotocolCaps": {"ipv4Unicast": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, } ] @@ -1899,7 +2017,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.10", "neighborCapabilities": { - "multiprotocolCaps": {"ipv4Unicast": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, } ] @@ -1940,7 +2064,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "multiprotocolCaps": {"ipv4Unicast": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, } ] @@ -1948,7 +2078,15 @@ DATA: list[dict[str, Any]] = [ } } ], - "inputs": {"bgp_peers": [{"peer_address": "172.30.11.1", "vrf": "default", "capabilities": ["ipv4 Unicast", "L2VpnEVPN"]}]}, + "inputs": { + "bgp_peers": [ + { + "peer_address": "172.30.11.1", + "vrf": "default", + "capabilities": ["ipv4 Unicast", "L2VpnEVPN"], + } + ] + }, "expected": { "result": "failure", "messages": [ @@ -1968,8 +2106,16 @@ DATA: list[dict[str, Any]] = [ "peerAddress": "172.30.11.1", "neighborCapabilities": { "multiprotocolCaps": { - "ipv4Unicast": {"advertised": False, "received": False, "enabled": False}, - "ipv4MplsVpn": {"advertised": False, "received": True, "enabled": False}, + "ipv4Unicast": { + "advertised": False, + "received": False, + "enabled": False, + }, + "ipv4MplsVpn": { + "advertised": False, + "received": True, + "enabled": False, + }, }, }, } @@ -1981,8 +2127,16 @@ DATA: list[dict[str, Any]] = [ "peerAddress": "172.30.11.10", "neighborCapabilities": { "multiprotocolCaps": { - "l2VpnEvpn": {"advertised": True, "received": False, "enabled": False}, - "ipv4MplsVpn": {"advertised": False, "received": False, "enabled": True}, + "l2VpnEvpn": { + "advertised": True, + "received": False, + "enabled": False, + }, + "ipv4MplsVpn": { + "advertised": False, + "received": False, + "enabled": True, + }, }, }, }, @@ -1990,8 +2144,16 @@ DATA: list[dict[str, Any]] = [ "peerAddress": "172.30.11.11", "neighborCapabilities": { "multiprotocolCaps": { - "ipv4Unicast": {"advertised": False, "received": False, "enabled": False}, - "ipv4MplsVpn": {"advertised": False, "received": False, "enabled": False}, + "ipv4Unicast": { + "advertised": False, + "received": False, + "enabled": False, + }, + "ipv4MplsVpn": { + "advertised": False, + "received": False, + "enabled": False, + }, }, }, }, @@ -2002,9 +2164,21 @@ DATA: list[dict[str, Any]] = [ ], "inputs": { "bgp_peers": [ - {"peer_address": "172.30.11.1", "vrf": "default", "capabilities": ["ipv4 unicast", "ipv4 mpls vpn", "L2 vpn EVPN"]}, - {"peer_address": "172.30.11.10", "vrf": "MGMT", "capabilities": ["ipv4unicast", "ipv4 mplsvpn", "L2vpnEVPN"]}, - {"peer_address": "172.30.11.11", "vrf": "MGMT", "capabilities": ["Ipv4 Unicast", "ipv4 MPLSVPN", "L2 vpnEVPN"]}, + { + "peer_address": "172.30.11.1", + "vrf": "default", + "capabilities": ["ipv4 unicast", "ipv4 mpls vpn", "L2 vpn EVPN"], + }, + { + "peer_address": "172.30.11.10", + "vrf": "MGMT", + "capabilities": ["ipv4unicast", "ipv4 mplsvpn", "L2vpnEVPN"], + }, + { + "peer_address": "172.30.11.11", + "vrf": "MGMT", + "capabilities": ["Ipv4 Unicast", "ipv4 MPLSVPN", "L2 vpnEVPN"], + }, ] }, "expected": { @@ -2031,7 +2205,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "fourOctetAsnCap": {"advertised": True, "received": True, "enabled": True}, + "fourOctetAsnCap": { + "advertised": True, + "received": True, + "enabled": True, + }, }, } ] @@ -2041,7 +2219,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.10", "neighborCapabilities": { - "fourOctetAsnCap": {"advertised": True, "received": True, "enabled": True}, + "fourOctetAsnCap": { + "advertised": True, + "received": True, + "enabled": True, + }, }, } ] @@ -2074,7 +2256,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "fourOctetAsnCap": {"advertised": True, "received": True, "enabled": True}, + "fourOctetAsnCap": { + "advertised": True, + "received": True, + "enabled": True, + }, }, } ] @@ -2085,7 +2271,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.10", "neighborCapabilities": { - "fourOctetAsnCap": {"advertised": True, "received": True, "enabled": True}, + "fourOctetAsnCap": { + "advertised": True, + "received": True, + "enabled": True, + }, }, } ] @@ -2123,7 +2313,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "multiprotocolCaps": {"ipv4Unicast": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, }, ] @@ -2157,7 +2353,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "multiprotocolCaps": {"ipv4Unicast": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, } ] @@ -2167,7 +2369,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.10", "neighborCapabilities": { - "multiprotocolCaps": {"ipv4MplsLabels": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ipv4MplsLabels": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, } ] @@ -2175,7 +2383,12 @@ DATA: list[dict[str, Any]] = [ } } ], - "inputs": {"bgp_peers": [{"peer_address": "172.30.11.1", "vrf": "default"}, {"peer_address": "172.30.11.10", "vrf": "MGMT"}]}, + "inputs": { + "bgp_peers": [ + {"peer_address": "172.30.11.1", "vrf": "default"}, + {"peer_address": "172.30.11.10", "vrf": "MGMT"}, + ] + }, "expected": { "result": "failure", "messages": [ @@ -2195,7 +2408,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "fourOctetAsnCap": {"advertised": False, "received": False, "enabled": False}, + "fourOctetAsnCap": { + "advertised": False, + "received": False, + "enabled": False, + }, }, } ] @@ -2205,7 +2422,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.10", "neighborCapabilities": { - "fourOctetAsnCap": {"advertised": True, "received": False, "enabled": True}, + "fourOctetAsnCap": { + "advertised": True, + "received": False, + "enabled": True, + }, }, } ] @@ -2213,7 +2434,12 @@ DATA: list[dict[str, Any]] = [ } } ], - "inputs": {"bgp_peers": [{"peer_address": "172.30.11.1", "vrf": "default"}, {"peer_address": "172.30.11.10", "vrf": "MGMT"}]}, + "inputs": { + "bgp_peers": [ + {"peer_address": "172.30.11.1", "vrf": "default"}, + {"peer_address": "172.30.11.10", "vrf": "MGMT"}, + ] + }, "expected": { "result": "failure", "messages": [ @@ -2234,7 +2460,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "routeRefreshCap": {"advertised": True, "received": True, "enabled": True}, + "routeRefreshCap": { + "advertised": True, + "received": True, + "enabled": True, + }, }, } ] @@ -2244,7 +2474,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.11", "neighborCapabilities": { - "routeRefreshCap": {"advertised": True, "received": True, "enabled": True}, + "routeRefreshCap": { + "advertised": True, + "received": True, + "enabled": True, + }, }, } ] @@ -2296,7 +2530,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "multiprotocolCaps": {"ip4Unicast": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ip4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, } ] @@ -2306,7 +2546,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.12", "neighborCapabilities": { - "multiprotocolCaps": {"ip4Unicast": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ip4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, } ] @@ -2345,7 +2591,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "multiprotocolCaps": {"ipv4Unicast": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, } ] @@ -2355,7 +2607,13 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.11", "neighborCapabilities": { - "multiprotocolCaps": {"ipv4Unicast": {"advertised": True, "received": True, "enabled": True}}, + "multiprotocolCaps": { + "ipv4Unicast": { + "advertised": True, + "received": True, + "enabled": True, + } + }, }, } ] @@ -2363,7 +2621,12 @@ DATA: list[dict[str, Any]] = [ } } ], - "inputs": {"bgp_peers": [{"peer_address": "172.30.11.1", "vrf": "default"}, {"peer_address": "172.30.11.11", "vrf": "CS"}]}, + "inputs": { + "bgp_peers": [ + {"peer_address": "172.30.11.1", "vrf": "default"}, + {"peer_address": "172.30.11.11", "vrf": "CS"}, + ] + }, "expected": { "result": "failure", "messages": [ @@ -2383,7 +2646,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.1", "neighborCapabilities": { - "routeRefreshCap": {"advertised": False, "received": False, "enabled": False}, + "routeRefreshCap": { + "advertised": False, + "received": False, + "enabled": False, + }, }, } ] @@ -2393,7 +2660,11 @@ DATA: list[dict[str, Any]] = [ { "peerAddress": "172.30.11.11", "neighborCapabilities": { - "routeRefreshCap": {"advertised": True, "received": True, "enabled": True}, + "routeRefreshCap": { + "advertised": True, + "received": True, + "enabled": True, + }, }, } ] @@ -2401,7 +2672,12 @@ DATA: list[dict[str, Any]] = [ } } ], - "inputs": {"bgp_peers": [{"peer_address": "172.30.11.1", "vrf": "default"}, {"peer_address": "172.30.11.11", "vrf": "CS"}]}, + "inputs": { + "bgp_peers": [ + {"peer_address": "172.30.11.1", "vrf": "default"}, + {"peer_address": "172.30.11.11", "vrf": "CS"}, + ] + }, "expected": { "result": "failure", "messages": [ @@ -2592,10 +2868,22 @@ DATA: list[dict[str, Any]] = [ "peerAddress": "172.30.11.1", "state": "Established", }, - {"peerAddress": "172.30.11.10", "state": "Established", "md5AuthEnabled": False}, + { + "peerAddress": "172.30.11.10", + "state": "Established", + "md5AuthEnabled": False, + }, + ] + }, + "MGMT": { + "peerList": [ + { + "peerAddress": "172.30.11.11", + "state": "Established", + "md5AuthEnabled": False, + } ] }, - "MGMT": {"peerList": [{"peerAddress": "172.30.11.11", "state": "Established", "md5AuthEnabled": False}]}, } } ], @@ -2684,7 +2972,12 @@ DATA: list[dict[str, Any]] = [ }, }, ], - "inputs": {"vxlan_endpoints": [{"address": "192.168.20.102", "vni": 10020}, {"address": "aac1.ab5d.b41e", "vni": 10010}]}, + "inputs": { + "vxlan_endpoints": [ + {"address": "192.168.20.102", "vni": 10020}, + {"address": "aac1.ab5d.b41e", "vni": 10010}, + ] + }, "expected": {"result": "success"}, }, { @@ -3024,7 +3317,12 @@ DATA: list[dict[str, Any]] = [ }, }, ], - "inputs": {"vxlan_endpoints": [{"address": "192.168.20.102", "vni": 10020}, {"address": "aac1.ab5d.b41e", "vni": 10010}]}, + "inputs": { + "vxlan_endpoints": [ + {"address": "192.168.20.102", "vni": 10020}, + {"address": "aac1.ab5d.b41e", "vni": 10010}, + ] + }, "expected": { "result": "failure", "messages": [ @@ -3057,7 +3355,12 @@ DATA: list[dict[str, Any]] = [ }, }, ], - "inputs": {"vxlan_endpoints": [{"address": "aac1.ab4e.bec2", "vni": 10020}, {"address": "192.168.10.101", "vni": 10010}]}, + "inputs": { + "vxlan_endpoints": [ + {"address": "aac1.ab4e.bec2", "vni": 10020}, + {"address": "192.168.10.101", "vni": 10010}, + ] + }, "expected": { "result": "failure", "messages": [ @@ -3074,7 +3377,12 @@ DATA: list[dict[str, Any]] = [ {"vrf": "default", "routerId": "10.1.0.3", "asn": 65120, "evpnRoutes": {}}, {"vrf": "default", "routerId": "10.1.0.3", "asn": 65120, "evpnRoutes": {}}, ], - "inputs": {"vxlan_endpoints": [{"address": "aac1.ab4e.bec2", "vni": 10020}, {"address": "192.168.10.101", "vni": 10010}]}, + "inputs": { + "vxlan_endpoints": [ + {"address": "aac1.ab4e.bec2", "vni": 10020}, + {"address": "192.168.10.101", "vni": 10010}, + ] + }, "expected": { "result": "failure", "messages": ["The following VXLAN endpoint do not have any EVPN Type-2 route: [('aa:c1:ab:4e:be:c2', 10020), ('192.168.10.101', 10010)]"], @@ -3090,7 +3398,11 @@ DATA: list[dict[str, Any]] = [ "peerList": [ { "peerAddress": "172.30.11.1", - "advertisedCommunities": {"standard": True, "extended": True, "large": True}, + "advertisedCommunities": { + "standard": True, + "extended": True, + "large": True, + }, } ] }, @@ -3098,7 +3410,11 @@ DATA: list[dict[str, Any]] = [ "peerList": [ { "peerAddress": "172.30.11.10", - "advertisedCommunities": {"standard": True, "extended": True, "large": True}, + "advertisedCommunities": { + "standard": True, + "extended": True, + "large": True, + }, } ] }, @@ -3128,7 +3444,11 @@ DATA: list[dict[str, Any]] = [ "peerList": [ { "peerAddress": "172.30.11.1", - "advertisedCommunities": {"standard": True, "extended": True, "large": True}, + "advertisedCommunities": { + "standard": True, + "extended": True, + "large": True, + }, } ] }, @@ -3161,7 +3481,11 @@ DATA: list[dict[str, Any]] = [ "peerList": [ { "peerAddress": "172.30.11.1", - "advertisedCommunities": {"standard": True, "extended": True, "large": True}, + "advertisedCommunities": { + "standard": True, + "extended": True, + "large": True, + }, } ] }, @@ -3169,7 +3493,11 @@ DATA: list[dict[str, Any]] = [ "peerList": [ { "peerAddress": "172.30.11.1", - "advertisedCommunities": {"standard": True, "extended": True, "large": True}, + "advertisedCommunities": { + "standard": True, + "extended": True, + "large": True, + }, } ] }, @@ -3206,7 +3534,11 @@ DATA: list[dict[str, Any]] = [ "peerList": [ { "peerAddress": "172.30.11.1", - "advertisedCommunities": {"standard": False, "extended": False, "large": False}, + "advertisedCommunities": { + "standard": False, + "extended": False, + "large": False, + }, } ] }, @@ -3214,7 +3546,11 @@ DATA: list[dict[str, Any]] = [ "peerList": [ { "peerAddress": "172.30.11.10", - "advertisedCommunities": {"standard": True, "extended": True, "large": False}, + "advertisedCommunities": { + "standard": True, + "extended": True, + "large": False, + }, } ] }, diff --git a/tests/units/anta_tests/routing/test_generic.py b/tests/units/anta_tests/routing/test_generic.py index 90e70f8..36658f5 100644 --- a/tests/units/anta_tests/routing/test_generic.py +++ b/tests/units/anta_tests/routing/test_generic.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.routing.generic.py -""" +"""Tests for anta.tests.routing.generic.py.""" + from __future__ import annotations from typing import Any @@ -43,9 +42,9 @@ DATA: list[dict[str, Any]] = [ # Output truncated "maskLen": {"8": 2}, "totalRoutes": 123, - } + }, }, - } + }, ], "inputs": {"minimum": 42, "maximum": 666}, "expected": {"result": "success"}, @@ -60,9 +59,9 @@ DATA: list[dict[str, Any]] = [ # Output truncated "maskLen": {"8": 2}, "totalRoutes": 1000, - } + }, }, - } + }, ], "inputs": {"minimum": 42, "maximum": 666}, "expected": {"result": "failure", "messages": ["routing-table has 1000 routes and not between min (42) and maximum (666)"]}, @@ -99,10 +98,10 @@ DATA: list[dict[str, Any]] = [ "preference": 20, "metric": 0, "vias": [{"nexthopAddr": "10.1.255.4", "interface": "Ethernet1"}], - } + }, }, - } - } + }, + }, }, { "vrfs": { @@ -122,10 +121,10 @@ DATA: list[dict[str, Any]] = [ "preference": 20, "metric": 0, "vias": [{"nexthopAddr": "10.1.255.6", "interface": "Ethernet2"}], - } + }, }, - } - } + }, + }, }, ], "inputs": {"vrf": "default", "routes": ["10.1.0.1", "10.1.0.2"]}, @@ -143,8 +142,8 @@ DATA: list[dict[str, Any]] = [ "allRoutesProgrammedKernel": True, "defaultRouteState": "notSet", "routes": {}, - } - } + }, + }, }, { "vrfs": { @@ -164,10 +163,10 @@ DATA: list[dict[str, Any]] = [ "preference": 20, "metric": 0, "vias": [{"nexthopAddr": "10.1.255.6", "interface": "Ethernet2"}], - } + }, }, - } - } + }, + }, }, ], "inputs": {"vrf": "default", "routes": ["10.1.0.1", "10.1.0.2"]}, @@ -195,10 +194,10 @@ DATA: list[dict[str, Any]] = [ "preference": 20, "metric": 0, "vias": [{"nexthopAddr": "10.1.255.4", "interface": "Ethernet1"}], - } + }, }, - } - } + }, + }, }, { "vrfs": { @@ -218,10 +217,10 @@ DATA: list[dict[str, Any]] = [ "preference": 20, "metric": 0, "vias": [{"nexthopAddr": "10.1.255.6", "interface": "Ethernet2"}], - } + }, }, - } - } + }, + }, }, ], "inputs": {"vrf": "default", "routes": ["10.1.0.1", "10.1.0.2"]}, diff --git a/tests/units/anta_tests/routing/test_ospf.py b/tests/units/anta_tests/routing/test_ospf.py index fbabee9..81d8010 100644 --- a/tests/units/anta_tests/routing/test_ospf.py +++ b/tests/units/anta_tests/routing/test_ospf.py @@ -1,14 +1,13 @@ # Copyright (c) 2023-2024 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.routing.ospf.py -""" +"""Tests for anta.tests.routing.ospf.py.""" + from __future__ import annotations from typing import Any -from anta.tests.routing.ospf import VerifyOSPFNeighborCount, VerifyOSPFNeighborState +from anta.tests.routing.ospf import VerifyOSPFMaxLSA, VerifyOSPFNeighborCount, VerifyOSPFNeighborState from tests.lib.anta import test # noqa: F401; pylint: disable=W0611 DATA: list[dict[str, Any]] = [ @@ -40,9 +39,9 @@ DATA: list[dict[str, Any]] = [ "inactivity": 1683298014.844345, "interfaceAddress": "10.3.0.1", }, - ] - } - } + ], + }, + }, }, "BLAH": { "instList": { @@ -56,13 +55,13 @@ DATA: list[dict[str, Any]] = [ "adjacencyState": "full", "inactivity": 1683298014.844345, "interfaceAddress": "10.3.0.1", - } - ] - } - } + }, + ], + }, + }, }, - } - } + }, + }, ], "inputs": None, "expected": {"result": "success"}, @@ -95,9 +94,9 @@ DATA: list[dict[str, Any]] = [ "inactivity": 1683298014.844345, "interfaceAddress": "10.3.0.1", }, - ] - } - } + ], + }, + }, }, "BLAH": { "instList": { @@ -111,20 +110,20 @@ DATA: list[dict[str, Any]] = [ "adjacencyState": "down", "inactivity": 1683298014.844345, "interfaceAddress": "10.3.0.1", - } - ] - } - } + }, + ], + }, + }, }, - } - } + }, + }, ], "inputs": None, "expected": { "result": "failure", "messages": [ "Some neighbors are not correctly configured: [{'vrf': 'default', 'instance': '666', 'neighbor': '7.7.7.7', 'state': '2-way'}," - " {'vrf': 'BLAH', 'instance': '777', 'neighbor': '8.8.8.8', 'state': 'down'}]." + " {'vrf': 'BLAH', 'instance': '777', 'neighbor': '8.8.8.8', 'state': 'down'}].", ], }, }, @@ -134,7 +133,7 @@ DATA: list[dict[str, Any]] = [ "eos_data": [ { "vrfs": {}, - } + }, ], "inputs": None, "expected": {"result": "skipped", "messages": ["no OSPF neighbor found"]}, @@ -167,9 +166,9 @@ DATA: list[dict[str, Any]] = [ "inactivity": 1683298014.844345, "interfaceAddress": "10.3.0.1", }, - ] - } - } + ], + }, + }, }, "BLAH": { "instList": { @@ -183,13 +182,13 @@ DATA: list[dict[str, Any]] = [ "adjacencyState": "full", "inactivity": 1683298014.844345, "interfaceAddress": "10.3.0.1", - } - ] - } - } + }, + ], + }, + }, }, - } - } + }, + }, ], "inputs": {"number": 3}, "expected": {"result": "success"}, @@ -213,12 +212,12 @@ DATA: list[dict[str, Any]] = [ "inactivity": 1683298014.844345, "interfaceAddress": "10.3.0.1", }, - ] - } - } - } - } - } + ], + }, + }, + }, + }, + }, ], "inputs": {"number": 3}, "expected": {"result": "failure", "messages": ["device has 1 neighbors (expected 3)"]}, @@ -251,9 +250,9 @@ DATA: list[dict[str, Any]] = [ "inactivity": 1683298014.844345, "interfaceAddress": "10.3.0.1", }, - ] - } - } + ], + }, + }, }, "BLAH": { "instList": { @@ -267,20 +266,20 @@ DATA: list[dict[str, Any]] = [ "adjacencyState": "down", "inactivity": 1683298014.844345, "interfaceAddress": "10.3.0.1", - } - ] - } - } + }, + ], + }, + }, }, - } - } + }, + }, ], "inputs": {"number": 3}, "expected": { "result": "failure", "messages": [ "Some neighbors are not correctly configured: [{'vrf': 'default', 'instance': '666', 'neighbor': '7.7.7.7', 'state': '2-way'}," - " {'vrf': 'BLAH', 'instance': '777', 'neighbor': '8.8.8.8', 'state': 'down'}]." + " {'vrf': 'BLAH', 'instance': '777', 'neighbor': '8.8.8.8', 'state': 'down'}].", ], }, }, @@ -290,9 +289,123 @@ DATA: list[dict[str, Any]] = [ "eos_data": [ { "vrfs": {}, - } + }, ], "inputs": {"number": 3}, "expected": {"result": "skipped", "messages": ["no OSPF neighbor found"]}, }, + { + "name": "success", + "test": VerifyOSPFMaxLSA, + "eos_data": [ + { + "vrfs": { + "default": { + "instList": { + "1": { + "instanceId": 1, + "maxLsaInformation": { + "maxLsa": 12000, + "maxLsaThreshold": 75, + }, + "routerId": "1.1.1.1", + "lsaInformation": { + "lsaArrivalInterval": 1000, + "lsaStartInterval": 1000, + "lsaHoldInterval": 5000, + "lsaMaxWaitInterval": 5000, + "numLsa": 9, + }, + }, + }, + }, + "TEST": { + "instList": { + "10": { + "instanceId": 10, + "maxLsaInformation": { + "maxLsa": 1000, + "maxLsaThreshold": 75, + }, + "routerId": "20.20.20.20", + "lsaInformation": { + "lsaArrivalInterval": 1000, + "lsaStartInterval": 1000, + "lsaHoldInterval": 5000, + "lsaMaxWaitInterval": 5000, + "numLsa": 5, + }, + }, + }, + }, + }, + }, + ], + "inputs": None, + "expected": {"result": "success"}, + }, + { + "name": "failure", + "test": VerifyOSPFMaxLSA, + "eos_data": [ + { + "vrfs": { + "default": { + "instList": { + "1": { + "instanceId": 1, + "maxLsaInformation": { + "maxLsa": 12000, + "maxLsaThreshold": 75, + }, + "routerId": "1.1.1.1", + "lsaInformation": { + "lsaArrivalInterval": 1000, + "lsaStartInterval": 1000, + "lsaHoldInterval": 5000, + "lsaMaxWaitInterval": 5000, + "numLsa": 11500, + }, + }, + }, + }, + "TEST": { + "instList": { + "10": { + "instanceId": 10, + "maxLsaInformation": { + "maxLsa": 1000, + "maxLsaThreshold": 75, + }, + "routerId": "20.20.20.20", + "lsaInformation": { + "lsaArrivalInterval": 1000, + "lsaStartInterval": 1000, + "lsaHoldInterval": 5000, + "lsaMaxWaitInterval": 5000, + "numLsa": 1500, + }, + }, + }, + }, + }, + }, + ], + "inputs": None, + "expected": { + "result": "failure", + "messages": ["OSPF Instances ['1', '10'] crossed the maximum LSA threshold."], + }, + }, + { + "name": "skipped", + "test": VerifyOSPFMaxLSA, + "eos_data": [ + { + "vrfs": {}, + }, + ], + "inputs": None, + "expected": {"result": "skipped", "messages": ["No OSPF instance found."]}, + }, ] diff --git a/tests/units/anta_tests/test_aaa.py b/tests/units/anta_tests/test_aaa.py index 2992290..f0324c5 100644 --- a/tests/units/anta_tests/test_aaa.py +++ b/tests/units/anta_tests/test_aaa.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.aaa.py -""" +"""Tests for anta.tests.aaa.py.""" + from __future__ import annotations from typing import Any @@ -28,11 +27,11 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [ { "serverInfo": {"hostname": "10.22.10.91", "authport": 49, "vrf": "MGMT"}, - } + }, ], "groups": {"GROUP1": {"serverGroup": "TACACS+", "members": [{"hostname": "SERVER1", "authport": 49, "vrf": "MGMT"}]}}, "srcIntf": {"MGMT": "Management0"}, - } + }, ], "inputs": {"intf": "Management0", "vrf": "MGMT"}, "expected": {"result": "success"}, @@ -45,7 +44,7 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [], "groups": {}, "srcIntf": {}, - } + }, ], "inputs": {"intf": "Management0", "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["Source-interface Management0 is not configured in VRF MGMT"]}, @@ -58,11 +57,11 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [ { "serverInfo": {"hostname": "10.22.10.91", "authport": 49, "vrf": "MGMT"}, - } + }, ], "groups": {"GROUP1": {"serverGroup": "TACACS+", "members": [{"hostname": "SERVER1", "authport": 49, "vrf": "MGMT"}]}}, "srcIntf": {"MGMT": "Management1"}, - } + }, ], "inputs": {"intf": "Management0", "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["Wrong source-interface configured in VRF MGMT"]}, @@ -75,11 +74,11 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [ { "serverInfo": {"hostname": "10.22.10.91", "authport": 49, "vrf": "MGMT"}, - } + }, ], "groups": {"GROUP1": {"serverGroup": "TACACS+", "members": [{"hostname": "SERVER1", "authport": 49, "vrf": "MGMT"}]}}, "srcIntf": {"PROD": "Management0"}, - } + }, ], "inputs": {"intf": "Management0", "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["Source-interface Management0 is not configured in VRF MGMT"]}, @@ -92,11 +91,11 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [ { "serverInfo": {"hostname": "10.22.10.91", "authport": 49, "vrf": "MGMT"}, - } + }, ], "groups": {"GROUP1": {"serverGroup": "TACACS+", "members": [{"hostname": "SERVER1", "authport": 49, "vrf": "MGMT"}]}}, "srcIntf": {"MGMT": "Management0"}, - } + }, ], "inputs": {"servers": ["10.22.10.91"], "vrf": "MGMT"}, "expected": {"result": "success"}, @@ -109,7 +108,7 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [], "groups": {}, "srcIntf": {}, - } + }, ], "inputs": {"servers": ["10.22.10.91"], "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["No TACACS servers are configured"]}, @@ -122,11 +121,11 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [ { "serverInfo": {"hostname": "10.22.10.91", "authport": 49, "vrf": "MGMT"}, - } + }, ], "groups": {"GROUP1": {"serverGroup": "TACACS+", "members": [{"hostname": "SERVER1", "authport": 49, "vrf": "MGMT"}]}}, "srcIntf": {"MGMT": "Management0"}, - } + }, ], "inputs": {"servers": ["10.22.10.91", "10.22.10.92"], "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["TACACS servers ['10.22.10.92'] are not configured in VRF MGMT"]}, @@ -139,11 +138,11 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [ { "serverInfo": {"hostname": "10.22.10.91", "authport": 49, "vrf": "PROD"}, - } + }, ], "groups": {"GROUP1": {"serverGroup": "TACACS+", "members": [{"hostname": "SERVER1", "authport": 49, "vrf": "MGMT"}]}}, "srcIntf": {"MGMT": "Management0"}, - } + }, ], "inputs": {"servers": ["10.22.10.91"], "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["TACACS servers ['10.22.10.91'] are not configured in VRF MGMT"]}, @@ -156,11 +155,11 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [ { "serverInfo": {"hostname": "10.22.10.91", "authport": 49, "vrf": "MGMT"}, - } + }, ], "groups": {"GROUP1": {"serverGroup": "TACACS+", "members": [{"hostname": "SERVER1", "authport": 49, "vrf": "MGMT"}]}}, "srcIntf": {"MGMT": "Management0"}, - } + }, ], "inputs": {"groups": ["GROUP1"]}, "expected": {"result": "success"}, @@ -173,7 +172,7 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [], "groups": {}, "srcIntf": {}, - } + }, ], "inputs": {"groups": ["GROUP1"]}, "expected": {"result": "failure", "messages": ["No TACACS server group(s) are configured"]}, @@ -186,11 +185,11 @@ DATA: list[dict[str, Any]] = [ "tacacsServers": [ { "serverInfo": {"hostname": "10.22.10.91", "authport": 49, "vrf": "MGMT"}, - } + }, ], "groups": {"GROUP2": {"serverGroup": "TACACS+", "members": [{"hostname": "SERVER1", "authport": 49, "vrf": "MGMT"}]}}, "srcIntf": {"MGMT": "Management0"}, - } + }, ], "inputs": {"groups": ["GROUP1"]}, "expected": {"result": "failure", "messages": ["TACACS server group(s) ['GROUP1'] are not configured"]}, @@ -203,7 +202,7 @@ DATA: list[dict[str, Any]] = [ "loginAuthenMethods": {"default": {"methods": ["group tacacs+", "local"]}, "login": {"methods": ["group tacacs+", "local"]}}, "enableAuthenMethods": {"default": {"methods": ["group tacacs+", "local"]}}, "dot1xAuthenMethods": {"default": {"methods": ["group radius"]}}, - } + }, ], "inputs": {"methods": ["tacacs+", "local"], "types": ["login", "enable"]}, "expected": {"result": "success"}, @@ -216,7 +215,7 @@ DATA: list[dict[str, Any]] = [ "loginAuthenMethods": {"default": {"methods": ["group tacacs+", "local"]}, "login": {"methods": ["group tacacs+", "local"]}}, "enableAuthenMethods": {"default": {"methods": ["group tacacs+", "local"]}}, "dot1xAuthenMethods": {"default": {"methods": ["group radius"]}}, - } + }, ], "inputs": {"methods": ["radius"], "types": ["dot1x"]}, "expected": {"result": "success"}, @@ -229,7 +228,7 @@ DATA: list[dict[str, Any]] = [ "loginAuthenMethods": {"default": {"methods": ["group tacacs+", "local"]}}, "enableAuthenMethods": {"default": {"methods": ["group tacacs+", "local"]}}, "dot1xAuthenMethods": {"default": {"methods": ["group radius"]}}, - } + }, ], "inputs": {"methods": ["tacacs+", "local"], "types": ["login", "enable"]}, "expected": {"result": "failure", "messages": ["AAA authentication methods are not configured for login console"]}, @@ -242,7 +241,7 @@ DATA: list[dict[str, Any]] = [ "loginAuthenMethods": {"default": {"methods": ["group tacacs+", "local"]}, "login": {"methods": ["group radius", "local"]}}, "enableAuthenMethods": {"default": {"methods": ["group tacacs+", "local"]}}, "dot1xAuthenMethods": {"default": {"methods": ["group radius"]}}, - } + }, ], "inputs": {"methods": ["tacacs+", "local"], "types": ["login", "enable"]}, "expected": {"result": "failure", "messages": ["AAA authentication methods ['group tacacs+', 'local'] are not matching for login console"]}, @@ -255,7 +254,7 @@ DATA: list[dict[str, Any]] = [ "loginAuthenMethods": {"default": {"methods": ["group radius", "local"]}, "login": {"methods": ["group tacacs+", "local"]}}, "enableAuthenMethods": {"default": {"methods": ["group tacacs+", "local"]}}, "dot1xAuthenMethods": {"default": {"methods": ["group radius"]}}, - } + }, ], "inputs": {"methods": ["tacacs+", "local"], "types": ["login", "enable"]}, "expected": {"result": "failure", "messages": ["AAA authentication methods ['group tacacs+', 'local'] are not matching for ['login']"]}, @@ -267,7 +266,7 @@ DATA: list[dict[str, Any]] = [ { "commandsAuthzMethods": {"privilege0-15": {"methods": ["group tacacs+", "local"]}}, "execAuthzMethods": {"exec": {"methods": ["group tacacs+", "local"]}}, - } + }, ], "inputs": {"methods": ["tacacs+", "local"], "types": ["commands", "exec"]}, "expected": {"result": "success"}, @@ -279,7 +278,7 @@ DATA: list[dict[str, Any]] = [ { "commandsAuthzMethods": {"privilege0-15": {"methods": ["group radius", "local"]}}, "execAuthzMethods": {"exec": {"methods": ["group tacacs+", "local"]}}, - } + }, ], "inputs": {"methods": ["tacacs+", "local"], "types": ["commands", "exec"]}, "expected": {"result": "failure", "messages": ["AAA authorization methods ['group tacacs+', 'local'] are not matching for ['commands']"]}, @@ -291,7 +290,7 @@ DATA: list[dict[str, Any]] = [ { "commandsAuthzMethods": {"privilege0-15": {"methods": ["group tacacs+", "local"]}}, "execAuthzMethods": {"exec": {"methods": ["group radius", "local"]}}, - } + }, ], "inputs": {"methods": ["tacacs+", "local"], "types": ["commands", "exec"]}, "expected": {"result": "failure", "messages": ["AAA authorization methods ['group tacacs+', 'local'] are not matching for ['exec']"]}, @@ -305,7 +304,7 @@ DATA: list[dict[str, Any]] = [ "execAcctMethods": {"exec": {"defaultAction": "startStop", "defaultMethods": ["group tacacs+", "logging"], "consoleMethods": []}}, "systemAcctMethods": {"system": {"defaultAction": "startStop", "defaultMethods": ["group tacacs+", "logging"], "consoleMethods": []}}, "dot1xAcctMethods": {"dot1x": {"defaultMethods": [], "consoleMethods": []}}, - } + }, ], "inputs": {"methods": ["tacacs+", "logging"], "types": ["commands", "exec", "system"]}, "expected": {"result": "success"}, @@ -319,7 +318,7 @@ DATA: list[dict[str, Any]] = [ "execAcctMethods": {"exec": {"defaultAction": "startStop", "defaultMethods": ["group tacacs+", "logging"], "consoleMethods": []}}, "systemAcctMethods": {"system": {"defaultAction": "startStop", "defaultMethods": ["group tacacs+", "logging"], "consoleMethods": []}}, "dot1xAcctMethods": {"dot1x": {"defaultAction": "startStop", "defaultMethods": ["group radius", "logging"], "consoleMethods": []}}, - } + }, ], "inputs": {"methods": ["radius", "logging"], "types": ["dot1x"]}, "expected": {"result": "success"}, @@ -333,7 +332,7 @@ DATA: list[dict[str, Any]] = [ "execAcctMethods": {"exec": {"defaultAction": "startStop", "defaultMethods": ["group tacacs+", "logging"], "consoleMethods": []}}, "systemAcctMethods": {"system": {"defaultAction": "startStop", "defaultMethods": ["group tacacs+", "logging"], "consoleMethods": []}}, "dot1xAcctMethods": {"dot1x": {"defaultMethods": [], "consoleMethods": []}}, - } + }, ], "inputs": {"methods": ["tacacs+", "logging"], "types": ["commands", "exec", "system"]}, "expected": {"result": "failure", "messages": ["AAA default accounting is not configured for ['commands']"]}, @@ -347,7 +346,7 @@ DATA: list[dict[str, Any]] = [ "execAcctMethods": {"exec": {"defaultMethods": [], "consoleMethods": []}}, "commandsAcctMethods": {"privilege0-15": {"defaultMethods": [], "consoleMethods": []}}, "dot1xAcctMethods": {"dot1x": {"defaultMethods": [], "consoleMethods": []}}, - } + }, ], "inputs": {"methods": ["tacacs+", "logging"], "types": ["commands", "exec", "system"]}, "expected": {"result": "failure", "messages": ["AAA default accounting is not configured for ['system', 'exec', 'commands']"]}, @@ -361,7 +360,7 @@ DATA: list[dict[str, Any]] = [ "execAcctMethods": {"exec": {"defaultAction": "startStop", "defaultMethods": ["group tacacs+", "logging"], "consoleMethods": []}}, "systemAcctMethods": {"system": {"defaultAction": "startStop", "defaultMethods": ["group tacacs+", "logging"], "consoleMethods": []}}, "dot1xAcctMethods": {"dot1x": {"defaultMethods": [], "consoleMethods": []}}, - } + }, ], "inputs": {"methods": ["tacacs+", "logging"], "types": ["commands", "exec", "system"]}, "expected": {"result": "failure", "messages": ["AAA accounting default methods ['group tacacs+', 'logging'] are not matching for ['commands']"]}, @@ -376,24 +375,24 @@ DATA: list[dict[str, Any]] = [ "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "execAcctMethods": { "exec": { "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "systemAcctMethods": { "system": { "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "dot1xAcctMethods": {"dot1x": {"defaultMethods": [], "consoleMethods": []}}, - } + }, ], "inputs": {"methods": ["tacacs+", "logging"], "types": ["commands", "exec", "system"]}, "expected": {"result": "success"}, @@ -408,30 +407,30 @@ DATA: list[dict[str, Any]] = [ "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "execAcctMethods": { "exec": { "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "systemAcctMethods": { "system": { "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "dot1xAcctMethods": { "dot1x": { "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, - } + }, ], "inputs": {"methods": ["tacacs+", "logging"], "types": ["dot1x"]}, "expected": {"result": "success"}, @@ -445,24 +444,24 @@ DATA: list[dict[str, Any]] = [ "privilege0-15": { "defaultMethods": [], "consoleMethods": [], - } + }, }, "execAcctMethods": { "exec": { "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "systemAcctMethods": { "system": { "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "dot1xAcctMethods": {"dot1x": {"defaultMethods": [], "consoleMethods": []}}, - } + }, ], "inputs": {"methods": ["tacacs+", "logging"], "types": ["commands", "exec", "system"]}, "expected": {"result": "failure", "messages": ["AAA console accounting is not configured for ['commands']"]}, @@ -476,7 +475,7 @@ DATA: list[dict[str, Any]] = [ "execAcctMethods": {"exec": {"defaultMethods": [], "consoleMethods": []}}, "commandsAcctMethods": {"privilege0-15": {"defaultMethods": [], "consoleMethods": []}}, "dot1xAcctMethods": {"dot1x": {"defaultMethods": [], "consoleMethods": []}}, - } + }, ], "inputs": {"methods": ["tacacs+", "logging"], "types": ["commands", "exec", "system"]}, "expected": {"result": "failure", "messages": ["AAA console accounting is not configured for ['system', 'exec', 'commands']"]}, @@ -491,24 +490,24 @@ DATA: list[dict[str, Any]] = [ "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group radius", "logging"], - } + }, }, "execAcctMethods": { "exec": { "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "systemAcctMethods": { "system": { "defaultMethods": [], "consoleAction": "startStop", "consoleMethods": ["group tacacs+", "logging"], - } + }, }, "dot1xAcctMethods": {"dot1x": {"defaultMethods": [], "consoleMethods": []}}, - } + }, ], "inputs": {"methods": ["tacacs+", "logging"], "types": ["commands", "exec", "system"]}, "expected": {"result": "failure", "messages": ["AAA accounting console methods ['group tacacs+', 'logging'] are not matching for ['commands']"]}, diff --git a/tests/units/anta_tests/test_bfd.py b/tests/units/anta_tests/test_bfd.py index 67bb0b4..54dc7a0 100644 --- a/tests/units/anta_tests/test_bfd.py +++ b/tests/units/anta_tests/test_bfd.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.bfd.py -""" +"""Tests for anta.tests.bfd.py.""" + # pylint: disable=C0302 from __future__ import annotations @@ -11,7 +10,7 @@ from typing import Any # pylint: disable=C0413 # because of the patch above -from anta.tests.bfd import VerifyBFDPeersHealth, VerifyBFDPeersIntervals, VerifyBFDSpecificPeers # noqa: E402 +from anta.tests.bfd import VerifyBFDPeersHealth, VerifyBFDPeersIntervals, VerifyBFDSpecificPeers from tests.lib.anta import test # noqa: F401; pylint: disable=W0611 DATA: list[dict[str, Any]] = [ diff --git a/tests/units/anta_tests/test_configuration.py b/tests/units/anta_tests/test_configuration.py index a2ab673..0444db6 100644 --- a/tests/units/anta_tests/test_configuration.py +++ b/tests/units/anta_tests/test_configuration.py @@ -1,7 +1,8 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Data for testing anta.tests.configuration""" +"""Data for testing anta.tests.configuration.""" + from __future__ import annotations from typing import Any diff --git a/tests/units/anta_tests/test_connectivity.py b/tests/units/anta_tests/test_connectivity.py index f79ce24..bd30811 100644 --- a/tests/units/anta_tests/test_connectivity.py +++ b/tests/units/anta_tests/test_connectivity.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.connectivity.py -""" +"""Tests for anta.tests.connectivity.py.""" + from __future__ import annotations from typing import Any @@ -27,8 +26,8 @@ DATA: list[dict[str, Any]] = [ 2 packets transmitted, 2 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.072/0.159/0.247/0.088 ms, ipg/ewma 0.370/0.225 ms - """ - ] + """, + ], }, { "messages": [ @@ -40,8 +39,8 @@ DATA: list[dict[str, Any]] = [ 2 packets transmitted, 2 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.072/0.159/0.247/0.088 ms, ipg/ewma 0.370/0.225 ms - """ - ] + """, + ], }, ], "expected": {"result": "success"}, @@ -61,8 +60,8 @@ DATA: list[dict[str, Any]] = [ 2 packets transmitted, 2 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.072/0.159/0.247/0.088 ms, ipg/ewma 0.370/0.225 ms - """ - ] + """, + ], }, { "messages": [ @@ -74,8 +73,8 @@ DATA: list[dict[str, Any]] = [ 2 packets transmitted, 2 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.072/0.159/0.247/0.088 ms, ipg/ewma 0.370/0.225 ms - """ - ] + """, + ], }, ], "expected": {"result": "success"}, @@ -94,8 +93,8 @@ DATA: list[dict[str, Any]] = [ 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.072/0.159/0.247/0.088 ms, ipg/ewma 0.370/0.225 ms - """ - ] + """, + ], }, ], "expected": {"result": "success"}, @@ -115,8 +114,8 @@ DATA: list[dict[str, Any]] = [ 2 packets transmitted, 0 received, 100% packet loss, time 10ms - """ - ] + """, + ], }, { "messages": [ @@ -128,8 +127,8 @@ DATA: list[dict[str, Any]] = [ 2 packets transmitted, 2 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.072/0.159/0.247/0.088 ms, ipg/ewma 0.370/0.225 ms - """ - ] + """, + ], }, ], "expected": {"result": "failure", "messages": ["Connectivity test failed for the following source-destination pairs: [('10.0.0.5', '10.0.0.11')]"]}, @@ -149,8 +148,8 @@ DATA: list[dict[str, Any]] = [ 2 packets transmitted, 0 received, 100% packet loss, time 10ms - """ - ] + """, + ], }, { "messages": [ @@ -162,8 +161,8 @@ DATA: list[dict[str, Any]] = [ 2 packets transmitted, 2 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.072/0.159/0.247/0.088 ms, ipg/ewma 0.370/0.225 ms - """ - ] + """, + ], }, ], "expected": {"result": "failure", "messages": ["Connectivity test failed for the following source-destination pairs: [('Management0', '10.0.0.11')]"]}, @@ -175,7 +174,7 @@ DATA: list[dict[str, Any]] = [ "neighbors": [ {"port": "Ethernet1", "neighbor_device": "DC1-SPINE1", "neighbor_port": "Ethernet1"}, {"port": "Ethernet2", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"}, - ] + ], }, "eos_data": [ { @@ -192,8 +191,8 @@ DATA: list[dict[str, Any]] = [ "interfaceId_v2": "Ethernet1", "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet1", }, - } - ] + }, + ], }, "Ethernet2": { "lldpNeighborInfo": [ @@ -207,11 +206,53 @@ DATA: list[dict[str, Any]] = [ "interfaceId_v2": "Ethernet1", "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet2", }, - } - ] + }, + ], }, - } - } + }, + }, + ], + "expected": {"result": "success"}, + }, + { + "name": "success-multiple-neighbors", + "test": VerifyLLDPNeighbors, + "inputs": { + "neighbors": [ + {"port": "Ethernet1", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"}, + ], + }, + "eos_data": [ + { + "lldpNeighbors": { + "Ethernet1": { + "lldpNeighborInfo": [ + { + "chassisIdType": "macAddress", + "chassisId": "001c.73a0.fc18", + "systemName": "DC1-SPINE1", + "neighborInterfaceInfo": { + "interfaceIdType": "interfaceName", + "interfaceId": '"Ethernet1"', + "interfaceId_v2": "Ethernet1", + "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet1", + }, + }, + { + "chassisIdType": "macAddress", + "chassisId": "001c.73f7.d138", + "systemName": "DC1-SPINE2", + "neighborInterfaceInfo": { + "interfaceIdType": "interfaceName", + "interfaceId": '"Ethernet1"', + "interfaceId_v2": "Ethernet1", + "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet2", + }, + }, + ], + }, + }, + }, ], "expected": {"result": "success"}, }, @@ -222,7 +263,7 @@ DATA: list[dict[str, Any]] = [ "neighbors": [ {"port": "Ethernet1", "neighbor_device": "DC1-SPINE1", "neighbor_port": "Ethernet1"}, {"port": "Ethernet2", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"}, - ] + ], }, "eos_data": [ { @@ -239,13 +280,13 @@ DATA: list[dict[str, Any]] = [ "interfaceId_v2": "Ethernet1", "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet1", }, - } - ] + }, + ], }, - } - } + }, + }, ], - "expected": {"result": "failure", "messages": ["The following port(s) have issues: {'port_not_configured': ['Ethernet2']}"]}, + "expected": {"result": "failure", "messages": ["Port(s) not configured:\n Ethernet2"]}, }, { "name": "failure-no-neighbor", @@ -254,7 +295,7 @@ DATA: list[dict[str, Any]] = [ "neighbors": [ {"port": "Ethernet1", "neighbor_device": "DC1-SPINE1", "neighbor_port": "Ethernet1"}, {"port": "Ethernet2", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"}, - ] + ], }, "eos_data": [ { @@ -271,14 +312,14 @@ DATA: list[dict[str, Any]] = [ "interfaceId_v2": "Ethernet1", "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet1", }, - } - ] + }, + ], }, "Ethernet2": {"lldpNeighborInfo": []}, - } - } + }, + }, ], - "expected": {"result": "failure", "messages": ["The following port(s) have issues: {'no_lldp_neighbor': ['Ethernet2']}"]}, + "expected": {"result": "failure", "messages": ["No LLDP neighbor(s) on port(s):\n Ethernet2"]}, }, { "name": "failure-wrong-neighbor", @@ -287,7 +328,7 @@ DATA: list[dict[str, Any]] = [ "neighbors": [ {"port": "Ethernet1", "neighbor_device": "DC1-SPINE1", "neighbor_port": "Ethernet1"}, {"port": "Ethernet2", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"}, - ] + ], }, "eos_data": [ { @@ -304,8 +345,8 @@ DATA: list[dict[str, Any]] = [ "interfaceId_v2": "Ethernet1", "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet1", }, - } - ] + }, + ], }, "Ethernet2": { "lldpNeighborInfo": [ @@ -319,13 +360,13 @@ DATA: list[dict[str, Any]] = [ "interfaceId_v2": "Ethernet2", "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet2", }, - } - ] + }, + ], }, - } - } + }, + }, ], - "expected": {"result": "failure", "messages": ["The following port(s) have issues: {'wrong_lldp_neighbor': ['Ethernet2']}"]}, + "expected": {"result": "failure", "messages": ["Wrong LLDP neighbor(s) on port(s):\n Ethernet2\n DC1-SPINE2_Ethernet2"]}, }, { "name": "failure-multiple", @@ -335,7 +376,7 @@ DATA: list[dict[str, Any]] = [ {"port": "Ethernet1", "neighbor_device": "DC1-SPINE1", "neighbor_port": "Ethernet1"}, {"port": "Ethernet2", "neighbor_device": "DC1-SPINE2", "neighbor_port": "Ethernet1"}, {"port": "Ethernet3", "neighbor_device": "DC1-SPINE3", "neighbor_port": "Ethernet1"}, - ] + ], }, "eos_data": [ { @@ -352,18 +393,62 @@ DATA: list[dict[str, Any]] = [ "interfaceId_v2": "Ethernet2", "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet1", }, - } - ] + }, + ], }, "Ethernet2": {"lldpNeighborInfo": []}, - } - } + }, + }, ], "expected": { "result": "failure", "messages": [ - "The following port(s) have issues: {'wrong_lldp_neighbor': ['Ethernet1'], 'no_lldp_neighbor': ['Ethernet2'], 'port_not_configured': ['Ethernet3']}" + "Wrong LLDP neighbor(s) on port(s):\n Ethernet1\n DC1-SPINE1_Ethernet2\n" + "No LLDP neighbor(s) on port(s):\n Ethernet2\n" + "Port(s) not configured:\n Ethernet3" ], }, }, + { + "name": "failure-multiple-neighbors", + "test": VerifyLLDPNeighbors, + "inputs": { + "neighbors": [ + {"port": "Ethernet1", "neighbor_device": "DC1-SPINE3", "neighbor_port": "Ethernet1"}, + ], + }, + "eos_data": [ + { + "lldpNeighbors": { + "Ethernet1": { + "lldpNeighborInfo": [ + { + "chassisIdType": "macAddress", + "chassisId": "001c.73a0.fc18", + "systemName": "DC1-SPINE1", + "neighborInterfaceInfo": { + "interfaceIdType": "interfaceName", + "interfaceId": '"Ethernet1"', + "interfaceId_v2": "Ethernet1", + "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet1", + }, + }, + { + "chassisIdType": "macAddress", + "chassisId": "001c.73f7.d138", + "systemName": "DC1-SPINE2", + "neighborInterfaceInfo": { + "interfaceIdType": "interfaceName", + "interfaceId": '"Ethernet1"', + "interfaceId_v2": "Ethernet1", + "interfaceDescription": "P2P_LINK_TO_DC1-LEAF1A_Ethernet2", + }, + }, + ], + }, + }, + }, + ], + "expected": {"result": "failure", "messages": ["Wrong LLDP neighbor(s) on port(s):\n Ethernet1\n DC1-SPINE1_Ethernet1\n DC1-SPINE2_Ethernet1"]}, + }, ] diff --git a/tests/units/anta_tests/test_field_notices.py b/tests/units/anta_tests/test_field_notices.py index 7c17f22..66e7801 100644 --- a/tests/units/anta_tests/test_field_notices.py +++ b/tests/units/anta_tests/test_field_notices.py @@ -1,7 +1,8 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Test inputs for anta.tests.field_notices""" +"""Test inputs for anta.tests.field_notices.""" + from __future__ import annotations from typing import Any @@ -22,7 +23,7 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "Aboot", "version": "Aboot-veos-8.0.0-3255441"}], }, - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -39,10 +40,13 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "Aboot", "version": "Aboot-veos-4.0.1-3255441"}], }, - } + }, ], "inputs": None, - "expected": {"result": "failure", "messages": ["device is running incorrect version of aboot (4.0.1)"]}, + "expected": { + "result": "failure", + "messages": ["device is running incorrect version of aboot (4.0.1)"], + }, }, { "name": "failure-4.1", @@ -56,10 +60,13 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "Aboot", "version": "Aboot-veos-4.1.0-3255441"}], }, - } + }, ], "inputs": None, - "expected": {"result": "failure", "messages": ["device is running incorrect version of aboot (4.1.0)"]}, + "expected": { + "result": "failure", + "messages": ["device is running incorrect version of aboot (4.1.0)"], + }, }, { "name": "failure-6.0", @@ -73,10 +80,13 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "Aboot", "version": "Aboot-veos-6.0.1-3255441"}], }, - } + }, ], "inputs": None, - "expected": {"result": "failure", "messages": ["device is running incorrect version of aboot (6.0.1)"]}, + "expected": { + "result": "failure", + "messages": ["device is running incorrect version of aboot (6.0.1)"], + }, }, { "name": "failure-6.1", @@ -90,10 +100,13 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "Aboot", "version": "Aboot-veos-6.1.1-3255441"}], }, - } + }, ], "inputs": None, - "expected": {"result": "failure", "messages": ["device is running incorrect version of aboot (6.1.1)"]}, + "expected": { + "result": "failure", + "messages": ["device is running incorrect version of aboot (6.1.1)"], + }, }, { "name": "skipped-model", @@ -107,10 +120,13 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "Aboot", "version": "Aboot-veos-8.0.0-3255441"}], }, - } + }, ], "inputs": None, - "expected": {"result": "skipped", "messages": ["device is not impacted by FN044"]}, + "expected": { + "result": "skipped", + "messages": ["device is not impacted by FN044"], + }, }, { "name": "success-JPE", @@ -123,7 +139,7 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "7"}], }, - } + }, ], "inputs": None, "expected": {"result": "success", "messages": ["FN72 is mitigated"]}, @@ -139,7 +155,7 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "7"}], }, - } + }, ], "inputs": None, "expected": {"result": "success", "messages": ["FN72 is mitigated"]}, @@ -155,7 +171,7 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "7"}], }, - } + }, ], "inputs": None, "expected": {"result": "success", "messages": ["FN72 is mitigated"]}, @@ -171,7 +187,7 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "7"}], }, - } + }, ], "inputs": None, "expected": {"result": "success", "messages": ["FN72 is mitigated"]}, @@ -187,7 +203,7 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "7"}], }, - } + }, ], "inputs": None, "expected": {"result": "skipped", "messages": ["Device not exposed"]}, @@ -203,10 +219,13 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "5"}], }, - } + }, ], "inputs": None, - "expected": {"result": "skipped", "messages": ["Platform is not impacted by FN072"]}, + "expected": { + "result": "skipped", + "messages": ["Platform is not impacted by FN072"], + }, }, { "name": "skipped-range-JPE", @@ -219,7 +238,39 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "5"}], }, - } + }, + ], + "inputs": None, + "expected": {"result": "skipped", "messages": ["Device not exposed"]}, + }, + { + "name": "skipped-range-K-JPE", + "test": VerifyFieldNotice72Resolution, + "eos_data": [ + { + "modelName": "DCS-7280SR3K-48YC8", + "serialNumber": "JPE2134000", + "details": { + "deviations": [], + "components": [{"name": "FixedSystemvrm1", "version": "5"}], + }, + }, + ], + "inputs": None, + "expected": {"result": "skipped", "messages": ["Device not exposed"]}, + }, + { + "name": "skipped-range-JAS", + "test": VerifyFieldNotice72Resolution, + "eos_data": [ + { + "modelName": "DCS-7280SR3-48YC8", + "serialNumber": "JAS2041000", + "details": { + "deviations": [], + "components": [{"name": "FixedSystemvrm1", "version": "5"}], + }, + }, ], "inputs": None, "expected": {"result": "skipped", "messages": ["Device not exposed"]}, @@ -235,7 +286,7 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "5"}], }, - } + }, ], "inputs": None, "expected": {"result": "skipped", "messages": ["Device not exposed"]}, @@ -251,7 +302,7 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "5"}], }, - } + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["Device is exposed to FN72"]}, @@ -267,7 +318,7 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm1", "version": "5"}], }, - } + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["Device is exposed to FN72"]}, @@ -283,9 +334,12 @@ DATA: list[dict[str, Any]] = [ "deviations": [], "components": [{"name": "FixedSystemvrm2", "version": "5"}], }, - } + }, ], "inputs": None, - "expected": {"result": "error", "messages": ["Error in running test - FixedSystemvrm1 not found"]}, + "expected": { + "result": "error", + "messages": ["Error in running test - FixedSystemvrm1 not found"], + }, }, ] diff --git a/tests/units/anta_tests/test_greent.py b/tests/units/anta_tests/test_greent.py index 65789a2..2c48301 100644 --- a/tests/units/anta_tests/test_greent.py +++ b/tests/units/anta_tests/test_greent.py @@ -1,12 +1,14 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Data for testing anta.tests.configuration""" +"""Data for testing anta.tests.configuration.""" + from __future__ import annotations from typing import Any from anta.tests.greent import VerifyGreenT, VerifyGreenTCounters +from tests.lib.anta import test # noqa: F401; pylint: disable=W0611 DATA: list[dict[str, Any]] = [ { @@ -21,12 +23,19 @@ DATA: list[dict[str, Any]] = [ "test": VerifyGreenTCounters, "eos_data": [{"sampleRcvd": 0, "sampleDiscarded": 0, "multiDstSampleRcvd": 0, "grePktSent": 0, "sampleSent": 0}], "inputs": None, - "expected": {"result": "failure"}, + "expected": {"result": "failure", "messages": ["GreenT counters are not incremented"]}, }, { "name": "success", "test": VerifyGreenT, - "eos_data": [{"sampleRcvd": 0, "sampleDiscarded": 0, "multiDstSampleRcvd": 0, "grePktSent": 1, "sampleSent": 0}], + "eos_data": [ + { + "profiles": { + "default": {"interfaces": [], "appliedInterfaces": [], "samplePolicy": "default", "failures": {}, "appliedInterfaces6": [], "failures6": {}}, + "testProfile": {"interfaces": [], "appliedInterfaces": [], "samplePolicy": "default", "failures": {}, "appliedInterfaces6": [], "failures6": {}}, + }, + }, + ], "inputs": None, "expected": {"result": "success"}, }, @@ -37,11 +46,10 @@ DATA: list[dict[str, Any]] = [ { "profiles": { "default": {"interfaces": [], "appliedInterfaces": [], "samplePolicy": "default", "failures": {}, "appliedInterfaces6": [], "failures6": {}}, - "testProfile": {"interfaces": [], "appliedInterfaces": [], "samplePolicy": "default", "failures": {}, "appliedInterfaces6": [], "failures6": {}}, - } - } + }, + }, ], "inputs": None, - "expected": {"result": "failure"}, + "expected": {"result": "failure", "messages": ["No GreenT policy is created"]}, }, ] diff --git a/tests/units/anta_tests/test_hardware.py b/tests/units/anta_tests/test_hardware.py index 5279d89..e601c68 100644 --- a/tests/units/anta_tests/test_hardware.py +++ b/tests/units/anta_tests/test_hardware.py @@ -1,7 +1,8 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Test inputs for anta.tests.hardware""" +"""Test inputs for anta.tests.hardware.""" + from __future__ import annotations from typing import Any @@ -26,8 +27,8 @@ DATA: list[dict[str, Any]] = [ "xcvrSlots": { "1": {"mfgName": "Arista Networks", "modelName": "QSFP-100G-DR", "serialNum": "XKT203501340", "hardwareRev": "21"}, "2": {"mfgName": "Arista Networks", "modelName": "QSFP-100G-DR", "serialNum": "XKT203501337", "hardwareRev": "21"}, - } - } + }, + }, ], "inputs": {"manufacturers": ["Arista Networks"]}, "expected": {"result": "success"}, @@ -40,8 +41,8 @@ DATA: list[dict[str, Any]] = [ "xcvrSlots": { "1": {"mfgName": "Arista Networks", "modelName": "QSFP-100G-DR", "serialNum": "XKT203501340", "hardwareRev": "21"}, "2": {"mfgName": "Arista Networks", "modelName": "QSFP-100G-DR", "serialNum": "XKT203501337", "hardwareRev": "21"}, - } - } + }, + }, ], "inputs": {"manufacturers": ["Arista"]}, "expected": {"result": "failure", "messages": ["Some transceivers are from unapproved manufacturers: {'1': 'Arista Networks', '2': 'Arista Networks'}"]}, @@ -57,7 +58,7 @@ DATA: list[dict[str, Any]] = [ "shutdownOnOverheat": "True", "systemStatus": "temperatureOk", "recoveryModeOnOverheat": "recoveryModeNA", - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -73,7 +74,7 @@ DATA: list[dict[str, Any]] = [ "shutdownOnOverheat": "True", "systemStatus": "temperatureKO", "recoveryModeOnOverheat": "recoveryModeNA", - } + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["Device temperature exceeds acceptable limits. Current system status: 'temperatureKO'"]}, @@ -100,10 +101,10 @@ DATA: list[dict[str, Any]] = [ "pidDriverCount": 0, "isPidDriver": False, "name": "DomTemperatureSensor54", - } + }, ], "cardSlots": [], - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -130,10 +131,10 @@ DATA: list[dict[str, Any]] = [ "pidDriverCount": 0, "isPidDriver": False, "name": "DomTemperatureSensor54", - } + }, ], "cardSlots": [], - } + }, ], "inputs": None, "expected": { @@ -141,7 +142,7 @@ DATA: list[dict[str, Any]] = [ "messages": [ "The following sensors are operating outside the acceptable temperature range or have raised alerts: " "{'DomTemperatureSensor54': " - "{'hwStatus': 'ko', 'alertCount': 0}}" + "{'hwStatus': 'ko', 'alertCount': 0}}", ], }, }, @@ -167,10 +168,10 @@ DATA: list[dict[str, Any]] = [ "pidDriverCount": 0, "isPidDriver": False, "name": "DomTemperatureSensor54", - } + }, ], "cardSlots": [], - } + }, ], "inputs": None, "expected": { @@ -178,7 +179,7 @@ DATA: list[dict[str, Any]] = [ "messages": [ "The following sensors are operating outside the acceptable temperature range or have raised alerts: " "{'DomTemperatureSensor54': " - "{'hwStatus': 'ok', 'alertCount': 1}}" + "{'hwStatus': 'ok', 'alertCount': 1}}", ], }, }, @@ -200,7 +201,7 @@ DATA: list[dict[str, Any]] = [ "currentZones": 1, "configuredZones": 0, "systemStatus": "coolingOk", - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -223,7 +224,7 @@ DATA: list[dict[str, Any]] = [ "currentZones": 1, "configuredZones": 0, "systemStatus": "coolingKo", - } + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["Device system cooling is not OK: 'coolingKo'"]}, @@ -254,7 +255,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": True, "speedStable": True, "label": "PowerSupply1/1", - } + }, ], "speed": 30, "label": "PowerSupply1", @@ -272,7 +273,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": True, "speedStable": True, "label": "PowerSupply2/1", - } + }, ], "speed": 30, "label": "PowerSupply2", @@ -292,7 +293,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "1/1", - } + }, ], "speed": 30, "label": "1", @@ -310,7 +311,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "2/1", - } + }, ], "speed": 30, "label": "2", @@ -328,7 +329,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "3/1", - } + }, ], "speed": 30, "label": "3", @@ -346,7 +347,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "4/1", - } + }, ], "speed": 30, "label": "4", @@ -356,7 +357,7 @@ DATA: list[dict[str, Any]] = [ "currentZones": 1, "configuredZones": 0, "systemStatus": "coolingOk", - } + }, ], "inputs": {"states": ["ok"]}, "expected": {"result": "success"}, @@ -387,7 +388,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": True, "speedStable": True, "label": "PowerSupply1/1", - } + }, ], "speed": 30, "label": "PowerSupply1", @@ -405,7 +406,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": True, "speedStable": True, "label": "PowerSupply2/1", - } + }, ], "speed": 30, "label": "PowerSupply2", @@ -425,7 +426,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "1/1", - } + }, ], "speed": 30, "label": "1", @@ -443,7 +444,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "2/1", - } + }, ], "speed": 30, "label": "2", @@ -461,7 +462,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "3/1", - } + }, ], "speed": 30, "label": "3", @@ -479,7 +480,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "4/1", - } + }, ], "speed": 30, "label": "4", @@ -489,7 +490,7 @@ DATA: list[dict[str, Any]] = [ "currentZones": 1, "configuredZones": 0, "systemStatus": "coolingOk", - } + }, ], "inputs": {"states": ["ok", "Not Inserted"]}, "expected": {"result": "success"}, @@ -520,7 +521,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": True, "speedStable": True, "label": "PowerSupply1/1", - } + }, ], "speed": 30, "label": "PowerSupply1", @@ -538,7 +539,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": True, "speedStable": True, "label": "PowerSupply2/1", - } + }, ], "speed": 30, "label": "PowerSupply2", @@ -558,7 +559,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "1/1", - } + }, ], "speed": 30, "label": "1", @@ -576,7 +577,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "2/1", - } + }, ], "speed": 30, "label": "2", @@ -594,7 +595,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "3/1", - } + }, ], "speed": 30, "label": "3", @@ -612,7 +613,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "4/1", - } + }, ], "speed": 30, "label": "4", @@ -622,7 +623,7 @@ DATA: list[dict[str, Any]] = [ "currentZones": 1, "configuredZones": 0, "systemStatus": "CoolingKo", - } + }, ], "inputs": {"states": ["ok", "Not Inserted"]}, "expected": {"result": "failure", "messages": ["Fan 1/1 on Fan Tray 1 is: 'down'"]}, @@ -653,7 +654,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": True, "speedStable": True, "label": "PowerSupply1/1", - } + }, ], "speed": 30, "label": "PowerSupply1", @@ -671,7 +672,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": True, "speedStable": True, "label": "PowerSupply2/1", - } + }, ], "speed": 30, "label": "PowerSupply2", @@ -691,7 +692,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "1/1", - } + }, ], "speed": 30, "label": "1", @@ -709,7 +710,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "2/1", - } + }, ], "speed": 30, "label": "2", @@ -727,7 +728,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "3/1", - } + }, ], "speed": 30, "label": "3", @@ -745,7 +746,7 @@ DATA: list[dict[str, Any]] = [ "speedHwOverride": False, "speedStable": True, "label": "4/1", - } + }, ], "speed": 30, "label": "4", @@ -755,7 +756,7 @@ DATA: list[dict[str, Any]] = [ "currentZones": 1, "configuredZones": 0, "systemStatus": "CoolingKo", - } + }, ], "inputs": {"states": ["ok", "Not Inserted"]}, "expected": {"result": "failure", "messages": ["Fan PowerSupply1/1 on PowerSupply PowerSupply1 is: 'down'"]}, @@ -801,8 +802,8 @@ DATA: list[dict[str, Any]] = [ "outputCurrent": 9.828125, "managed": True, }, - } - } + }, + }, ], "inputs": {"states": ["ok"]}, "expected": {"result": "success"}, @@ -848,8 +849,8 @@ DATA: list[dict[str, Any]] = [ "outputCurrent": 9.828125, "managed": True, }, - } - } + }, + }, ], "inputs": {"states": ["ok", "Not Inserted"]}, "expected": {"result": "success"}, @@ -895,8 +896,8 @@ DATA: list[dict[str, Any]] = [ "outputCurrent": 9.828125, "managed": True, }, - } - } + }, + }, ], "inputs": {"states": ["ok"]}, "expected": {"result": "failure", "messages": ["The following power supplies status are not in the accepted states list: {'1': {'state': 'powerLoss'}}"]}, diff --git a/tests/units/anta_tests/test_interfaces.py b/tests/units/anta_tests/test_interfaces.py index 5b0d845..58f568f 100644 --- a/tests/units/anta_tests/test_interfaces.py +++ b/tests/units/anta_tests/test_interfaces.py @@ -1,7 +1,9 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Test inputs for anta.tests.hardware""" +"""Test inputs for anta.tests.hardware.""" + +# pylint: disable=C0302 from __future__ import annotations from typing import Any @@ -30,25 +32,772 @@ DATA: list[dict[str, Any]] = [ "name": "success", "test": VerifyInterfaceUtilization, "eos_data": [ - """Port Name Intvl In Mbps % In Kpps Out Mbps % Out Kpps -Et1 5:00 0.0 0.0% 0 0.0 0.0% 0 -Et4 5:00 0.0 0.0% 0 0.0 0.0% 0 -""" + { + "interfaces": { + "Ethernet1/1": { + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "interval": 300, + "inBpsRate": 2242.2497205060313, + "inPktsRate": 0.00028663359326985426, + "inPpsRate": 3.9005388262031966, + "outBpsRate": 0.0, + "outPktsRate": 0.0, + "outPpsRate": 0.0, + "lastUpdateTimestamp": 1710253727.138605, + }, + "Port-Channel31": { + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "interval": 300, + "inBpsRate": 1862.4876594267096, + "inPktsRate": 0.00011473185873493155, + "inPpsRate": 2.7009344704495084, + "outBpsRate": 1758.0044570479704, + "outPktsRate": 0.00010844978034772172, + "outPpsRate": 2.5686946869154013, + "lastUpdateTimestamp": 1710253726.4029949, + }, + } + }, + { + "interfaces": { + "Ethernet1/1": { + "name": "Ethernet1/1", + "forwardingModel": "routed", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "ethernet", + "interfaceAddress": [ + { + "primaryIp": {"address": "10.255.255.1", "maskLen": 31}, + "secondaryIps": {}, + "secondaryIpsOrderedList": [], + "virtualIp": {"address": "0.0.0.0", "maskLen": 0}, + "virtualSecondaryIps": {}, + "virtualSecondaryIpsOrderedList": [], + "broadcastAddress": "255.255.255.255", + "dhcp": False, + } + ], + "physicalAddress": "aa:c1:ab:7e:76:36", + "burnedInAddress": "aa:c1:ab:7e:76:36", + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "bandwidth": 1000000000, + "mtu": 1500, + "l3MtuConfigured": True, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234511.3085763, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 2240.0023281094, + "inPktsRate": 3.8978070399448654, + "outBitsRate": 0.0, + "outPktsRate": 0.0, + }, + "interfaceCounters": { + "inOctets": 5413008, + "inUcastPkts": 74693, + "inMulticastPkts": 643, + "inBroadcastPkts": 1, + "inDiscards": 0, + "inTotalPkts": 75337, + "outOctets": 0, + "outUcastPkts": 0, + "outMulticastPkts": 0, + "outBroadcastPkts": 0, + "outDiscards": 0, + "outTotalPkts": 0, + "linkStatusChanges": 2, + "totalInErrors": 0, + "inputErrorsDetail": {"runtFrames": 0, "giantFrames": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0, "rxPause": 0}, + "totalOutErrors": 0, + "outputErrorsDetail": {"collisions": 0, "lateCollisions": 0, "deferredTransmissions": 0, "txPause": 0}, + "counterRefreshTime": 1710253760.6489396, + }, + "duplex": "duplexFull", + "autoNegotiate": "unknown", + "loopbackMode": "loopbackNone", + "lanes": 0, + }, + "Port-Channel31": { + "name": "Port-Channel31", + "forwardingModel": "bridged", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "portChannel", + "interfaceAddress": [], + "physicalAddress": "aa:c1:ab:72:58:40", + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "bandwidth": 2000000000, + "mtu": 9214, + "l3MtuConfigured": False, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234510.1133935, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 1854.287898883752, + "inPktsRate": 2.6902775246495665, + "outBitsRate": 1749.1141130864632, + "outPktsRate": 2.5565618978302362, + }, + "interfaceCounters": { + "inOctets": 4475556, + "inUcastPkts": 48949, + "inMulticastPkts": 2579, + "inBroadcastPkts": 2, + "inDiscards": 0, + "inTotalPkts": 51530, + "outOctets": 4230011, + "outUcastPkts": 48982, + "outMulticastPkts": 6, + "outBroadcastPkts": 2, + "outDiscards": 0, + "outTotalPkts": 48990, + "linkStatusChanges": 2, + "totalInErrors": 0, + "totalOutErrors": 0, + "counterRefreshTime": 1710253760.6500373, + }, + "memberInterfaces": { + "Ethernet3/1": {"bandwidth": 1000000000, "duplex": "duplexFull"}, + "Ethernet4/1": {"bandwidth": 1000000000, "duplex": "duplexFull"}, + }, + "fallbackEnabled": False, + "fallbackEnabledType": "fallbackNone", + }, + } + }, ], - "inputs": None, + "inputs": {"threshold": 70.0}, + "expected": {"result": "success"}, + }, + { + "name": "success-ignored-interface", + "test": VerifyInterfaceUtilization, + "eos_data": [ + { + "interfaces": { + "Ethernet1/1": { + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "interval": 300, + "inBpsRate": 2242.2497205060313, + "inPktsRate": 0.00028663359326985426, + "inPpsRate": 3.9005388262031966, + "outBpsRate": 0.0, + "outPktsRate": 0.0, + "outPpsRate": 0.0, + "lastUpdateTimestamp": 1710253727.138605, + }, + "Port-Channel31": { + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "interval": 300, + "inBpsRate": 1862.4876594267096, + "inPktsRate": 0.00011473185873493155, + "inPpsRate": 2.7009344704495084, + "outBpsRate": 1758.0044570479704, + "outPktsRate": 0.00010844978034772172, + "outPpsRate": 2.5686946869154013, + "lastUpdateTimestamp": 1710253726.4029949, + }, + "Port-Channel51": { + "description": "dc1-leaf1-server1", + "interval": 300, + "inBpsRate": 0.0023680437493116147, + "inPpsRate": 2.3125427239371238e-06, + "outBpsRate": 0.0, + "outPpsRate": 0.0, + "lastUpdateTimestamp": 1712928643.7805147, + }, + }, + }, + { + "interfaces": { + "Ethernet1/1": { + "name": "Ethernet1/1", + "forwardingModel": "routed", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "ethernet", + "interfaceAddress": [ + { + "primaryIp": {"address": "10.255.255.1", "maskLen": 31}, + "secondaryIps": {}, + "secondaryIpsOrderedList": [], + "virtualIp": {"address": "0.0.0.0", "maskLen": 0}, + "virtualSecondaryIps": {}, + "virtualSecondaryIpsOrderedList": [], + "broadcastAddress": "255.255.255.255", + "dhcp": False, + } + ], + "physicalAddress": "aa:c1:ab:7e:76:36", + "burnedInAddress": "aa:c1:ab:7e:76:36", + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "bandwidth": 1000000000, + "mtu": 1500, + "l3MtuConfigured": True, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234511.3085763, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 2240.0023281094, + "inPktsRate": 3.8978070399448654, + "outBitsRate": 0.0, + "outPktsRate": 0.0, + }, + "interfaceCounters": { + "inOctets": 5413008, + "inUcastPkts": 74693, + "inMulticastPkts": 643, + "inBroadcastPkts": 1, + "inDiscards": 0, + "inTotalPkts": 75337, + "outOctets": 0, + "outUcastPkts": 0, + "outMulticastPkts": 0, + "outBroadcastPkts": 0, + "outDiscards": 0, + "outTotalPkts": 0, + "linkStatusChanges": 2, + "totalInErrors": 0, + "inputErrorsDetail": {"runtFrames": 0, "giantFrames": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0, "rxPause": 0}, + "totalOutErrors": 0, + "outputErrorsDetail": {"collisions": 0, "lateCollisions": 0, "deferredTransmissions": 0, "txPause": 0}, + "counterRefreshTime": 1710253760.6489396, + }, + "duplex": "duplexFull", + "autoNegotiate": "unknown", + "loopbackMode": "loopbackNone", + "lanes": 0, + }, + "Port-Channel31": { + "name": "Port-Channel31", + "forwardingModel": "bridged", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "portChannel", + "interfaceAddress": [], + "physicalAddress": "aa:c1:ab:72:58:40", + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "bandwidth": 2000000000, + "mtu": 9214, + "l3MtuConfigured": False, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234510.1133935, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 1854.287898883752, + "inPktsRate": 2.6902775246495665, + "outBitsRate": 1749.1141130864632, + "outPktsRate": 2.5565618978302362, + }, + "interfaceCounters": { + "inOctets": 4475556, + "inUcastPkts": 48949, + "inMulticastPkts": 2579, + "inBroadcastPkts": 2, + "inDiscards": 0, + "inTotalPkts": 51530, + "outOctets": 4230011, + "outUcastPkts": 48982, + "outMulticastPkts": 6, + "outBroadcastPkts": 2, + "outDiscards": 0, + "outTotalPkts": 48990, + "linkStatusChanges": 2, + "totalInErrors": 0, + "totalOutErrors": 0, + "counterRefreshTime": 1710253760.6500373, + }, + "memberInterfaces": { + "Ethernet3/1": {"bandwidth": 1000000000, "duplex": "duplexFull"}, + "Ethernet4/1": {"bandwidth": 1000000000, "duplex": "duplexFull"}, + }, + "fallbackEnabled": False, + "fallbackEnabledType": "fallbackNone", + }, + "Port-Channel51": { + "name": "Port-Channel51", + "forwardingModel": "bridged", + "lineProtocolStatus": "lowerLayerDown", + "interfaceStatus": "notconnect", + "hardware": "portChannel", + "interfaceAddress": [], + "physicalAddress": "00:00:00:00:00:00", + "description": "dc1-leaf1-server1", + "bandwidth": 0, + "mtu": 9214, + "l3MtuConfigured": False, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1712925798.5035574, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 0.00839301770723288, + "inPktsRate": 8.19630635471961e-06, + "outBitsRate": 0.0, + "outPktsRate": 0.0, + }, + "interfaceCounters": { + "inOctets": 329344, + "inUcastPkts": 0, + "inMulticastPkts": 2573, + "inBroadcastPkts": 0, + "inDiscards": 0, + "inTotalPkts": 2573, + "outOctets": 0, + "outUcastPkts": 0, + "outMulticastPkts": 0, + "outBroadcastPkts": 0, + "outDiscards": 0, + "outTotalPkts": 0, + "linkStatusChanges": 3, + "totalInErrors": 0, + "totalOutErrors": 0, + "counterRefreshTime": 1712928265.9816775, + }, + "memberInterfaces": {}, + "fallbackEnabled": False, + "fallbackEnabledType": "fallbackNone", + }, + } + }, + ], + "inputs": {"threshold": 70.0}, "expected": {"result": "success"}, }, { "name": "failure", "test": VerifyInterfaceUtilization, "eos_data": [ - """Port Name Intvl In Mbps % In Kpps Out Mbps % Out Kpps -Et1 5:00 0.0 0.0% 0 0.0 80.0% 0 -Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 -""" + { + "interfaces": { + "Ethernet1/1": { + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "interval": 300, + "inBpsRate": 100000000.0, + "inPktsRate": 0.00028663359326985426, + "inPpsRate": 3.9005388262031966, + "outBpsRate": 0.0, + "outPktsRate": 0.0, + "outPpsRate": 0.0, + "lastUpdateTimestamp": 1710253727.138605, + }, + "Port-Channel31": { + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "interval": 300, + "inBpsRate": 1862.4876594267096, + "inPktsRate": 0.00011473185873493155, + "inPpsRate": 2.7009344704495084, + "outBpsRate": 100000000.0, + "outPktsRate": 0.00010844978034772172, + "outPpsRate": 2.5686946869154013, + "lastUpdateTimestamp": 1710253726.4029949, + }, + } + }, + { + "interfaces": { + "Ethernet1/1": { + "name": "Ethernet1/1", + "forwardingModel": "routed", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "ethernet", + "interfaceAddress": [ + { + "primaryIp": {"address": "10.255.255.1", "maskLen": 31}, + "secondaryIps": {}, + "secondaryIpsOrderedList": [], + "virtualIp": {"address": "0.0.0.0", "maskLen": 0}, + "virtualSecondaryIps": {}, + "virtualSecondaryIpsOrderedList": [], + "broadcastAddress": "255.255.255.255", + "dhcp": False, + } + ], + "physicalAddress": "aa:c1:ab:7e:76:36", + "burnedInAddress": "aa:c1:ab:7e:76:36", + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "bandwidth": 1000000000, + "mtu": 1500, + "l3MtuConfigured": True, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234511.3085763, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 2240.0023281094, + "inPktsRate": 3.8978070399448654, + "outBitsRate": 0.0, + "outPktsRate": 0.0, + }, + "interfaceCounters": { + "inOctets": 5413008, + "inUcastPkts": 74693, + "inMulticastPkts": 643, + "inBroadcastPkts": 1, + "inDiscards": 0, + "inTotalPkts": 75337, + "outOctets": 0, + "outUcastPkts": 0, + "outMulticastPkts": 0, + "outBroadcastPkts": 0, + "outDiscards": 0, + "outTotalPkts": 0, + "linkStatusChanges": 2, + "totalInErrors": 0, + "inputErrorsDetail": {"runtFrames": 0, "giantFrames": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0, "rxPause": 0}, + "totalOutErrors": 0, + "outputErrorsDetail": {"collisions": 0, "lateCollisions": 0, "deferredTransmissions": 0, "txPause": 0}, + "counterRefreshTime": 1710253760.6489396, + }, + "duplex": "duplexFull", + "autoNegotiate": "unknown", + "loopbackMode": "loopbackNone", + "lanes": 0, + }, + "Port-Channel31": { + "name": "Port-Channel31", + "forwardingModel": "bridged", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "portChannel", + "interfaceAddress": [], + "physicalAddress": "aa:c1:ab:72:58:40", + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "bandwidth": 2000000000, + "mtu": 9214, + "l3MtuConfigured": False, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234510.1133935, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 1854.287898883752, + "inPktsRate": 2.6902775246495665, + "outBitsRate": 1749.1141130864632, + "outPktsRate": 2.5565618978302362, + }, + "interfaceCounters": { + "inOctets": 4475556, + "inUcastPkts": 48949, + "inMulticastPkts": 2579, + "inBroadcastPkts": 2, + "inDiscards": 0, + "inTotalPkts": 51530, + "outOctets": 4230011, + "outUcastPkts": 48982, + "outMulticastPkts": 6, + "outBroadcastPkts": 2, + "outDiscards": 0, + "outTotalPkts": 48990, + "linkStatusChanges": 2, + "totalInErrors": 0, + "totalOutErrors": 0, + "counterRefreshTime": 1710253760.6500373, + }, + "memberInterfaces": { + "Ethernet3/1": {"bandwidth": 1000000000, "duplex": "duplexFull"}, + "Ethernet4/1": {"bandwidth": 1000000000, "duplex": "duplexFull"}, + }, + "fallbackEnabled": False, + "fallbackEnabledType": "fallbackNone", + }, + } + }, ], - "inputs": None, - "expected": {"result": "failure", "messages": ["The following interfaces have a usage > 75%: {'Et1': '80.0%', 'Et4': '99.9%'}"]}, + "inputs": {"threshold": 3.0}, + "expected": { + "result": "failure", + "messages": ["The following interfaces have a usage > 3.0%: {'Ethernet1/1': {'inBpsRate': 10.0}, 'Port-Channel31': {'outBpsRate': 5.0}}"], + }, + }, + { + "name": "error-duplex-half", + "test": VerifyInterfaceUtilization, + "eos_data": [ + { + "interfaces": { + "Ethernet1/1": { + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "interval": 300, + "inBpsRate": 2242.2497205060313, + "inPktsRate": 0.00028663359326985426, + "inPpsRate": 3.9005388262031966, + "outBpsRate": 0.0, + "outPktsRate": 0.0, + "outPpsRate": 0.0, + "lastUpdateTimestamp": 1710253727.138605, + }, + "Port-Channel31": { + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "interval": 300, + "inBpsRate": 1862.4876594267096, + "inPktsRate": 0.00011473185873493155, + "inPpsRate": 2.7009344704495084, + "outBpsRate": 1758.0044570479704, + "outPktsRate": 0.00010844978034772172, + "outPpsRate": 2.5686946869154013, + "lastUpdateTimestamp": 1710253726.4029949, + }, + } + }, + { + "interfaces": { + "Ethernet1/1": { + "name": "Ethernet1/1", + "forwardingModel": "routed", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "ethernet", + "interfaceAddress": [ + { + "primaryIp": {"address": "10.255.255.1", "maskLen": 31}, + "secondaryIps": {}, + "secondaryIpsOrderedList": [], + "virtualIp": {"address": "0.0.0.0", "maskLen": 0}, + "virtualSecondaryIps": {}, + "virtualSecondaryIpsOrderedList": [], + "broadcastAddress": "255.255.255.255", + "dhcp": False, + } + ], + "physicalAddress": "aa:c1:ab:7e:76:36", + "burnedInAddress": "aa:c1:ab:7e:76:36", + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "bandwidth": 1000000000, + "mtu": 1500, + "l3MtuConfigured": True, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234511.3085763, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 2240.0023281094, + "inPktsRate": 3.8978070399448654, + "outBitsRate": 0.0, + "outPktsRate": 0.0, + }, + "interfaceCounters": { + "inOctets": 5413008, + "inUcastPkts": 74693, + "inMulticastPkts": 643, + "inBroadcastPkts": 1, + "inDiscards": 0, + "inTotalPkts": 75337, + "outOctets": 0, + "outUcastPkts": 0, + "outMulticastPkts": 0, + "outBroadcastPkts": 0, + "outDiscards": 0, + "outTotalPkts": 0, + "linkStatusChanges": 2, + "totalInErrors": 0, + "inputErrorsDetail": {"runtFrames": 0, "giantFrames": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0, "rxPause": 0}, + "totalOutErrors": 0, + "outputErrorsDetail": {"collisions": 0, "lateCollisions": 0, "deferredTransmissions": 0, "txPause": 0}, + "counterRefreshTime": 1710253760.6489396, + }, + "duplex": "duplexHalf", + "autoNegotiate": "unknown", + "loopbackMode": "loopbackNone", + "lanes": 0, + }, + "Port-Channel31": { + "name": "Port-Channel31", + "forwardingModel": "bridged", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "portChannel", + "interfaceAddress": [], + "physicalAddress": "aa:c1:ab:72:58:40", + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "bandwidth": 2000000000, + "mtu": 9214, + "l3MtuConfigured": False, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234510.1133935, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 1854.287898883752, + "inPktsRate": 2.6902775246495665, + "outBitsRate": 1749.1141130864632, + "outPktsRate": 2.5565618978302362, + }, + "interfaceCounters": { + "inOctets": 4475556, + "inUcastPkts": 48949, + "inMulticastPkts": 2579, + "inBroadcastPkts": 2, + "inDiscards": 0, + "inTotalPkts": 51530, + "outOctets": 4230011, + "outUcastPkts": 48982, + "outMulticastPkts": 6, + "outBroadcastPkts": 2, + "outDiscards": 0, + "outTotalPkts": 48990, + "linkStatusChanges": 2, + "totalInErrors": 0, + "totalOutErrors": 0, + "counterRefreshTime": 1710253760.6500373, + }, + "memberInterfaces": { + "Ethernet3/1": {"bandwidth": 1000000000, "duplex": "duplexFull"}, + "Ethernet4/1": {"bandwidth": 1000000000, "duplex": "duplexFull"}, + }, + "fallbackEnabled": False, + "fallbackEnabledType": "fallbackNone", + }, + } + }, + ], + "inputs": {"threshold": 70.0}, + "expected": { + "result": "error", + "messages": ["Interface Ethernet1/1 or one of its member interfaces is not Full-Duplex. VerifyInterfaceUtilization has not been implemented."], + }, + }, + { + "name": "error-duplex-half-po", + "test": VerifyInterfaceUtilization, + "eos_data": [ + { + "interfaces": { + "Ethernet1/1": { + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "interval": 300, + "inBpsRate": 2242.2497205060313, + "inPktsRate": 0.00028663359326985426, + "inPpsRate": 3.9005388262031966, + "outBpsRate": 0.0, + "outPktsRate": 0.0, + "outPpsRate": 0.0, + "lastUpdateTimestamp": 1710253727.138605, + }, + "Port-Channel31": { + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "interval": 300, + "inBpsRate": 1862.4876594267096, + "inPktsRate": 0.00011473185873493155, + "inPpsRate": 2.7009344704495084, + "outBpsRate": 1758.0044570479704, + "outPktsRate": 0.00010844978034772172, + "outPpsRate": 2.5686946869154013, + "lastUpdateTimestamp": 1710253726.4029949, + }, + } + }, + { + "interfaces": { + "Ethernet1/1": { + "name": "Ethernet1/1", + "forwardingModel": "routed", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "ethernet", + "interfaceAddress": [ + { + "primaryIp": {"address": "10.255.255.1", "maskLen": 31}, + "secondaryIps": {}, + "secondaryIpsOrderedList": [], + "virtualIp": {"address": "0.0.0.0", "maskLen": 0}, + "virtualSecondaryIps": {}, + "virtualSecondaryIpsOrderedList": [], + "broadcastAddress": "255.255.255.255", + "dhcp": False, + } + ], + "physicalAddress": "aa:c1:ab:7e:76:36", + "burnedInAddress": "aa:c1:ab:7e:76:36", + "description": "P2P_LINK_TO_DC1-SPINE1_Ethernet1/1", + "bandwidth": 1000000000, + "mtu": 1500, + "l3MtuConfigured": True, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234511.3085763, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 2240.0023281094, + "inPktsRate": 3.8978070399448654, + "outBitsRate": 0.0, + "outPktsRate": 0.0, + }, + "interfaceCounters": { + "inOctets": 5413008, + "inUcastPkts": 74693, + "inMulticastPkts": 643, + "inBroadcastPkts": 1, + "inDiscards": 0, + "inTotalPkts": 75337, + "outOctets": 0, + "outUcastPkts": 0, + "outMulticastPkts": 0, + "outBroadcastPkts": 0, + "outDiscards": 0, + "outTotalPkts": 0, + "linkStatusChanges": 2, + "totalInErrors": 0, + "inputErrorsDetail": {"runtFrames": 0, "giantFrames": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0, "rxPause": 0}, + "totalOutErrors": 0, + "outputErrorsDetail": {"collisions": 0, "lateCollisions": 0, "deferredTransmissions": 0, "txPause": 0}, + "counterRefreshTime": 1710253760.6489396, + }, + "duplex": "duplexFull", + "autoNegotiate": "unknown", + "loopbackMode": "loopbackNone", + "lanes": 0, + }, + "Port-Channel31": { + "name": "Port-Channel31", + "forwardingModel": "bridged", + "lineProtocolStatus": "up", + "interfaceStatus": "connected", + "hardware": "portChannel", + "interfaceAddress": [], + "physicalAddress": "aa:c1:ab:72:58:40", + "description": "MLAG_PEER_dc1-leaf1b_Po31", + "bandwidth": 2000000000, + "mtu": 9214, + "l3MtuConfigured": False, + "l2Mru": 0, + "lastStatusChangeTimestamp": 1710234510.1133935, + "interfaceStatistics": { + "updateInterval": 300.0, + "inBitsRate": 1854.287898883752, + "inPktsRate": 2.6902775246495665, + "outBitsRate": 1749.1141130864632, + "outPktsRate": 2.5565618978302362, + }, + "interfaceCounters": { + "inOctets": 4475556, + "inUcastPkts": 48949, + "inMulticastPkts": 2579, + "inBroadcastPkts": 2, + "inDiscards": 0, + "inTotalPkts": 51530, + "outOctets": 4230011, + "outUcastPkts": 48982, + "outMulticastPkts": 6, + "outBroadcastPkts": 2, + "outDiscards": 0, + "outTotalPkts": 48990, + "linkStatusChanges": 2, + "totalInErrors": 0, + "totalOutErrors": 0, + "counterRefreshTime": 1710253760.6500373, + }, + "memberInterfaces": { + "Ethernet3/1": {"bandwidth": 1000000000, "duplex": "duplexHalf"}, + "Ethernet4/1": {"bandwidth": 1000000000, "duplex": "duplexFull"}, + }, + "fallbackEnabled": False, + "fallbackEnabledType": "fallbackNone", + }, + } + }, + ], + "inputs": {"threshold": 70.0}, + "expected": { + "result": "error", + "messages": ["Interface Port-Channel31 or one of its member interfaces is not Full-Duplex. VerifyInterfaceUtilization has not been implemented."], + }, }, { "name": "success", @@ -58,8 +807,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "interfaceErrorCounters": { "Ethernet1": {"inErrors": 0, "frameTooLongs": 0, "outErrors": 0, "frameTooShorts": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0}, "Ethernet6": {"inErrors": 0, "frameTooLongs": 0, "outErrors": 0, "frameTooShorts": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0}, - } - } + }, + }, ], "inputs": None, "expected": {"result": "success"}, @@ -72,8 +821,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "interfaceErrorCounters": { "Ethernet1": {"inErrors": 42, "frameTooLongs": 0, "outErrors": 0, "frameTooShorts": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0}, "Ethernet6": {"inErrors": 0, "frameTooLongs": 0, "outErrors": 0, "frameTooShorts": 0, "fcsErrors": 0, "alignmentErrors": 666, "symbolErrors": 0}, - } - } + }, + }, ], "inputs": None, "expected": { @@ -81,7 +830,7 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "messages": [ "The following interface(s) have non-zero error counters: [{'Ethernet1': {'inErrors': 42, 'frameTooLongs': 0, 'outErrors': 0, 'frameTooShorts': 0," " 'fcsErrors': 0, 'alignmentErrors': 0, 'symbolErrors': 0}}, {'Ethernet6': {'inErrors': 0, 'frameTooLongs': 0, 'outErrors': 0, 'frameTooShorts':" - " 0, 'fcsErrors': 0, 'alignmentErrors': 666, 'symbolErrors': 0}}]" + " 0, 'fcsErrors': 0, 'alignmentErrors': 666, 'symbolErrors': 0}}]", ], }, }, @@ -93,8 +842,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "interfaceErrorCounters": { "Ethernet1": {"inErrors": 42, "frameTooLongs": 0, "outErrors": 10, "frameTooShorts": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0}, "Ethernet6": {"inErrors": 0, "frameTooLongs": 0, "outErrors": 0, "frameTooShorts": 0, "fcsErrors": 0, "alignmentErrors": 6, "symbolErrors": 10}, - } - } + }, + }, ], "inputs": None, "expected": { @@ -102,7 +851,7 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "messages": [ "The following interface(s) have non-zero error counters: [{'Ethernet1': {'inErrors': 42, 'frameTooLongs': 0, 'outErrors': 10, 'frameTooShorts': 0," " 'fcsErrors': 0, 'alignmentErrors': 0, 'symbolErrors': 0}}, {'Ethernet6': {'inErrors': 0, 'frameTooLongs': 0, 'outErrors': 0, 'frameTooShorts':" - " 0, 'fcsErrors': 0, 'alignmentErrors': 6, 'symbolErrors': 10}}]" + " 0, 'fcsErrors': 0, 'alignmentErrors': 6, 'symbolErrors': 10}}]", ], }, }, @@ -113,15 +862,15 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 { "interfaceErrorCounters": { "Ethernet1": {"inErrors": 42, "frameTooLongs": 0, "outErrors": 2, "frameTooShorts": 0, "fcsErrors": 0, "alignmentErrors": 0, "symbolErrors": 0}, - } - } + }, + }, ], "inputs": None, "expected": { "result": "failure", "messages": [ "The following interface(s) have non-zero error counters: [{'Ethernet1': {'inErrors': 42, 'frameTooLongs': 0, 'outErrors': 2, 'frameTooShorts': 0," - " 'fcsErrors': 0, 'alignmentErrors': 0, 'symbolErrors': 0}}]" + " 'fcsErrors': 0, 'alignmentErrors': 0, 'symbolErrors': 0}}]", ], }, }, @@ -136,7 +885,7 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "Ethernet1": {"outDiscards": 0, "inDiscards": 0}, }, "outDiscardsTotal": 0, - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -152,14 +901,14 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "Ethernet1": {"outDiscards": 0, "inDiscards": 42}, }, "outDiscardsTotal": 0, - } + }, ], "inputs": None, "expected": { "result": "failure", "messages": [ "The following interfaces have non 0 discard counter(s): [{'Ethernet2': {'outDiscards': 42, 'inDiscards': 0}}," - " {'Ethernet1': {'outDiscards': 0, 'inDiscards': 42}}]" + " {'Ethernet1': {'outDiscards': 0, 'inDiscards': 42}}]", ], }, }, @@ -175,8 +924,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "Ethernet8": { "linkStatus": "connected", }, - } - } + }, + }, ], "inputs": None, "expected": {"result": "success"}, @@ -193,8 +942,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "Ethernet8": { "linkStatus": "errdisabled", }, - } - } + }, + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["The following interfaces are in error disabled state: ['Management1', 'Ethernet8']"]}, @@ -208,8 +957,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "Ethernet8": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, "Ethernet2": {"interfaceStatus": "adminDown", "description": "", "lineProtocolStatus": "down"}, "Ethernet3": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, - } - } + }, + }, ], "inputs": {"interfaces": [{"name": "Ethernet2", "status": "adminDown"}, {"name": "Ethernet8", "status": "up"}, {"name": "Ethernet3", "status": "up"}]}, "expected": {"result": "success"}, @@ -257,8 +1006,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "Ethernet8": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, "Ethernet2": {"interfaceStatus": "adminDown", "description": "", "lineProtocolStatus": "down"}, "Ethernet3": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, - } - } + }, + }, ], "inputs": {"interfaces": [{"name": "ethernet2", "status": "adminDown"}, {"name": "ethernet8", "status": "up"}, {"name": "ethernet3", "status": "up"}]}, "expected": {"result": "success"}, @@ -272,8 +1021,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "Ethernet8": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, "Ethernet2": {"interfaceStatus": "adminDown", "description": "", "lineProtocolStatus": "down"}, "Ethernet3": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, - } - } + }, + }, ], "inputs": {"interfaces": [{"name": "eth2", "status": "adminDown"}, {"name": "et8", "status": "up"}, {"name": "et3", "status": "up"}]}, "expected": {"result": "success"}, @@ -285,8 +1034,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 { "interfaceDescriptions": { "Port-Channel100": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, - } - } + }, + }, ], "inputs": {"interfaces": [{"name": "po100", "status": "up"}]}, "expected": {"result": "success"}, @@ -298,8 +1047,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 { "interfaceDescriptions": { "Ethernet52/1.1963": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, - } - } + }, + }, ], "inputs": {"interfaces": [{"name": "Ethernet52/1.1963", "status": "up"}]}, "expected": {"result": "success"}, @@ -351,8 +1100,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "interfaceDescriptions": { "Ethernet2": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, "Ethernet3": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, - } - } + }, + }, ], "inputs": {"interfaces": [{"name": "Ethernet2", "status": "up"}, {"name": "Ethernet8", "status": "up"}, {"name": "Ethernet3", "status": "up"}]}, "expected": { @@ -369,8 +1118,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "Ethernet8": {"interfaceStatus": "down", "description": "", "lineProtocolStatus": "down"}, "Ethernet2": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, "Ethernet3": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, - } - } + }, + }, ], "inputs": {"interfaces": [{"name": "Ethernet2", "status": "up"}, {"name": "Ethernet8", "status": "up"}, {"name": "Ethernet3", "status": "up"}]}, "expected": { @@ -387,8 +1136,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "Ethernet8": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "down"}, "Ethernet2": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, "Ethernet3": {"interfaceStatus": "up", "description": "", "lineProtocolStatus": "up"}, - } - } + }, + }, ], "inputs": { "interfaces": [ @@ -454,9 +1203,9 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "active": True, "reason": "", "errdisabled": False, - } + }, }, - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -473,9 +1222,9 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "active": True, "reason": "", "errdisabled": False, - } + }, }, - } + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["The following interfaces have none 0 storm-control drop counters {'Ethernet1': {'broadcast': 666}}"]}, @@ -496,9 +1245,9 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "inactivePorts": {}, "activePorts": {}, "inactiveLag": False, - } - } - } + }, + }, + }, ], "inputs": None, "expected": {"result": "success"}, @@ -519,9 +1268,9 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "inactivePorts": {"Ethernet8": {"reasonUnconfigured": "waiting for LACP response"}}, "activePorts": {}, "inactiveLag": False, - } - } - } + }, + }, + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["The following port-channels have inactive port(s): ['Port-Channel42']"]}, @@ -543,12 +1292,12 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "lacpdusTxCount": 454, "markersTxCount": 0, "markersRxCount": 0, - } - } - } + }, + }, + }, }, "orphanPorts": {}, - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -570,17 +1319,17 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "lacpdusTxCount": 454, "markersTxCount": 0, "markersRxCount": 0, - } - } - } + }, + }, + }, }, "orphanPorts": {}, - } + }, ], "inputs": None, "expected": { "result": "failure", - "messages": ["The following port-channels have recieved illegal lacp packets on the following ports: [{'Port-Channel42': 'Ethernet8'}]"], + "messages": ["The following port-channels have received illegal LACP packets on the following ports: [{'Port-Channel42': 'Ethernet8'}]"], }, }, { @@ -605,8 +1354,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "lineProtocolStatus": "up", "mtu": 65535, }, - } - } + }, + }, ], "inputs": {"number": 2}, "expected": {"result": "success"}, @@ -633,8 +1382,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "lineProtocolStatus": "down", "mtu": 65535, }, - } - } + }, + }, ], "inputs": {"number": 2}, "expected": {"result": "failure", "messages": ["The following Loopbacks are not up: ['Loopback666']"]}, @@ -653,8 +1402,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "lineProtocolStatus": "up", "mtu": 65535, }, - } - } + }, + }, ], "inputs": {"number": 2}, "expected": {"result": "failure", "messages": ["Found 1 Loopbacks when expecting 2"]}, @@ -672,9 +1421,9 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "ipv4Routable240": False, "lineProtocolStatus": "up", "mtu": 1500, - } - } - } + }, + }, + }, ], "inputs": None, "expected": {"result": "success"}, @@ -692,9 +1441,9 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "ipv4Routable240": False, "lineProtocolStatus": "lowerLayerDown", "mtu": 1500, - } - } - } + }, + }, + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["The following SVIs are not up: ['Vlan42']"]}, @@ -766,7 +1515,7 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "l2Mru": 0, }, }, - } + }, ], "inputs": {"mtu": 1500}, "expected": {"result": "success"}, @@ -838,7 +1587,7 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "l2Mru": 0, }, }, - } + }, ], "inputs": {"mtu": 1500, "ignored_interfaces": ["Loopback", "Port-Channel", "Management", "Vxlan"], "specific_mtu": [{"Ethernet10": 1501}]}, "expected": {"result": "success"}, @@ -910,7 +1659,7 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "l2Mru": 0, }, }, - } + }, ], "inputs": {"mtu": 1500}, "expected": {"result": "failure", "messages": ["Some interfaces do not have correct MTU configured:\n[{'Ethernet2': 1600}]"]}, @@ -921,8 +1670,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "eos_data": [ { "interfaces": { - "Ethernet2": { - "name": "Ethernet2", + "Ethernet2/1": { + "name": "Ethernet2/1", "forwardingModel": "routed", "lineProtocolStatus": "up", "interfaceStatus": "connected", @@ -982,7 +1731,7 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "l2Mru": 0, }, }, - } + }, ], "inputs": {"mtu": 9214}, "expected": {"result": "success"}, @@ -1054,7 +1803,7 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "l2Mru": 0, }, }, - } + }, ], "inputs": {"mtu": 1500}, "expected": {"result": "failure", "messages": ["Some L2 interfaces do not have correct MTU configured:\n[{'Ethernet10': 9214}, {'Port-Channel2': 9214}]"]}, @@ -1084,8 +1833,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "directedBroadcastEnabled": False, "maxMssIngress": 0, "maxMssEgress": 0, - } - } + }, + }, }, { "interfaces": { @@ -1108,8 +1857,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "directedBroadcastEnabled": False, "maxMssIngress": 0, "maxMssEgress": 0, - } - } + }, + }, }, ], "inputs": {"interfaces": ["Ethernet1", "Ethernet2"]}, @@ -1140,8 +1889,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "directedBroadcastEnabled": False, "maxMssIngress": 0, "maxMssEgress": 0, - } - } + }, + }, }, { "interfaces": { @@ -1164,8 +1913,8 @@ Et4 5:00 0.0 99.9% 0 0.0 0.0% 0 "directedBroadcastEnabled": False, "maxMssIngress": 0, "maxMssEgress": 0, - } - } + }, + }, }, ], "inputs": {"interfaces": ["Ethernet1", "Ethernet2"]}, diff --git a/tests/units/anta_tests/test_lanz.py b/tests/units/anta_tests/test_lanz.py index 932d1ac..bfbf6ae 100644 --- a/tests/units/anta_tests/test_lanz.py +++ b/tests/units/anta_tests/test_lanz.py @@ -1,7 +1,8 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Data for testing anta.tests.configuration""" +"""Data for testing anta.tests.lanz.""" + from __future__ import annotations from typing import Any @@ -15,7 +16,7 @@ DATA: list[dict[str, Any]] = [ "test": VerifyLANZ, "eos_data": [{"lanzEnabled": True}], "inputs": None, - "expected": {"result": "success", "messages": ["LANZ is enabled"]}, + "expected": {"result": "success"}, }, { "name": "failure", diff --git a/tests/units/anta_tests/test_logging.py b/tests/units/anta_tests/test_logging.py index 8ac2323..1e8ee3d 100644 --- a/tests/units/anta_tests/test_logging.py +++ b/tests/units/anta_tests/test_logging.py @@ -1,7 +1,8 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Data for testing anta.tests.logging""" +"""Data for testing anta.tests.logging.""" + from __future__ import annotations from typing import Any @@ -77,7 +78,7 @@ DATA: list[dict[str, Any]] = [ Logging to '10.22.10.93' port 514 in VRF MGMT via tcp Logging to '10.22.10.94' port 911 in VRF MGMT via udp - """ + """, ], "inputs": {"interface": "Management0", "vrf": "MGMT"}, "expected": {"result": "success"}, @@ -92,7 +93,7 @@ DATA: list[dict[str, Any]] = [ Logging to '10.22.10.93' port 514 in VRF MGMT via tcp Logging to '10.22.10.94' port 911 in VRF MGMT via udp - """ + """, ], "inputs": {"interface": "Management0", "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["Source-interface 'Management0' is not configured in VRF MGMT"]}, @@ -107,7 +108,7 @@ DATA: list[dict[str, Any]] = [ Logging to '10.22.10.93' port 514 in VRF MGMT via tcp Logging to '10.22.10.94' port 911 in VRF MGMT via udp - """ + """, ], "inputs": {"interface": "Management0", "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["Source-interface 'Management0' is not configured in VRF MGMT"]}, @@ -122,7 +123,7 @@ DATA: list[dict[str, Any]] = [ Logging to '10.22.10.93' port 514 in VRF MGMT via tcp Logging to '10.22.10.94' port 911 in VRF MGMT via udp - """ + """, ], "inputs": {"hosts": ["10.22.10.92", "10.22.10.93", "10.22.10.94"], "vrf": "MGMT"}, "expected": {"result": "success"}, @@ -137,7 +138,7 @@ DATA: list[dict[str, Any]] = [ Logging to '10.22.10.103' port 514 in VRF MGMT via tcp Logging to '10.22.10.104' port 911 in VRF MGMT via udp - """ + """, ], "inputs": {"hosts": ["10.22.10.92", "10.22.10.93", "10.22.10.94"], "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["Syslog servers ['10.22.10.93', '10.22.10.94'] are not configured in VRF MGMT"]}, @@ -152,7 +153,7 @@ DATA: list[dict[str, Any]] = [ Logging to '10.22.10.93' port 514 in VRF default via tcp Logging to '10.22.10.94' port 911 in VRF default via udp - """ + """, ], "inputs": {"hosts": ["10.22.10.92", "10.22.10.93", "10.22.10.94"], "vrf": "MGMT"}, "expected": {"result": "failure", "messages": ["Syslog servers ['10.22.10.93', '10.22.10.94'] are not configured in VRF MGMT"]}, @@ -246,7 +247,7 @@ DATA: list[dict[str, Any]] = [ "name": "failure", "test": VerifyLoggingErrors, "eos_data": [ - "Aug 2 19:57:42 DC1-LEAF1A Mlag: %FWK-3-SOCKET_CLOSE_REMOTE: Connection to Mlag (pid:27200) at tbt://192.168.0.1:4432/+n closed by peer (EOF)" + "Aug 2 19:57:42 DC1-LEAF1A Mlag: %FWK-3-SOCKET_CLOSE_REMOTE: Connection to Mlag (pid:27200) at tbt://192.168.0.1:4432/+n closed by peer (EOF)", ], "inputs": None, "expected": {"result": "failure", "messages": ["Device has reported syslog messages with a severity of ERRORS or higher"]}, diff --git a/tests/units/anta_tests/test_mlag.py b/tests/units/anta_tests/test_mlag.py index 90f3c7a..ae8ff7c 100644 --- a/tests/units/anta_tests/test_mlag.py +++ b/tests/units/anta_tests/test_mlag.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.mlag.py -""" +"""Tests for anta.tests.mlag.py.""" + from __future__ import annotations from typing import Any @@ -25,7 +24,7 @@ DATA: list[dict[str, Any]] = [ "eos_data": [ { "state": "disabled", - } + }, ], "inputs": None, "expected": {"result": "skipped", "messages": ["MLAG is disabled"]}, @@ -47,7 +46,7 @@ DATA: list[dict[str, Any]] = [ { "state": "active", "mlagPorts": {"Disabled": 0, "Configured": 0, "Inactive": 0, "Active-partial": 0, "Active-full": 1}, - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -58,7 +57,7 @@ DATA: list[dict[str, Any]] = [ "eos_data": [ { "state": "disabled", - } + }, ], "inputs": None, "expected": {"result": "skipped", "messages": ["MLAG is disabled"]}, @@ -70,7 +69,7 @@ DATA: list[dict[str, Any]] = [ { "state": "active", "mlagPorts": {"Disabled": 0, "Configured": 0, "Inactive": 0, "Active-partial": 1, "Active-full": 1}, - } + }, ], "inputs": None, "expected": { @@ -85,7 +84,7 @@ DATA: list[dict[str, Any]] = [ { "state": "active", "mlagPorts": {"Disabled": 0, "Configured": 0, "Inactive": 1, "Active-partial": 1, "Active-full": 1}, - } + }, ], "inputs": None, "expected": { @@ -106,7 +105,7 @@ DATA: list[dict[str, Any]] = [ "eos_data": [ { "mlagActive": False, - } + }, ], "inputs": None, "expected": {"result": "skipped", "messages": ["MLAG is disabled"]}, @@ -117,7 +116,7 @@ DATA: list[dict[str, Any]] = [ "eos_data": [ { "dummy": False, - } + }, ], "inputs": None, "expected": {"result": "error", "messages": ["Incorrect JSON response - 'mlagActive' state was not found"]}, @@ -131,7 +130,7 @@ DATA: list[dict[str, Any]] = [ "interfaceConfiguration": {}, "mlagActive": True, "mlagConnected": True, - } + }, ], "inputs": None, "expected": { @@ -140,7 +139,7 @@ DATA: list[dict[str, Any]] = [ "MLAG config-sanity returned inconsistencies: " "{'globalConfiguration': {'mlag': {'globalParameters': " "{'dual-primary-detection-delay': {'localValue': '0', 'peerValue': '200'}}}}, " - "'interfaceConfiguration': {}}" + "'interfaceConfiguration': {}}", ], }, }, @@ -153,7 +152,7 @@ DATA: list[dict[str, Any]] = [ "interfaceConfiguration": {"trunk-native-vlan mlag30": {"interface": {"Port-Channel30": {"localValue": "123", "peerValue": "3700"}}}}, "mlagActive": True, "mlagConnected": True, - } + }, ], "inputs": None, "expected": { @@ -162,7 +161,7 @@ DATA: list[dict[str, Any]] = [ "MLAG config-sanity returned inconsistencies: " "{'globalConfiguration': {}, " "'interfaceConfiguration': {'trunk-native-vlan mlag30': " - "{'interface': {'Port-Channel30': {'localValue': '123', 'peerValue': '3700'}}}}}" + "{'interface': {'Port-Channel30': {'localValue': '123', 'peerValue': '3700'}}}}}", ], }, }, @@ -179,7 +178,7 @@ DATA: list[dict[str, Any]] = [ "eos_data": [ { "state": "disabled", - } + }, ], "inputs": {"reload_delay": 300, "reload_delay_non_mlag": 330}, "expected": {"result": "skipped", "messages": ["MLAG is disabled"]}, @@ -202,7 +201,7 @@ 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"}, @@ -213,7 +212,7 @@ DATA: list[dict[str, Any]] = [ "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"]}, @@ -226,7 +225,7 @@ DATA: list[dict[str, Any]] = [ "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"]}, @@ -242,7 +241,7 @@ 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": { @@ -254,7 +253,7 @@ DATA: list[dict[str, Any]] = [ "'detail.dualPrimaryAction': 'none', " "'dualPrimaryMlagRecoveryDelay': 160, " "'dualPrimaryNonMlagRecoveryDelay': 0}" - ) + ), ], }, }, @@ -269,7 +268,7 @@ 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": { @@ -281,7 +280,7 @@ DATA: list[dict[str, Any]] = [ "'detail.dualPrimaryAction': 'none', " "'dualPrimaryMlagRecoveryDelay': 60, " "'dualPrimaryNonMlagRecoveryDelay': 0}" - ) + ), ], }, }, diff --git a/tests/units/anta_tests/test_multicast.py b/tests/units/anta_tests/test_multicast.py index 9276a9f..a52a1d2 100644 --- a/tests/units/anta_tests/test_multicast.py +++ b/tests/units/anta_tests/test_multicast.py @@ -1,7 +1,8 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Test inputs for anta.tests.multicast""" +"""Test inputs for anta.tests.multicast.""" + from __future__ import annotations from typing import Any @@ -44,7 +45,7 @@ DATA: list[dict[str, Any]] = [ "robustness": 2, "immediateLeave": "enabled", "reportFloodingSwitchPorts": [], - } + }, ], "inputs": {"vlans": {1: True, 42: True}}, "expected": {"result": "success"}, @@ -67,12 +68,12 @@ DATA: list[dict[str, Any]] = [ "maxGroups": 65534, "immediateLeave": "default", "floodingTraffic": True, - } + }, }, "robustness": 2, "immediateLeave": "enabled", "reportFloodingSwitchPorts": [], - } + }, ], "inputs": {"vlans": {42: False}}, "expected": {"result": "success"}, @@ -100,7 +101,7 @@ DATA: list[dict[str, Any]] = [ "robustness": 2, "immediateLeave": "enabled", "reportFloodingSwitchPorts": [], - } + }, ], "inputs": {"vlans": {1: False, 42: False}}, "expected": {"result": "failure", "messages": ["IGMP state for vlan 1 is enabled", "Supplied vlan 42 is not present on the device."]}, @@ -128,7 +129,7 @@ DATA: list[dict[str, Any]] = [ "robustness": 2, "immediateLeave": "enabled", "reportFloodingSwitchPorts": [], - } + }, ], "inputs": {"vlans": {1: True}}, "expected": {"result": "failure", "messages": ["IGMP state for vlan 1 is disabled"]}, @@ -143,7 +144,7 @@ DATA: list[dict[str, Any]] = [ "robustness": 2, "immediateLeave": "enabled", "reportFloodingSwitchPorts": [], - } + }, ], "inputs": {"enabled": True}, "expected": {"result": "success"}, @@ -155,7 +156,7 @@ DATA: list[dict[str, Any]] = [ { "reportFlooding": "disabled", "igmpSnoopingState": "disabled", - } + }, ], "inputs": {"enabled": False}, "expected": {"result": "success"}, @@ -167,7 +168,7 @@ DATA: list[dict[str, Any]] = [ { "reportFlooding": "disabled", "igmpSnoopingState": "disabled", - } + }, ], "inputs": {"enabled": True}, "expected": {"result": "failure", "messages": ["IGMP state is not valid: disabled"]}, diff --git a/tests/units/anta_tests/test_profiles.py b/tests/units/anta_tests/test_profiles.py index c0ebb57..d58e987 100644 --- a/tests/units/anta_tests/test_profiles.py +++ b/tests/units/anta_tests/test_profiles.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.profiles.py -""" +"""Tests for anta.tests.profiles.py.""" + from __future__ import annotations from typing import Any @@ -30,7 +29,7 @@ DATA: list[dict[str, Any]] = [ "name": "success", "test": VerifyTcamProfile, "eos_data": [ - {"pmfProfiles": {"FixedSystem": {"config": "test", "configType": "System Profile", "status": "test", "mode": "tcam"}}, "lastProgrammingStatus": {}} + {"pmfProfiles": {"FixedSystem": {"config": "test", "configType": "System Profile", "status": "test", "mode": "tcam"}}, "lastProgrammingStatus": {}}, ], "inputs": {"profile": "test"}, "expected": {"result": "success"}, @@ -39,7 +38,7 @@ DATA: list[dict[str, Any]] = [ "name": "failure", "test": VerifyTcamProfile, "eos_data": [ - {"pmfProfiles": {"FixedSystem": {"config": "test", "configType": "System Profile", "status": "default", "mode": "tcam"}}, "lastProgrammingStatus": {}} + {"pmfProfiles": {"FixedSystem": {"config": "test", "configType": "System Profile", "status": "default", "mode": "tcam"}}, "lastProgrammingStatus": {}}, ], "inputs": {"profile": "test"}, "expected": {"result": "failure", "messages": ["Incorrect profile running on device: default"]}, diff --git a/tests/units/anta_tests/test_ptp.py b/tests/units/anta_tests/test_ptp.py index 3969c97..ef42a58 100644 --- a/tests/units/anta_tests/test_ptp.py +++ b/tests/units/anta_tests/test_ptp.py @@ -1,17 +1,19 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Data for testing anta.tests.configuration""" +"""Data for testing anta.tests.ptp.""" + from __future__ import annotations from typing import Any -from anta.tests.ptp import VerifyPtpStatus +from anta.tests.ptp import VerifyPtpGMStatus, VerifyPtpLockStatus, VerifyPtpModeStatus, VerifyPtpOffset, VerifyPtpPortModeStatus +from tests.lib.anta import test # noqa: F401; pylint: disable=W0611 DATA: list[dict[str, Any]] = [ { "name": "success", - "test": VerifyPtpStatus, + "test": VerifyPtpModeStatus, "eos_data": [ { "ptpMode": "ptpBoundaryClock", @@ -34,9 +36,305 @@ DATA: list[dict[str, Any]] = [ }, { "name": "failure", - "test": VerifyPtpStatus, + "test": VerifyPtpModeStatus, + "eos_data": [{"ptpMode": "ptpDisabled", "ptpIntfSummaries": {}}], + "inputs": None, + "expected": {"result": "failure", "messages": ["The device is not configured as a PTP Boundary Clock: 'ptpDisabled'"]}, + }, + { + "name": "error", + "test": VerifyPtpModeStatus, + "eos_data": [{"ptpIntfSummaries": {}}], + "inputs": None, + "expected": {"result": "error", "messages": ["'ptpMode' variable is not present in the command output"]}, + }, + { + "name": "success", + "test": VerifyPtpGMStatus, + "eos_data": [ + { + "ptpMode": "ptpBoundaryClock", + "ptpProfile": "ptpDefaultProfile", + "ptpClockSummary": { + "clockIdentity": "0x00:1c:73:ff:ff:14:00:01", + "gmClockIdentity": "0xec:46:70:ff:fe:00:ff:a8", + "numberOfSlavePorts": 1, + "numberOfMasterPorts": 8, + "slavePort": "Ethernet27/1", + "slaveVlanId": 0, + "offsetFromMaster": -11, + "meanPathDelay": 105, + "stepsRemoved": 2, + "skew": 1.0000015265007687, + "lastSyncTime": 1708599750, + "currentPtpSystemTime": 1708599750, + }, + } + ], + "inputs": {"gmid": "0xec:46:70:ff:fe:00:ff:a8"}, + "expected": {"result": "success"}, + }, + { + "name": "failure", + "test": VerifyPtpGMStatus, + "eos_data": [ + { + "ptpMode": "ptpBoundaryClock", + "ptpProfile": "ptpDefaultProfile", + "ptpClockSummary": { + "clockIdentity": "0x00:1c:73:ff:ff:0a:00:01", + "gmClockIdentity": "0x00:1c:73:ff:ff:0a:00:01", + "numberOfSlavePorts": 0, + "numberOfMasterPorts": 4, + "offsetFromMaster": 3, + "meanPathDelay": 496, + "stepsRemoved": 0, + "skew": 1.0000074628720317, + "lastSyncTime": 1708600129, + "currentPtpSystemTime": 1708600153, + }, + } + ], + "inputs": {"gmid": "0xec:46:70:ff:fe:00:ff:a8"}, + "expected": { + "result": "failure", + "messages": [ + "The device is locked to the following Grandmaster: '0x00:1c:73:ff:ff:0a:00:01', which differ from the expected one.", + ], + }, + }, + { + "name": "error", + "test": VerifyPtpGMStatus, + "eos_data": [{"ptpIntfSummaries": {}}], + "inputs": {"gmid": "0xec:46:70:ff:fe:00:ff:a8"}, + "expected": {"result": "error", "messages": ["'ptpClockSummary' variable is not present in the command output"]}, + }, + { + "name": "success", + "test": VerifyPtpLockStatus, + "eos_data": [ + { + "ptpMode": "ptpBoundaryClock", + "ptpProfile": "ptpDefaultProfile", + "ptpClockSummary": { + "clockIdentity": "0x00:1c:73:ff:ff:14:00:01", + "gmClockIdentity": "0xec:46:70:ff:fe:00:ff:a8", + "numberOfSlavePorts": 1, + "numberOfMasterPorts": 8, + "slavePort": "Ethernet27/1", + "slaveVlanId": 0, + "offsetFromMaster": -11, + "meanPathDelay": 105, + "stepsRemoved": 2, + "skew": 1.0000015265007687, + "lastSyncTime": 1708599750, + "currentPtpSystemTime": 1708599750, + }, + } + ], + "inputs": None, + "expected": {"result": "success"}, + }, + { + "name": "failure", + "test": VerifyPtpLockStatus, + "eos_data": [ + { + "ptpMode": "ptpBoundaryClock", + "ptpProfile": "ptpDefaultProfile", + "ptpClockSummary": { + "clockIdentity": "0x00:1c:73:ff:ff:0a:00:01", + "gmClockIdentity": "0x00:1c:73:ff:ff:0a:00:01", + "numberOfSlavePorts": 0, + "numberOfMasterPorts": 4, + "offsetFromMaster": 3, + "meanPathDelay": 496, + "stepsRemoved": 0, + "skew": 1.0000074628720317, + "lastSyncTime": 1708600129, + "currentPtpSystemTime": 1708600286, + }, + } + ], + "inputs": None, + "expected": {"result": "failure", "messages": ["The device lock is more than 60s old: 157s"]}, + }, + { + "name": "error", + "test": VerifyPtpLockStatus, + "eos_data": [{"ptpIntfSummaries": {}}], + "inputs": None, + "expected": { + "result": "error", + "messages": [ + "'ptpClockSummary' variable is not present in the command output", + ], + }, + }, + { + "name": "success", + "test": VerifyPtpOffset, + "eos_data": [ + { + "monitorEnabled": True, + "ptpMode": "ptpBoundaryClock", + "offsetFromMasterThreshold": 250, + "meanPathDelayThreshold": 1500, + "ptpMonitorData": [ + { + "intf": "Ethernet27/1", + "realLastSyncTime": 1708599815611398400, + "lastSyncSeqId": 44413, + "offsetFromMaster": 2, + "meanPathDelay": 105, + "skew": 1.000001614, + }, + { + "intf": "Ethernet27/1", + "realLastSyncTime": 1708599815486101500, + "lastSyncSeqId": 44412, + "offsetFromMaster": -13, + "meanPathDelay": 105, + "skew": 1.000001614, + }, + ], + } + ], + "inputs": None, + "expected": {"result": "success"}, + }, + { + "name": "failure", + "test": VerifyPtpOffset, + "eos_data": [ + { + "monitorEnabled": True, + "ptpMode": "ptpBoundaryClock", + "offsetFromMasterThreshold": 250, + "meanPathDelayThreshold": 1500, + "ptpMonitorData": [ + { + "intf": "Ethernet27/1", + "realLastSyncTime": 1708599815611398400, + "lastSyncSeqId": 44413, + "offsetFromMaster": 1200, + "meanPathDelay": 105, + "skew": 1.000001614, + }, + { + "intf": "Ethernet27/1", + "realLastSyncTime": 1708599815486101500, + "lastSyncSeqId": 44412, + "offsetFromMaster": -1300, + "meanPathDelay": 105, + "skew": 1.000001614, + }, + ], + } + ], + "inputs": None, + "expected": { + "result": "failure", + "messages": [("The device timing offset from master is greater than +/- 1000ns: {'Ethernet27/1': [1200, -1300]}")], + }, + }, + { + "name": "skipped", + "test": VerifyPtpOffset, + "eos_data": [ + { + "monitorEnabled": True, + "ptpMonitorData": [], + }, + ], + "inputs": None, + "expected": {"result": "skipped", "messages": ["PTP is not configured"]}, + }, + { + "name": "success", + "test": VerifyPtpPortModeStatus, + "eos_data": [ + { + "ptpMode": "ptpBoundaryClock", + "ptpProfile": "ptpDefaultProfile", + "ptpClockSummary": { + "clockIdentity": "0x00:1c:73:ff:ff:0a:00:01", + "gmClockIdentity": "0x00:1c:73:ff:ff:0a:00:01", + "numberOfSlavePorts": 0, + "numberOfMasterPorts": 4, + "offsetFromMaster": 0, + "meanPathDelay": 0, + "stepsRemoved": 0, + "skew": 1.0, + }, + "ptpIntfSummaries": { + "Ethernet53": { + "interface": "Ethernet53", + "ptpIntfVlanSummaries": [ + { + "vlanId": 0, + "portState": "psDisabled", + "delayMechanism": "e2e", + "transportMode": "ipv4", + "mpassEnabled": False, + "mpassStatus": "active", + } + ], + }, + "Ethernet1": { + "interface": "Ethernet1", + "ptpIntfVlanSummaries": [ + {"vlanId": 0, "portState": "psMaster", "delayMechanism": "e2e", "transportMode": "ipv4", "mpassEnabled": False, "mpassStatus": "active"} + ], + }, + }, + } + ], + "inputs": None, + "expected": {"result": "success"}, + }, + { + "name": "failure", + "test": VerifyPtpPortModeStatus, "eos_data": [{"ptpIntfSummaries": {}}], "inputs": None, - "expected": {"result": "failure"}, + "expected": {"result": "failure", "messages": ["No interfaces are PTP enabled"]}, + }, + { + "name": "failure", + "test": VerifyPtpPortModeStatus, + "eos_data": [ + { + "ptpMode": "ptpBoundaryClock", + "ptpProfile": "ptpDefaultProfile", + "ptpClockSummary": { + "clockIdentity": "0x00:1c:73:ff:ff:0a:00:01", + "gmClockIdentity": "0x00:1c:73:ff:ff:0a:00:01", + "numberOfSlavePorts": 0, + "numberOfMasterPorts": 4, + "offsetFromMaster": 0, + "meanPathDelay": 0, + "stepsRemoved": 0, + "skew": 1.0, + }, + "ptpIntfSummaries": { + "Ethernet53": { + "interface": "Ethernet53", + "ptpIntfVlanSummaries": [ + {"vlanId": 0, "portState": "none", "delayMechanism": "e2e", "transportMode": "ipv4", "mpassEnabled": False, "mpassStatus": "active"} + ], + }, + "Ethernet1": { + "interface": "Ethernet1", + "ptpIntfVlanSummaries": [ + {"vlanId": 0, "portState": "none", "delayMechanism": "e2e", "transportMode": "ipv4", "mpassEnabled": False, "mpassStatus": "active"} + ], + }, + }, + } + ], + "inputs": None, + "expected": {"result": "failure", "messages": ["The following interface(s) are not in a valid PTP state: '['Ethernet53', 'Ethernet1']'"]}, }, ] diff --git a/tests/units/anta_tests/test_security.py b/tests/units/anta_tests/test_security.py index 17fa04e..4c28541 100644 --- a/tests/units/anta_tests/test_security.py +++ b/tests/units/anta_tests/test_security.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.security.py -""" +"""Tests for anta.tests.security.py.""" + from __future__ import annotations from typing import Any @@ -16,7 +15,9 @@ from anta.tests.security import ( VerifyAPISSLCertificate, VerifyBannerLogin, VerifyBannerMotd, + VerifyIPSecConnHealth, VerifyIPv4ACL, + VerifySpecificIPSecConn, VerifySSHIPv4Acl, VerifySSHIPv6Acl, VerifySSHStatus, @@ -107,7 +108,7 @@ DATA: list[dict[str, Any]] = [ "unixSocketServer": {"configured": False, "running": False}, "sslProfile": {"name": "API_SSL_Profile", "configured": True, "state": "valid"}, "tlsProtocol": ["1.2"], - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -124,7 +125,7 @@ DATA: list[dict[str, Any]] = [ "unixSocketServer": {"configured": False, "running": False}, "sslProfile": {"name": "API_SSL_Profile", "configured": True, "state": "valid"}, "tlsProtocol": ["1.2"], - } + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["eAPI HTTP server is enabled globally"]}, @@ -141,7 +142,7 @@ DATA: list[dict[str, Any]] = [ "unixSocketServer": {"configured": False, "running": False}, "sslProfile": {"name": "API_SSL_Profile", "configured": True, "state": "valid"}, "tlsProtocol": ["1.2"], - } + }, ], "inputs": {"profile": "API_SSL_Profile"}, "expected": {"result": "success"}, @@ -157,7 +158,7 @@ DATA: list[dict[str, Any]] = [ "httpsServer": {"configured": True, "running": True, "port": 443}, "unixSocketServer": {"configured": False, "running": False}, "tlsProtocol": ["1.2"], - } + }, ], "inputs": {"profile": "API_SSL_Profile"}, "expected": {"result": "failure", "messages": ["eAPI HTTPS server SSL profile (API_SSL_Profile) is not configured"]}, @@ -174,7 +175,7 @@ DATA: list[dict[str, Any]] = [ "unixSocketServer": {"configured": False, "running": False}, "sslProfile": {"name": "Wrong_SSL_Profile", "configured": True, "state": "valid"}, "tlsProtocol": ["1.2"], - } + }, ], "inputs": {"profile": "API_SSL_Profile"}, "expected": {"result": "failure", "messages": ["eAPI HTTPS server SSL profile (API_SSL_Profile) is misconfigured or invalid"]}, @@ -897,4 +898,278 @@ DATA: list[dict[str, Any]] = [ ], }, }, + { + "name": "success", + "test": VerifyIPSecConnHealth, + "eos_data": [ + { + "connections": { + "default-172.18.3.2-172.18.5.2-srcUnused-0": { + "pathDict": {"path9": "Established"}, + }, + "default-100.64.3.2-100.64.5.2-srcUnused-0": { + "pathDict": {"path10": "Established"}, + }, + } + } + ], + "inputs": {}, + "expected": {"result": "success"}, + }, + { + "name": "failure-no-connection", + "test": VerifyIPSecConnHealth, + "eos_data": [{"connections": {}}], + "inputs": {}, + "expected": {"result": "failure", "messages": ["No IPv4 security connection configured."]}, + }, + { + "name": "failure-not-established", + "test": VerifyIPSecConnHealth, + "eos_data": [ + { + "connections": { + "default-172.18.3.2-172.18.5.2-srcUnused-0": { + "pathDict": {"path9": "Idle"}, + "saddr": "172.18.3.2", + "daddr": "172.18.2.2", + "tunnelNs": "default", + }, + "Guest-100.64.3.2-100.64.5.2-srcUnused-0": {"pathDict": {"path10": "Idle"}, "saddr": "100.64.3.2", "daddr": "100.64.5.2", "tunnelNs": "Guest"}, + } + } + ], + "inputs": {}, + "expected": { + "result": "failure", + "messages": [ + "The following IPv4 security connections are not established:\n" + "source:172.18.3.2 destination:172.18.2.2 vrf:default\n" + "source:100.64.3.2 destination:100.64.5.2 vrf:Guest." + ], + }, + }, + { + "name": "success-with-connection", + "test": VerifySpecificIPSecConn, + "eos_data": [ + { + "connections": { + "Guest-172.18.3.2-172.18.2.2-srcUnused-0": { + "pathDict": {"path9": "Established"}, + "saddr": "172.18.3.2", + "daddr": "172.18.2.2", + "tunnelNs": "Guest", + }, + "Guest-100.64.3.2-100.64.2.2-srcUnused-0": { + "pathDict": {"path10": "Established"}, + "saddr": "100.64.3.2", + "daddr": "100.64.2.2", + "tunnelNs": "Guest", + }, + } + } + ], + "inputs": { + "ip_security_connections": [ + { + "peer": "10.255.0.1", + "vrf": "Guest", + "connections": [ + {"source_address": "100.64.3.2", "destination_address": "100.64.2.2"}, + {"source_address": "172.18.3.2", "destination_address": "172.18.2.2"}, + ], + }, + ] + }, + "expected": {"result": "success"}, + }, + { + "name": "success-without-connection", + "test": VerifySpecificIPSecConn, + "eos_data": [ + { + "connections": { + "default-172.18.3.2-172.18.2.2-srcUnused-0": { + "pathDict": {"path9": "Established"}, + "saddr": "172.18.3.2", + "daddr": "172.18.2.2", + "tunnelNs": "default", + }, + "default-100.64.3.2-100.64.2.2-srcUnused-0": {"pathDict": {"path10": "Established"}, "saddr": "100.64.3.2", "daddr": "100.64.2.2"}, + } + } + ], + "inputs": { + "ip_security_connections": [ + { + "peer": "10.255.0.1", + "vrf": "default", + }, + ] + }, + "expected": {"result": "success"}, + }, + { + "name": "failure-no-connection", + "test": VerifySpecificIPSecConn, + "eos_data": [ + {"connections": {}}, + { + "connections": { + "DATA-172.18.3.2-172.18.2.2-srcUnused-0": { + "pathDict": {"path9": "Established"}, + "saddr": "172.18.3.2", + "daddr": "172.18.2.2", + "tunnelNs": "DATA", + }, + "DATA-100.64.3.2-100.64.2.2-srcUnused-0": { + "pathDict": {"path10": "Established"}, + "saddr": "100.64.3.2", + "daddr": "100.64.2.2", + "tunnelNs": "DATA", + }, + } + }, + ], + "inputs": { + "ip_security_connections": [ + { + "peer": "10.255.0.1", + "vrf": "default", + }, + { + "peer": "10.255.0.2", + "vrf": "DATA", + "connections": [ + {"source_address": "100.64.3.2", "destination_address": "100.64.2.2"}, + {"source_address": "172.18.3.2", "destination_address": "172.18.2.2"}, + ], + }, + ] + }, + "expected": {"result": "failure", "messages": ["No IPv4 security connection configured for peer `10.255.0.1`."]}, + }, + { + "name": "failure-not-established", + "test": VerifySpecificIPSecConn, + "eos_data": [ + { + "connections": { + "default-172.18.3.2-172.18.5.2-srcUnused-0": { + "pathDict": {"path9": "Idle"}, + "saddr": "172.18.3.2", + "daddr": "172.18.2.2", + "tunnelNs": "default", + }, + "default-100.64.3.2-100.64.5.2-srcUnused-0": { + "pathDict": {"path10": "Idle"}, + "saddr": "100.64.2.2", + "daddr": "100.64.1.2", + "tunnelNs": "default", + }, + }, + }, + { + "connections": { + "MGMT-172.18.2.2-172.18.1.2-srcUnused-0": {"pathDict": {"path9": "Idle"}, "saddr": "172.18.2.2", "daddr": "172.18.1.2", "tunnelNs": "MGMT"}, + "MGMT-100.64.2.2-100.64.1.2-srcUnused-0": {"pathDict": {"path10": "Idle"}, "saddr": "100.64.2.2", "daddr": "100.64.1.2", "tunnelNs": "MGMT"}, + } + }, + ], + "inputs": { + "ip_security_connections": [ + { + "peer": "10.255.0.1", + "vrf": "default", + }, + { + "peer": "10.255.0.2", + "vrf": "MGMT", + "connections": [ + {"source_address": "100.64.2.2", "destination_address": "100.64.1.2"}, + {"source_address": "172.18.2.2", "destination_address": "172.18.1.2"}, + ], + }, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "Expected state of IPv4 security connection `source:172.18.3.2 destination:172.18.2.2 vrf:default` for peer `10.255.0.1` is `Established` " + "but found `Idle` instead.", + "Expected state of IPv4 security connection `source:100.64.2.2 destination:100.64.1.2 vrf:default` for peer `10.255.0.1` is `Established` " + "but found `Idle` instead.", + "Expected state of IPv4 security connection `source:100.64.2.2 destination:100.64.1.2 vrf:MGMT` for peer `10.255.0.2` is `Established` " + "but found `Idle` instead.", + "Expected state of IPv4 security connection `source:172.18.2.2 destination:172.18.1.2 vrf:MGMT` for peer `10.255.0.2` is `Established` " + "but found `Idle` instead.", + ], + }, + }, + { + "name": "failure-missing-connection", + "test": VerifySpecificIPSecConn, + "eos_data": [ + { + "connections": { + "default-172.18.3.2-172.18.5.2-srcUnused-0": { + "pathDict": {"path9": "Idle"}, + "saddr": "172.18.3.2", + "daddr": "172.18.2.2", + "tunnelNs": "default", + }, + "default-100.64.3.2-100.64.5.2-srcUnused-0": { + "pathDict": {"path10": "Idle"}, + "saddr": "100.64.3.2", + "daddr": "100.64.2.2", + "tunnelNs": "default", + }, + }, + }, + { + "connections": { + "default-172.18.2.2-172.18.1.2-srcUnused-0": { + "pathDict": {"path9": "Idle"}, + "saddr": "172.18.2.2", + "daddr": "172.18.1.2", + "tunnelNs": "default", + }, + "default-100.64.2.2-100.64.1.2-srcUnused-0": { + "pathDict": {"path10": "Idle"}, + "saddr": "100.64.2.2", + "daddr": "100.64.1.2", + "tunnelNs": "default", + }, + } + }, + ], + "inputs": { + "ip_security_connections": [ + { + "peer": "10.255.0.1", + "vrf": "default", + }, + { + "peer": "10.255.0.2", + "vrf": "default", + "connections": [ + {"source_address": "100.64.4.2", "destination_address": "100.64.1.2"}, + {"source_address": "172.18.4.2", "destination_address": "172.18.1.2"}, + ], + }, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "Expected state of IPv4 security connection `source:172.18.3.2 destination:172.18.2.2 vrf:default` for peer `10.255.0.1` is `Established` " + "but found `Idle` instead.", + "Expected state of IPv4 security connection `source:100.64.3.2 destination:100.64.2.2 vrf:default` for peer `10.255.0.1` is `Established` " + "but found `Idle` instead.", + "IPv4 security connection `source:100.64.4.2 destination:100.64.1.2 vrf:default` for peer `10.255.0.2` is not found.", + "IPv4 security connection `source:172.18.4.2 destination:172.18.1.2 vrf:default` for peer `10.255.0.2` is not found.", + ], + }, + }, ] diff --git a/tests/units/anta_tests/test_services.py b/tests/units/anta_tests/test_services.py index dcd1ee2..ed86e10 100644 --- a/tests/units/anta_tests/test_services.py +++ b/tests/units/anta_tests/test_services.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.services.py -""" +"""Tests for anta.tests.services.py.""" + from __future__ import annotations from typing import Any diff --git a/tests/units/anta_tests/test_snmp.py b/tests/units/anta_tests/test_snmp.py index 7009689..b4d3152 100644 --- a/tests/units/anta_tests/test_snmp.py +++ b/tests/units/anta_tests/test_snmp.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.snmp.py -""" +"""Tests for anta.tests.snmp.py.""" + from __future__ import annotations from typing import Any diff --git a/tests/units/anta_tests/test_software.py b/tests/units/anta_tests/test_software.py index 6d39c04..84e90e8 100644 --- a/tests/units/anta_tests/test_software.py +++ b/tests/units/anta_tests/test_software.py @@ -1,7 +1,8 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Test inputs for anta.tests.hardware""" +"""Test inputs for anta.tests.hardware.""" + from __future__ import annotations from typing import Any @@ -18,7 +19,7 @@ DATA: list[dict[str, Any]] = [ "modelName": "vEOS-lab", "internalVersion": "4.27.0F-24305004.4270F", "version": "4.27.0F", - } + }, ], "inputs": {"versions": ["4.27.0F", "4.28.0F"]}, "expected": {"result": "success"}, @@ -31,7 +32,7 @@ DATA: list[dict[str, Any]] = [ "modelName": "vEOS-lab", "internalVersion": "4.27.0F-24305004.4270F", "version": "4.27.0F", - } + }, ], "inputs": {"versions": ["4.27.1F"]}, "expected": {"result": "failure", "messages": ["device is running version \"4.27.0F\" not in expected versions: ['4.27.1F']"]}, @@ -52,7 +53,7 @@ DATA: list[dict[str, Any]] = [ "TerminAttr-core": {"release": "1", "version": "v1.17.0"}, }, }, - } + }, ], "inputs": {"versions": ["v1.17.0", "v1.18.1"]}, "expected": {"result": "success"}, @@ -73,7 +74,7 @@ DATA: list[dict[str, Any]] = [ "TerminAttr-core": {"release": "1", "version": "v1.17.0"}, }, }, - } + }, ], "inputs": {"versions": ["v1.17.1", "v1.18.1"]}, "expected": {"result": "failure", "messages": ["device is running TerminAttr version v1.17.0 and is not in the allowed list: ['v1.17.1', 'v1.18.1']"]}, diff --git a/tests/units/anta_tests/test_stp.py b/tests/units/anta_tests/test_stp.py index 26f0b90..64a1168 100644 --- a/tests/units/anta_tests/test_stp.py +++ b/tests/units/anta_tests/test_stp.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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 -""" +"""Tests for anta.tests.stp.py.""" + from __future__ import annotations from typing import Any @@ -84,8 +83,8 @@ DATA: list[dict[str, Any]] = [ "interfaces": { "Ethernet10": {"bpduSent": 201, "bpduReceived": 0, "bpduTaggedError": 3, "bpduOtherError": 0, "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']"]}, @@ -145,7 +144,7 @@ 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 fowarding state: [{'VLAN 10': ['Ethernet10']}, {'VLAN 20': ['Ethernet10']}]"], + "messages": ["The following VLAN(s) have interface(s) that are not in a forwarding state: [{'VLAN 10': ['Ethernet10']}, {'VLAN 20': ['Ethernet10']}]"], }, }, { @@ -162,7 +161,7 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } + }, }, "VL20": { "rootBridge": { @@ -172,7 +171,7 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } + }, }, "VL30": { "rootBridge": { @@ -182,10 +181,10 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } + }, }, - } - } + }, + }, ], "inputs": {"priority": 32768, "instances": [10, 20]}, "expected": {"result": "success"}, @@ -204,7 +203,7 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } + }, }, "VL20": { "rootBridge": { @@ -214,7 +213,7 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } + }, }, "VL30": { "rootBridge": { @@ -224,10 +223,10 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } + }, }, - } - } + }, + }, ], "inputs": {"priority": 32768}, "expected": {"result": "success"}, @@ -246,10 +245,10 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } - } - } - } + }, + }, + }, + }, ], "inputs": {"priority": 16384, "instances": [0]}, "expected": {"result": "success"}, @@ -268,10 +267,10 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } - } - } - } + }, + }, + }, + }, ], "inputs": {"priority": 32768, "instances": [0]}, "expected": {"result": "failure", "messages": ["Unsupported STP instance type: WRONG0"]}, @@ -297,7 +296,7 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } + }, }, "VL20": { "rootBridge": { @@ -307,7 +306,7 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } + }, }, "VL30": { "rootBridge": { @@ -317,10 +316,10 @@ DATA: list[dict[str, Any]] = [ "helloTime": 2.0, "maxAge": 20, "forwardDelay": 15, - } + }, }, - } - } + }, + }, ], "inputs": {"priority": 32768, "instances": [10, 20, 30]}, "expected": {"result": "failure", "messages": ["The following instance(s) have the wrong STP root priority configured: ['VL20', 'VL30']"]}, diff --git a/tests/units/anta_tests/test_stun.py b/tests/units/anta_tests/test_stun.py new file mode 100644 index 0000000..2c87365 --- /dev/null +++ b/tests/units/anta_tests/test_stun.py @@ -0,0 +1,176 @@ +# Copyright (c) 2023-2024 Arista Networks, Inc. +# Use of this source code is governed by the Apache License 2.0 +# that can be found in the LICENSE file. +"""Test inputs for anta.tests.stun.py.""" + +from __future__ import annotations + +from typing import Any + +from anta.tests.stun import VerifyStunClient +from tests.lib.anta import test # noqa: F401; pylint: disable=W0611 + +DATA: list[dict[str, Any]] = [ + { + "name": "success", + "test": VerifyStunClient, + "eos_data": [ + { + "bindings": { + "000000010a64ff0100000000": { + "sourceAddress": {"ip": "100.64.3.2", "port": 4500}, + "publicAddress": {"ip": "192.64.3.2", "port": 6006}, + } + } + }, + { + "bindings": { + "000000040a64ff0100000000": { + "sourceAddress": {"ip": "172.18.3.2", "port": 4500}, + "publicAddress": {"ip": "192.18.3.2", "port": 6006}, + } + } + }, + { + "bindings": { + "000000040a64ff0100000000": { + "sourceAddress": {"ip": "172.18.4.2", "port": 4500}, + "publicAddress": {"ip": "192.18.4.2", "port": 6006}, + } + } + }, + { + "bindings": { + "000000040a64ff0100000000": { + "sourceAddress": {"ip": "172.18.6.2", "port": 4500}, + "publicAddress": {"ip": "192.18.6.2", "port": 6006}, + } + } + }, + ], + "inputs": { + "stun_clients": [ + {"source_address": "100.64.3.2", "public_address": "192.64.3.2", "source_port": 4500, "public_port": 6006}, + {"source_address": "172.18.3.2"}, + {"source_address": "172.18.4.2", "source_port": 4500, "public_address": "192.18.4.2"}, + {"source_address": "172.18.6.2", "source_port": 4500, "public_port": 6006}, + ] + }, + "expected": {"result": "success"}, + }, + { + "name": "failure-incorrect-public-ip", + "test": VerifyStunClient, + "eos_data": [ + { + "bindings": { + "000000010a64ff0100000000": { + "sourceAddress": {"ip": "100.64.3.2", "port": 4500}, + "publicAddress": {"ip": "192.64.3.2", "port": 6006}, + } + } + }, + { + "bindings": { + "000000040a64ff0100000000": { + "sourceAddress": {"ip": "172.18.3.2", "port": 4500}, + "publicAddress": {"ip": "192.18.3.2", "port": 6006}, + } + } + }, + ], + "inputs": { + "stun_clients": [ + {"source_address": "100.64.3.2", "public_address": "192.164.3.2", "source_port": 4500, "public_port": 6006}, + {"source_address": "172.18.3.2", "public_address": "192.118.3.2", "source_port": 4500, "public_port": 6006}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "For STUN source `100.64.3.2:4500`:\nExpected `192.164.3.2` as the public ip, but found `192.64.3.2` instead.", + "For STUN source `172.18.3.2:4500`:\nExpected `192.118.3.2` as the public ip, but found `192.18.3.2` instead.", + ], + }, + }, + { + "name": "failure-no-client", + "test": VerifyStunClient, + "eos_data": [ + {"bindings": {}}, + {"bindings": {}}, + ], + "inputs": { + "stun_clients": [ + {"source_address": "100.64.3.2", "public_address": "192.164.3.2", "source_port": 4500, "public_port": 6006}, + {"source_address": "172.18.3.2", "public_address": "192.118.3.2", "source_port": 4500, "public_port": 6006}, + ] + }, + "expected": { + "result": "failure", + "messages": ["STUN client transaction for source `100.64.3.2:4500` is not found.", "STUN client transaction for source `172.18.3.2:4500` is not found."], + }, + }, + { + "name": "failure-incorrect-public-port", + "test": VerifyStunClient, + "eos_data": [ + {"bindings": {}}, + { + "bindings": { + "000000040a64ff0100000000": { + "sourceAddress": {"ip": "172.18.3.2", "port": 4500}, + "publicAddress": {"ip": "192.18.3.2", "port": 4800}, + } + } + }, + ], + "inputs": { + "stun_clients": [ + {"source_address": "100.64.3.2", "public_address": "192.164.3.2", "source_port": 4500, "public_port": 6006}, + {"source_address": "172.18.3.2", "public_address": "192.118.3.2", "source_port": 4500, "public_port": 6006}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "STUN client transaction for source `100.64.3.2:4500` is not found.", + "For STUN source `172.18.3.2:4500`:\n" + "Expected `192.118.3.2` as the public ip, but found `192.18.3.2` instead.\n" + "Expected `6006` as the public port, but found `4800` instead.", + ], + }, + }, + { + "name": "failure-all-type", + "test": VerifyStunClient, + "eos_data": [ + {"bindings": {}}, + { + "bindings": { + "000000040a64ff0100000000": { + "sourceAddress": {"ip": "172.18.3.2", "port": 4500}, + "publicAddress": {"ip": "192.18.3.2", "port": 4800}, + } + } + }, + ], + "inputs": { + "stun_clients": [ + {"source_address": "100.64.3.2", "public_address": "192.164.3.2", "source_port": 4500, "public_port": 6006}, + {"source_address": "172.18.4.2", "public_address": "192.118.3.2", "source_port": 4800, "public_port": 6006}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "STUN client transaction for source `100.64.3.2:4500` is not found.", + "For STUN source `172.18.4.2:4800`:\n" + "Expected `172.18.4.2` as the source ip, but found `172.18.3.2` instead.\n" + "Expected `4800` as the source port, but found `4500` instead.\n" + "Expected `192.118.3.2` as the public ip, but found `192.18.3.2` instead.\n" + "Expected `6006` as the public port, but found `4800` instead.", + ], + }, + }, +] diff --git a/tests/units/anta_tests/test_system.py b/tests/units/anta_tests/test_system.py index 62260fa..6965461 100644 --- a/tests/units/anta_tests/test_system.py +++ b/tests/units/anta_tests/test_system.py @@ -1,7 +1,8 @@ # Copyright (c) 2023-2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -"""Test inputs for anta.tests.system""" +"""Test inputs for anta.tests.system.""" + from __future__ import annotations from typing import Any @@ -46,10 +47,15 @@ DATA: list[dict[str, Any]] = [ "eos_data": [ { "resetCauses": [ - {"recommendedAction": "No action necessary.", "description": "Reload requested by the user.", "timestamp": 1683186892.0, "debugInfoIsDir": False} + { + "recommendedAction": "No action necessary.", + "description": "Reload requested by the user.", + "timestamp": 1683186892.0, + "debugInfoIsDir": False, + }, ], "full": False, - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -61,10 +67,10 @@ DATA: list[dict[str, Any]] = [ "eos_data": [ { "resetCauses": [ - {"recommendedAction": "No action necessary.", "description": "Reload after crash.", "timestamp": 1683186892.0, "debugInfoIsDir": False} + {"recommendedAction": "No action necessary.", "description": "Reload after crash.", "timestamp": 1683186892.0, "debugInfoIsDir": False}, ], "full": False, - } + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["Reload cause is: 'Reload after crash.'"]}, @@ -125,7 +131,7 @@ EntityManager::doBackoff waiting for remote sysdb version ....ok ===> /var/log/agents/Acl-830 Fri Jul 7 15:07:00 2023 <=== ===== Output from /usr/bin/Acl [] (PID=830) started Jul 7 15:06:10.871700 === EntityManager::doBackoff waiting for remote sysdb version ...................ok -""" +""", ], "inputs": None, "expected": { @@ -158,9 +164,9 @@ EntityManager::doBackoff waiting for remote sysdb version ...................ok "activeTime": 360, "virtMem": "6644", "sharedMem": "3996", - } + }, }, - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -185,9 +191,9 @@ EntityManager::doBackoff waiting for remote sysdb version ...................ok "activeTime": 360, "virtMem": "6644", "sharedMem": "3996", - } + }, }, - } + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["Device has reported a high CPU utilization: 75.2%"]}, @@ -203,7 +209,7 @@ EntityManager::doBackoff waiting for remote sysdb version ...................ok "memTotal": 2004568, "memFree": 879004, "version": "4.27.3F", - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -219,7 +225,7 @@ EntityManager::doBackoff waiting for remote sysdb version ...................ok "memTotal": 2004568, "memFree": 89004, "version": "4.27.3F", - } + }, ], "inputs": None, "expected": {"result": "failure", "messages": ["Device has reported a high memory usage: 95.56%"]}, @@ -233,7 +239,7 @@ EntityManager::doBackoff waiting for remote sysdb version ...................ok none 294M 78M 217M 27% / none 294M 78M 217M 27% /.overlay /dev/loop0 461M 461M 0 100% /rootfs-i386 -""" +""", ], "inputs": None, "expected": {"result": "success"}, @@ -247,7 +253,7 @@ none 294M 78M 217M 27% /.overlay none 294M 78M 217M 27% / none 294M 78M 217M 84% /.overlay /dev/loop0 461M 461M 0 100% /rootfs-i386 -""" +""", ], "inputs": None, "expected": { @@ -264,7 +270,7 @@ none 294M 78M 217M 84% /.overlay "eos_data": [ """synchronised poll interval unknown -""" +""", ], "inputs": None, "expected": {"result": "success"}, @@ -275,7 +281,7 @@ poll interval unknown "eos_data": [ """unsynchronised poll interval unknown -""" +""", ], "inputs": None, "expected": {"result": "failure", "messages": ["The device is not synchronized with the configured NTP server(s): 'unsynchronised'"]}, diff --git a/tests/units/anta_tests/test_vlan.py b/tests/units/anta_tests/test_vlan.py index 93398f6..53bf92f 100644 --- a/tests/units/anta_tests/test_vlan.py +++ b/tests/units/anta_tests/test_vlan.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.vlan.py -""" +"""Tests for anta.tests.vlan.py.""" + from __future__ import annotations from typing import Any diff --git a/tests/units/anta_tests/test_vxlan.py b/tests/units/anta_tests/test_vxlan.py index 2a9a875..f450897 100644 --- a/tests/units/anta_tests/test_vxlan.py +++ b/tests/units/anta_tests/test_vxlan.py @@ -1,9 +1,8 @@ # Copyright (c) 2023-2024 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.vxlan.py -""" +"""Tests for anta.tests.vxlan.py.""" + from __future__ import annotations from typing import Any @@ -107,7 +106,7 @@ DATA: list[dict[str, Any]] = [ }, }, "warnings": [], - } + }, ], "inputs": None, "expected": {"result": "success"}, @@ -172,7 +171,7 @@ DATA: list[dict[str, Any]] = [ }, }, "warnings": ["Your configuration contains warnings. This does not mean misconfigurations. But you may wish to re-check your configurations."], - } + }, ], "inputs": None, "expected": { @@ -184,7 +183,7 @@ DATA: list[dict[str, Any]] = [ "'No VLAN-VNI mapping in Vxlan1'}, {'name': 'Flood List', 'checkPass': False, 'hasWarning': True, 'detail': " "'No VXLAN VLANs in Vxlan1'}, {'name': 'Routing', 'checkPass': True, 'hasWarning': False, 'detail': ''}, {'name': " "'VNI VRF ACL', 'checkPass': True, 'hasWarning': False, 'detail': ''}, {'name': 'VRF-VNI Dynamic VLAN', 'checkPass': True, " - "'hasWarning': False, 'detail': ''}, {'name': 'Decap VRF-VNI Map', 'checkPass': True, 'hasWarning': False, 'detail': ''}]}}" + "'hasWarning': False, 'detail': ''}, {'name': 'Decap VRF-VNI Map', 'checkPass': True, 'hasWarning': False, 'detail': ''}]}}", ], }, }, @@ -203,12 +202,12 @@ DATA: list[dict[str, Any]] = [ "vxlanIntfs": { "Vxlan1": { "vniBindings": { - "10020": {"vlan": 20, "dynamicVlan": False, "source": "static", "interfaces": {"Ethernet31": {"dot1q": 0}, "Vxlan1": {"dot1q": 20}}} + "10020": {"vlan": 20, "dynamicVlan": False, "source": "static", "interfaces": {"Ethernet31": {"dot1q": 0}, "Vxlan1": {"dot1q": 20}}}, }, "vniBindingsToVrf": {"500": {"vrfName": "PROD", "vlan": 1199, "source": "evpn"}}, - } - } - } + }, + }, + }, ], "inputs": {"bindings": {10020: 20, 500: 1199}}, "expected": {"result": "success"}, @@ -221,12 +220,12 @@ DATA: list[dict[str, Any]] = [ "vxlanIntfs": { "Vxlan1": { "vniBindings": { - "10020": {"vlan": 20, "dynamicVlan": False, "source": "static", "interfaces": {"Ethernet31": {"dot1q": 0}, "Vxlan1": {"dot1q": 20}}} + "10020": {"vlan": 20, "dynamicVlan": False, "source": "static", "interfaces": {"Ethernet31": {"dot1q": 0}, "Vxlan1": {"dot1q": 20}}}, }, "vniBindingsToVrf": {"500": {"vrfName": "PROD", "vlan": 1199, "source": "evpn"}}, - } - } - } + }, + }, + }, ], "inputs": {"bindings": {10010: 10, 10020: 20, 500: 1199}}, "expected": {"result": "failure", "messages": ["The following VNI(s) have no binding: ['10010']"]}, @@ -239,12 +238,12 @@ DATA: list[dict[str, Any]] = [ "vxlanIntfs": { "Vxlan1": { "vniBindings": { - "10020": {"vlan": 30, "dynamicVlan": False, "source": "static", "interfaces": {"Ethernet31": {"dot1q": 0}, "Vxlan1": {"dot1q": 20}}} + "10020": {"vlan": 30, "dynamicVlan": False, "source": "static", "interfaces": {"Ethernet31": {"dot1q": 0}, "Vxlan1": {"dot1q": 20}}}, }, "vniBindingsToVrf": {"500": {"vrfName": "PROD", "vlan": 1199, "source": "evpn"}}, - } - } - } + }, + }, + }, ], "inputs": {"bindings": {10020: 20, 500: 1199}}, "expected": {"result": "failure", "messages": ["The following VNI(s) have the wrong VLAN binding: [{'10020': 30}]"]}, @@ -257,12 +256,12 @@ DATA: list[dict[str, Any]] = [ "vxlanIntfs": { "Vxlan1": { "vniBindings": { - "10020": {"vlan": 30, "dynamicVlan": False, "source": "static", "interfaces": {"Ethernet31": {"dot1q": 0}, "Vxlan1": {"dot1q": 20}}} + "10020": {"vlan": 30, "dynamicVlan": False, "source": "static", "interfaces": {"Ethernet31": {"dot1q": 0}, "Vxlan1": {"dot1q": 20}}}, }, "vniBindingsToVrf": {"500": {"vrfName": "PROD", "vlan": 1199, "source": "evpn"}}, - } - } - } + }, + }, + }, ], "inputs": {"bindings": {10010: 10, 10020: 20, 500: 1199}}, "expected": { |