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 OSPF test module  #1040

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

geetanjalimanegslab
Copy link
Collaborator

Description

Nicer result failure messages for following test module.

  1. OSPF

Fixes #587

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • 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
  • New and existing unit tests pass locally with my changes (tox -e testenv)

Copy link

codspeed-hq bot commented Feb 12, 2025

CodSpeed Performance Report

Merging #1040 will not alter performance

Comparing geetanjalimanegslab:fix_ospf_module_failure_msg (ae995b5) with main (9ba0284)

Summary

✅ 22 untouched benchmarks

f"Instance: {instance} VRF: {vrf} Interface: {interface[0]} - Incorrect adjacency state - Expected: Full Actual: {interface[1]}"
)

# If OSPF neighbors are not configured on device, test fails.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# If OSPF neighbors are not configured on device, test fails.
# If OSPF neighbors are not configured on device, test is skipped.

no_neighbor = False
interfaces.extend([neighbor["routerId"] for neighbor in neighbors if neighbor["adjacencyState"] == "full"])

# If OSPF neighbors are not configured on device, test fails.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# If OSPF neighbors are not configured on device, test fails.
# If OSPF neighbors are not configured on device, test is skipped.

@@ -661,7 +661,7 @@ anta.tests.routing.isis:
nexthop: 1.1.1.1
anta.tests.routing.ospf:
- VerifyOSPFMaxLSA:
# Verifies all OSPF instances did not cross the maximum LSA threshold.
# Verifies LSAs present in the OSPF link state database did not cross the maximum LSA Threshold.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the current one.

Comment on lines 159 to 161
max_lsa = instance_data.get("maxLsaInformation", {}).get("maxLsa")
max_lsa_threshold = instance_data.get("maxLsaInformation", {}).get("maxLsaThreshold")
num_lsa = instance_data.get("lsaInformation", {}).get("numLsa")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use get_value here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, check in EOS CLI models if these keys could be missing, otherwise we can simply use instance_data["maxLsaThreshold"] like before.

if num_lsa > max_lsa * (max_lsa_threshold / 100):
exceeded_instances.append(instance)
if exceeded_instances:
self.result.is_failure(f"Following OSPF Instances crossed the maximum LSA threshold - {', '.join(exceeded_instances)}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.result.is_failure(f"Following OSPF Instances crossed the maximum LSA threshold - {', '.join(exceeded_instances)}")
self.result.is_failure(f"Following OSPF instances crossed the maximum LSA threshold - {', '.join(exceeded_instances)}")

Can we add some numbers here? Expected Actual?

@geetanjalimanegslab geetanjalimanegslab force-pushed the fix_ospf_module_failure_msg branch from eda29fd to 76544e2 Compare February 27, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have nicer result failure messages
3 participants