]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / static_routing_with_ebgp / test_static_routes_topo4_ebgp.py
1 #!/usr/bin/python
2 # SPDX-License-Identifier: ISC
3
4 #
5 # Copyright (c) 2020 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation,
7 # Inc. ("NetDEF") in this file.
8 #
9
10 """
11
12 Following tests are covered in the script.
13
14 - Verify static route are blocked from route-map and prefix-list
15 applied in BGP nbrs
16 - Verify Static route when FRR connected to 2 TOR
17 """
18
19 import sys
20 import time
21 import os
22 import pytest
23 import platform
24 import ipaddress
25 from copy import deepcopy
26
27 # Save the Current Working Directory to find configuration files.
28 CWD = os.path.dirname(os.path.realpath(__file__))
29 sys.path.append(os.path.join(CWD, "../"))
30 sys.path.append(os.path.join(CWD, "../lib/"))
31 # pylint: disable=C0413
32 # Import topogen and topotest helpers
33 from lib.topogen import Topogen, get_topogen
34 from lib.topotest import version_cmp
35
36 # Import topoJson from lib, to create topology and initial configuration
37 from lib.common_config import (
38 start_topology,
39 write_test_header,
40 write_test_footer,
41 reset_config_on_routers,
42 verify_rib,
43 check_address_types,
44 step,
45 create_prefix_lists,
46 create_route_maps,
47 verify_prefix_lists,
48 verify_route_maps,
49 )
50 from lib.topolog import logger
51 from lib.bgp import (
52 verify_bgp_convergence,
53 create_router_bgp,
54 clear_bgp_and_verify,
55 clear_bgp,
56 )
57 from lib.topojson import build_config_from_json
58
59
60 pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
61
62 # Global variables
63 BGP_CONVERGENCE = False
64 ADDR_TYPES = check_address_types()
65 NETWORK = {"ipv4": "2.2.2.2/32", "ipv6": "22:22::2/128"}
66 NEXT_HOP_IP = {}
67
68 pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
69
70
71 def setup_module(mod):
72 """
73 Set up the pytest environment.
74 * `mod`: module name
75 """
76
77 testsuite_run_time = time.asctime(time.localtime(time.time()))
78 logger.info("Testsuite start time: {}".format(testsuite_run_time))
79 logger.info("=" * 40)
80
81 logger.info("Running setup_module to create topology")
82
83 # This function initiates the topology build with Topogen...
84 json_file = "{}/static_routes_topo4_ebgp.json".format(CWD)
85 tgen = Topogen(json_file, mod.__name__)
86 global topo
87 topo = tgen.json_topo
88 # ... and here it calls Mininet initialization functions.
89
90 # Starting topology, create tmp files which are loaded to routers
91 # to start daemons and then start routers
92 start_topology(tgen)
93
94 # Creating configuration from JSON
95 build_config_from_json(tgen, topo)
96
97 if version_cmp(platform.release(), "4.19") < 0:
98 error_msg = (
99 'These tests will not run. (have kernel "{}", '
100 "requires kernel >= 4.19)".format(platform.release())
101 )
102 pytest.skip(error_msg)
103
104 # Checking BGP convergence
105
106 # Don't run this test if we have any failure.
107 if tgen.routers_have_failure():
108 pytest.skip(tgen.errors)
109 # Api call verify whether BGP is converged
110 BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
111 assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
112 BGP_CONVERGENCE
113 )
114
115 logger.info("Running setup_module() done")
116
117
118 def teardown_module(mod):
119 """
120 Teardown the pytest environment.
121
122 * `mod`: module name
123 """
124 logger.info("Running teardown_module to delete topology")
125
126 tgen = get_topogen()
127
128 # Stop toplogy and Remove tmp files
129 tgen.stop_topology()
130
131 logger.info(
132 "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
133 )
134 logger.info("=" * 40)
135
136
137 #####################################################
138 #
139 # Tests starting
140 #
141 #####################################################
142 def test_static_routes_rmap_pfxlist_p0_tc7_ebgp(request):
143 """
144 Verify static route are blocked from route-map & prefix-list applied in BGP
145 nbrs
146
147 """
148 tc_name = request.node.name
149 write_test_header(tc_name)
150 tgen = get_topogen()
151 # Don't run this test if we have any failure.
152 if tgen.routers_have_failure():
153 pytest.skip(tgen.errors)
154 reset_config_on_routers(tgen)
155 step("Configure holddown timer = 1 keep alive = 3 in all the neighbors")
156 step("verify bgp convergence before starting test case")
157
158 bgp_convergence = verify_bgp_convergence(tgen, topo)
159 assert bgp_convergence is True, "Testcase {} : Failed \n Error: {}".format(
160 tc_name, bgp_convergence
161 )
162
163 step(
164 "Configure 4 IPv4 and 4 IPv6 nbrs with password with mismatch "
165 " authentication between FRR routers "
166 )
167
168 for addr_type in ADDR_TYPES:
169 # Api call to modify BGP timers
170 input_dict = {
171 "r2": {
172 "bgp": {
173 "local_as": "200",
174 "address_family": {
175 addr_type: {
176 "unicast": {
177 "neighbor": {
178 "r1": {
179 "dest_link": {
180 "r2-link0": {"password": "r2"},
181 "r2-link1": {"password": "r2"},
182 "r2-link2": {"password": "r2"},
183 "r2-link3": {"password": "r2"},
184 }
185 },
186 "r3": {
187 "dest_link": {
188 "r2-link0": {"password": "r2"},
189 "r2-link1": {"password": "r2"},
190 "r2-link2": {"password": "r2"},
191 "r2-link3": {"password": "r2"},
192 }
193 },
194 }
195 }
196 }
197 },
198 }
199 }
200 }
201 result = create_router_bgp(tgen, topo, input_dict)
202 assert result is True, "Testcase {} :Failed \n Error: {}".format(
203 tc_name, result
204 )
205 clear_bgp(tgen, addr_type, "r2")
206
207 step(" All BGP nbrs are down as authentication is mismatch on both" " the sides")
208
209 bgp_convergence = verify_bgp_convergence(tgen, topo, expected=False)
210 assert (
211 bgp_convergence is not True
212 ), "Testcase {} : " "Failed \n BGP nbrs must be down. Error: {}".format(
213 tc_name, bgp_convergence
214 )
215
216 step(
217 "Configure 4 IPv4 and 4 IPv6 nbrs with macthing password "
218 " authentication between FRR routers "
219 )
220 for addr_type in ADDR_TYPES:
221 input_dict = {
222 "r2": {
223 "bgp": {
224 "local_as": "200",
225 "address_family": {
226 addr_type: {
227 "unicast": {
228 "neighbor": {
229 "r1": {
230 "dest_link": {
231 "r2-link0": {"password": "r1"},
232 "r2-link1": {"password": "r1"},
233 "r2-link2": {"password": "r1"},
234 "r2-link3": {"password": "r1"},
235 }
236 },
237 "r3": {
238 "dest_link": {
239 "r2-link0": {"password": "r1"},
240 "r2-link1": {"password": "r1"},
241 "r2-link2": {"password": "r1"},
242 "r2-link3": {"password": "r1"},
243 }
244 },
245 }
246 }
247 }
248 },
249 }
250 }
251 }
252 result = create_router_bgp(tgen, topo, deepcopy(input_dict))
253 assert result is True, "Testcase {} :Failed \n Error: {}".format(
254 tc_name, result
255 )
256
257 step("All BGP nbrs are up as authentication is matched now")
258 bgp_convergence = verify_bgp_convergence(tgen, topo)
259 assert bgp_convergence is True, "Testcase {} : Failed \n " "Error: {}".format(
260 tc_name, bgp_convergence
261 )
262
263 step("Create prefix list P1 to permit VM3 & deny VM1 v4 & v6 routes")
264 step("Create prefix list P2 to permit VM6 IPv4 and IPv6 routes")
265 for addr_type in ADDR_TYPES:
266 input_dict_2 = {
267 "r2": {
268 "prefix_lists": {
269 addr_type: {
270 "pf_list_1_{}".format(addr_type): [
271 {
272 "seqid": 10,
273 "network": topo["routers"]["r2"]["links"]["vm3"][
274 addr_type
275 ],
276 "action": "permit",
277 },
278 {
279 "seqid": 20,
280 "network": topo["routers"]["r2"]["links"]["vm1"][
281 addr_type
282 ],
283 "action": "deny",
284 },
285 ],
286 "pf_list_2_{}".format(addr_type): [
287 {
288 "seqid": 10,
289 "network": topo["routers"]["r2"]["links"]["vm6"][
290 addr_type
291 ],
292 "action": "permit",
293 }
294 ],
295 }
296 }
297 }
298 }
299 result = create_prefix_lists(tgen, input_dict_2)
300 assert result is True, "Testcase {} : Failed \n Error: {}".format(
301 tc_name, result
302 )
303
304 step(
305 "Prefix list created with matching networks deny or permit "
306 "show ip prefix list"
307 )
308 result = verify_prefix_lists(tgen, input_dict_2)
309 assert result is not True, "Testcase {} : Failed \n" " Error: {}".format(
310 tc_name, result
311 )
312
313 step("Redistribute all the routes (connected, static)")
314 input_dict_2_r1 = {
315 "r1": {
316 "bgp": {
317 "address_family": {
318 addr_type: {
319 "unicast": {"redistribute": [{"redist_type": "static"}]}
320 }
321 }
322 }
323 }
324 }
325 result = create_router_bgp(tgen, topo, input_dict_2_r1)
326 assert result is True, "Testcase {} : Failed \n Error: {}".format(
327 tc_name, result
328 )
329
330 input_dict_2_r2 = {
331 "r2": {
332 "bgp": {
333 "address_family": {
334 addr_type: {
335 "unicast": {"redistribute": [{"redist_type": "static"}]}
336 }
337 }
338 }
339 }
340 }
341 result = create_router_bgp(tgen, topo, input_dict_2_r2)
342 assert result is True, "Testcase {} : Failed \n Error: {}".format(
343 tc_name, result
344 )
345
346 input_dict_2_r3 = {
347 "r3": {
348 "bgp": {
349 "address_family": {
350 addr_type: {
351 "unicast": {"redistribute": [{"redist_type": "static"}]}
352 }
353 }
354 }
355 }
356 }
357 result = create_router_bgp(tgen, topo, input_dict_2_r3)
358 assert result is True, "Testcase {} : Failed \n Error: {}".format(
359 tc_name, result
360 )
361
362 step("configure redistribute connected in Router BGP")
363
364 input_dict_2_r1 = {
365 "r1": {
366 "bgp": {
367 "address_family": {
368 addr_type: {
369 "unicast": {"redistribute": [{"redist_type": "connected"}]}
370 }
371 }
372 }
373 }
374 }
375 result = create_router_bgp(tgen, topo, input_dict_2_r1)
376 assert result is True, "Testcase {} : Failed \n Error: {}".format(
377 tc_name, result
378 )
379
380 input_dict_2_r3 = {
381 "r3": {
382 "bgp": {
383 "address_family": {
384 addr_type: {
385 "unicast": {"redistribute": [{"redist_type": "connected"}]}
386 }
387 }
388 }
389 }
390 }
391 result = create_router_bgp(tgen, topo, input_dict_2_r3)
392 assert result is True, "Testcase {} : Failed \n Error: {}".format(
393 tc_name, result
394 )
395
396 input_dict_2 = {
397 "r2": {
398 "bgp": {
399 "address_family": {
400 addr_type: {
401 "unicast": {"redistribute": [{"redist_type": "connected"}]}
402 }
403 }
404 }
405 }
406 }
407 result = create_router_bgp(tgen, topo, input_dict_2)
408 assert result is True, "Testcase {} : Failed \n Error: {}".format(
409 tc_name, result
410 )
411
412 step("Apply prefix list P1 on BGP neighbors 1 2 3 4 connected from " "frr r1")
413 # Configure prefix list to bgp neighbor
414 input_dict_4 = {
415 "r2": {
416 "bgp": {
417 "address_family": {
418 addr_type: {
419 "unicast": {
420 "neighbor": {
421 "r1": {
422 "dest_link": {
423 "r2-link0": {
424 "prefix_lists": [
425 {
426 "name": "pf_list_1_{}".format(
427 addr_type
428 ),
429 "direction": "out",
430 }
431 ]
432 },
433 "r2-link1": {
434 "prefix_lists": [
435 {
436 "name": "pf_list_1_{}".format(
437 addr_type
438 ),
439 "direction": "out",
440 }
441 ]
442 },
443 "r2-link2": {
444 "prefix_lists": [
445 {
446 "name": "pf_list_1_{}".format(
447 addr_type
448 ),
449 "direction": "out",
450 }
451 ]
452 },
453 "r2-link3": {
454 "prefix_lists": [
455 {
456 "name": "pf_list_1_{}".format(
457 addr_type
458 ),
459 "direction": "out",
460 }
461 ]
462 },
463 }
464 }
465 }
466 }
467 }
468 }
469 }
470 }
471 }
472 result = create_router_bgp(tgen, topo, input_dict_4)
473 assert result is True, "Testcase {} : Failed \n Error: {}".format(
474 tc_name, result
475 )
476
477 step("Apply prefix list P2 on BGP nbrs 5 & 6 connected from FRR-2")
478 # Configure prefix list to bgp neighbor
479 input_dict_4 = {
480 "r2": {
481 "bgp": {
482 "address_family": {
483 addr_type: {
484 "unicast": {
485 "neighbor": {
486 "r3": {
487 "dest_link": {
488 "r2-link0": {
489 "prefix_lists": [
490 {
491 "name": "pf_list_2_{}".format(
492 addr_type
493 ),
494 "direction": "out",
495 }
496 ]
497 },
498 "r2-link1": {
499 "prefix_lists": [
500 {
501 "name": "pf_list_2_{}".format(
502 addr_type
503 ),
504 "direction": "out",
505 }
506 ]
507 },
508 "r2-link2": {
509 "prefix_lists": [
510 {
511 "name": "pf_list_2_{}".format(
512 addr_type
513 ),
514 "direction": "out",
515 }
516 ]
517 },
518 "r2-link3": {
519 "prefix_lists": [
520 {
521 "name": "pf_list_2_{}".format(
522 addr_type
523 ),
524 "direction": "out",
525 }
526 ]
527 },
528 }
529 }
530 }
531 }
532 }
533 }
534 }
535 }
536 }
537 result = create_router_bgp(tgen, topo, input_dict_4)
538 assert result is True, "Testcase {} : Failed \n Error: {}".format(
539 tc_name, result
540 )
541
542 clear_bgp_and_verify(tgen, topo, "r2")
543
544 step(
545 "VM1 IPv4 and IPv6 Route which is denied using prefix list is "
546 "not present on FRR1 side routing table , also not able to "
547 "ping the routes show ip route"
548 )
549
550 dut = "r1"
551 protocol = "bgp"
552 ntwk_r2_vm1 = str(
553 ipaddress.ip_interface(
554 u"{}".format(topo["routers"]["r2"]["links"]["vm1"][addr_type])
555 ).network
556 )
557 input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}}
558 result4 = verify_rib(
559 tgen, addr_type, dut, input_dict, protocol=protocol, expected=False
560 )
561 assert result4 is not True, (
562 "Testcase {} : Failed , VM1 route is "
563 "not filtered out via prefix list. \n Error: {}".format(tc_name, result4)
564 )
565
566 step(
567 "VM4 and VM6 IPV4 and IPv6 address are present in local and "
568 "FRR2 routing table show ip bgp show ip route"
569 )
570
571 dut = "r2"
572 ntwk_r2_vm6 = str(
573 ipaddress.ip_interface(
574 u"{}".format(topo["routers"]["r2"]["links"]["vm6"][addr_type])
575 ).network
576 )
577 input_dict = {"r3": {"static_routes": [{"network": ntwk_r2_vm6}]}}
578 result4 = verify_rib(tgen, addr_type, dut, input_dict)
579 assert result4 is True, "Testcase {} : Failed.\n Error: {}".format(
580 tc_name, result4
581 )
582
583 step("Remove prefix list from all the neighbors")
584 input_dict_4 = {
585 "r2": {
586 "bgp": {
587 "address_family": {
588 addr_type: {
589 "unicast": {
590 "neighbor": {
591 "r1": {
592 "dest_link": {
593 "r2-link0": {
594 "prefix_lists": [
595 {
596 "name": "pf_list_1_{}".format(
597 addr_type
598 ),
599 "direction": "out",
600 "delete": True,
601 }
602 ]
603 },
604 "r2-link1": {
605 "prefix_lists": [
606 {
607 "name": "pf_list_1_{}".format(
608 addr_type
609 ),
610 "direction": "out",
611 "delete": True,
612 }
613 ]
614 },
615 "r2-link2": {
616 "prefix_lists": [
617 {
618 "name": "pf_list_1_{}".format(
619 addr_type
620 ),
621 "direction": "out",
622 "delete": True,
623 }
624 ]
625 },
626 "r2-link3": {
627 "prefix_lists": [
628 {
629 "name": "pf_list_1_{}".format(
630 addr_type
631 ),
632 "direction": "out",
633 "delete": True,
634 }
635 ]
636 },
637 }
638 }
639 }
640 }
641 }
642 }
643 }
644 }
645 }
646 result = create_router_bgp(tgen, topo, input_dict_4)
647 assert result is True, "Testcase {} : Failed \n Error: {}".format(
648 tc_name, result
649 )
650
651 input_dict_4 = {
652 "r2": {
653 "bgp": {
654 "address_family": {
655 addr_type: {
656 "unicast": {
657 "neighbor": {
658 "r3": {
659 "dest_link": {
660 "r2-link0": {
661 "prefix_lists": [
662 {
663 "name": "pf_list_2_{}".format(
664 addr_type
665 ),
666 "direction": "out",
667 "delete": True,
668 }
669 ]
670 },
671 "r2-link1": {
672 "prefix_lists": [
673 {
674 "name": "pf_list_2_{}".format(
675 addr_type
676 ),
677 "direction": "out",
678 "delete": True,
679 }
680 ]
681 },
682 "r2-link2": {
683 "prefix_lists": [
684 {
685 "name": "pf_list_2_{}".format(
686 addr_type
687 ),
688 "direction": "out",
689 "delete": True,
690 }
691 ]
692 },
693 "r2-link3": {
694 "prefix_lists": [
695 {
696 "name": "pf_list_2_{}".format(
697 addr_type
698 ),
699 "direction": "out",
700 "delete": True,
701 }
702 ]
703 },
704 }
705 }
706 }
707 }
708 }
709 }
710 }
711 }
712 }
713 result = create_router_bgp(tgen, topo, input_dict_4)
714 assert result is True, "Testcase {} : Failed \n Error: {}".format(
715 tc_name, result
716 )
717
718 clear_bgp_and_verify(tgen, topo, "r2")
719
720 step("Create RouteMap_1 with prefix list P1 and weight 50")
721 # Create route map
722 rmap_dict = {
723 "r2": {
724 "route_maps": {
725 "rmap_pf_list_1_{}".format(addr_type): [
726 {
727 "action": "permit",
728 "set": {"weight": 50},
729 "match": {
730 addr_type: {
731 "prefix_lists": "pf_list_1_{}".format(addr_type)
732 }
733 },
734 }
735 ]
736 }
737 }
738 }
739 result = create_route_maps(tgen, rmap_dict)
740 assert result is True, "Testcase {} : Failed \n Error: {}".format(
741 tc_name, result
742 )
743
744 step("Create RouteMap_2 with prefix list P2 and weight 50")
745 # Create route map
746 rmap_dict = {
747 "r2": {
748 "route_maps": {
749 "rmap_pf_list_2_{}".format(addr_type): [
750 {
751 "action": "permit",
752 "set": {"weight": 50},
753 "match": {
754 addr_type: {
755 "prefix_lists": "pf_list_2_{}".format(addr_type)
756 }
757 },
758 }
759 ]
760 }
761 }
762 }
763 result = create_route_maps(tgen, rmap_dict)
764 assert result is True, "Testcase {} : Failed \n Error: {}".format(
765 tc_name, result
766 )
767
768 step("Verify Route-map created verify using show route-map")
769 # verify rmap_pf_list_1 and rmap_pf_list_2 are present in router r2
770 input_dict = {
771 "r2": {
772 "route_maps": [
773 "rmap_pf_list_1_{}".format(addr_type),
774 "rmap_pf_list_2_{}".format(addr_type),
775 ]
776 }
777 }
778 result = verify_route_maps(tgen, input_dict, expected=False)
779 assert result is not True, "Testcase {} : Failed \n Error: {}".format(
780 tc_name, result
781 )
782
783 step("Apply policy RouteMap_1 nbrs 1 2 3 4 to FRR 1")
784 # Configure prefix list to bgp neighbor
785 input_dict_4 = {
786 "r2": {
787 "bgp": {
788 "address_family": {
789 addr_type: {
790 "unicast": {
791 "neighbor": {
792 "r1": {
793 "dest_link": {
794 "r2-link0": {
795 "route_maps": [
796 {
797 "name": "rmap_pf_list_1_"
798 "{}".format(addr_type),
799 "direction": "out",
800 }
801 ]
802 },
803 "r2-link1": {
804 "route_maps": [
805 {
806 "name": "rmap_pf_list_1_"
807 "{}".format(addr_type),
808 "direction": "out",
809 }
810 ]
811 },
812 "r2-link2": {
813 "route_maps": [
814 {
815 "name": "rmap_pf_list_1_"
816 "{}".format(addr_type),
817 "direction": "out",
818 }
819 ]
820 },
821 "r2-link3": {
822 "route_maps": [
823 {
824 "name": "rmap_pf_list_1_"
825 "{}".format(addr_type),
826 "direction": "out",
827 }
828 ]
829 },
830 }
831 }
832 }
833 }
834 }
835 }
836 }
837 }
838 }
839 result = create_router_bgp(tgen, topo, input_dict_4)
840 assert result is True, "Testcase {} : Failed \n Error: {}".format(
841 tc_name, result
842 )
843
844 step("Apply policy RouteMap_2 nbrs 5 and 6 to FRR2")
845 # Configure prefix list to bgp neighbor
846 input_dict_4 = {
847 "r2": {
848 "bgp": {
849 "address_family": {
850 addr_type: {
851 "unicast": {
852 "neighbor": {
853 "r3": {
854 "dest_link": {
855 "r2-link0": {
856 "route_maps": [
857 {
858 "name": "rmap_pf_list_2_"
859 "{}".format(addr_type),
860 "direction": "out",
861 }
862 ]
863 },
864 "r2-link1": {
865 "route_maps": [
866 {
867 "name": "rmap_pf_list_2_"
868 "{}".format(addr_type),
869 "direction": "out",
870 }
871 ]
872 },
873 "r2-link2": {
874 "route_maps": [
875 {
876 "name": "rmap_pf_list_2_"
877 "{}".format(addr_type),
878 "direction": "out",
879 }
880 ]
881 },
882 "r2-link3": {
883 "route_maps": [
884 {
885 "name": "rmap_pf_list_2_"
886 "{}".format(addr_type),
887 "direction": "out",
888 }
889 ]
890 },
891 }
892 }
893 }
894 }
895 }
896 }
897 }
898 }
899 }
900 result = create_router_bgp(tgen, topo, input_dict_4)
901 assert result is True, "Testcase {} : Failed \n Error: {}".format(
902 tc_name, result
903 )
904
905 step(
906 "After applying to BGP neighbors verify VM1 IPv4 and IPv6 Route"
907 " which is denied using prefix list is not present on FRR side"
908 " routing table , also not able to ping the routes show ip route"
909 " and VM4 and VM6 IPV4 and IPv6 address are present in local and"
910 " FRR routing table show ip bgp show ip route"
911 )
912
913 dut = "r1"
914 protocol = "bgp"
915 ntwk_r2_vm1 = str(
916 ipaddress.ip_interface(
917 u"{}".format(topo["routers"]["r2"]["links"]["vm1"][addr_type])
918 ).network
919 )
920 input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}}
921 result4 = verify_rib(
922 tgen, addr_type, dut, input_dict, protocol=protocol, expected=False
923 )
924 assert (
925 result4 is not True
926 ), "Testcase {} : Failed \n" "routes are still present \n Error: {}".format(
927 tc_name, result4
928 )
929
930 step("vm4 should be present in FRR1")
931 dut = "r1"
932 ntwk_r2_vm1 = str(
933 ipaddress.ip_interface(
934 u"{}".format(topo["routers"]["r1"]["links"]["vm4"][addr_type])
935 ).network
936 )
937 input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}}
938 result4 = verify_rib(tgen, addr_type, dut, input_dict)
939 assert result4 is True, (
940 "Testcase {} : Failed , VM1 route is "
941 "not filtered out via prefix list. \n Error: {}".format(tc_name, result4)
942 )
943
944 step("vm4 should be present in FRR2")
945 dut = "r2"
946 ntwk_r2_vm1 = str(
947 ipaddress.ip_interface(
948 u"{}".format(topo["routers"]["r1"]["links"]["vm4"][addr_type])
949 ).network
950 )
951 input_dict = {"r1": {"static_routes": [{"network": ntwk_r2_vm1}]}}
952 result4 = verify_rib(tgen, addr_type, dut, input_dict)
953 assert result4 is True, (
954 "Testcase {} : Failed , VM1 route is "
955 "not filtered out via prefix list. \n Error: {}".format(tc_name, result4)
956 )
957
958 dut = "r3"
959 protocol = "bgp"
960 ntwk_r2_vm6 = str(
961 ipaddress.ip_interface(
962 u"{}".format(topo["routers"]["r2"]["links"]["vm6"][addr_type])
963 ).network
964 )
965 input_dict = {"r3": {"static_routes": [{"network": ntwk_r2_vm6}]}}
966 result4 = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol)
967 assert result4 is True, "Testcase {} : Failed.\n Error: {}".format(
968 tc_name, result4
969 )
970
971 write_test_footer(tc_name)
972
973
974 if __name__ == "__main__":
975 args = ["-s"] + sys.argv[1:]
976 sys.exit(pytest.main(args))