Debian Codegraph @

tests/units/anta_tests/test_bfd.py

raw symbols SCIP
1 # Copyright (c) 2023-2026 Arista Networks, Inc.
2 # Use of this source code is governed by the Apache License 2.0
3 # that can be found in the LICENSE file.
4 """Tests for anta.tests.bfd.py."""
5
6 # pylint: disable=C0302
7 from __future__ import annotations
8
9 import sys
10 from typing import TYPE_CHECKING, Any
11
12 from anta.models import AntaTest
13 from anta.result_manager.models import AntaTestStatus
14 from anta.tests.bfd import VerifyBFDPeersHealth, VerifyBFDPeersIntervals, VerifyBFDPeersRegProtocols, VerifyBFDSpecificPeers
15 from tests.units.anta_tests import test
16
17 if TYPE_CHECKING:
18 from tests.units.anta_tests import AntaUnitTestData
19
20 DATA: AntaUnitTestData = {
21 (VerifyBFDPeersIntervals, "success"): {
22 "eos_data": [
23 {
24 "vrfs": {
25 "default": {
26 "ipv4Neighbors": {
27 "192.0.255.7": {
28 "peerStats": {
29 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
30 }
31 }
32 }
33 },
34 "MGMT": {
35 "ipv4Neighbors": {
36 "192.0.255.70": {
37 "peerStats": {
38 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
39 }
40 }
41 }
42 },
43 }
44 }
45 ],
46 "inputs": {
47 "bfd_peers": [
48 {"peer_address": "192.0.255.7", "vrf": "default", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3},
49 {"peer_address": "192.0.255.70", "vrf": "MGMT", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3},
50 ]
51 },
52 "expected": {"result": AntaTestStatus.SUCCESS},
53 },
54 (VerifyBFDPeersIntervals, "success-single-hop-ipv6"): {
55 "eos_data": [
56 {
57 "vrfs": {
58 "default": {
59 "ipv4Neighbors": {
60 "192.0.255.7": {
61 "peerStats": {
62 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
63 }
64 }
65 }
66 },
67 "MGMT": {
68 "ipv4Neighbors": {
69 "192.0.255.70": {
70 "peerStats": {
71 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
72 }
73 }
74 },
75 "ipv6Neighbors": {
76 "fe80::a8c1:abff:fe91:788e": {
77 "peerStats": {
78 "Ethernet1": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
79 }
80 }
81 },
82 },
83 "PROD": {
84 "ipv6Neighbors": {
85 "fe80::a8c1:abff:fe4b:8c48": {
86 "peerStats": {
87 "Ethernet2": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
88 }
89 }
90 }
91 },
92 }
93 }
94 ],
95 "inputs": {
96 "bfd_peers": [
97 {"peer_address": "192.0.255.7", "vrf": "default", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
98 {"peer_address": "192.0.255.70", "vrf": "MGMT", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
99 {"peer_address": "fe80::a8c1:abff:fe91:788e", "vrf": "MGMT", "interface": "Ethernet1", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3},
100 {
101 "peer_address": "fe80::a8c1:abff:fe4b:8c48",
102 "vrf": "PROD",
103 "interface": "Ethernet2",
104 "tx_interval": 1200,
105 "rx_interval": 1200,
106 "multiplier": 3,
107 "detection_time": 3600,
108 },
109 ]
110 },
111 "expected": {"result": AntaTestStatus.SUCCESS},
112 },
113 (VerifyBFDPeersIntervals, "success-detection-time"): {
114 "eos_data": [
115 {
116 "vrfs": {
117 "default": {
118 "ipv4Neighbors": {
119 "192.0.255.7": {
120 "peerStats": {
121 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
122 }
123 }
124 }
125 },
126 "MGMT": {
127 "ipv4Neighbors": {
128 "192.0.255.70": {
129 "peerStats": {
130 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
131 }
132 }
133 }
134 },
135 }
136 }
137 ],
138 "inputs": {
139 "bfd_peers": [
140 {"peer_address": "192.0.255.7", "vrf": "default", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
141 {"peer_address": "192.0.255.70", "vrf": "MGMT", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
142 ]
143 },
144 "expected": {"result": AntaTestStatus.SUCCESS},
145 },
146 (VerifyBFDPeersIntervals, "failure-no-peer"): {
147 "eos_data": [
148 {
149 "vrfs": {
150 "default": {
151 "ipv4Neighbors": {
152 "192.0.255.7": {
153 "peerStats": {
154 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
155 }
156 }
157 }
158 },
159 "MGMT": {
160 "ipv4Neighbors": {
161 "192.0.255.71": {
162 "peerStats": {
163 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
164 }
165 }
166 }
167 },
168 }
169 }
170 ],
171 "inputs": {
172 "bfd_peers": [
173 {"peer_address": "192.0.255.7", "vrf": "CS", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
174 {"peer_address": "192.0.255.70", "vrf": "MGMT", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
175 ]
176 },
177 "expected": {"result": AntaTestStatus.FAILURE, "messages": ["Peer: 192.0.255.7 VRF: CS - Not found", "Peer: 192.0.255.70 VRF: MGMT - Not found"]},
178 },
179 (VerifyBFDPeersIntervals, "failure-single-hop-ipv6"): {
180 "eos_data": [
181 {
182 "vrfs": {
183 "default": {
184 "ipv4Neighbors": {
185 "192.0.255.7": {
186 "peerStats": {
187 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
188 }
189 }
190 }
191 },
192 "MGMT": {
193 "ipv4Neighbors": {
194 "192.0.255.70": {
195 "peerStats": {
196 "": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
197 }
198 }
199 },
200 "ipv6Neighbors": {
201 "fe80::a8c1:abff:fe91:788e": {
202 "peerStats": {
203 "Ethernet1": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
204 }
205 }
206 },
207 },
208 "PROD": {
209 "ipv6Neighbors": {
210 "fe80::a8c1:abff:fe4b:8c48": {
211 "peerStats": {
212 "Ethernet3": {"peerStatsDetail": {"operTxInterval": 1200000, "operRxInterval": 1200000, "detectMult": 3, "detectTime": 3600000}}
213 }
214 }
215 }
216 },
217 }
218 }
219 ],
220 "inputs": {
221 "bfd_peers": [
222 {"peer_address": "192.0.255.7", "vrf": "default", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
223 {"peer_address": "192.0.255.70", "vrf": "MGMT", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
224 {"peer_address": "fe80::a8c1:abff:fe91:788e", "vrf": "MGMT", "interface": "Ethernet1", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3},
225 {
226 "peer_address": "fe80::a8c1:abff:fe4b:8c48",
227 "vrf": "PROD",
228 "interface": "Ethernet2",
229 "tx_interval": 1200,
230 "rx_interval": 1200,
231 "multiplier": 3,
232 "detection_time": 3600,
233 },
234 ]
235 },
236 "expected": {"result": AntaTestStatus.FAILURE, "messages": ["Peer: fe80::a8c1:abff:fe4b:8c48 VRF: PROD Interface: Ethernet2 - Not found"]},
237 },
238 (VerifyBFDPeersIntervals, "failure-incorrect-timers"): {
239 "eos_data": [
240 {
241 "vrfs": {
242 "default": {
243 "ipv4Neighbors": {
244 "192.0.255.7": {
245 "peerStats": {
246 "": {"peerStatsDetail": {"operTxInterval": 1300000, "operRxInterval": 1200000, "detectMult": 4, "detectTime": 4000000}}
247 }
248 }
249 }
250 },
251 "MGMT": {
252 "ipv4Neighbors": {
253 "192.0.255.70": {
254 "peerStats": {"": {"peerStatsDetail": {"operTxInterval": 120000, "operRxInterval": 120000, "detectMult": 5, "detectTime": 4000000}}}
255 }
256 }
257 },
258 }
259 }
260 ],
261 "inputs": {
262 "bfd_peers": [
263 {"peer_address": "192.0.255.7", "vrf": "default", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3},
264 {"peer_address": "192.0.255.70", "vrf": "MGMT", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3},
265 ]
266 },
267 "expected": {
268 "result": AntaTestStatus.FAILURE,
269 "messages": [
270 "Peer: 192.0.255.7 VRF: default - Incorrect Transmit interval - Expected: 1200 Actual: 1300",
271 "Peer: 192.0.255.7 VRF: default - Incorrect Multiplier - Expected: 3 Actual: 4",
272 "Peer: 192.0.255.70 VRF: MGMT - Incorrect Transmit interval - Expected: 1200 Actual: 120",
273 "Peer: 192.0.255.70 VRF: MGMT - Incorrect Receive interval - Expected: 1200 Actual: 120",
274 "Peer: 192.0.255.70 VRF: MGMT - Incorrect Multiplier - Expected: 3 Actual: 5",
275 ],
276 },
277 },
278 (VerifyBFDPeersIntervals, "failure-incorrect-timers-with-detection-time"): {
279 "eos_data": [
280 {
281 "vrfs": {
282 "default": {
283 "ipv4Neighbors": {
284 "192.0.255.7": {
285 "peerStats": {
286 "": {"peerStatsDetail": {"operTxInterval": 1300000, "operRxInterval": 1200000, "detectMult": 4, "detectTime": 4000000}}
287 }
288 }
289 }
290 },
291 "MGMT": {
292 "ipv4Neighbors": {
293 "192.0.255.70": {
294 "peerStats": {"": {"peerStatsDetail": {"operTxInterval": 120000, "operRxInterval": 120000, "detectMult": 5, "detectTime": 4000000}}}
295 }
296 }
297 },
298 }
299 }
300 ],
301 "inputs": {
302 "bfd_peers": [
303 {"peer_address": "192.0.255.7", "vrf": "default", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
304 {"peer_address": "192.0.255.70", "vrf": "MGMT", "tx_interval": 1200, "rx_interval": 1200, "multiplier": 3, "detection_time": 3600},
305 ]
306 },
307 "expected": {
308 "result": AntaTestStatus.FAILURE,
309 "messages": [
310 "Peer: 192.0.255.7 VRF: default - Incorrect Transmit interval - Expected: 1200 Actual: 1300",
311 "Peer: 192.0.255.7 VRF: default - Incorrect Multiplier - Expected: 3 Actual: 4",
312 "Peer: 192.0.255.7 VRF: default - Incorrect Detection Time - Expected: 3600 Actual: 4000",
313 "Peer: 192.0.255.70 VRF: MGMT - Incorrect Transmit interval - Expected: 1200 Actual: 120",
314 "Peer: 192.0.255.70 VRF: MGMT - Incorrect Receive interval - Expected: 1200 Actual: 120",
315 "Peer: 192.0.255.70 VRF: MGMT - Incorrect Multiplier - Expected: 3 Actual: 5",
316 "Peer: 192.0.255.70 VRF: MGMT - Incorrect Detection Time - Expected: 3600 Actual: 4000",
317 ],
318 },
319 },
320 (VerifyBFDSpecificPeers, "success"): {
321 "eos_data": [
322 {
323 "vrfs": {
324 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}}},
325 "MGMT": {"ipv4Neighbors": {"192.0.255.70": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}}},
326 }
327 }
328 ],
329 "inputs": {"bfd_peers": [{"peer_address": "192.0.255.7", "vrf": "default"}, {"peer_address": "192.0.255.70", "vrf": "MGMT"}]},
330 "expected": {"result": AntaTestStatus.SUCCESS},
331 },
332 (VerifyBFDSpecificPeers, "success-single-hop-ipv6"): {
333 "eos_data": [
334 {
335 "vrfs": {
336 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}}},
337 "MGMT": {
338 "ipv4Neighbors": {"192.0.255.70": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}},
339 "ipv6Neighbors": {"fe80::a8c1:abff:fe91:788e": {"peerStats": {"Ethernet1": {"status": "up", "remoteDisc": 108328132}}}},
340 },
341 "PROD": {"ipv6Neighbors": {"fe80::a8c1:abff:fe4b:8c48": {"peerStats": {"Ethernet2": {"status": "up", "remoteDisc": 108328132}}}}},
342 }
343 }
344 ],
345 "inputs": {
346 "bfd_peers": [
347 {"peer_address": "192.0.255.7", "vrf": "default"},
348 {"peer_address": "192.0.255.70", "vrf": "MGMT"},
349 {"peer_address": "fe80::a8c1:abff:fe91:788e", "vrf": "MGMT", "interface": "Ethernet1"},
350 {"peer_address": "fe80::a8c1:abff:fe4b:8c48", "vrf": "PROD", "interface": "Ethernet2"},
351 ]
352 },
353 "expected": {"result": AntaTestStatus.SUCCESS},
354 },
355 (VerifyBFDSpecificPeers, "failure-no-peer"): {
356 "eos_data": [
357 {
358 "vrfs": {
359 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}}},
360 "MGMT": {"ipv4Neighbors": {"192.0.255.71": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}}},
361 }
362 }
363 ],
364 "inputs": {"bfd_peers": [{"peer_address": "192.0.255.7", "vrf": "CS"}, {"peer_address": "192.0.255.70", "vrf": "MGMT"}]},
365 "expected": {"result": AntaTestStatus.FAILURE, "messages": ["Peer: 192.0.255.7 VRF: CS - Not found", "Peer: 192.0.255.70 VRF: MGMT - Not found"]},
366 },
367 (VerifyBFDSpecificPeers, "failure-single-hop-ipv6"): {
368 "eos_data": [
369 {
370 "vrfs": {
371 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}}},
372 "MGMT": {
373 "ipv4Neighbors": {"192.0.255.70": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}},
374 "ipv6Neighbors": {"fe80::a8c1:abff:fe91:788e": {"peerStats": {"Ethernet1": {"status": "up", "remoteDisc": 108328132}}}},
375 },
376 "PROD": {"ipv6Neighbors": {}},
377 }
378 }
379 ],
380 "inputs": {
381 "bfd_peers": [
382 {"peer_address": "192.0.255.7", "vrf": "default"},
383 {"peer_address": "192.0.255.70", "vrf": "MGMT"},
384 {"peer_address": "fe80::a8c1:abff:fe91:788e", "vrf": "MGMT", "interface": "Ethernet1"},
385 {"peer_address": "fe80::a8c1:abff:fe4b:8c48", "vrf": "PROD", "interface": "Ethernet2"},
386 ]
387 },
388 "expected": {"result": AntaTestStatus.FAILURE, "messages": ["Peer: fe80::a8c1:abff:fe4b:8c48 VRF: PROD Interface: Ethernet2 - Not found"]},
389 },
390 (VerifyBFDSpecificPeers, "failure-session-down"): {
391 "eos_data": [
392 {
393 "vrfs": {
394 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"status": "down", "remoteDisc": 108328132}}}}},
395 "MGMT": {"ipv4Neighbors": {"192.0.255.70": {"peerStats": {"": {"status": "down", "remoteDisc": 0}}}}},
396 }
397 }
398 ],
399 "inputs": {"bfd_peers": [{"peer_address": "192.0.255.7", "vrf": "default"}, {"peer_address": "192.0.255.70", "vrf": "MGMT"}]},
400 "expected": {
401 "result": AntaTestStatus.FAILURE,
402 "messages": [
403 "Peer: 192.0.255.7 VRF: default - Session not properly established - State: down Remote Discriminator: 108328132",
404 "Peer: 192.0.255.70 VRF: MGMT - Session not properly established - State: down Remote Discriminator: 0",
405 ],
406 },
407 },
408 (VerifyBFDPeersHealth, "success"): {
409 "eos_data": [
410 {
411 "vrfs": {
412 "default": {
413 "ipv4Neighbors": {
414 "192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 3940685114, "lastDown": 1703657258.652725, "l3intf": ""}}}
415 },
416 "ipv6Neighbors": {},
417 },
418 "MGMT": {
419 "ipv4Neighbors": {
420 "192.0.255.71": {"peerStats": {"": {"status": "up", "remoteDisc": 3940685114, "lastDown": 1703657258.652725, "l3intf": ""}}}
421 },
422 "ipv6Neighbors": {},
423 },
424 }
425 },
426 {"utcTime": 1703667348.111288},
427 ],
428 "inputs": {"down_threshold": 2},
429 "expected": {"result": AntaTestStatus.SUCCESS},
430 },
431 (VerifyBFDPeersHealth, "success-single-hop-ipv6"): {
432 "eos_data": [
433 {
434 "vrfs": {
435 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}}, "ipv6Neighbors": {}},
436 "MGMT": {
437 "ipv4Neighbors": {"192.0.255.70": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}},
438 "ipv6Neighbors": {"fe80::a8c1:abff:fe91:788e": {"peerStats": {"Ethernet1": {"status": "up", "remoteDisc": 108328132}}}},
439 },
440 "PROD": {
441 "ipv6Neighbors": {"fe80::a8c1:abff:fe4b:8c48": {"peerStats": {"Ethernet2": {"status": "up", "remoteDisc": 108328132}}}},
442 "ipv4Neighbors": {},
443 },
444 }
445 },
446 {"utcTime": 1703667348.111288},
447 ],
448 "expected": {"result": AntaTestStatus.SUCCESS},
449 },
450 (VerifyBFDPeersHealth, "failure-no-peer"): {
451 "eos_data": [
452 {"vrfs": {"MGMT": {"ipv6Neighbors": {}, "ipv4Neighbors": {}}, "default": {"ipv6Neighbors": {}, "ipv4Neighbors": {}}}},
453 {"utcTime": 1703658481.8778424},
454 ],
455 "expected": {"result": AntaTestStatus.FAILURE, "messages": ["No IPv4 or IPv6 BFD peers configured for any VRF"]},
456 },
457 (VerifyBFDPeersHealth, "failure-ipv6"): {
458 "eos_data": [
459 {
460 "vrfs": {
461 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}}, "ipv6Neighbors": {}},
462 "MGMT": {
463 "ipv4Neighbors": {"192.0.255.70": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132}}}},
464 "ipv6Neighbors": {"fe80::a8c1:abff:fe91:788e": {"peerStats": {"Ethernet1": {"status": "down", "remoteDisc": 0}}}},
465 },
466 "PROD": {"ipv6Neighbors": {"fe80::a8c1:abff:fe4b:8c48": {"peerStats": {"": {"status": "down", "remoteDisc": 0}}}}, "ipv4Neighbors": {}},
467 }
468 },
469 {"utcTime": 1703667348.111288},
470 ],
471 "expected": {
472 "result": AntaTestStatus.FAILURE,
473 "messages": [
474 "Peer: fe80::a8c1:abff:fe91:788e VRF: MGMT Interface: Ethernet1 - Session not properly established - State: down Remote Discriminator: 0",
475 "Peer: fe80::a8c1:abff:fe4b:8c48 VRF: PROD - Session not properly established - State: down Remote Discriminator: 0",
476 ],
477 },
478 },
479 (VerifyBFDPeersHealth, "failure-session-down"): {
480 "eos_data": [
481 {
482 "vrfs": {
483 "default": {
484 "ipv4Neighbors": {
485 "192.0.255.7": {"peerStats": {"": {"status": "down", "remoteDisc": 0, "lastDown": 1703657258.652725, "l3intf": ""}}},
486 "192.0.255.70": {"peerStats": {"": {"status": "up", "remoteDisc": 3940685114, "lastDown": 1703657258.652725, "l3intf": ""}}},
487 },
488 "ipv6Neighbors": {},
489 },
490 "MGMT": {
491 "ipv4Neighbors": {"192.0.255.71": {"peerStats": {"": {"status": "down", "remoteDisc": 0, "lastDown": 1703657258.652725, "l3intf": ""}}}},
492 "ipv6Neighbors": {},
493 },
494 }
495 },
496 {"utcTime": 1703658481.8778424},
497 ],
498 "inputs": {},
499 "expected": {
500 "result": AntaTestStatus.FAILURE,
501 "messages": [
502 "Peer: 192.0.255.7 VRF: default - Session not properly established - State: down Remote Discriminator: 0",
503 "Peer: 192.0.255.71 VRF: MGMT - Session not properly established - State: down Remote Discriminator: 0",
504 ],
505 },
506 },
507 (VerifyBFDPeersHealth, "failure-session-up-disc"): {
508 "eos_data": [
509 {
510 "vrfs": {
511 "default": {
512 "ipv4Neighbors": {
513 "192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 0, "lastDown": 1703657258.652725, "l3intf": "Ethernet2"}}},
514 "192.0.255.71": {"peerStats": {"": {"status": "up", "remoteDisc": 0, "lastDown": 1703657258.652725, "l3intf": "Ethernet2"}}},
515 },
516 "ipv6Neighbors": {},
517 }
518 }
519 },
520 {"utcTime": 1703658481.8778424},
521 ],
522 "inputs": {},
523 "expected": {
524 "result": AntaTestStatus.FAILURE,
525 "messages": [
526 "Peer: 192.0.255.7 VRF: default - Session not properly established - State: up Remote Discriminator: 0",
527 "Peer: 192.0.255.71 VRF: default - Session not properly established - State: up Remote Discriminator: 0",
528 ],
529 },
530 },
531 (VerifyBFDPeersHealth, "failure-last-down"): {
532 "eos_data": [
533 {
534 "vrfs": {
535 "default": {
536 "ipv4Neighbors": {
537 "192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 3940685114, "lastDown": 1703657258.652725, "l3intf": ""}}},
538 "192.0.255.71": {"peerStats": {"": {"status": "up", "remoteDisc": 3940685114, "lastDown": 1703657258.652725, "l3intf": ""}}},
539 "192.0.255.17": {"peerStats": {"": {"status": "up", "remoteDisc": 3940685114, "lastDown": 1703657258.652725, "l3intf": ""}}},
540 },
541 "ipv6Neighbors": {},
542 }
543 }
544 },
545 {"utcTime": 1703667348.111288},
546 ],
547 "inputs": {"down_threshold": 4},
548 "expected": {
549 "result": AntaTestStatus.FAILURE,
550 "messages": [
551 "Peer: 192.0.255.7 VRF: default - Session failure detected within the expected uptime threshold (3 hours ago)",
552 "Peer: 192.0.255.71 VRF: default - Session failure detected within the expected uptime threshold (3 hours ago)",
553 "Peer: 192.0.255.17 VRF: default - Session failure detected within the expected uptime threshold (3 hours ago)",
554 ],
555 },
556 },
557 (VerifyBFDPeersRegProtocols, "success"): {
558 "eos_data": [
559 {
560 "vrfs": {
561 "default": {
562 "ipv4Neighbors": {
563 "192.0.255.7": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132, "peerStatsDetail": {"role": "active", "apps": ["ospf"]}}}}
564 }
565 },
566 "MGMT": {
567 "ipv4Neighbors": {
568 "192.0.255.70": {"peerStats": {"": {"status": "up", "remoteDisc": 108328132, "peerStatsDetail": {"role": "active", "apps": ["bgp"]}}}}
569 }
570 },
571 }
572 }
573 ],
574 "inputs": {
575 "bfd_peers": [
576 {"peer_address": "192.0.255.7", "vrf": "default", "protocols": ["ospf"]},
577 {"peer_address": "192.0.255.70", "vrf": "MGMT", "protocols": ["bgp"]},
578 ]
579 },
580 "expected": {"result": AntaTestStatus.SUCCESS},
581 },
582 (VerifyBFDPeersRegProtocols, "success-single-hop-ipv6"): {
583 "eos_data": [
584 {
585 "vrfs": {
586 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"peerStatsDetail": {"apps": ["ospf", "lag"]}}}}}},
587 "MGMT": {
588 "ipv4Neighbors": {"192.0.255.70": {"peerStats": {"": {"peerStatsDetail": {"apps": ["bgp"]}}}}},
589 "ipv6Neighbors": {"fe80::a8c1:abff:fe91:788e": {"peerStats": {"Ethernet1": {"peerStatsDetail": {"apps": ["vxlan", "isis"]}}}}},
590 },
591 "PROD": {"ipv6Neighbors": {"fe80::a8c1:abff:fe4b:8c48": {"peerStats": {"Ethernet2": {"peerStatsDetail": {"apps": ["static-bfd", "pim"]}}}}}},
592 }
593 }
594 ],
595 "inputs": {
596 "bfd_peers": [
597 {"peer_address": "192.0.255.7", "vrf": "default", "protocols": ["ospf", "lag"]},
598 {"peer_address": "192.0.255.70", "vrf": "MGMT", "protocols": ["bgp"]},
599 {"peer_address": "fe80::a8c1:abff:fe91:788e", "vrf": "MGMT", "interface": "Ethernet1", "protocols": ["vxlan", "isis"]},
600 {"peer_address": "fe80::a8c1:abff:fe4b:8c48", "vrf": "PROD", "interface": "Ethernet2", "protocols": ["static-bfd", "pim"]},
601 ]
602 },
603 "expected": {"result": AntaTestStatus.SUCCESS},
604 },
605 (VerifyBFDPeersRegProtocols, "failure"): {
606 "eos_data": [
607 {
608 "vrfs": {
609 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"status": "up", "peerStatsDetail": {"role": "active", "apps": ["ospf"]}}}}}},
610 "MGMT": {
611 "ipv4Neighbors": {
612 "192.0.255.70": {"peerStats": {"": {"status": "up", "remoteDisc": 0, "peerStatsDetail": {"role": "active", "apps": ["bgp"]}}}}
613 }
614 },
615 }
616 }
617 ],
618 "inputs": {
619 "bfd_peers": [
620 {"peer_address": "192.0.255.7", "vrf": "default", "protocols": ["isis"]},
621 {"peer_address": "192.0.255.70", "vrf": "MGMT", "protocols": ["isis", "ospf"]},
622 ]
623 },
624 "expected": {
625 "result": AntaTestStatus.FAILURE,
626 "messages": [
627 "Peer: 192.0.255.7 VRF: default - isis protocol not registered",
628 "Peer: 192.0.255.70 VRF: MGMT - isis, ospf protocols not registered",
629 ],
630 },
631 },
632 (VerifyBFDPeersRegProtocols, "failure-not-found"): {
633 "eos_data": [{"vrfs": {"default": {}, "MGMT": {}}}],
634 "inputs": {
635 "bfd_peers": [
636 {"peer_address": "192.0.255.7", "vrf": "default", "protocols": ["isis"]},
637 {"peer_address": "192.0.255.70", "vrf": "MGMT", "protocols": ["isis"]},
638 ]
639 },
640 "expected": {"result": AntaTestStatus.FAILURE, "messages": ["Peer: 192.0.255.7 VRF: default - Not found", "Peer: 192.0.255.70 VRF: MGMT - Not found"]},
641 },
642 (VerifyBFDPeersRegProtocols, "failure-ipv6"): {
643 "eos_data": [
644 {
645 "vrfs": {
646 "default": {"ipv4Neighbors": {"192.0.255.7": {"peerStats": {"": {"peerStatsDetail": {"apps": ["ospf", "lag"]}}}}}},
647 "MGMT": {
648 "ipv4Neighbors": {"192.0.255.70": {"peerStats": {"": {"peerStatsDetail": {"apps": ["bgp"]}}}}},
649 "ipv6Neighbors": {"fe80::a8c1:abff:fe91:788e": {"peerStats": {"Ethernet1": {"peerStatsDetail": {"apps": ["vxlan", "isis"]}}}}},
650 },
651 "PROD": {"ipv6Neighbors": {"fe80::a8c1:abff:fe4b:8c48": {"peerStats": {"": {"peerStatsDetail": {"apps": ["static-bfd", "pim"]}}}}}},
652 }
653 }
654 ],
655 "inputs": {
656 "bfd_peers": [
657 {"peer_address": "192.0.255.7", "vrf": "default", "protocols": ["ospf", "lag"]},
658 {"peer_address": "192.0.255.70", "vrf": "MGMT", "protocols": ["bgp"]},
659 {"peer_address": "fe80::a8c1:abff:fe91:788e", "vrf": "MGMT", "interface": "Ethernet1", "protocols": ["bgp", "vrrp"]},
660 {"peer_address": "fe80::a8c1:abff:fe4b:8c48", "vrf": "PROD", "protocols": ["ospfv3", "pim"]},
661 ]
662 },
663 "expected": {
664 "result": AntaTestStatus.FAILURE,
665 "messages": [
666 "Peer: fe80::a8c1:abff:fe91:788e VRF: MGMT Interface: Ethernet1 - bgp, vrrp protocols not registered",
667 "Peer: fe80::a8c1:abff:fe4b:8c48 VRF: PROD - ospfv3 protocol not registered",
668 ],
669 },
670 },
671 }