diff --git a/anta/tests/vxlan.py b/anta/tests/vxlan.py index d45ff8dd0..72003a66a 100644 --- a/anta/tests/vxlan.py +++ b/anta/tests/vxlan.py @@ -5,19 +5,29 @@ from anta.models import AntaCommand, AntaTest -class VerifyVxlan(AntaTest): +class VerifyVxlan1Interface(AntaTest): """ - Verifies if Vxlan1 interface is configured, and is up/up + This test verifies if the Vxlan1 interface is configured and 'up/up'. + + !!! warning + The name of this test has been updated from 'VerifyVxlan' for better representation. + + Expected Results: + * success: The test will pass if the Vxlan1 interface is configured with line protocol status and interface status 'up'. + * failure: The test will fail if the Vxlan1 interface line protocol status or interface status are not 'up'. + * skipped: The test will be skipped if the Vxlan1 interface is not configured. """ - name = "VerifyVxlan" - description = "Verifies Vxlan1 status" + name = "VerifyVxlan1Interface" + description = "This test verifies if the Vxlan1 interface is configured and 'up/up'." categories = ["vxlan"] commands = [AntaCommand(command="show interfaces description", ofmt="json")] @AntaTest.anta_test def test(self) -> None: - """Run VerifyVxlan validation""" + """ + Run VerifyVxlan1Interface validation + """ command_output = self.instance_commands[0].json_output @@ -37,22 +47,29 @@ def test(self) -> None: class VerifyVxlanConfigSanity(AntaTest): """ - Verifies that there are no VXLAN config-sanity issues flagged + This test verifies that no issues are detected with the VXLAN configuration. + + Expected Results: + * success: The test will pass if no issues are detected with the VXLAN configuration. + * failure: The test will fail if issues are detected with the VXLAN configuration. + * skipped: The test will be skipped if VXLAN is not configured on the device. """ name = "VerifyVxlanConfigSanity" - description = "Verifies VXLAN config-sanity" + description = "This test verifies that no issues are detected with the VXLAN configuration." categories = ["vxlan"] commands = [AntaCommand(command="show vxlan config-sanity", ofmt="json")] @AntaTest.anta_test def test(self) -> None: - """Run VerifyVxlanConfigSanity validation""" + """ + Run VerifyVxlanConfigSanity validation + """ command_output = self.instance_commands[0].json_output if "categories" not in command_output or len(command_output["categories"]) == 0: - self.result.is_skipped("VXLAN is not configured on this device") + self.result.is_skipped("VXLAN is not configured") return failed_categories = { @@ -62,6 +79,6 @@ def test(self) -> None: } if len(failed_categories) > 0: - self.result.is_failure(f"Vxlan config sanity check is not passing: {failed_categories}") + self.result.is_failure(f"VXLAN config sanity check is not passing: {failed_categories}") else: self.result.is_success() diff --git a/docs/api/tests.md b/docs/api/tests.md index 7201899fb..2af8e421d 100644 --- a/docs/api/tests.md +++ b/docs/api/tests.md @@ -21,7 +21,7 @@ This section describes all the available tests provided by ANTA package. - [Software](tests.software.md) - [STP](tests.stp.md) - [System](tests.system.md) -- [VxLAN](tests.vxlan.md) +- [VXLAN](tests.vxlan.md) diff --git a/docs/api/tests.vxlan.md b/docs/api/tests.vxlan.md index f456ccacb..806796dc6 100644 --- a/docs/api/tests.vxlan.md +++ b/docs/api/tests.vxlan.md @@ -1,4 +1,4 @@ -# ANTA catalog for VxLAN tests +# ANTA catalog for VXLAN tests ::: anta.tests.vxlan options: diff --git a/examples/tests.yaml b/examples/tests.yaml index 6a8be9794..09b51340f 100644 --- a/examples/tests.yaml +++ b/examples/tests.yaml @@ -217,7 +217,7 @@ anta.tests.system: - VerifyNTP: anta.tests.vxlan: - - VerifyVxlan: + - VerifyVxlan1Interface: - VerifyVxlanConfigSanity: anta.tests.routing: diff --git a/mkdocs.yml b/mkdocs.yml index a78a2f16f..27266e70d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -185,7 +185,7 @@ nav: - STP: api/tests.stp.md - Software: api/tests.software.md - System: api/tests.system.md - - VxLAN: api/tests.vxlan.md + - VXLAN: api/tests.vxlan.md - API Documentation: - Inventory: - Inventory module: api/inventory.md diff --git a/tests/units/anta_tests/vxlan/data.py b/tests/units/anta_tests/vxlan/data.py index 2b34d521b..2d0e67f0a 100644 --- a/tests/units/anta_tests/vxlan/data.py +++ b/tests/units/anta_tests/vxlan/data.py @@ -387,7 +387,7 @@ ], "side_effect": [], "expected_result": "failure", - "expected_messages": ["Vxlan config sanity check is not passing: {'localVtep': {'description': 'Local VTEP Configuration Check', " + "expected_messages": ["VXLAN config sanity check is not passing: {'localVtep': {'description': 'Local VTEP Configuration Check', " "'allCheckPass': False, 'detail': '', 'hasWarning': True, 'items': [{'name': 'Loopback IP Address', 'checkPass': True, " "'hasWarning': False, 'detail': ''}, {'name': 'VLAN-VNI Map', 'checkPass': False, 'hasWarning': False, 'detail': " "'No VLAN-VNI mapping in Vxlan1'}, {'name': 'Flood List', 'checkPass': False, 'hasWarning': True, 'detail': " @@ -405,6 +405,6 @@ ], "side_effect": [], "expected_result": "skipped", - "expected_messages": ["VXLAN is not configured on this device"] + "expected_messages": ["VXLAN is not configured"] }, ] diff --git a/tests/units/anta_tests/vxlan/test_exc.py b/tests/units/anta_tests/vxlan/test_exc.py index 677312da0..fa36fb73a 100644 --- a/tests/units/anta_tests/vxlan/test_exc.py +++ b/tests/units/anta_tests/vxlan/test_exc.py @@ -10,20 +10,20 @@ import pytest -from anta.tests.vxlan import VerifyVxlan, VerifyVxlanConfigSanity +from anta.tests.vxlan import VerifyVxlan1Interface, VerifyVxlanConfigSanity from tests.lib.utils import generate_test_ids_list from .data import INPUT_VXLAN_CONFIG_SANITY, INPUT_VXLAN_STATUS @pytest.mark.parametrize("test_data", INPUT_VXLAN_STATUS, ids=generate_test_ids_list(INPUT_VXLAN_STATUS)) -def test_VerifyVxlan(mocked_device: MagicMock, test_data: Any) -> None: - """Check VerifyVxlan""" +def test_VerifyVxlan1Interface(mocked_device: MagicMock, test_data: Any) -> None: + """Check VerifyVxlan1Interface""" logging.info(f"Mocked device is: {mocked_device.host}") logging.info(f"Mocked HW is: {mocked_device.hw_model}") - test = VerifyVxlan(mocked_device, eos_data=test_data["eos_data"]) + test = VerifyVxlan1Interface(mocked_device, eos_data=test_data["eos_data"]) asyncio.run(test.test()) logging.info(f"test result is: {test.result}") @@ -34,7 +34,7 @@ def test_VerifyVxlan(mocked_device: MagicMock, test_data: Any) -> None: @pytest.mark.parametrize("test_data", INPUT_VXLAN_CONFIG_SANITY, ids=generate_test_ids_list(INPUT_VXLAN_CONFIG_SANITY)) def test_VerifyVxlanConfigSanity(mocked_device: MagicMock, test_data: Any) -> None: - """Check VerifyVxlan""" + """Check VerifyVxlanConfigSanity""" logging.info(f"Mocked device is: {mocked_device.host}") logging.info(f"Mocked HW is: {mocked_device.hw_model}")