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(eos_validate_state): ANTA Refactor AvdTestBase #3701

Merged
merged 9 commits into from Mar 8, 2024

Conversation

carl-baillargeon
Copy link
Contributor

Change Summary

Refactor AvdTestBase to improve maintainability, clarity and performance (fixes #3304).

Related Issue(s)

Fixes #3304

Component(s) name

arista.avd.eos_validate_state ANTA mode

Proposed changes

  • Added ConfigManager class to manage each device configuration and create required variables for the tests. This class improves performance since it is created per device and not per tests.
  • Added DeviceUtilsMixin and ValidationMixin mixin classes to the AvdTestBase and move the existing methods to these.
  • Moved logging function to utils and improve logging for tests
  • Removed logged_get as it was unnecessary and was removing functionality of the get util function.

How to test

ansible-playbook playbooks/fabric-validate.yml -e use_anta=true

Checklist

User Checklist

  • N/A

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

Copy link
Contributor

@MaheshGSLAB MaheshGSLAB left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 89 to 90
for loopback_interface in loopback_interfaces:
if loopback_interface.get("name") == "Loopback0":
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
for loopback_interface in loopback_interfaces:
if loopback_interface.get("name") == "Loopback0":
for loopback_interface in loopback_interfaces:
if (loopback_intefrace := get_item(loopback_interface, "name", "Loopback0") is not None:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right I refactored the function a bit in 554e20b we can't really use continue since we want to check the VTEP loopbacks as well.

log_msg = f"{message}. {log_msg}" if prepend_message else f"{log_msg} {message}."

# Logging the message
log_level = logging.getLevelName(log_level.upper())
Copy link
Contributor

Choose a reason for hiding this comment

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

upper is seless here as it would have failed line 38 already if not upper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No because I want the function to handle both lower and upper case log_level argument.

@gmuloc gmuloc merged commit bdc5cab into aristanetworks:devel Mar 8, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor(eos_validate_state): ANTA Slow catalog creation when high amount of devices
3 participants