From 8a43251c1b701c58786b33865a9662e5fefef3cb Mon Sep 17 00:00:00 2001 From: Geetanjali Mane Date: Thu, 26 Dec 2024 14:46:49 +0530 Subject: [PATCH 1/6] feat(anta): Issue_882-Added the test case to verify the Graceful Restart (GR) and GR-Helper --- anta/input_models/routing/isis.py | 26 +++++ anta/tests/routing/isis.py | 91 ++++++++++++++++ examples/tests.yaml | 20 ++++ tests/units/anta_tests/routing/test_isis.py | 115 ++++++++++++++++++++ 4 files changed, 252 insertions(+) create mode 100644 anta/input_models/routing/isis.py diff --git a/anta/input_models/routing/isis.py b/anta/input_models/routing/isis.py new file mode 100644 index 000000000..62c8dd2a4 --- /dev/null +++ b/anta/input_models/routing/isis.py @@ -0,0 +1,26 @@ +# 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. +"""Module containing input models for ISIS tests.""" + +from __future__ import annotations + +from pydantic import BaseModel, ConfigDict + + +class ISISInstances(BaseModel): + """Model for a list of ISIS instance entries.""" + + model_config = ConfigDict(extra="forbid") + vrf: str = "default" + """VRF context. Defaults to `default` VRF.""" + name: str + """The instance name or ID to validated the instance specific isis details.""" + graceful_restart: bool = True + """Flag to check if the graceful restart is enabled for isis instance, Defaults to `True`""" + graceful_helper: bool = True + """Flag to check if the graceful helper is enabled for isis instance, Defaults to `True`""" + + def __str__(self) -> str: + """Return a human-readable string representation of the ISISInstances for reporting.""" + return f"VRF: {self.vrf} Instance: {self.name}" diff --git a/anta/tests/routing/isis.py b/anta/tests/routing/isis.py index 562ff6d65..f614b0d72 100644 --- a/anta/tests/routing/isis.py +++ b/anta/tests/routing/isis.py @@ -13,6 +13,7 @@ from pydantic import BaseModel from anta.custom_types import Interface +from anta.input_models.routing.isis import ISISInstances from anta.models import AntaCommand, AntaTemplate, AntaTest from anta.tools import get_value @@ -728,3 +729,93 @@ def _check_tunnel_id(self, via_input: VerifyISISSegmentRoutingTunnels.Input.Entr for eos_via in eos_entry["vias"] ) return True + + +class VerifyISISGracefulRestart(AntaTest): + """Verifies the graceful restart and helper mechanism. + + This test performs the following checks: + + 1. Verifies that the ISIS is configured. + 2. Verifies that the specified VRF is found. + 3. Verifies that the specified VRF instance is found. + 4. Verifies that the IS-IS graceful restart and graceful helper are set as expected in the inputs. + + Expected Results + ---------------- + * Success: The test will pass if graceful restart and graceful helper are set as expected for a specified VRF instance. + * Failure: The test will fail if graceful restart and graceful helper are not set as expected for a specified VRF instance. + + Examples + -------- + ```yaml + anta.tests.routing: + isis: + - VerifyISISGracefulRestart: + instances: + - vrf: default + name: 1 + graceful_restart: True + graceful_helper: True + - vrf: default + name: 2 + graceful_restart: True + graceful_helper: True + - vrf: test + name: 1 + graceful_restart: True + graceful_helper: True + - vrf: test + name: 2 + graceful_restart: True + graceful_helper: True + + ``` + """ + + categories: ClassVar[list[str]] = ["isis"] + commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis summary", revision=1)] + + class Input(AntaTest.Input): + """Input model for the VerifyISISGracefulRestart test.""" + + instances: list[ISISInstances] + """List of ISIS instance entries.""" + + @AntaTest.anta_test + def test(self) -> None: + """Main test function for VerifyISISGracefulRestart.""" + self.result.is_success() + command_output = self.instance_commands[0].json_output + isis_details = command_output.get("vrfs") + + # If ISIS is not configured, test fails + if not isis_details: + self.result.is_failure("ISIS is not configured") + return + + # If VRF, vrf-instance is not found or GR and GR helpers are not matching with the expected values, test fails. + for instance in self.inputs.instances: + vrf = instance.vrf + instance_name = str(instance.name) + graceful_restart = instance.graceful_restart + graceful_helper = instance.graceful_helper + + if (vrf_details := get_value(isis_details, vrf)) is None: + self.result.is_failure(f"{instance} - VRF is not configured") + continue + + if (instance_details := get_value(vrf_details, f"isisInstances.{instance_name}")) is None: + self.result.is_failure(f"{instance} - Not found") + continue + + if instance_details.get("gracefulRestart") != graceful_restart: + self.result.is_failure( + f"{instance} - Incorrect value for Graceful Restart - Expected: {graceful_restart}, Actual: {instance_details.get('gracefulRestart')}" + ) + + if instance_details.get("gracefulRestartHelper") != graceful_helper: + self.result.is_failure( + f"{instance} - Incorrect value for Graceful Restart Helper - Expected: {graceful_helper}, Actual: {instance_details.get('gracefulRestartHelper') + }" + ) diff --git a/examples/tests.yaml b/examples/tests.yaml index a4bc1fabf..e432550eb 100644 --- a/examples/tests.yaml +++ b/examples/tests.yaml @@ -541,6 +541,26 @@ anta.tests.routing.generic: minimum: 2 maximum: 20 anta.tests.routing.isis: + - VerifyISISGracefulRestart: + # Verifies the graceful restart and helper mechanism. + instances: + - vrf: default + name: 1 + graceful_restart: True + graceful_helper: True + - vrf: default + name: 2 + graceful_restart: True + graceful_helper: True + - vrf: test + name: 1 + graceful_restart: True + graceful_helper: True + - vrf: test + name: 2 + graceful_restart: True + graceful_helper: True + - VerifyISISInterfaceMode: # Verifies interface mode for IS-IS interfaces: diff --git a/tests/units/anta_tests/routing/test_isis.py b/tests/units/anta_tests/routing/test_isis.py index 9c379eae3..ba3baf4e7 100644 --- a/tests/units/anta_tests/routing/test_isis.py +++ b/tests/units/anta_tests/routing/test_isis.py @@ -12,6 +12,7 @@ import pytest from anta.tests.routing.isis import ( + VerifyISISGracefulRestart, VerifyISISInterfaceMode, VerifyISISNeighborCount, VerifyISISNeighborState, @@ -1840,6 +1841,120 @@ "messages": ["Tunnel to 1.0.0.111/32 is incorrect: incorrect tunnel ID"], }, }, + { + "name": "success", + "test": VerifyISISGracefulRestart, + "eos_data": [ + { + "vrfs": { + "default": { + "isisInstances": { + "1": {"gracefulRestart": True, "gracefulRestartHelper": True}, + "2": {"gracefulRestart": True, "gracefulRestartHelper": True}, + } + }, + "test": { + "isisInstances": { + "1": {"gracefulRestart": True, "gracefulRestartHelper": True}, + "2": {"gracefulRestart": True, "gracefulRestartHelper": True}, + } + }, + } + } + ], + "inputs": { + "instances": [ + {"vrf": "default", "name": "1", "graceful_restart": True, "graceful_helper": True}, + {"vrf": "default", "name": "2", "graceful_restart": True, "graceful_helper": True}, + {"vrf": "test", "name": "1", "graceful_restart": True, "graceful_helper": True}, + {"vrf": "test", "name": "2", "graceful_restart": True, "graceful_helper": True}, + ] + }, + "expected": {"result": "success"}, + }, + { + "name": "failure-isis-not-configured", + "test": VerifyISISGracefulRestart, + "eos_data": [{"vrfs": {}}], + "inputs": {"instances": [{"vrf": "default", "name": "1", "graceful_restart": True, "graceful_helper": True}]}, + "expected": {"result": "failure", "messages": ["ISIS is not configured"]}, + }, + { + "name": "failure-isis-vrf-not-found", + "test": VerifyISISGracefulRestart, + "eos_data": [{"vrfs": {"test": {"isisInstances": {"1": {"gracefulRestart": True, "gracefulRestartHelper": True}}}}}], + "inputs": {"instances": [{"vrf": "default", "name": "1", "graceful_restart": True, "graceful_helper": True}]}, + "expected": {"result": "failure", "messages": ["VRF: default Instance: 1 - VRF is not configured"]}, + }, + { + "name": "failure-isis-instance-not-found", + "test": VerifyISISGracefulRestart, + "eos_data": [{"vrfs": {"default": {"isisInstances": {"2": {"gracefulRestart": True, "gracefulRestartHelper": True}}}}}], + "inputs": {"instances": [{"vrf": "default", "name": "1", "graceful_restart": True, "graceful_helper": True}]}, + "expected": {"result": "failure", "messages": ["VRF: default Instance: 1 - Not found"]}, + }, + { + "name": "failure-graceful-restart-disabled", + "test": VerifyISISGracefulRestart, + "eos_data": [ + { + "vrfs": { + "default": { + "isisInstances": { + "1": {"gracefulRestart": False, "gracefulRestartHelper": True}, + "2": {"gracefulRestart": True, "gracefulRestartHelper": True}, + } + }, + "test": { + "isisInstances": { + "1": {"gracefulRestart": False, "gracefulRestartHelper": True}, + "2": {"gracefulRestart": True, "gracefulRestartHelper": True}, + } + }, + } + } + ], + "inputs": { + "instances": [ + {"vrf": "default", "name": "1", "graceful_restart": True, "graceful_helper": True}, + {"vrf": "default", "name": "2", "graceful_restart": True, "graceful_helper": True}, + {"vrf": "test", "name": "1", "graceful_restart": True, "graceful_helper": True}, + {"vrf": "test", "name": "2", "graceful_restart": True, "graceful_helper": True}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "VRF: default Instance: 1 - Incorrect value for Graceful Restart - Expected: True, Actual: False", + "VRF: test Instance: 1 - Incorrect value for Graceful Restart - Expected: True, Actual: False", + ], + }, + }, + { + "name": "failure-graceful-restart--helper-disabled", + "test": VerifyISISGracefulRestart, + "eos_data": [ + { + "vrfs": { + "default": {"isisInstances": {"1": {"gracefulRestart": True, "gracefulRestartHelper": False}}}, + "test": {"isisInstances": {"1": {"gracefulRestart": True, "gracefulRestartHelper": False}}}, + } + } + ], + "inputs": { + "instances": [ + {"vrf": "default", "name": "1", "graceful_restart": True, "graceful_helper": True}, + {"vrf": "test", "name": "1", "graceful_restart": True, "graceful_helper": True}, + ] + }, + "expected": { + "result": "failure", + "messages": [ + "VRF: default Instance: 1 - Incorrect value for Graceful Restart Helper - Expected: True, Actual: False", + "VRF: test Instance: 1 - Incorrect value for Graceful Restart Helper - Expected: True, Actual: False", + ], + }, + }, ] From 6f40cfa8a980927aca532df4d464f94b342e7378 Mon Sep 17 00:00:00 2001 From: Geetanjali Mane Date: Thu, 26 Dec 2024 15:18:24 +0530 Subject: [PATCH 2/6] Issue_882: Added documenation for isis input model --- anta/tests/routing/isis.py | 9 +++------ docs/api/tests.routing.isis.md | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/anta/tests/routing/isis.py b/anta/tests/routing/isis.py index f614b0d72..f79e6ff49 100644 --- a/anta/tests/routing/isis.py +++ b/anta/tests/routing/isis.py @@ -800,7 +800,6 @@ def test(self) -> None: instance_name = str(instance.name) graceful_restart = instance.graceful_restart graceful_helper = instance.graceful_helper - if (vrf_details := get_value(isis_details, vrf)) is None: self.result.is_failure(f"{instance} - VRF is not configured") continue @@ -814,8 +813,6 @@ def test(self) -> None: f"{instance} - Incorrect value for Graceful Restart - Expected: {graceful_restart}, Actual: {instance_details.get('gracefulRestart')}" ) - if instance_details.get("gracefulRestartHelper") != graceful_helper: - self.result.is_failure( - f"{instance} - Incorrect value for Graceful Restart Helper - Expected: {graceful_helper}, Actual: {instance_details.get('gracefulRestartHelper') - }" - ) + actual_gr_helper = instance_details.get("gracefulRestartHelper") + if actual_gr_helper != graceful_helper: + self.result.is_failure(f"{instance} - Incorrect value for Graceful Restart Helper - Expected: {graceful_helper}, Actual: {actual_gr_helper}") diff --git a/docs/api/tests.routing.isis.md b/docs/api/tests.routing.isis.md index 90e6d25d9..dbe924dda 100644 --- a/docs/api/tests.routing.isis.md +++ b/docs/api/tests.routing.isis.md @@ -7,6 +7,8 @@ anta_title: ANTA catalog for IS-IS tests ~ that can be found in the LICENSE file. --> +# Test + ::: anta.tests.routing.isis options: @@ -20,3 +22,16 @@ anta_title: ANTA catalog for IS-IS tests - "!test" - "!render" - "!^_[^_]" + +# Input models + +::: anta.input_models.routing.isis + + options: + show_root_heading: false + show_root_toc_entry: false + show_bases: false + merge_init_into_class: false + anta_hide_test_module_description: true + show_labels: true + filters: ["!^__str__"] From 1dd3e8dd8177280f1fe0d2d5795b921256b51e33 Mon Sep 17 00:00:00 2001 From: Geetanjali Mane Date: Tue, 31 Dec 2024 15:42:51 +0530 Subject: [PATCH 3/6] Issue_882: Updated test descriptions --- anta/input_models/routing/isis.py | 10 ++++++++-- anta/tests/routing/isis.py | 20 +++++++++++++------- tests/units/anta_tests/routing/test_isis.py | 9 +++------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/anta/input_models/routing/isis.py b/anta/input_models/routing/isis.py index 62c8dd2a4..02fb7dba5 100644 --- a/anta/input_models/routing/isis.py +++ b/anta/input_models/routing/isis.py @@ -17,9 +17,15 @@ class ISISInstances(BaseModel): name: str """The instance name or ID to validated the instance specific isis details.""" graceful_restart: bool = True - """Flag to check if the graceful restart is enabled for isis instance, Defaults to `True`""" + """Specifies the Graceful Restart, + Options: + - True: Default mode, refer as graceful restart is enabled. + - False: Refer as graceful restart is disabled.""" graceful_helper: bool = True - """Flag to check if the graceful helper is enabled for isis instance, Defaults to `True`""" + """Specifies the Graceful Restart Helper, + Options: + - True: Default mode, refer as graceful restart helper is enabled. + - False: Refer as graceful restart helper is disabled.""" def __str__(self) -> str: """Return a human-readable string representation of the ISISInstances for reporting.""" diff --git a/anta/tests/routing/isis.py b/anta/tests/routing/isis.py index f79e6ff49..840c3f208 100644 --- a/anta/tests/routing/isis.py +++ b/anta/tests/routing/isis.py @@ -737,14 +737,22 @@ class VerifyISISGracefulRestart(AntaTest): This test performs the following checks: 1. Verifies that the ISIS is configured. - 2. Verifies that the specified VRF is found. + 2. Verifies that the specified VRF is configured. 3. Verifies that the specified VRF instance is found. 4. Verifies that the IS-IS graceful restart and graceful helper are set as expected in the inputs. Expected Results ---------------- - * Success: The test will pass if graceful restart and graceful helper are set as expected for a specified VRF instance. - * Failure: The test will fail if graceful restart and graceful helper are not set as expected for a specified VRF instance. + * Success: The test will pass if all of the following conditions are met: + - ISIS is configured on the device. + - Specified VRF is configured. + - Specified VRF instance is found + - Expected and actual IS-IS graceful restart and graceful helper values are matched. + * Failure: The test will fail if any of the following conditions is met: + - ISIS is not configured on the device. + - Specified VRF is not configured. + - Specified VRF instance is not found. + - Expected and actual IS-IS graceful restart and graceful helper values are not matched. Examples -------- @@ -809,10 +817,8 @@ def test(self) -> None: continue if instance_details.get("gracefulRestart") != graceful_restart: - self.result.is_failure( - f"{instance} - Incorrect value for Graceful Restart - Expected: {graceful_restart}, Actual: {instance_details.get('gracefulRestart')}" - ) + self.result.is_failure(f"{instance} - Graceful Restart disabled") actual_gr_helper = instance_details.get("gracefulRestartHelper") if actual_gr_helper != graceful_helper: - self.result.is_failure(f"{instance} - Incorrect value for Graceful Restart Helper - Expected: {graceful_helper}, Actual: {actual_gr_helper}") + self.result.is_failure(f"{instance} - Graceful Restart Helper disabled") diff --git a/tests/units/anta_tests/routing/test_isis.py b/tests/units/anta_tests/routing/test_isis.py index ba3baf4e7..06740a42f 100644 --- a/tests/units/anta_tests/routing/test_isis.py +++ b/tests/units/anta_tests/routing/test_isis.py @@ -1925,8 +1925,8 @@ "expected": { "result": "failure", "messages": [ - "VRF: default Instance: 1 - Incorrect value for Graceful Restart - Expected: True, Actual: False", - "VRF: test Instance: 1 - Incorrect value for Graceful Restart - Expected: True, Actual: False", + "VRF: default Instance: 1 - Graceful Restart disabled", + "VRF: test Instance: 1 - Graceful Restart disabled", ], }, }, @@ -1949,10 +1949,7 @@ }, "expected": { "result": "failure", - "messages": [ - "VRF: default Instance: 1 - Incorrect value for Graceful Restart Helper - Expected: True, Actual: False", - "VRF: test Instance: 1 - Incorrect value for Graceful Restart Helper - Expected: True, Actual: False", - ], + "messages": ["VRF: default Instance: 1 - Graceful Restart Helper disabled", "VRF: test Instance: 1 - Graceful Restart Helper disabled"], }, }, ] From c2134a015f1a30a6d2347fd61f6abc345e95aa6a Mon Sep 17 00:00:00 2001 From: Geetanjali Mane Date: Tue, 31 Dec 2024 16:33:55 +0530 Subject: [PATCH 4/6] Issue_882: Updated instance name as str --- anta/tests/routing/isis.py | 8 ++++---- examples/tests.yaml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/anta/tests/routing/isis.py b/anta/tests/routing/isis.py index 840c3f208..fa4374626 100644 --- a/anta/tests/routing/isis.py +++ b/anta/tests/routing/isis.py @@ -762,19 +762,19 @@ class VerifyISISGracefulRestart(AntaTest): - VerifyISISGracefulRestart: instances: - vrf: default - name: 1 + name: '1' graceful_restart: True graceful_helper: True - vrf: default - name: 2 + name: '2' graceful_restart: True graceful_helper: True - vrf: test - name: 1 + name: '1' graceful_restart: True graceful_helper: True - vrf: test - name: 2 + name: '2' graceful_restart: True graceful_helper: True diff --git a/examples/tests.yaml b/examples/tests.yaml index e432550eb..440456bbe 100644 --- a/examples/tests.yaml +++ b/examples/tests.yaml @@ -545,19 +545,19 @@ anta.tests.routing.isis: # Verifies the graceful restart and helper mechanism. instances: - vrf: default - name: 1 + name: '1' graceful_restart: True graceful_helper: True - vrf: default - name: 2 + name: '2' graceful_restart: True graceful_helper: True - vrf: test - name: 1 + name: '1' graceful_restart: True graceful_helper: True - vrf: test - name: 2 + name: '2' graceful_restart: True graceful_helper: True From 43516d82634301d4ff26d6d35831b37196570344 Mon Sep 17 00:00:00 2001 From: Geetanjali Mane Date: Fri, 3 Jan 2025 19:43:36 +0530 Subject: [PATCH 5/6] Issue_882: Updated docstrings and removed VRF check --- anta/input_models/routing/isis.py | 8 +++--- anta/tests/routing/isis.py | 29 ++++++++------------- examples/tests.yaml | 3 +-- tests/units/anta_tests/routing/test_isis.py | 16 +++--------- 4 files changed, 19 insertions(+), 37 deletions(-) diff --git a/anta/input_models/routing/isis.py b/anta/input_models/routing/isis.py index 02fb7dba5..91cb6af4c 100644 --- a/anta/input_models/routing/isis.py +++ b/anta/input_models/routing/isis.py @@ -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. """Module containing input models for ISIS tests.""" @@ -12,10 +12,10 @@ class ISISInstances(BaseModel): """Model for a list of ISIS instance entries.""" model_config = ConfigDict(extra="forbid") - vrf: str = "default" - """VRF context. Defaults to `default` VRF.""" name: str """The instance name or ID to validated the instance specific isis details.""" + vrf: str = "default" + """VRF context. Defaults to `default` VRF.""" graceful_restart: bool = True """Specifies the Graceful Restart, Options: @@ -29,4 +29,4 @@ class ISISInstances(BaseModel): def __str__(self) -> str: """Return a human-readable string representation of the ISISInstances for reporting.""" - return f"VRF: {self.vrf} Instance: {self.name}" + return f"Instance: {self.name} VRF: {self.vrf}" diff --git a/anta/tests/routing/isis.py b/anta/tests/routing/isis.py index fa4374626..cbb2706ef 100644 --- a/anta/tests/routing/isis.py +++ b/anta/tests/routing/isis.py @@ -732,26 +732,23 @@ def _check_tunnel_id(self, via_input: VerifyISISSegmentRoutingTunnels.Input.Entr class VerifyISISGracefulRestart(AntaTest): - """Verifies the graceful restart and helper mechanism. + """Verifies the graceful restart and helper mechanism. This test performs the following checks: 1. Verifies that the ISIS is configured. - 2. Verifies that the specified VRF is configured. - 3. Verifies that the specified VRF instance is found. - 4. Verifies that the IS-IS graceful restart and graceful helper are set as expected in the inputs. + 2. Verifies that the specified ISIS instance is found on the device. + 4. Verifies that the expected and actual IS-IS graceful restart and graceful helper values are matched. Expected Results ---------------- * Success: The test will pass if all of the following conditions are met: - - ISIS is configured on the device. - - Specified VRF is configured. - - Specified VRF instance is found + - The ISIS is configured on the device. + - The specified ISIS instance is exist on the device. - Expected and actual IS-IS graceful restart and graceful helper values are matched. * Failure: The test will fail if any of the following conditions is met: - - ISIS is not configured on the device. - - Specified VRF is not configured. - - Specified VRF instance is not found. + - The ISIS is not configured on the device. + - The Specified ISIS instance do not exist on the device. - Expected and actual IS-IS graceful restart and graceful helper values are not matched. Examples @@ -777,12 +774,11 @@ class VerifyISISGracefulRestart(AntaTest): name: '2' graceful_restart: True graceful_helper: True - ``` """ categories: ClassVar[list[str]] = ["isis"] - commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis summary", revision=1)] + commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis summary vrf all")] class Input(AntaTest.Input): """Input model for the VerifyISISGracefulRestart test.""" @@ -797,22 +793,19 @@ def test(self) -> None: command_output = self.instance_commands[0].json_output isis_details = command_output.get("vrfs") - # If ISIS is not configured, test fails + # If ISIS is not configured, test fails. if not isis_details: self.result.is_failure("ISIS is not configured") return - # If VRF, vrf-instance is not found or GR and GR helpers are not matching with the expected values, test fails. + # If ISIS-instance is not found or GR and GR helpers are not matching with the expected values, test fails. for instance in self.inputs.instances: vrf = instance.vrf instance_name = str(instance.name) graceful_restart = instance.graceful_restart graceful_helper = instance.graceful_helper - if (vrf_details := get_value(isis_details, vrf)) is None: - self.result.is_failure(f"{instance} - VRF is not configured") - continue - if (instance_details := get_value(vrf_details, f"isisInstances.{instance_name}")) is None: + if (instance_details := get_value(isis_details, f"{vrf}.isisInstances.{instance_name}")) is None: self.result.is_failure(f"{instance} - Not found") continue diff --git a/examples/tests.yaml b/examples/tests.yaml index 440456bbe..6b3be4985 100644 --- a/examples/tests.yaml +++ b/examples/tests.yaml @@ -542,7 +542,7 @@ anta.tests.routing.generic: maximum: 20 anta.tests.routing.isis: - VerifyISISGracefulRestart: - # Verifies the graceful restart and helper mechanism. + # Verifies the graceful restart and helper mechanism. instances: - vrf: default name: '1' @@ -560,7 +560,6 @@ anta.tests.routing.isis: name: '2' graceful_restart: True graceful_helper: True - - VerifyISISInterfaceMode: # Verifies interface mode for IS-IS interfaces: diff --git a/tests/units/anta_tests/routing/test_isis.py b/tests/units/anta_tests/routing/test_isis.py index 06740a42f..d27e075c2 100644 --- a/tests/units/anta_tests/routing/test_isis.py +++ b/tests/units/anta_tests/routing/test_isis.py @@ -1879,19 +1879,12 @@ "inputs": {"instances": [{"vrf": "default", "name": "1", "graceful_restart": True, "graceful_helper": True}]}, "expected": {"result": "failure", "messages": ["ISIS is not configured"]}, }, - { - "name": "failure-isis-vrf-not-found", - "test": VerifyISISGracefulRestart, - "eos_data": [{"vrfs": {"test": {"isisInstances": {"1": {"gracefulRestart": True, "gracefulRestartHelper": True}}}}}], - "inputs": {"instances": [{"vrf": "default", "name": "1", "graceful_restart": True, "graceful_helper": True}]}, - "expected": {"result": "failure", "messages": ["VRF: default Instance: 1 - VRF is not configured"]}, - }, { "name": "failure-isis-instance-not-found", "test": VerifyISISGracefulRestart, "eos_data": [{"vrfs": {"default": {"isisInstances": {"2": {"gracefulRestart": True, "gracefulRestartHelper": True}}}}}], "inputs": {"instances": [{"vrf": "default", "name": "1", "graceful_restart": True, "graceful_helper": True}]}, - "expected": {"result": "failure", "messages": ["VRF: default Instance: 1 - Not found"]}, + "expected": {"result": "failure", "messages": ["Instance: 1 VRF: default - Not found"]}, }, { "name": "failure-graceful-restart-disabled", @@ -1924,10 +1917,7 @@ }, "expected": { "result": "failure", - "messages": [ - "VRF: default Instance: 1 - Graceful Restart disabled", - "VRF: test Instance: 1 - Graceful Restart disabled", - ], + "messages": ["Instance: 1 VRF: default - Graceful Restart disabled", "Instance: 1 VRF: test - Graceful Restart disabled"], }, }, { @@ -1949,7 +1939,7 @@ }, "expected": { "result": "failure", - "messages": ["VRF: default Instance: 1 - Graceful Restart Helper disabled", "VRF: test Instance: 1 - Graceful Restart Helper disabled"], + "messages": ["Instance: 1 VRF: default - Graceful Restart Helper disabled", "Instance: 1 VRF: test - Graceful Restart Helper disabled"], }, }, ] From 44ed38a9329ddcea85b8233a5af88edcedd02f81 Mon Sep 17 00:00:00 2001 From: "Geetanjali.mane" Date: Tue, 7 Jan 2025 09:55:14 +0000 Subject: [PATCH 6/6] Issue_882: Updated docstrings and test description --- anta/input_models/routing/isis.py | 2 +- anta/tests/routing/isis.py | 24 ++++++++++----------- examples/tests.yaml | 16 +++++++------- tests/units/anta_tests/routing/test_isis.py | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/anta/input_models/routing/isis.py b/anta/input_models/routing/isis.py index 91cb6af4c..c32babaad 100644 --- a/anta/input_models/routing/isis.py +++ b/anta/input_models/routing/isis.py @@ -13,7 +13,7 @@ class ISISInstances(BaseModel): model_config = ConfigDict(extra="forbid") name: str - """The instance name or ID to validated the instance specific isis details.""" + """The instance name to validated the instance specific isis details.""" vrf: str = "default" """VRF context. Defaults to `default` VRF.""" graceful_restart: bool = True diff --git a/anta/tests/routing/isis.py b/anta/tests/routing/isis.py index cbb2706ef..44332acc4 100644 --- a/anta/tests/routing/isis.py +++ b/anta/tests/routing/isis.py @@ -758,33 +758,33 @@ class VerifyISISGracefulRestart(AntaTest): isis: - VerifyISISGracefulRestart: instances: - - vrf: default - name: '1' + - name: '1' + vrf: default graceful_restart: True graceful_helper: True - - vrf: default - name: '2' + - name: '2' + vrf: default graceful_restart: True graceful_helper: True - - vrf: test - name: '1' + - name: '1' + vrf: test graceful_restart: True graceful_helper: True - - vrf: test - name: '2' + - name: '2' + vrf: test graceful_restart: True graceful_helper: True ``` """ categories: ClassVar[list[str]] = ["isis"] - commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis summary vrf all")] + commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis summary vrf all", revision=2)] class Input(AntaTest.Input): """Input model for the VerifyISISGracefulRestart test.""" instances: list[ISISInstances] - """List of ISIS instance entries.""" + """List of IS-IS instance entries.""" @AntaTest.anta_test def test(self) -> None: @@ -793,12 +793,12 @@ def test(self) -> None: command_output = self.instance_commands[0].json_output isis_details = command_output.get("vrfs") - # If ISIS is not configured, test fails. + # If IS-IS is not configured, test fails. if not isis_details: self.result.is_failure("ISIS is not configured") return - # If ISIS-instance is not found or GR and GR helpers are not matching with the expected values, test fails. + # If IS-IS instance is not found or GR and GR helpers are not matching with the expected values, test fails. for instance in self.inputs.instances: vrf = instance.vrf instance_name = str(instance.name) diff --git a/examples/tests.yaml b/examples/tests.yaml index 6b3be4985..e8f9c6049 100644 --- a/examples/tests.yaml +++ b/examples/tests.yaml @@ -544,20 +544,20 @@ anta.tests.routing.isis: - VerifyISISGracefulRestart: # Verifies the graceful restart and helper mechanism. instances: - - vrf: default - name: '1' + - name: '1' + vrf: default graceful_restart: True graceful_helper: True - - vrf: default - name: '2' + - name: '2' + vrf: default graceful_restart: True graceful_helper: True - - vrf: test - name: '1' + - name: '1' + vrf: test graceful_restart: True graceful_helper: True - - vrf: test - name: '2' + - name: '2' + vrf: test graceful_restart: True graceful_helper: True - VerifyISISInterfaceMode: diff --git a/tests/units/anta_tests/routing/test_isis.py b/tests/units/anta_tests/routing/test_isis.py index d27e075c2..023f8718d 100644 --- a/tests/units/anta_tests/routing/test_isis.py +++ b/tests/units/anta_tests/routing/test_isis.py @@ -1921,7 +1921,7 @@ }, }, { - "name": "failure-graceful-restart--helper-disabled", + "name": "failure-graceful-restart-helper-disabled", "test": VerifyISISGracefulRestart, "eos_data": [ {