-
Notifications
You must be signed in to change notification settings - Fork 34
feat(anta.tests): Added test VerifyInterfacesCounters to support all interface errors with expected threshold #1188
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
base: main
Are you sure you want to change the base?
Conversation
…aceDiscards to support all interface errors with expected threshold
CodSpeed Performance ReportMerging #1188 will not alter performanceComparing Summary
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
|
if interface_time_stamp: | ||
then = datetime.fromtimestamp(interface_time_stamp, tz=timezone.utc) | ||
delta = now - then | ||
return delta.days * 24 if delta.days < 1 else delta.days |
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.
If the delta is less than one day, it will be converted to hours. We should update the message accordingly to avoid confusion in the failure messages.
# Verify the interface status | ||
if data["lineProtocolStatus"] == "down" or data["lineProtocolStatus"] == "notPresent": | ||
self.result.is_failure( | ||
f"Interface: {interface} Description: {int_desc} Downtime: {last_state_timestamp} - Incorrect state - Expected: up" |
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.
Here the downtime
# Verify interface error counter details | ||
self.verify_interface_error_counter_details(interface, error_counters, int_desc, last_state_timestamp) | ||
|
||
def verify_interface_error_counter_details(self, interface: str, error_counters: dict[str, Any], int_desc: str | None, last_state_timestamp: int | None) -> None: |
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.
Do we really need a separate util just to call another util here?
continue | ||
|
||
# Verify that link status changes are within the expected range | ||
if error_counters.get("linkStatusChanges") > self.inputs.link_status_changes_threshold: |
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 use assignment expression operator (:=).
Same for other places.
"result": AntaTestStatus.FAILURE, | ||
"messages": [ | ||
"Interface: Ethernet52/1 Description: None Downtime: None - Incorrect state - Expected: up Actual: notPresent", | ||
"Interface: Ethernet27 Description: None Downtime: 204 - Incorrect state - Expected: up Actual: down", |
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 skip the description if it's not available?
Also, the 204 isn't clearly associated with any specific action. Please update
Description
Added test VerifyInterfacesCounters to support all interface errors with expected threshold
Added test changes -
1. interfaces_errors_and_discards_test.py
2. interfaces_mgmt_only_test.py
Checklist:
pre-commit run
)tox -e testenv
)