Repository: aristanetworks/anta
Pull request #1131: refactor(anta): Updated failure messages, updated skip_on_platforms decorator message
Author: login: vitthalmagadum
Labels: name: rn: refactor(anta)
Created: 2025-04-01T07:45:43Z | Merged: 2025-04-01T13:38:04Z

# Description

Updated failure messages, updated skip_on_platforms decorator message

# Checklist:

- [X] My code follows the style guidelines of this project
- [X] I have performed a self-review of my code
- [X] I have run pre-commit for code linting and typing (`pre-commit run`)
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [X] New and existing unit tests pass locally with my changes (`tox -e testenv`)



Diff:
diff --git a/anta/decorators.py b/anta/decorators.py
index 0ca2be89d..3474e57b7 100644
--- a/anta/decorators.py
+++ b/anta/decorators.py
@@ -161,7 +161,7 @@ async def wrapper(*args: Any, **kwargs: Any) -> TestResult:
                 return anta_test.result
 
             if anta_test.device.hw_model in platforms:
-                anta_test.result.is_skipped(f"{anta_test.__class__.__name__} test is not supported on {anta_test.device.hw_model}.")
+                anta_test.result.is_skipped(f"{anta_test.__class__.__name__} test is not supported on {anta_test.device.hw_model}")
                 AntaTest.update_progress()
                 return anta_test.result
 
diff --git a/anta/tests/cvx.py b/anta/tests/cvx.py
index 25d824567..d80f9b90a 100644
--- a/anta/tests/cvx.py
+++ b/anta/tests/cvx.py
@@ -149,7 +149,7 @@ def test(self) -> None:
         active_count = 0
 
         if not (connections := command_output.get("connections")):
-            self.result.is_failure("CVX connections are not available.")
+            self.result.is_failure("CVX connections are not available")
             return
 
         for connection in connections:
diff --git a/anta/tests/flow_tracking.py b/anta/tests/flow_tracking.py
index a115949eb..57b42549b 100644
--- a/anta/tests/flow_tracking.py
+++ b/anta/tests/flow_tracking.py
@@ -109,7 +109,7 @@ def test(self) -> None:
         command_output = self.instance_commands[0].json_output
         # Check if hardware flow tracking is configured
         if not command_output.get("running"):
-            self.result.is_failure("Hardware flow tracking is not running.")
+            self.result.is_failure("Hardware flow tracking is not running")
             return
 
         for tracker in self.inputs.trackers:
diff --git a/anta/tests/snmp.py b/anta/tests/snmp.py
index 1d022522e..9a9acdeb1 100644
--- a/anta/tests/snmp.py
+++ b/anta/tests/snmp.py
@@ -320,7 +320,7 @@ def test(self) -> None:
 
         # Verify SNMP PDU counters.
         if not (snmp_counters := get_value(command_output, "counters")):
-            self.result.is_failure("SNMP counters not found.")
+            self.result.is_failure("SNMP counters not found")
             return
 
         # In case SNMP error counters not provided, It will check all the error counters.
