Adding upstream version 1.4.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
dc7df702ea
commit
7996c81031
166 changed files with 13787 additions and 11959 deletions
|
@ -5,65 +5,58 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from anta.models import AntaTest
|
||||
from anta.result_manager.models import AntaTestStatus
|
||||
from anta.tests.services import VerifyDNSLookup, VerifyDNSServers, VerifyErrdisableRecovery, VerifyHostname
|
||||
from tests.units.anta_tests import test
|
||||
|
||||
DATA: list[dict[str, Any]] = [
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyHostname,
|
||||
if TYPE_CHECKING:
|
||||
from tests.units.anta_tests import AntaUnitTestDataDict
|
||||
|
||||
DATA: AntaUnitTestDataDict = {
|
||||
(VerifyHostname, "success"): {
|
||||
"eos_data": [{"hostname": "s1-spine1", "fqdn": "s1-spine1.fun.aristanetworks.com"}],
|
||||
"inputs": {"hostname": "s1-spine1"},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure-incorrect-hostname",
|
||||
"test": VerifyHostname,
|
||||
(VerifyHostname, "failure-incorrect-hostname"): {
|
||||
"eos_data": [{"hostname": "s1-spine2", "fqdn": "s1-spine1.fun.aristanetworks.com"}],
|
||||
"inputs": {"hostname": "s1-spine1"},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["Incorrect Hostname - Expected: s1-spine1 Actual: s1-spine2"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Incorrect Hostname - Expected: s1-spine1 Actual: s1-spine2"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyDNSLookup,
|
||||
(VerifyDNSLookup, "success"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"messages": [
|
||||
"Server:\t\t127.0.0.1\nAddress:\t127.0.0.1#53\n\nNon-authoritative answer:\nName:\tarista.com\nAddress: 151.101.130.132\nName:\tarista.com\n"
|
||||
"Address: 151.101.2.132\nName:\tarista.com\nAddress: 151.101.194.132\nName:\tarista.com\nAddress: 151.101.66.132\n\n"
|
||||
"Server:\t\t127.0.0.1\nAddress:\t127.0.0.1#53\n\nNon-authoritative answer:\nName:\tarista.com\nAddress: 151.101.130.132\n"
|
||||
"Name:\tarista.com\nAddress: 151.101.2.132\nName:\tarista.com\nAddress: 151.101.194.132\nName:\tarista.com\nAddress: 151.101.66.132\n\n"
|
||||
]
|
||||
},
|
||||
{"messages": ["Server:\t\t127.0.0.1\nAddress:\t127.0.0.1#53\n\nNon-authoritative answer:\nName:\twww.google.com\nAddress: 172.217.12.100\n\n"]},
|
||||
],
|
||||
"inputs": {"domain_names": ["arista.com", "www.google.com"]},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure",
|
||||
"test": VerifyDNSLookup,
|
||||
(VerifyDNSLookup, "failure"): {
|
||||
"eos_data": [
|
||||
{"messages": ["Server:\t\t127.0.0.1\nAddress:\t127.0.0.1#53\n\nNon-authoritative answer:\n*** Can't find arista.ca: No answer\n\n"]},
|
||||
{"messages": ["Server:\t\t127.0.0.1\nAddress:\t127.0.0.1#53\n\nNon-authoritative answer:\nName:\twww.google.com\nAddress: 172.217.12.100\n\n"]},
|
||||
{"messages": ["Server:\t\t127.0.0.1\nAddress:\t127.0.0.1#53\n\nNon-authoritative answer:\n*** Can't find google.ca: No answer\n\n"]},
|
||||
],
|
||||
"inputs": {"domain_names": ["arista.ca", "www.google.com", "google.ca"]},
|
||||
"expected": {"result": "failure", "messages": ["The following domain(s) are not resolved to an IP address: arista.ca, google.ca"]},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["The following domain(s) are not resolved to an IP address: arista.ca, google.ca"]},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyDNSServers,
|
||||
(VerifyDNSServers, "success"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"nameServerConfigs": [
|
||||
{"ipAddr": "10.14.0.1", "vrf": "default", "priority": 0},
|
||||
{"ipAddr": "10.14.0.11", "vrf": "MGMT", "priority": 1},
|
||||
{"ipAddr": "fd12:3456:789a::1", "vrf": "default", "priority": 0},
|
||||
],
|
||||
]
|
||||
}
|
||||
],
|
||||
"inputs": {
|
||||
|
@ -73,32 +66,20 @@ DATA: list[dict[str, Any]] = [
|
|||
{"server_address": "fd12:3456:789a::1", "vrf": "default", "priority": 0},
|
||||
]
|
||||
},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure-no-dns-found",
|
||||
"test": VerifyDNSServers,
|
||||
"eos_data": [
|
||||
{
|
||||
"nameServerConfigs": [],
|
||||
}
|
||||
],
|
||||
(VerifyDNSServers, "failure-no-dns-found"): {
|
||||
"eos_data": [{"nameServerConfigs": []}],
|
||||
"inputs": {
|
||||
"dns_servers": [{"server_address": "10.14.0.10", "vrf": "default", "priority": 0}, {"server_address": "10.14.0.21", "vrf": "MGMT", "priority": 1}]
|
||||
},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": ["Server 10.14.0.10 VRF: default Priority: 0 - Not configured", "Server 10.14.0.21 VRF: MGMT Priority: 1 - Not configured"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-incorrect-dns-details",
|
||||
"test": VerifyDNSServers,
|
||||
"eos_data": [
|
||||
{
|
||||
"nameServerConfigs": [{"ipAddr": "10.14.0.1", "vrf": "CS", "priority": 1}, {"ipAddr": "10.14.0.11", "vrf": "MGMT", "priority": 1}],
|
||||
}
|
||||
],
|
||||
(VerifyDNSServers, "failure-incorrect-dns-details"): {
|
||||
"eos_data": [{"nameServerConfigs": [{"ipAddr": "10.14.0.1", "vrf": "CS", "priority": 1}, {"ipAddr": "10.14.0.11", "vrf": "MGMT", "priority": 1}]}],
|
||||
"inputs": {
|
||||
"dns_servers": [
|
||||
{"server_address": "10.14.0.1", "vrf": "CS", "priority": 0},
|
||||
|
@ -107,7 +88,7 @@ DATA: list[dict[str, Any]] = [
|
|||
]
|
||||
},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": [
|
||||
"Server 10.14.0.1 VRF: CS Priority: 0 - Incorrect priority - Priority: 1",
|
||||
"Server 10.14.0.11 VRF: default Priority: 0 - Not configured",
|
||||
|
@ -115,94 +96,62 @@ DATA: list[dict[str, Any]] = [
|
|||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyErrdisableRecovery,
|
||||
(VerifyErrdisableRecovery, "success"): {
|
||||
"eos_data": [
|
||||
# Adding empty line on purpose to verify they are skipped
|
||||
"""
|
||||
Errdisable Reason Timer Status Timer Interval
|
||||
------------------------------ ----------------- --------------
|
||||
acl Enabled 300
|
||||
|
||||
bpduguard Enabled 300
|
||||
arp-inspection Enabled 30
|
||||
"""
|
||||
"\n Errdisable Reason Timer Status Timer Interval\n ------------------------------"
|
||||
" ----------------- --------------\n acl Enabled 300\n\n "
|
||||
" bpduguard Enabled 300\n arp-inspection "
|
||||
" Enabled 30\n "
|
||||
],
|
||||
"inputs": {"reasons": [{"reason": "acl", "interval": 300}, {"reason": "bpduguard", "interval": 300}]},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure-reason-missing",
|
||||
"test": VerifyErrdisableRecovery,
|
||||
(VerifyErrdisableRecovery, "failure-reason-missing"): {
|
||||
"eos_data": [
|
||||
"""
|
||||
Errdisable Reason Timer Status Timer Interval
|
||||
------------------------------ ----------------- --------------
|
||||
acl Enabled 300
|
||||
bpduguard Enabled 300
|
||||
arp-inspection Enabled 30
|
||||
"""
|
||||
"\n Errdisable Reason Timer Status Timer Interval\n ------------------------------"
|
||||
" ----------------- --------------\n acl Enabled 300\n "
|
||||
" bpduguard Enabled 300\n arp-inspection Enabled"
|
||||
" 30\n "
|
||||
],
|
||||
"inputs": {"reasons": [{"reason": "acl", "interval": 300}, {"reason": "arp-inspection", "interval": 30}, {"reason": "tapagg", "interval": 30}]},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["Reason: tapagg Status: Enabled Interval: 30 - Not found"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Reason: tapagg Status: Enabled Interval: 30 - Not found"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-reason-disabled",
|
||||
"test": VerifyErrdisableRecovery,
|
||||
(VerifyErrdisableRecovery, "failure-reason-disabled"): {
|
||||
"eos_data": [
|
||||
"""
|
||||
Errdisable Reason Timer Status Timer Interval
|
||||
------------------------------ ----------------- --------------
|
||||
acl Disabled 300
|
||||
bpduguard Enabled 300
|
||||
arp-inspection Enabled 30
|
||||
"""
|
||||
"\n Errdisable Reason Timer Status Timer Interval\n ------------------------------ "
|
||||
"----------------- --------------\n acl Disabled 300\n "
|
||||
"bpduguard Enabled 300\n arp-inspection Enabled"
|
||||
" 30\n "
|
||||
],
|
||||
"inputs": {"reasons": [{"reason": "acl", "interval": 300}, {"reason": "arp-inspection", "interval": 30}]},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": ["Reason: acl Status: Enabled Interval: 300 - Incorrect configuration - Status: Disabled Interval: 300"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-interval-not-ok",
|
||||
"test": VerifyErrdisableRecovery,
|
||||
(VerifyErrdisableRecovery, "failure-interval-not-ok"): {
|
||||
"eos_data": [
|
||||
"""
|
||||
Errdisable Reason Timer Status Timer Interval
|
||||
------------------------------ ----------------- --------------
|
||||
acl Enabled 300
|
||||
bpduguard Enabled 300
|
||||
arp-inspection Enabled 30
|
||||
"""
|
||||
"\n Errdisable Reason Timer Status Timer Interval\n ------------------------------ "
|
||||
"----------------- --------------\n acl Enabled 300\n "
|
||||
"bpduguard Enabled 300\n arp-inspection Enabled "
|
||||
" 30\n "
|
||||
],
|
||||
"inputs": {"reasons": [{"reason": "acl", "interval": 30}, {"reason": "arp-inspection", "interval": 30}]},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": [
|
||||
"Reason: acl Status: Enabled Interval: 30 - Incorrect configuration - Status: Enabled Interval: 300",
|
||||
],
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": ["Reason: acl Status: Enabled Interval: 30 - Incorrect configuration - Status: Enabled Interval: 300"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-all-type",
|
||||
"test": VerifyErrdisableRecovery,
|
||||
(VerifyErrdisableRecovery, "failure-all-type"): {
|
||||
"eos_data": [
|
||||
"""
|
||||
Errdisable Reason Timer Status Timer Interval
|
||||
------------------------------ ----------------- --------------
|
||||
acl Disabled 300
|
||||
bpduguard Enabled 300
|
||||
arp-inspection Enabled 30
|
||||
"""
|
||||
"\n Errdisable Reason Timer Status Timer Interval\n ------------------------------ "
|
||||
"----------------- --------------\n acl Disabled 300\n "
|
||||
"bpduguard Enabled 300\n arp-inspection Enabled "
|
||||
" 30\n "
|
||||
],
|
||||
"inputs": {"reasons": [{"reason": "acl", "interval": 30}, {"reason": "arp-inspection", "interval": 300}, {"reason": "tapagg", "interval": 30}]},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": [
|
||||
"Reason: acl Status: Enabled Interval: 30 - Incorrect configuration - Status: Disabled Interval: 300",
|
||||
"Reason: arp-inspection Status: Enabled Interval: 300 - Incorrect configuration - Status: Enabled Interval: 30",
|
||||
|
@ -210,4 +159,4 @@ DATA: list[dict[str, Any]] = [
|
|||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue