Skip to content

Commit

Permalink
feat(anta): Updated VerifyBFDPeersIntervals for failure message to be…
Browse files Browse the repository at this point in the history
… in milliseconds like the inputs (#805)
  • Loading branch information
vitthalmagadum authored Aug 29, 2024
1 parent 91a3c22 commit 30f731c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions anta/tests/bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,34 +157,34 @@ def test(self) -> None:
for bfd_peers in self.inputs.bfd_peers:
peer = str(bfd_peers.peer_address)
vrf = bfd_peers.vrf

# Converting milliseconds intervals into actual value
tx_interval = bfd_peers.tx_interval * 1000
rx_interval = bfd_peers.rx_interval * 1000
tx_interval = bfd_peers.tx_interval
rx_interval = bfd_peers.rx_interval
multiplier = bfd_peers.multiplier

# Check if BFD peer configured
bfd_output = get_value(
self.instance_commands[0].json_output,
f"vrfs..{vrf}..ipv4Neighbors..{peer}..peerStats..",
separator="..",
)

# Check if BFD peer configured
if not bfd_output:
failures[peer] = {vrf: "Not Configured"}
continue

# Convert interval timer(s) into milliseconds to be consistent with the inputs.
bfd_details = bfd_output.get("peerStatsDetail", {})
intervals_ok = (
bfd_details.get("operTxInterval") == tx_interval and bfd_details.get("operRxInterval") == rx_interval and bfd_details.get("detectMult") == multiplier
)
op_tx_interval = bfd_details.get("operTxInterval") // 1000
op_rx_interval = bfd_details.get("operRxInterval") // 1000
detect_multiplier = bfd_details.get("detectMult")
intervals_ok = op_tx_interval == tx_interval and op_rx_interval == rx_interval and detect_multiplier == multiplier

# Check timers of BFD peer
if not intervals_ok:
failures[peer] = {
vrf: {
"tx_interval": bfd_details.get("operTxInterval"),
"rx_interval": bfd_details.get("operRxInterval"),
"multiplier": bfd_details.get("detectMult"),
"tx_interval": op_tx_interval,
"rx_interval": op_rx_interval,
"multiplier": detect_multiplier,
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/units/anta_tests/test_bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@
"result": "failure",
"messages": [
"Following BFD peers are not configured or timers are not correct:\n"
"{'192.0.255.7': {'default': {'tx_interval': 1300000, 'rx_interval': 1200000, 'multiplier': 4}}, "
"'192.0.255.70': {'MGMT': {'tx_interval': 120000, 'rx_interval': 120000, 'multiplier': 5}}}"
"{'192.0.255.7': {'default': {'tx_interval': 1300, 'rx_interval': 1200, 'multiplier': 4}}, "
"'192.0.255.70': {'MGMT': {'tx_interval': 120, 'rx_interval': 120, 'multiplier': 5}}}"
],
},
},
Expand Down

0 comments on commit 30f731c

Please sign in to comment.