diff --git a/anta/tests/system.py b/anta/tests/system.py
index 048f98780..7e2e65da1 100644
--- a/anta/tests/system.py
+++ b/anta/tests/system.py
@@ -451,7 +451,7 @@ class VerifyMaintenance(AntaTest):
     ```
     """
 
-    categories: ClassVar[list[str]] = ["Maintenance"]
+    categories: ClassVar[list[str]] = ["system"]
     commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show maintenance", revision=1)]
 
     @AntaTest.anta_test
@@ -476,8 +476,8 @@ def test(self) -> None:
 
         # Building the error message.
         if units_under_maintenance:
-            self.result.is_failure(f"Units under maintenance: '{', '.join(units_under_maintenance)}'.")
+            self.result.is_failure(f"Units under maintenance: '{', '.join(units_under_maintenance)}'")
         if units_entering_maintenance:
-            self.result.is_failure(f"Units entering maintenance: '{', '.join(units_entering_maintenance)}'.")
+            self.result.is_failure(f"Units entering maintenance: '{', '.join(units_entering_maintenance)}'")
         if causes:
-            self.result.is_failure(f"Possible causes: '{', '.join(sorted(causes))}'.")
+            self.result.is_failure(f"Possible causes: '{', '.join(sorted(causes))}'")
diff --git a/anta/tests/vxlan.py b/anta/tests/vxlan.py
index 04c3994a1..09bd30f3c 100644
--- a/anta/tests/vxlan.py
+++ b/anta/tests/vxlan.py
@@ -136,7 +136,7 @@ def test(self) -> None:
         self.result.is_success()
 
         if (vxlan1 := get_value(self.instance_commands[0].json_output, "vxlanIntfs.Vxlan1")) is None:
-            self.result.is_skipped("Vxlan1 interface is not configured")
+            self.result.is_skipped("Interface: Vxlan1 - Not configured")
             return
 
         for vni, vlan in self.inputs.bindings.items():
@@ -155,7 +155,7 @@ def test(self) -> None:
 
 
 class VerifyVxlanVtep(AntaTest):
-    """Verifies the VTEP peers of the Vxlan1 interface.
+    """Verifies Vxlan1 VTEP peers.
 
     Expected Results
     ----------------
@@ -191,7 +191,7 @@ def test(self) -> None:
         inputs_vteps = [str(input_vtep) for input_vtep in self.inputs.vteps]
 
         if (vxlan1 := get_value(self.instance_commands[0].json_output, "interfaces.Vxlan1")) is None:
-            self.result.is_skipped("Vxlan1 interface is not configured")
+            self.result.is_skipped("Interface: Vxlan1 - Not configured")
             return
 
         difference1 = set(inputs_vteps).difference(set(vxlan1["vteps"]))
@@ -205,7 +205,7 @@ def test(self) -> None:
 
 
 class VerifyVxlan1ConnSettings(AntaTest):
-    """Verifies the interface vxlan1 source interface and UDP port.
+    """Verifies Vxlan1 source interface and UDP port.
 
     Expected Results
     ----------------
@@ -243,7 +243,7 @@ def test(self) -> None:
         # Skip the test case if vxlan1 interface is not configured
         vxlan_output = get_value(command_output, "interfaces.Vxlan1")
         if not vxlan_output:
-            self.result.is_skipped("Vxlan1 interface is not configured.")
+            self.result.is_skipped("Interface: Vxlan1 - Not configured")
             return
 
         src_intf = vxlan_output.get("srcIpIntf")
diff --git a/examples/tests.yaml b/examples/tests.yaml
index e7a67852d..f0e014acf 100644
--- a/examples/tests.yaml
+++ b/examples/tests.yaml
@@ -1028,7 +1028,7 @@ anta.tests.vlan:
       end_vlan_id: 4094
 anta.tests.vxlan:
   - VerifyVxlan1ConnSettings:
-      # Verifies the interface vxlan1 source interface and UDP port.
+      # Verifies Vxlan1 source interface and UDP port.
       source_interface: Loopback1
       udp_port: 4789
   - VerifyVxlan1Interface:
@@ -1041,7 +1041,7 @@ anta.tests.vxlan:
         10010: 10
         10020: 20
   - VerifyVxlanVtep:
-      # Verifies the VTEP peers of the Vxlan1 interface.
+      # Verifies Vxlan1 VTEP peers.
       vteps:
         - 10.1.1.5
         - 10.1.1.6
diff --git a/tests/units/anta_tests/test_flow_tracking.py b/tests/units/anta_tests/test_flow_tracking.py
index cdd274601..b4356f8fb 100644
--- a/tests/units/anta_tests/test_flow_tracking.py
+++ b/tests/units/anta_tests/test_flow_tracking.py
@@ -81,7 +81,7 @@
         "inputs": {"trackers": [{"name": "FLOW-TRACKER"}]},
         "expected": {
             "result": "failure",
-            "messages": ["Hardware flow tracking is not running."],
+            "messages": ["Hardware flow tracking is not running"],
         },
     },
     {
diff --git a/tests/units/anta_tests/test_system.py b/tests/units/anta_tests/test_system.py
index 052202923..08e010df1 100644
--- a/tests/units/anta_tests/test_system.py
+++ b/tests/units/anta_tests/test_system.py
@@ -758,8 +758,8 @@
         "expected": {
             "result": "failure",
             "messages": [
-                "Units under maintenance: 'mlag'.",
-                "Possible causes: 'Quiesce is configured'.",
+                "Units under maintenance: 'mlag'",
+                "Possible causes: 'Quiesce is configured'",
             ],
         },
     },
@@ -796,9 +796,9 @@
         "expected": {
             "result": "failure",
             "messages": [
-                "Units under maintenance: 'mlag'.",
-                "Units entering maintenance: 'System'.",
-                "Possible causes: 'Quiesce is configured'.",
+                "Units under maintenance: 'mlag'",
+                "Units entering maintenance: 'System'",
+                "Possible causes: 'Quiesce is configured'",
             ],
         },
     },
@@ -826,8 +826,8 @@
         "expected": {
             "result": "failure",
             "messages": [
-                "Units under maintenance: 'System'.",
-                "Possible causes: 'On-boot maintenance is configured, Quiesce is configured'.",
+                "Units under maintenance: 'System'",
+                "Possible causes: 'On-boot maintenance is configured, Quiesce is configured'",
             ],
         },
     },
@@ -855,8 +855,8 @@
         "expected": {
             "result": "failure",
             "messages": [
-                "Units entering maintenance: 'System'.",
-                "Possible causes: 'Interface traffic threshold violation, Quiesce is configured'.",
+                "Units entering maintenance: 'System'",
+                "Possible causes: 'Interface traffic threshold violation, Quiesce is configured'",
             ],
         },
     },
diff --git a/tests/units/anta_tests/test_vxlan.py b/tests/units/anta_tests/test_vxlan.py
index ef8a294c9..8e5ff2263 100644
--- a/tests/units/anta_tests/test_vxlan.py
+++ b/tests/units/anta_tests/test_vxlan.py
@@ -266,7 +266,7 @@
         "test": VerifyVxlanVniBinding,
         "eos_data": [{"vxlanIntfs": {}}],
         "inputs": {"bindings": {10020: 20, 500: 1199}},
-        "expected": {"result": "skipped", "messages": ["Vxlan1 interface is not configured"]},
+        "expected": {"result": "skipped", "messages": ["Interface: Vxlan1 - Not configured"]},
     },
     {
         "name": "success",
@@ -314,7 +314,7 @@
         "test": VerifyVxlanVtep,
         "eos_data": [{"vteps": {}, "interfaces": {}}],
         "inputs": {"vteps": ["10.1.1.5", "10.1.1.6", "10.1.1.7"]},
-        "expected": {"result": "skipped", "messages": ["Vxlan1 interface is not configured"]},
+        "expected": {"result": "skipped", "messages": ["Interface: Vxlan1 - Not configured"]},
     },
     {
         "name": "success",
@@ -328,7 +328,7 @@
         "test": VerifyVxlan1ConnSettings,
         "eos_data": [{"interfaces": {}}],
         "inputs": {"source_interface": "Loopback1", "udp_port": 4789},
-        "expected": {"result": "skipped", "messages": ["Vxlan1 interface is not configured."]},
+        "expected": {"result": "skipped", "messages": ["Interface: Vxlan1 - Not configured"]},
     },
     {
         "name": "failure-wrong-interface",


Reviews:
user: login: geetanjalimanegslab
body: LGTM!
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-01T08:39:38Z
user: login: carl-baillargeon
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-01T13:17:48Z
user: login: carl-baillargeon
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-01T13:18:21Z
user: login: vitthalmagadum
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-01T13:30:58Z
user: login: vitthalmagadum
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-01T13:31:09Z
user: login: carl-baillargeon
body: LGTM.
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-01T13:34:59Z

Review comments:
diff_hunk: @@ -476,8 +476,8 @@ def test(self) -> None:
 
         # Building the error message.
         if units_under_maintenance:
-            self.result.is_failure(f"Units under maintenance: '{', '.join(units_under_maintenance)}'.")
+            self.result.is_failure(f"Units under maintenance: '{', '.join(units_under_maintenance)}'")
path: anta/tests/system.py
user: login: carl-baillargeon
body: Can we also change the category of this test to "system" please? :) Thanks
created_at: 2025-04-01T13:17:48Z
author_association: CONTRIBUTOR
diff_hunk: @@ -205,7 +205,7 @@ def test(self) -> None:
 
 
 class VerifyVxlan1ConnSettings(AntaTest):
-    """Verifies the interface vxlan1 source interface and UDP port.
+    """Verifies the Vxlan1 source interface and UDP port.
path: anta/tests/vxlan.py
user: login: carl-baillargeon
body: ```suggestion
    """Verifies Vxlan1 source interface and UDP port.
```
created_at: 2025-04-01T13:18:21Z
author_association: CONTRIBUTOR
diff_hunk: @@ -476,8 +476,8 @@ def test(self) -> None:
 
         # Building the error message.
         if units_under_maintenance:
-            self.result.is_failure(f"Units under maintenance: '{', '.join(units_under_maintenance)}'.")
+            self.result.is_failure(f"Units under maintenance: '{', '.join(units_under_maintenance)}'")
path: anta/tests/system.py
user: login: vitthalmagadum
body: Updated to system.
Thanks!!
created_at: 2025-04-01T13:30:58Z
author_association: CONTRIBUTOR
diff_hunk: @@ -205,7 +205,7 @@ def test(self) -> None:
 
 
 class VerifyVxlan1ConnSettings(AntaTest):
-    """Verifies the interface vxlan1 source interface and UDP port.
+    """Verifies the Vxlan1 source interface and UDP port.
path: anta/tests/vxlan.py
user: login: vitthalmagadum
body: updated.
created_at: 2025-04-01T13:31:09Z
author_association: CONTRIBUTOR

PR comments:
user: login: codspeed-hq[bot]
created_at: 2025-04-01T07:55:01Z
body: <!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->
<!-- __CODSPEED_INSTRUMENTATION_PERFORMANCE_REPORT_COMMENT__ -->

## [CodSpeed Performance Report](https://codspeed.io/aristanetworks/anta/branches/vitthalmagadum%3Arefactor%2Ffailure-msg)

### Merging #1131 will **not alter performance**

<sub>Comparing <code>vitthalmagadum:refactor/failure-msg</code> (a197100) with <code>main</code> (535289f)</sub>



### Summary

`✅ 22` untouched benchmarks  




author_association: NONE
user: login: sonarqubecloud[bot]
created_at: 2025-04-01T13:41:05Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=aristanetworks_anta&pullRequest=1131) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=aristanetworks_anta&pullRequest=1131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=aristanetworks_anta&pullRequest=1131&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=aristanetworks_anta&pullRequest=1131&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=aristanetworks_anta&pullRequest=1131&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=aristanetworks_anta&pullRequest=1131&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=aristanetworks_anta&pullRequest=1131)


author_association: NONE