-
Notifications
You must be signed in to change notification settings - Fork 31
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
base: main
Are you sure you want to change the base?
refactor(anta.tests): Nicer result failure messages interface(part -1) test module #1045
Conversation
CodSpeed Performance ReportMerging #1045 will not alter performanceComparing Summary
|
anta/tests/interfaces.py
Outdated
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}%") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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']}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check.
|
Nicer result failure messages Interface test module following testcases are covers.
Description
Fixes #587
Checklist:
pre-commit run
)tox -e testenv
)