]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_ecmp_topo2/test_ebgp_ecmp_topo2.py
Merge pull request #8144 from LabNConsulting/chopps/ly2
[mirror_frr.git] / tests / topotests / bgp_ecmp_topo2 / test_ebgp_ecmp_topo2.py
1 #!/usr/bin/env python
2
3 #
4 # Copyright (c) 2019 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
6 # ("NetDEF") in this file.
7 #
8 # Permission to use, copy, modify, and/or distribute this software
9 # for any purpose with or without fee is hereby granted, provided
10 # that the above copyright notice and this permission notice appear
11 # in all copies.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 # OF THIS SOFTWARE.
21 #
22
23
24 """
25 Following tests are covered to test ecmp functionality on EBGP.
26 1. Verify routes installed as per maximum-paths configuration (8/16/32)
27 2. Disable/Shut selected paths nexthops and verify other next are installed in
28 the RIB of DUT. Enable interfaces and verify RIB count.
29 3. Verify BGP table and RIB in DUT after clear BGP routes and neighbors.
30 4. Verify routes are cleared from BGP and RIB table of DUT when
31 redistribute static configuration is removed.
32 5. Shut BGP neigbors one by one and verify BGP and routing table updated
33 accordingly in DUT
34 6. Delete static routes and verify routers are cleared from BGP table and RIB
35 of DUT.
36 7. Verify routes are cleared from BGP and RIB table of DUT when advertise
37 network configuration is removed.
38 """
39 import os
40 import sys
41 import time
42 import json
43 import pytest
44
45 # Save the Current Working Directory to find configuration files.
46 CWD = os.path.dirname(os.path.realpath(__file__))
47 sys.path.append(os.path.join(CWD, "../"))
48 sys.path.append(os.path.join(CWD, "../../"))
49
50 # pylint: disable=C0413
51 # Import topogen and topotest helpers
52 from lib.topogen import Topogen, get_topogen
53 from mininet.topo import Topo
54
55 from lib.common_config import (
56 start_topology,
57 write_test_header,
58 write_test_footer,
59 verify_rib,
60 create_static_routes,
61 check_address_types,
62 interface_status,
63 reset_config_on_routers,
64 required_linux_kernel_version,
65 )
66 from lib.topolog import logger
67 from lib.bgp import verify_bgp_convergence, create_router_bgp, clear_bgp
68 from lib.topojson import build_topo_from_json, build_config_from_json
69
70
71 pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
72
73
74 # Reading the data from JSON File for topology and configuration creation
75 jsonFile = "{}/ebgp_ecmp_topo2.json".format(CWD)
76
77 try:
78 with open(jsonFile, "r") as topoJson:
79 topo = json.load(topoJson)
80 except IOError:
81 assert False, "Could not read file {}".format(jsonFile)
82
83 # Global variables
84 NEXT_HOPS = {"ipv4": [], "ipv6": []}
85 INTF_LIST_R3 = []
86 INTF_LIST_R2 = []
87 NETWORK = {"ipv4": "11.0.20.1/32", "ipv6": "1::/64"}
88 NEXT_HOP_IP = {"ipv4": "10.0.0.1", "ipv6": "fd00::1"}
89 BGP_CONVERGENCE = False
90
91
92 class CreateTopo(Topo):
93 """
94 Test topology builder.
95
96 * `Topo`: Topology object
97 """
98
99 def build(self, *_args, **_opts):
100 """Build function."""
101 tgen = get_topogen(self)
102
103 # Building topology from json file
104 build_topo_from_json(tgen, topo)
105
106
107 def setup_module(mod):
108 """
109 Sets up the pytest environment.
110
111 * `mod`: module name
112 """
113 global NEXT_HOPS, INTF_LIST_R3, INTF_LIST_R2, TEST_STATIC
114 global ADDR_TYPES
115
116 # Required linux kernel version for this suite to run.
117 result = required_linux_kernel_version("4.15")
118 if result is not True:
119 pytest.skip("Kernel requirements are not met")
120
121 testsuite_run_time = time.asctime(time.localtime(time.time()))
122 logger.info("Testsuite start time: {}".format(testsuite_run_time))
123 logger.info("=" * 40)
124
125 logger.info("Running setup_module to create topology")
126
127 # This function initiates the topology build with Topogen...
128 tgen = Topogen(CreateTopo, mod.__name__)
129
130 # Starting topology, create tmp files which are loaded to routers
131 # to start deamons and then start routers
132 start_topology(tgen)
133
134 # Creating configuration from JSON
135 build_config_from_json(tgen, topo)
136
137 # Don't run this test if we have any failure.
138 if tgen.routers_have_failure():
139 pytest.skip(tgen.errors)
140
141 # tgen.mininet_cli()
142 # Api call verify whether BGP is converged
143 ADDR_TYPES = check_address_types()
144
145 BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
146 assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error:" " {}".format(
147 BGP_CONVERGENCE
148 )
149
150 link_data = [
151 val for links, val in topo["routers"]["r2"]["links"].items() if "r3" in links
152 ]
153 for adt in ADDR_TYPES:
154 NEXT_HOPS[adt] = [val[adt].split("/")[0] for val in link_data]
155 if adt == "ipv4":
156 NEXT_HOPS[adt] = sorted(NEXT_HOPS[adt], key=lambda x: int(x.split(".")[2]))
157 elif adt == "ipv6":
158 NEXT_HOPS[adt] = sorted(
159 NEXT_HOPS[adt], key=lambda x: int(x.split(":")[-3], 16)
160 )
161
162 INTF_LIST_R2 = [val["interface"].split("/")[0] for val in link_data]
163 INTF_LIST_R2 = sorted(INTF_LIST_R2, key=lambda x: int(x.split("eth")[1]))
164
165 link_data = [
166 val for links, val in topo["routers"]["r3"]["links"].items() if "r2" in links
167 ]
168 INTF_LIST_R3 = [val["interface"].split("/")[0] for val in link_data]
169 INTF_LIST_R3 = sorted(INTF_LIST_R3, key=lambda x: int(x.split("eth")[1]))
170
171 # STATIC_ROUTE = True
172 logger.info("Running setup_module() done")
173
174
175 def teardown_module():
176 """
177 Teardown the pytest environment.
178
179 * `mod`: module name
180 """
181
182 logger.info("Running teardown_module to delete topology")
183
184 tgen = get_topogen()
185
186 # Stop toplogy and Remove tmp files
187 tgen.stop_topology()
188
189
190 def static_or_nw(tgen, topo, tc_name, test_type, dut):
191
192 if test_type == "redist_static":
193 input_dict_static = {
194 dut: {
195 "static_routes": [
196 {"network": NETWORK["ipv4"], "next_hop": NEXT_HOP_IP["ipv4"]},
197 {"network": NETWORK["ipv6"], "next_hop": NEXT_HOP_IP["ipv6"]},
198 ]
199 }
200 }
201 logger.info("Configuring static route on router %s", dut)
202 result = create_static_routes(tgen, input_dict_static)
203 assert result is True, "Testcase {} : Failed \n Error: {}".format(
204 tc_name, result
205 )
206
207 input_dict_2 = {
208 dut: {
209 "bgp": {
210 "address_family": {
211 "ipv4": {
212 "unicast": {"redistribute": [{"redist_type": "static"}]}
213 },
214 "ipv6": {
215 "unicast": {"redistribute": [{"redist_type": "static"}]}
216 },
217 }
218 }
219 }
220 }
221
222 logger.info("Configuring redistribute static route on router %s", dut)
223 result = create_router_bgp(tgen, topo, input_dict_2)
224 assert result is True, "Testcase {} : Failed \n Error: {}".format(
225 tc_name, result
226 )
227
228 elif test_type == "advertise_nw":
229 input_dict_nw = {
230 dut: {
231 "bgp": {
232 "address_family": {
233 "ipv4": {
234 "unicast": {
235 "advertise_networks": [{"network": NETWORK["ipv4"]}]
236 }
237 },
238 "ipv6": {
239 "unicast": {
240 "advertise_networks": [{"network": NETWORK["ipv6"]}]
241 }
242 },
243 }
244 }
245 }
246 }
247
248 logger.info(
249 "Advertising networks %s %s from router %s",
250 NETWORK["ipv4"],
251 NETWORK["ipv6"],
252 dut,
253 )
254 result = create_router_bgp(tgen, topo, input_dict_nw)
255 assert result is True, "Testcase {} : Failed \n Error: {}".format(
256 tc_name, result
257 )
258
259
260 @pytest.mark.parametrize("ecmp_num", ["8", "16", "32"])
261 @pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
262 def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
263 """
264 Verify routes installed as per maximum-paths
265 configuration (8/16/32).
266 """
267
268 tc_name = request.node.name
269 write_test_header(tc_name)
270 tgen = get_topogen()
271
272 reset_config_on_routers(tgen)
273
274 static_or_nw(tgen, topo, tc_name, test_type, "r2")
275
276 input_dict = {
277 "r3": {
278 "bgp": {
279 "address_family": {
280 "ipv4": {
281 "unicast": {
282 "maximum_paths": {
283 "ebgp": ecmp_num,
284 }
285 }
286 },
287 "ipv6": {
288 "unicast": {
289 "maximum_paths": {
290 "ebgp": ecmp_num,
291 }
292 }
293 },
294 }
295 }
296 }
297 }
298
299 logger.info("Configuring bgp maximum-paths %s on router r3", ecmp_num)
300 result = create_router_bgp(tgen, topo, input_dict)
301 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
302
303 # Verifying RIB routes
304 dut = "r3"
305 protocol = "bgp"
306
307 for addr_type in ADDR_TYPES:
308 input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
309
310 logger.info("Verifying %s routes on r3", addr_type)
311
312 # Only test the count of nexthops; the actual nexthop addresses
313 # can vary and are not deterministic.
314 #
315 result = verify_rib(
316 tgen,
317 addr_type,
318 dut,
319 input_dict_1,
320 next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
321 protocol=protocol,
322 count_only=True,
323 )
324
325 assert result is True, "Testcase {} : Failed \n Error: {}".format(
326 tc_name, result
327 )
328
329 write_test_footer(tc_name)
330
331
332 @pytest.mark.parametrize("ecmp_num", ["8", "16", "32"])
333 @pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
334 def test_ecmp_after_clear_bgp(request, ecmp_num, test_type):
335 """ Verify BGP table and RIB in DUT after clear BGP routes and neighbors"""
336
337 tc_name = request.node.name
338 write_test_header(tc_name)
339 tgen = get_topogen()
340
341 reset_config_on_routers(tgen)
342
343 # Verifying RIB routes
344 dut = "r3"
345 protocol = "bgp"
346
347 static_or_nw(tgen, topo, tc_name, test_type, "r2")
348 for addr_type in ADDR_TYPES:
349 input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
350
351 logger.info("Verifying %s routes on r3", addr_type)
352 result = verify_rib(
353 tgen,
354 addr_type,
355 dut,
356 input_dict_1,
357 next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
358 protocol=protocol,
359 )
360 assert result is True, "Testcase {} : Failed \n Error: {}".format(
361 tc_name, result
362 )
363
364 # Clear BGP
365 for addr_type in ADDR_TYPES:
366 clear_bgp(tgen, addr_type, dut)
367
368 # Verify BGP convergence
369 result = verify_bgp_convergence(tgen, topo)
370 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
371
372 for addr_type in ADDR_TYPES:
373 input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
374 logger.info("Verifying %s routes on r3", addr_type)
375 result = verify_rib(
376 tgen,
377 addr_type,
378 dut,
379 input_dict_1,
380 next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
381 protocol=protocol,
382 )
383 assert result is True, "Testcase {} : Failed \n Error: {}".format(
384 tc_name, result
385 )
386
387 write_test_footer(tc_name)
388
389
390 def test_ecmp_remove_redistribute_static(request):
391 """Verify routes are cleared from BGP and RIB table of DUT when
392 redistribute static configuration is removed."""
393
394 tc_name = request.node.name
395 write_test_header(tc_name)
396 tgen = get_topogen()
397
398 reset_config_on_routers(tgen)
399 static_or_nw(tgen, topo, tc_name, "redist_static", "r2")
400 for addr_type in ADDR_TYPES:
401
402 # Verifying RIB routes
403 dut = "r3"
404 protocol = "bgp"
405 input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
406
407 logger.info("Verifying %s routes on r3", addr_type)
408 result = verify_rib(
409 tgen,
410 addr_type,
411 dut,
412 input_dict_1,
413 next_hop=NEXT_HOPS[addr_type],
414 protocol=protocol,
415 )
416 assert result is True, "Testcase {} : Failed \n Error: {}".format(
417 tc_name, result
418 )
419
420 input_dict_2 = {
421 "r2": {
422 "bgp": {
423 "address_family": {
424 "ipv4": {
425 "unicast": {
426 "redistribute": [{"redist_type": "static", "delete": True}]
427 }
428 },
429 "ipv6": {
430 "unicast": {
431 "redistribute": [{"redist_type": "static", "delete": True}]
432 }
433 },
434 }
435 }
436 }
437 }
438
439 logger.info("Remove redistribute static")
440 result = create_router_bgp(tgen, topo, input_dict_2)
441 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
442
443 for addr_type in ADDR_TYPES:
444
445 # Verifying RIB routes
446 dut = "r3"
447 protocol = "bgp"
448 input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
449
450 logger.info("Verifying %s routes on r3 are deleted", addr_type)
451 result = verify_rib(
452 tgen,
453 addr_type,
454 dut,
455 input_dict_1,
456 next_hop=[],
457 protocol=protocol,
458 expected=False,
459 )
460 assert (
461 result is not True
462 ), "Testcase {} : Failed \n Routes still" " present in RIB".format(tc_name)
463
464 logger.info("Enable redistribute static")
465 input_dict_2 = {
466 "r2": {
467 "bgp": {
468 "address_family": {
469 "ipv4": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
470 "ipv6": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
471 }
472 }
473 }
474 }
475 result = create_router_bgp(tgen, topo, input_dict_2)
476 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
477
478 for addr_type in ADDR_TYPES:
479 # Verifying RIB routes
480 dut = "r3"
481 protocol = "bgp"
482 input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
483 logger.info("Verifying %s routes on r3", addr_type)
484 result = verify_rib(
485 tgen,
486 addr_type,
487 dut,
488 input_dict_1,
489 next_hop=NEXT_HOPS[addr_type],
490 protocol=protocol,
491 )
492 assert result is True, "Testcase {} : Failed \n Error: {}".format(
493 tc_name, result
494 )
495
496 write_test_footer(tc_name)
497
498
499 @pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
500 def test_ecmp_shut_bgp_neighbor(request, test_type):
501 """Shut BGP neigbors one by one and verify BGP and routing table updated
502 accordingly in DUT"""
503
504 tc_name = request.node.name
505 write_test_header(tc_name)
506 tgen = get_topogen()
507
508 logger.info(INTF_LIST_R2)
509 # Verifying RIB routes
510 dut = "r3"
511 protocol = "bgp"
512
513 reset_config_on_routers(tgen)
514 static_or_nw(tgen, topo, tc_name, test_type, "r2")
515
516 for addr_type in ADDR_TYPES:
517 input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
518
519 logger.info("Verifying %s routes on r3", addr_type)
520 result = verify_rib(
521 tgen,
522 addr_type,
523 dut,
524 input_dict,
525 next_hop=NEXT_HOPS[addr_type],
526 protocol=protocol,
527 )
528 assert result is True, "Testcase {} : Failed \n Error: {}".format(
529 tc_name, result
530 )
531
532 for intf_num in range(len(INTF_LIST_R2) + 1, 16):
533 intf_val = INTF_LIST_R2[intf_num : intf_num + 16]
534
535 input_dict_1 = {"r2": {"interface_list": [intf_val], "status": "down"}}
536 logger.info("Shutting down neighbor interface {} on r2".format(intf_val))
537 result = interface_status(tgen, topo, input_dict_1)
538 assert result is True, "Testcase {} : Failed \n Error: {}".format(
539 tc_name, result
540 )
541
542 for addr_type in ADDR_TYPES:
543 if intf_num + 16 < 32:
544 check_hops = NEXT_HOPS[addr_type]
545 else:
546 check_hops = []
547
548 input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
549 logger.info("Verifying %s routes on r3", addr_type)
550 result = verify_rib(
551 tgen, addr_type, dut, input_dict, next_hop=check_hops, protocol=protocol
552 )
553 assert result is True, "Testcase {} : Failed \n Error: {}".format(
554 tc_name, result
555 )
556
557 input_dict_1 = {"r2": {"interface_list": INTF_LIST_R2, "status": "up"}}
558
559 logger.info("Enabling all neighbor interface {} on r2")
560 result = interface_status(tgen, topo, input_dict_1)
561 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
562
563 static_or_nw(tgen, topo, tc_name, test_type, "r2")
564 for addr_type in ADDR_TYPES:
565 input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
566
567 logger.info("Verifying %s routes on r3", addr_type)
568 result = verify_rib(
569 tgen,
570 addr_type,
571 dut,
572 input_dict,
573 next_hop=NEXT_HOPS[addr_type],
574 protocol=protocol,
575 )
576 assert result is True, "Testcase {} : Failed \n Error: {}".format(
577 tc_name, result
578 )
579
580 write_test_footer(tc_name)
581
582
583 def test_ecmp_remove_static_route(request):
584 """
585 Delete static routes and verify routers are cleared from BGP table,
586 and RIB of DUT.
587 """
588
589 tc_name = request.node.name
590 write_test_header(tc_name)
591 tgen = get_topogen()
592
593 # Verifying RIB routes
594 dut = "r3"
595 protocol = "bgp"
596
597 reset_config_on_routers(tgen)
598
599 static_or_nw(tgen, topo, tc_name, "redist_static", "r2")
600 for addr_type in ADDR_TYPES:
601 input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
602
603 logger.info("Verifying %s routes on r3", addr_type)
604 result = verify_rib(
605 tgen,
606 addr_type,
607 dut,
608 input_dict_1,
609 next_hop=NEXT_HOPS[addr_type],
610 protocol=protocol,
611 )
612 assert result is True, "Testcase {} : Failed \n Error: {}".format(
613 tc_name, result
614 )
615
616 for addr_type in ADDR_TYPES:
617 input_dict_2 = {
618 "r2": {
619 "static_routes": [
620 {
621 "network": NETWORK[addr_type],
622 "next_hop": NEXT_HOP_IP[addr_type],
623 "delete": True,
624 }
625 ]
626 }
627 }
628
629 logger.info("Remove static routes")
630 result = create_static_routes(tgen, input_dict_2)
631 assert result is True, "Testcase {} : Failed \n Error: {}".format(
632 tc_name, result
633 )
634
635 logger.info("Verifying %s routes on r3 are removed", addr_type)
636 result = verify_rib(
637 tgen,
638 addr_type,
639 dut,
640 input_dict_2,
641 next_hop=[],
642 protocol=protocol,
643 expected=False,
644 )
645 assert (
646 result is not True
647 ), "Testcase {} : Failed \n Routes still" " present in RIB".format(tc_name)
648
649 for addr_type in ADDR_TYPES:
650 # Enable static routes
651 input_dict_4 = {
652 "r2": {
653 "static_routes": [
654 {"network": NETWORK[addr_type], "next_hop": NEXT_HOP_IP[addr_type]}
655 ]
656 }
657 }
658
659 logger.info("Enable static route")
660 result = create_static_routes(tgen, input_dict_4)
661 assert result is True, "Testcase {} : Failed \n Error: {}".format(
662 tc_name, result
663 )
664
665 logger.info("Verifying %s routes on r3", addr_type)
666 result = verify_rib(
667 tgen,
668 addr_type,
669 dut,
670 input_dict_4,
671 next_hop=NEXT_HOPS[addr_type],
672 protocol=protocol,
673 )
674 assert result is True, "Testcase {} : Failed \n Error: {}".format(
675 tc_name, result
676 )
677
678
679 def test_ecmp_remove_nw_advertise(request):
680 """
681 Verify routes are cleared from BGP and RIB table of DUT,
682 when advertise network configuration is removed
683 """
684
685 tc_name = request.node.name
686 write_test_header(tc_name)
687 tgen = get_topogen()
688
689 # Verifying RIB routes
690 dut = "r3"
691 protocol = "bgp"
692
693 reset_config_on_routers(tgen)
694 static_or_nw(tgen, topo, tc_name, "advertise_nw", "r2")
695 for addr_type in ADDR_TYPES:
696 input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
697
698 logger.info("Verifying %s routes on r3", addr_type)
699 result = verify_rib(
700 tgen,
701 addr_type,
702 dut,
703 input_dict,
704 next_hop=NEXT_HOPS[addr_type],
705 protocol=protocol,
706 )
707 assert result is True, "Testcase {} : Failed \n Error: {}".format(
708 tc_name, result
709 )
710
711 input_dict_3 = {
712 "r2": {
713 "bgp": {
714 "address_family": {
715 "ipv4": {
716 "unicast": {
717 "advertise_networks": [
718 {"network": NETWORK["ipv4"], "delete": True}
719 ]
720 }
721 },
722 "ipv6": {
723 "unicast": {
724 "advertise_networks": [
725 {"network": NETWORK["ipv6"], "delete": True}
726 ]
727 }
728 },
729 }
730 }
731 }
732 }
733
734 logger.info("Withdraw advertised networks")
735 result = create_router_bgp(tgen, topo, input_dict_3)
736 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
737
738 for addr_type in ADDR_TYPES:
739 input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
740
741 logger.info("Verifying %s routes on r3", addr_type)
742 result = verify_rib(
743 tgen,
744 addr_type,
745 dut,
746 input_dict,
747 next_hop=[],
748 protocol=protocol,
749 expected=False,
750 )
751 assert (
752 result is not True
753 ), "Testcase {} : Failed \n Routes still" " present in RIB".format(tc_name)
754
755 static_or_nw(tgen, topo, tc_name, "advertise_nw", "r2")
756 for addr_type in ADDR_TYPES:
757 input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
758 logger.info("Verifying %s routes on r3", addr_type)
759 result = verify_rib(
760 tgen,
761 addr_type,
762 dut,
763 input_dict,
764 next_hop=NEXT_HOPS[addr_type],
765 protocol=protocol,
766 )
767 assert result is True, "Testcase {} : Failed \n Error: {}".format(
768 tc_name, result
769 )
770
771 write_test_footer(tc_name)
772
773
774 if __name__ == "__main__":
775 args = ["-s"] + sys.argv[1:]
776 sys.exit(pytest.main(args))