Merging upstream version 1.3.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-03-17 07:33:51 +01:00
parent 5b922100c9
commit 8a6a3342fc
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
337 changed files with 16571 additions and 4891 deletions

View file

@ -1,4 +1,4 @@
# Copyright (c) 2023-2024 Arista Networks, Inc.
# Copyright (c) 2023-2025 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."""
@ -7,7 +7,7 @@ from __future__ import annotations
from typing import Any
from anta.tests.vlan import VerifyVlanInternalPolicy
from anta.tests.vlan import VerifyDynamicVlanSource, VerifyVlanInternalPolicy
from tests.units.anta_tests import test
DATA: list[dict[str, Any]] = [
@ -23,14 +23,70 @@ DATA: list[dict[str, Any]] = [
"test": VerifyVlanInternalPolicy,
"eos_data": [{"policy": "descending", "startVlanId": 4094, "endVlanId": 1006}],
"inputs": {"policy": "ascending", "start_vlan_id": 1006, "end_vlan_id": 4094},
"expected": {
"result": "failure",
"messages": ["Incorrect VLAN internal allocation policy configured - Expected: ascending Actual: descending"],
},
},
{
"name": "failure-incorrect-start-end-id",
"test": VerifyVlanInternalPolicy,
"eos_data": [{"policy": "ascending", "startVlanId": 4094, "endVlanId": 1006}],
"inputs": {"policy": "ascending", "start_vlan_id": 1006, "end_vlan_id": 4094},
"expected": {
"result": "failure",
"messages": [
"The VLAN internal allocation policy is not configured properly:\n"
"Expected `ascending` as the policy, but found `descending` instead.\n"
"Expected `1006` as the startVlanId, but found `4094` instead.\n"
"Expected `4094` as the endVlanId, but found `1006` instead."
"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,
"eos_data": [{"dynamicVlans": {"evpn": {"vlanIds": [1199]}, "mlagsync": {"vlanIds": [1401]}, "vccbfd": {"vlanIds": [1501]}}}],
"inputs": {"sources": ["evpn", "mlagsync"], "strict": False},
"expected": {"result": "success"},
},
{
"name": "failure-no-dynamic-vlan-sources",
"test": VerifyDynamicVlanSource,
"eos_data": [{"dynamicVlans": {}}],
"inputs": {"sources": ["evpn", "mlagsync"], "strict": False},
"expected": {"result": "failure", "messages": ["Dynamic VLAN source(s) not found in configuration: evpn, mlagsync"]},
},
{
"name": "failure-dynamic-vlan-sources-mismatch",
"test": VerifyDynamicVlanSource,
"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"],
},
},
{
"name": "success-strict-mode",
"test": VerifyDynamicVlanSource,
"eos_data": [{"dynamicVlans": {"evpn": {"vlanIds": [1199]}, "mlagsync": {"vlanIds": [1502], "vccbfd": {"vlanIds": []}}}}],
"inputs": {"sources": ["evpn", "mlagsync"], "strict": True},
"expected": {"result": "success"},
},
{
"name": "failure-all-sources-exact-match-additional-source-found",
"test": VerifyDynamicVlanSource,
"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"],
},
},
{
"name": "failure-all-sources-exact-match-expected-source-not-found",
"test": VerifyDynamicVlanSource,
"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"]},
},
]