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 interface(part -1) test module  #1045

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

Conversation

geetanjalimanegslab
Copy link
Collaborator

@geetanjalimanegslab geetanjalimanegslab commented Feb 18, 2025

Nicer result failure messages Interface test module following testcases are covers.

  1. VerifyInterfaceUtilization
  2. VerifyInterfaceErrors
  3. VerifyInterfaceDiscards
  4. VerifyInterfaceErrDisabled
  5. VerifyInterfacesStatus
  6. VerifyStormControlDrops

Description

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 18, 2025

CodSpeed Performance Report

Merging #1045 will not alter performance

Comparing geetanjalimanegslab:fix_interface_module_failure_msg (a3cd02f) with main (ecce5e5)

Summary

✅ 22 untouched benchmarks

@geetanjalimanegslab geetanjalimanegslab changed the title refactor(anta.tests): Nicer result failure messages interface(first 6 test) test module  refactor(anta.tests): Nicer result failure messages interface(part -1) test module  Feb 19, 2025
self.result.is_success()
else:
self.result.is_failure(f"The following interfaces have a usage > {self.inputs.threshold}%: {failed_interfaces}")
self.result.is_failure(f"Interface: {intf} BPS Rate: {bps_rate} - Greater threshold usage - Expected: {self.inputs.threshold}% Actual: {usage}%")
Copy link
Collaborator

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"Interface: {intf} BPS Rate: {bps_rate} - Greater threshold usage - Expected: {self.inputs.threshold}% Actual: {usage}%")
self.result.is_failure(f"Interface: {intf} BPS Rate: {bps_rate} Threshold: {self.inputs.threshold}% - usage exceeds the threshold - Usage: {usage}%")

self.result.is_success()
else:
self.result.is_failure(f"The following interface(s) have non-zero error counters: {wrong_interfaces}")
counters_data = [f"{counter}: {value}" for counter, value in counters.items() if value > 0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use format_data here from tools?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi, @vitthalmagadum , Although we can implement this, it would cause us to lose the original key names because the capitalize() method is applied to each key in the format_data() util. This could make it challenging for the end user to debug, as they might not notice the title case change in the keys.

Example:
format_data({'inErrors': 42, 'outErrors': 10})
output >> Inerrors: 42, Outerrors: 2"

self.result.is_success()
else:
self.result.is_failure(f"The following interfaces have none 0 storm-control drop counters {storm_controlled_interfaces}")
storm_controlled_interfaces.append(f"{traffic_type}: {traffic_type_dict['drop']}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please check.

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
2 participants