Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(anta.tests): Nicer result failure messages AVT, field_notice test module  #1036

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion anta/input_models/avt.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def __str__(self) -> str:
AVT CONTROL-PLANE-PROFILE VRF: default (Destination: 10.101.255.2, Next-hop: 10.101.255.1)

"""
return f"AVT {self.avt_name} VRF: {self.vrf} (Destination: {self.destination}, Next-hop: {self.next_hop})"
return f"AVT: {self.avt_name} VRF: {self.vrf} Destination: {self.destination} Next-hop: {self.next_hop}"
2 changes: 1 addition & 1 deletion anta/tests/avt.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ def test(self) -> None:

# Check if the AVT role matches the expected role
if self.inputs.role != command_output.get("role"):
self.result.is_failure(f"Expected AVT role as `{self.inputs.role}`, but found `{command_output.get('role')}` instead.")
self.result.is_failure(f"AVT role mismatch - Expected: {self.inputs.role}, Actual: {command_output.get('role')}")
4 changes: 2 additions & 2 deletions anta/tests/field_notices.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test(self) -> None:
for variant in variants:
model = model.replace(variant, "")
if model not in devices:
self.result.is_skipped("device is not impacted by FN044")
self.result.is_skipped("Device is not impacted by FN044")
return

for component in command_output["details"]["components"]:
Expand All @@ -117,7 +117,7 @@ def test(self) -> None:
)
)
if incorrect_aboot_version:
self.result.is_failure(f"device is running incorrect version of aboot ({aboot_version})")
self.result.is_failure(f"Device is running incorrect version of aboot {aboot_version}")


class VerifyFieldNotice72Resolution(AntaTest):
Expand Down
18 changes: 9 additions & 9 deletions tests/units/anta_tests/test_avt.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@
},
"expected": {
"result": "failure",
"messages": ["AVT MGMT-AVT-POLICY-DEFAULT VRF: default (Destination: 10.101.255.2, Next-hop: 10.101.255.1) - No AVT path configured"],
"messages": ["AVT: MGMT-AVT-POLICY-DEFAULT VRF: default Destination: 10.101.255.2 Next-hop: 10.101.255.1 - No AVT path configured"],
},
},
{
Expand Down Expand Up @@ -507,8 +507,8 @@
"expected": {
"result": "failure",
"messages": [
"AVT DEFAULT-AVT-POLICY-CONTROL-PLANE VRF: default (Destination: 10.101.255.2, Next-hop: 10.101.255.11) Path Type: multihop - Path not found",
"AVT DATA-AVT-POLICY-CONTROL-PLANE VRF: data (Destination: 10.101.255.1, Next-hop: 10.101.255.21) Path Type: direct - Path not found",
"AVT: DEFAULT-AVT-POLICY-CONTROL-PLANE VRF: default Destination: 10.101.255.2 Next-hop: 10.101.255.11 Path Type: multihop - Path not found",
"AVT: DATA-AVT-POLICY-CONTROL-PLANE VRF: data Destination: 10.101.255.1 Next-hop: 10.101.255.21 Path Type: direct - Path not found",
],
},
},
Expand Down Expand Up @@ -571,8 +571,8 @@
"expected": {
"result": "failure",
"messages": [
"AVT DEFAULT-AVT-POLICY-CONTROL-PLANE VRF: default (Destination: 10.101.255.2, Next-hop: 10.101.255.11) - Path not found",
"AVT DATA-AVT-POLICY-CONTROL-PLANE VRF: data (Destination: 10.101.255.1, Next-hop: 10.101.255.21) - Path not found",
"AVT: DEFAULT-AVT-POLICY-CONTROL-PLANE VRF: default Destination: 10.101.255.2 Next-hop: 10.101.255.11 - Path not found",
"AVT: DATA-AVT-POLICY-CONTROL-PLANE VRF: data Destination: 10.101.255.1 Next-hop: 10.101.255.21 - Path not found",
],
},
},
Expand Down Expand Up @@ -646,11 +646,11 @@
"expected": {
"result": "failure",
"messages": [
"AVT DEFAULT-AVT-POLICY-CONTROL-PLANE VRF: default (Destination: 10.101.255.2, Next-hop: 10.101.255.1) - "
"AVT: DEFAULT-AVT-POLICY-CONTROL-PLANE VRF: default Destination: 10.101.255.2 Next-hop: 10.101.255.1 - "
"Incorrect path multihop:3 - Valid: False, Active: True",
"AVT DATA-AVT-POLICY-CONTROL-PLANE VRF: data (Destination: 10.101.255.1, Next-hop: 10.101.255.1) - "
"AVT: DATA-AVT-POLICY-CONTROL-PLANE VRF: data Destination: 10.101.255.1 Next-hop: 10.101.255.1 - "
"Incorrect path direct:10 - Valid: False, Active: True",
"AVT DATA-AVT-POLICY-CONTROL-PLANE VRF: data (Destination: 10.101.255.1, Next-hop: 10.101.255.1) - "
"AVT: DATA-AVT-POLICY-CONTROL-PLANE VRF: data Destination: 10.101.255.1 Next-hop: 10.101.255.1 - "
"Incorrect path direct:9 - Valid: True, Active: False",
],
},
Expand All @@ -667,6 +667,6 @@
"test": VerifyAVTRole,
"eos_data": [{"role": "transit"}],
"inputs": {"role": "edge"},
"expected": {"result": "failure", "messages": ["Expected AVT role as `edge`, but found `transit` instead."]},
"expected": {"result": "failure", "messages": ["AVT role mismatch - Expected: edge, Actual: transit"]},
},
]
10 changes: 5 additions & 5 deletions tests/units/anta_tests/test_field_notices.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"inputs": None,
"expected": {
"result": "failure",
"messages": ["device is running incorrect version of aboot (4.0.1)"],
"messages": ["Device is running incorrect version of aboot 4.0.1"],
},
},
{
Expand All @@ -65,7 +65,7 @@
"inputs": None,
"expected": {
"result": "failure",
"messages": ["device is running incorrect version of aboot (4.1.0)"],
"messages": ["Device is running incorrect version of aboot 4.1.0"],
},
},
{
Expand All @@ -85,7 +85,7 @@
"inputs": None,
"expected": {
"result": "failure",
"messages": ["device is running incorrect version of aboot (6.0.1)"],
"messages": ["Device is running incorrect version of aboot 6.0.1"],
},
},
{
Expand All @@ -105,7 +105,7 @@
"inputs": None,
"expected": {
"result": "failure",
"messages": ["device is running incorrect version of aboot (6.1.1)"],
"messages": ["Device is running incorrect version of aboot 6.1.1"],
},
},
{
Expand All @@ -125,7 +125,7 @@
"inputs": None,
"expected": {
"result": "skipped",
"messages": ["device is not impacted by FN044"],
"messages": ["Device is not impacted by FN044"],
},
},
{
Expand Down
Loading