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

feat(anta.tests): Added testcase to verify ip address on interface #548

Merged
merged 3 commits into from
Feb 23, 2024

Conversation

MaheshGSLAB
Copy link
Contributor

Description

Added testcase to verify ip address(primary and secondary) on interface.

Fixes #545

Expected Results:
* success: The test will pass if an interface is configured with a correct primary and secondary IPv4 address.
* failure: The test will fail if an interface is not found or the primary and secondary IPv4 addresses do not match with the input.

Note: There is no optional input. All the input is required and restricted with values.

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)

input_secondary_ips = sorted([str(net) for net in command.params["secondary_ips"]])

# Check if the interface has an IP address configured
if not (interface_output := get_value(command.json_output, f"interfaces..{intf}..interfaceAddress", separator="..")):
Copy link
Contributor Author

@MaheshGSLAB MaheshGSLAB Jan 29, 2024

Choose a reason for hiding this comment

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

need to remove separator

@MaheshGSLAB MaheshGSLAB marked this pull request as ready for review January 30, 2024 13:43
class Input(AntaTest.Input):
"""Inputs for the VerifyInterfaceIPv4 test."""

interfaces: List[Interfaces]
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
interfaces: List[Interfaces]
interfaces: List[InterfaceDetail]

"""Name of the interface"""
primary_ip: IPv4Network
"""Primary IPv4 network on interface"""
secondary_ips: List[IPv4Network]
Copy link
Contributor

Choose a reason for hiding this comment

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

secondary_ips should be optional. Only check them if they are provided.

Copy link
Contributor

@carl-baillargeon carl-baillargeon left a comment

Choose a reason for hiding this comment

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

LGTM

@carl-baillargeon carl-baillargeon merged commit 27677f1 into aristanetworks:main Feb 23, 2024
19 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.

Add the testcase to verify IP address on interface
2 participants