Skip to content

Commit

Permalink
fix(anta.tests): Cleaning up BFD tests module (#926)
Browse files Browse the repository at this point in the history
* Refactor: VerifyBFDPeersRegProtocols, VerifyBFDPeersIntervals, VerifyBFDSpecificPeers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated unit tests and docs

* Addressed review commentsL: updated failure msgs

* updated failure msgs: removed , and ;

* updated docstring

---------

Co-authored-by: VitthalMagadum <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Guillaume Mulocher <[email protected]>
  • Loading branch information
4 people authored Nov 26, 2024
1 parent 1edbf9c commit 2de0f5a
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 148 deletions.
37 changes: 37 additions & 0 deletions anta/input_models/bfd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) 2023-2024 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
"""Module containing input models for BFD tests."""

from __future__ import annotations

from ipaddress import IPv4Address

from pydantic import BaseModel, ConfigDict

from anta.custom_types import BfdInterval, BfdMultiplier, BfdProtocol


class BFDPeer(BaseModel):
"""BFD (Bidirectional Forwarding Detection) model representing the peer details.
Only IPv4 peers are supported for now.
"""

model_config = ConfigDict(extra="forbid")
peer_address: IPv4Address
"""IPv4 address of a BFD peer."""
vrf: str = "default"
"""Optional VRF for the BFD peer. Defaults to `default`."""
tx_interval: BfdInterval | None = None
"""Tx interval of BFD peer in milliseconds. Required field in the `VerifyBFDPeersIntervals` test."""
rx_interval: BfdInterval | None = None
"""Rx interval of BFD peer in milliseconds. Required field in the `VerifyBFDPeersIntervals` test."""
multiplier: BfdMultiplier | None = None
"""Multiplier of BFD peer. Required field in the `VerifyBFDPeersIntervals` test."""
protocols: list[BfdProtocol] | None = None
"""List of protocols to be verified. Required field in the `VerifyBFDPeersRegProtocols` test."""

def __str__(self) -> str:
"""Return a human-readable string representation of the BFDPeer for reporting."""
return f"Peer: {self.peer_address} VRF: {self.vrf}"
Loading

0 comments on commit 2de0f5a

Please sign in to comment.