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,88 +5,109 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from anta.tests.vlan import VerifyDynamicVlanSource, VerifyVlanInternalPolicy
|
||||
from anta.models import AntaTest
|
||||
from anta.result_manager.models import AntaTestStatus
|
||||
from anta.tests.vlan import VerifyDynamicVlanSource, VerifyVlanInternalPolicy, VerifyVlanStatus
|
||||
from tests.units.anta_tests import test
|
||||
|
||||
DATA: list[dict[str, Any]] = [
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyVlanInternalPolicy,
|
||||
if TYPE_CHECKING:
|
||||
from tests.units.anta_tests import AntaUnitTestDataDict
|
||||
|
||||
DATA: AntaUnitTestDataDict = {
|
||||
(VerifyVlanInternalPolicy, "success"): {
|
||||
"eos_data": [{"policy": "ascending", "startVlanId": 1006, "endVlanId": 4094}],
|
||||
"inputs": {"policy": "ascending", "start_vlan_id": 1006, "end_vlan_id": 4094},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure-incorrect-policy",
|
||||
"test": VerifyVlanInternalPolicy,
|
||||
(VerifyVlanInternalPolicy, "failure-incorrect-policy"): {
|
||||
"eos_data": [{"policy": "descending", "startVlanId": 4094, "endVlanId": 1006}],
|
||||
"inputs": {"policy": "ascending", "start_vlan_id": 1006, "end_vlan_id": 4094},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": ["Incorrect VLAN internal allocation policy configured - Expected: ascending Actual: descending"],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "failure-incorrect-start-end-id",
|
||||
"test": VerifyVlanInternalPolicy,
|
||||
(VerifyVlanInternalPolicy, "failure-incorrect-start-end-id"): {
|
||||
"eos_data": [{"policy": "ascending", "startVlanId": 4094, "endVlanId": 1006}],
|
||||
"inputs": {"policy": "ascending", "start_vlan_id": 1006, "end_vlan_id": 4094},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": [
|
||||
"VLAN internal allocation policy: ascending - Incorrect start VLAN id configured - Expected: 1006 Actual: 4094",
|
||||
"VLAN internal allocation policy: ascending - Incorrect end VLAN id configured - Expected: 4094 Actual: 1006",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "success",
|
||||
"test": VerifyDynamicVlanSource,
|
||||
(VerifyDynamicVlanSource, "success"): {
|
||||
"eos_data": [{"dynamicVlans": {"evpn": {"vlanIds": [1199]}, "mlagsync": {"vlanIds": [1401]}, "vccbfd": {"vlanIds": [1501]}}}],
|
||||
"inputs": {"sources": ["evpn", "mlagsync"], "strict": False},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure-no-dynamic-vlan-sources",
|
||||
"test": VerifyDynamicVlanSource,
|
||||
(VerifyDynamicVlanSource, "failure-no-dynamic-vlan-sources"): {
|
||||
"eos_data": [{"dynamicVlans": {}}],
|
||||
"inputs": {"sources": ["evpn", "mlagsync"], "strict": False},
|
||||
"expected": {"result": "failure", "messages": ["Dynamic VLAN source(s) not found in configuration: evpn, mlagsync"]},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Dynamic VLAN source(s) not found in configuration: evpn, mlagsync"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-dynamic-vlan-sources-mismatch",
|
||||
"test": VerifyDynamicVlanSource,
|
||||
(VerifyDynamicVlanSource, "failure-dynamic-vlan-sources-mismatch"): {
|
||||
"eos_data": [{"dynamicVlans": {"vccbfd": {"vlanIds": [1500]}, "mlagsync": {"vlanIds": [1501]}}}],
|
||||
"inputs": {"sources": ["evpn", "mlagsync"], "strict": False},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["Dynamic VLAN source(s) not found in configuration: evpn"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Dynamic VLAN source(s) not found in configuration: evpn"]},
|
||||
},
|
||||
{
|
||||
"name": "success-strict-mode",
|
||||
"test": VerifyDynamicVlanSource,
|
||||
(VerifyDynamicVlanSource, "success-strict-mode"): {
|
||||
"eos_data": [{"dynamicVlans": {"evpn": {"vlanIds": [1199]}, "mlagsync": {"vlanIds": [1502], "vccbfd": {"vlanIds": []}}}}],
|
||||
"inputs": {"sources": ["evpn", "mlagsync"], "strict": True},
|
||||
"expected": {"result": "success"},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
{
|
||||
"name": "failure-all-sources-exact-match-additional-source-found",
|
||||
"test": VerifyDynamicVlanSource,
|
||||
(VerifyDynamicVlanSource, "failure-all-sources-exact-match-additional-source-found"): {
|
||||
"eos_data": [{"dynamicVlans": {"evpn": {"vlanIds": [1199]}, "mlagsync": {"vlanIds": [1500]}, "vccbfd": {"vlanIds": [1500]}}}],
|
||||
"inputs": {"sources": ["evpn", "mlagsync"], "strict": True},
|
||||
"expected": {
|
||||
"result": "failure",
|
||||
"messages": ["Strict mode enabled: Unexpected sources have VLANs allocated: vccbfd"],
|
||||
},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Strict mode enabled: Unexpected sources have VLANs allocated: vccbfd"]},
|
||||
},
|
||||
{
|
||||
"name": "failure-all-sources-exact-match-expected-source-not-found",
|
||||
"test": VerifyDynamicVlanSource,
|
||||
(VerifyDynamicVlanSource, "failure-all-sources-exact-match-expected-source-not-found"): {
|
||||
"eos_data": [{"dynamicVlans": {"evpn": {"vlanIds": [1199]}, "mlagsync": {"vlanIds": []}}}],
|
||||
"inputs": {"sources": ["evpn", "mlagsync"], "strict": True},
|
||||
"expected": {"result": "failure", "messages": ["Dynamic VLAN source(s) exist but have no VLANs allocated: mlagsync"]},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["Dynamic VLAN source(s) exist but have no VLANs allocated: mlagsync"]},
|
||||
},
|
||||
]
|
||||
(VerifyVlanStatus, "success"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"vlans": {
|
||||
"1": {"name": "default", "dynamic": False, "status": "active", "interfaces": {}},
|
||||
"4092": {"name": "VLAN4092", "dynamic": True, "status": "active", "interfaces": {}},
|
||||
"4094": {"name": "VLAN4094", "dynamic": True, "status": "active", "interfaces": {}},
|
||||
},
|
||||
"sourceDetail": "",
|
||||
}
|
||||
],
|
||||
"inputs": {"vlans": [{"vlan_id": 4092, "status": "active"}, {"vlan_id": 4094, "status": "active"}]},
|
||||
"expected": {"result": AntaTestStatus.SUCCESS},
|
||||
},
|
||||
(VerifyVlanStatus, "failure-vlan-not-conifgured"): {
|
||||
"eos_data": [{"vlans": {"1": {"name": "default", "dynamic": False, "status": "active", "interfaces": {}}}, "sourceDetail": ""}],
|
||||
"inputs": {"vlans": [{"vlan_id": 4092, "status": "active"}, {"vlan_id": 4094, "status": "active"}]},
|
||||
"expected": {"result": AntaTestStatus.FAILURE, "messages": ["VLAN: Vlan4092 - Not configured", "VLAN: Vlan4094 - Not configured"]},
|
||||
},
|
||||
(VerifyVlanStatus, "failure-incorrect-status"): {
|
||||
"eos_data": [
|
||||
{
|
||||
"vlans": {
|
||||
"1": {"name": "default", "dynamic": False, "status": "active", "interfaces": {}},
|
||||
"4092": {"name": "VLAN4092", "dynamic": True, "status": "suspended", "interfaces": {}},
|
||||
"4094": {"name": "VLAN4094", "dynamic": True, "status": "active", "interfaces": {}},
|
||||
},
|
||||
"sourceDetail": "",
|
||||
}
|
||||
],
|
||||
"inputs": {"vlans": [{"vlan_id": 4092, "status": "active"}, {"vlan_id": 4094, "status": "suspended"}]},
|
||||
"expected": {
|
||||
"result": AntaTestStatus.FAILURE,
|
||||
"messages": [
|
||||
"VLAN: Vlan4092 - Incorrect administrative status - Expected: active Actual: suspended",
|
||||
"VLAN: Vlan4094 - Incorrect administrative status - Expected: suspended Actual: active",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue