]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/ospf_basic_functionality/test_ospf_routemaps.py
2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2020 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
7 # ("NetDEF") in this file.
11 """OSPF Basic Functionality Automation."""
17 # Save the Current Working Directory to find configuration files.
18 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
19 sys
.path
.append(os
.path
.join(CWD
, "../"))
20 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
22 # pylint: disable=C0413
23 # Import topogen and topotest helpers
24 from lib
.topogen
import Topogen
, get_topogen
26 # Import topoJson from lib, to create topology and initial configuration
27 from lib
.common_config
import (
31 reset_config_on_routers
,
39 from lib
.topolog
import logger
40 from lib
.topojson
import build_config_from_json
41 from lib
.ospf
import (
48 pytestmark
= [pytest
.mark
.ospfd
, pytest
.mark
.staticd
]
63 routerids
= ["100.1.1.0", "100.1.1.1", "100.1.1.2", "100.1.1.3"]
67 Please view in a fixed-width font such as Courier.
69 +R1 +------------+R2 |
78 +R0 +-------------+R3 |
82 1. OSPF Route map - Verify OSPF route map support functionality.
83 2. Verify OSPF route map support functionality when route map is not
84 configured at system level but configured in OSPF
85 3. Verify OSPF route map support functionality with set/match clauses
86 /call/continue/goto in a route-map to see if it takes immediate effect.
87 4. Verify OSPF route map support functionality
88 when route map actions are toggled.
89 5. Verify OSPF route map support functionality with multiple sequence
90 numbers in a single route-map for different match/set clauses.
91 6. Verify OSPF route map support functionality when we add/remove route-maps
92 with multiple set clauses and without any match statement.(Set only)
93 7. Verify OSPF route map support functionality when we
94 add/remove route-maps with multiple match clauses and without
95 any set statement.(Match only)
99 def setup_module(mod
):
101 Sets up the pytest environment
105 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
106 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
107 logger
.info("=" * 40)
109 logger
.info("Running setup_module to create topology")
111 # This function initiates the topology build with Topogen...
112 json_file
= "{}/ospf_routemaps.json".format(CWD
)
113 tgen
= Topogen(json_file
, mod
.__name
__)
115 topo
= tgen
.json_topo
116 # ... and here it calls Mininet initialization functions.
118 # Starting topology, create tmp files which are loaded to routers
119 # to start daemons and then start routers
122 # Creating configuration from JSON
123 build_config_from_json(tgen
, topo
)
125 # Don't run this test if we have any failure.
126 if tgen
.routers_have_failure():
127 pytest
.skip(tgen
.errors
)
128 # Api call verify whether OSPF is converged
129 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
)
130 assert ospf_covergence
is True, "setup_module :Failed \n Error {}".format(
134 logger
.info("Running setup_module() done")
137 def teardown_module(mod
):
139 Teardown the pytest environment.
144 logger
.info("Running teardown_module to delete topology")
148 # Stop toplogy and Remove tmp files
152 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
154 logger
.info("=" * 40)
157 # ##################################
158 # Test cases start here.
159 # ##################################
162 def test_ospf_routemaps_functionality_tc19_p0(request
):
164 OSPF Route map - Verify OSPF route map support functionality.
167 tc_name
= request
.node
.name
168 write_test_header(tc_name
)
171 step("Bring up the base config as per the topology")
172 reset_config_on_routers(tgen
)
174 step("Create static routes(10.0.20.1/32 and 10.0.20.2/32) in R0")
175 # Create Static routes
180 "network": NETWORK
["ipv4"][0],
187 result
= create_static_routes(tgen
, input_dict
)
188 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
190 redistribute_ospf(tgen
, topo
, "r0", "static")
193 lsid
= NETWORK
["ipv4"][0].split("/")[0]
196 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
197 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
199 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
200 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
202 redistribute_ospf(tgen
, topo
, "r0", "static", delete
=True)
204 step("Create prefix-list in R0 to permit 10.0.20.1/32 prefix & deny 10.0.20.2/32")
206 # Create ip prefix list
214 "network": NETWORK
["ipv4"][0],
217 {"seqid": 11, "network": "any", "action": "deny"},
223 result
= create_prefix_lists(tgen
, pfx_list
)
224 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
233 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
239 result
= create_route_maps(tgen
, routemaps
)
240 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
243 "Configure route map rmap1 and redistribute static routes to"
244 " ospf using route map rmap1"
247 redistribute_ospf(tgen
, topo
, "r0", "static", route_map
="rmap_ipv4")
249 step("Change prefix rules to permit 10.0.20.2 and deny 10.0.20.1")
250 # Create ip prefix list
258 "network": NETWORK
["ipv4"][1],
261 {"seqid": 11, "network": "any", "action": "deny"},
267 result
= create_prefix_lists(tgen
, pfx_list
)
268 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
270 step("Verify that route 10.0.20.2 is allowed and 10.0.20.1 is denied.")
275 {"network": NETWORK
["ipv4"][1], "no_of_ip": 1, "next_hop": "Null0"}
279 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
280 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
282 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
283 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
288 {"network": NETWORK
["ipv4"][0], "no_of_ip": 1, "next_hop": "Null0"}
292 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
295 ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format(
300 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
304 ), "Testcase {} : Failed \n r1: routes are present in fib \n Error: {}".format(
308 step("Delete and reconfigure prefix list.")
309 # Create ip prefix list
317 "network": NETWORK
["ipv4"][1],
332 result
= create_prefix_lists(tgen
, pfx_list
)
333 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
335 result
= verify_prefix_lists(tgen
, pfx_list
)
336 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
341 {"network": NETWORK
["ipv4"][0], "no_of_ip": 5, "next_hop": "Null0"}
345 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
348 ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format(
353 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
357 ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format(
368 "network": NETWORK
["ipv4"][1],
371 {"seqid": 11, "network": "any", "action": "deny"},
377 result
= create_prefix_lists(tgen
, pfx_list
)
378 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
380 step("Verify that route 10.0.20.2 is allowed and 10.0.20.1 is denied.")
385 {"network": NETWORK
["ipv4"][1], "no_of_ip": 1, "next_hop": "Null0"}
389 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
390 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
392 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
393 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
398 {"network": NETWORK
["ipv4"][0], "no_of_ip": 1, "next_hop": "Null0"}
402 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
405 ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format(
410 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
414 ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format(
418 write_test_footer(tc_name
)
421 def test_ospf_routemaps_functionality_tc20_p0(request
):
423 OSPF route map support functionality.
425 Verify OSPF route map support functionality when route map is not
426 configured at system level but configured in OSPF
429 tc_name
= request
.node
.name
430 write_test_header(tc_name
)
433 step("Bring up the base config as per the topology")
434 reset_config_on_routers(tgen
)
436 step("Create static routes(10.0.20.1/32 and 10.0.20.2/32) in R0")
437 # Create Static routes
442 "network": NETWORK
["ipv4"][0],
449 result
= create_static_routes(tgen
, input_dict
)
450 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
452 step("Redistribute to ospf using route map ( non existent route map)")
453 redistribute_ospf(tgen
, topo
, "r0", "static", route_map
="rmap_ipv4")
456 "Verify that routes are not allowed in OSPF even tough no "
457 "matching routing map is configured."
462 result
= verify_ospf_rib(tgen
, dut
, input_dict
, retry_timeout
=4, expected
=False)
465 ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format(
480 ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format(
485 "configure the route map with the same name that is used "
486 "in the ospf with deny rule."
490 routemaps
= {"r0": {"route_maps": {"rmap_ipv4": [{"action": "deny"}]}}}
491 result
= create_route_maps(tgen
, routemaps
)
492 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
494 step("verify that now route map is activated & routes are denied in OSPF.")
497 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
500 ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format(
505 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
509 ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format(
514 routemaps
= {"r0": {"route_maps": {"rmap_ipv4": [{"action": "deny"}]}}}
515 result
= create_route_maps(tgen
, routemaps
)
516 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
518 step("verify that now route map is activated & routes are denied in OSPF.")
521 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
524 ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format(
529 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
533 ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format(
537 step("Delete the route map.")
540 "r0": {"route_maps": {"rmap_ipv4": [{"action": "deny", "delete": True}]}}
542 result
= create_route_maps(tgen
, routemaps
)
543 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
546 "Verify that routes are allowed in OSPF even tough "
547 "no matching routing map is configured."
551 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
554 ), "Testcase {} : Failed \n r1: OSPF routes are present \n Error: {}".format(
559 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
563 ), "Testcase {} : Failed \n r1: routes are still present \n Error: {}".format(
567 write_test_footer(tc_name
)
570 def test_ospf_routemaps_functionality_tc21_p0(request
):
572 OSPF route map support functionality.
574 Verify OSPF route map support functionality with set/match clauses
575 /call/continue/goto in a route-map to see if it takes immediate effect.
578 tc_name
= request
.node
.name
579 write_test_header(tc_name
)
582 step("Bring up the base config as per the topology")
583 reset_config_on_routers(tgen
)
586 "Create static routes(10.0.20.1/32) in R1 and redistribute "
587 "to OSPF using route map."
590 # Create Static routes
595 "network": NETWORK
["ipv4"][0],
602 result
= create_static_routes(tgen
, input_dict
)
603 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
605 redistribute_ospf(tgen
, topo
, "r0", "static", route_map
="rmap_ipv4")
609 "r0": {"route_maps": {"rmap_ipv4": [{"action": "permit", "seq_id": 10}]}}
611 result
= create_route_maps(tgen
, routemaps
)
612 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
614 step("Verify that route is advertised to R2.")
617 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
618 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
620 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
621 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
626 "rmap_ipv4": [{"action": "permit", "delete": True, "seq_id": 10}]
630 result
= create_route_maps(tgen
, routemaps
)
631 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
633 step(" Configure route map with set clause (set metric)")
638 "rmap_ipv4": [{"action": "permit", "set": {"med": 123}, "seq_id": 10}]
642 result
= create_route_maps(tgen
, routemaps
)
643 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
645 step("Verify that configured metric is applied to ospf routes.")
649 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
650 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
653 "Configure route map with match clause (match metric) with "
654 "some actions(change metric)."
663 "match": {"med": 123},
671 result
= create_route_maps(tgen
, routemaps
)
672 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
674 step("Configure route map with call clause")
676 # Create ip prefix list
682 {"seqid": 10, "network": "any", "action": "permit"}
688 result
= create_prefix_lists(tgen
, input_dict_2
)
689 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
698 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
700 "call": "rmap_match_pf_2_ipv4",
704 "rmap_match_pf_2_ipv4": [
707 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
715 result
= create_route_maps(tgen
, input_dict_3
)
716 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
718 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
719 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
721 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
722 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
725 routemaps
= {"r0": {"route_maps": {"rmap_ipv4": [{"delete": True}]}}}
726 result
= create_route_maps(tgen
, routemaps
)
727 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
729 step("Configure route map with continue clause")
739 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
746 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
752 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
760 result
= create_route_maps(tgen
, input_dict_3
)
761 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
763 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
764 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
766 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
767 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
769 step("Configure route map with goto clause")
778 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
784 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
790 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
797 result
= create_route_maps(tgen
, input_dict_3
)
798 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
800 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
801 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
803 write_test_footer(tc_name
)
806 def test_ospf_routemaps_functionality_tc24_p0(request
):
808 OSPF Route map - Multiple set clauses.
810 Verify OSPF route map support functionality when we
811 add/remove route-maps with multiple match clauses and without
812 any set statement.(Match only)
815 tc_name
= request
.node
.name
816 write_test_header(tc_name
)
819 step("Bring up the base config as per the topology")
820 reset_config_on_routers(tgen
)
823 "Create static routes(10.0.20.1/32) in R1 and redistribute to "
824 "OSPF using route map."
826 # Create Static routes
831 "network": NETWORK
["ipv4"][0],
838 result
= create_static_routes(tgen
, input_dict
)
839 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
841 redistribute_ospf(tgen
, topo
, "r0", "static", route_map
="rmap_ipv4")
843 # Create ip prefix list
849 {"seqid": 10, "network": "any", "action": "permit"}
855 result
= create_prefix_lists(tgen
, pfx_list
)
856 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
858 step("verify that prefix-list is created in R0.")
859 result
= verify_prefix_lists(tgen
, pfx_list
)
862 ), "Testcase {} : Failed \n Prefix list not present. Error: {}".format(
873 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
879 result
= create_route_maps(tgen
, routemaps
)
880 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
882 step("Verify that metric falls back to original metric for ospf routes.")
886 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
887 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
889 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
890 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
893 "Create static routes(10.0.20.1/32) in R1 and redistribute to "
894 "OSPF using route map."
896 # Create Static routes
901 "network": NETWORK
["ipv4"][1],
909 result
= create_static_routes(tgen
, input_dict
)
910 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
912 # Create ip prefix list
918 {"seqid": 10, "network": "any", "action": "permit"}
924 result
= create_prefix_lists(tgen
, pfx_list
)
925 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
927 step("verify that prefix-list is created in R0.")
928 result
= verify_prefix_lists(tgen
, pfx_list
)
931 ), "Testcase {} : Failed \n Prefix list not present. Error: {}".format(
939 "rmap_ipv4": [{"action": "permit", "match": {"ipv4": {"tag": "1000"}}}]
943 result
= create_route_maps(tgen
, routemaps
)
944 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
946 step("Verify that metric falls back to original metric for ospf routes.")
950 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
951 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
953 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
954 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
956 step("Delete the match clause with tag in route map")
964 "match": {"ipv4": {"tag": "1000", "delete": True}},
970 result
= create_route_maps(tgen
, routemaps
)
971 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
973 step("Verify that metric falls back to original metric for ospf routes.")
977 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
978 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
980 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
981 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
983 step("Delete the match clause with metric in route map.")
992 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
998 result
= create_route_maps(tgen
, routemaps
)
999 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1001 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
1002 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1004 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
1005 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1007 write_test_footer(tc_name
)
1010 def test_ospf_routemaps_functionality_tc25_p0(request
):
1012 OSPF route map support functionality.
1014 Verify OSPF route map support functionality
1015 when route map actions are toggled.
1018 tc_name
= request
.node
.name
1019 write_test_header(tc_name
)
1020 tgen
= get_topogen()
1022 step("Bring up the base config as per the topology")
1024 reset_config_on_routers(tgen
)
1027 "Create static routes(10.0.20.1/32) in R1 and redistribute "
1028 "to OSPF using route map."
1031 # Create Static routes
1036 "network": NETWORK
["ipv4"][0],
1038 "next_hop": "Null0",
1043 result
= create_static_routes(tgen
, input_dict
)
1044 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1049 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv4"}]
1053 result
= create_router_ospf(tgen
, topo
, ospf_red_r0
)
1054 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1055 step("Configure route map with permit rule")
1057 routemaps
= {"r0": {"route_maps": {"rmap_ipv4": [{"action": "permit"}]}}}
1058 result
= create_route_maps(tgen
, routemaps
)
1059 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1061 step("Verify that route is advertised to R1.")
1064 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
1065 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1067 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
1068 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1069 step("Configure route map with deny rule")
1072 "r0": {"route_maps": {"rmap_ipv4": [{"seq_id": 10, "action": "deny"}]}}
1074 result
= create_route_maps(tgen
, routemaps
)
1075 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1077 # Api call verify whether OSPF is converged
1078 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
)
1079 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
1083 step("Verify that route is not advertised to R1.")
1086 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
1087 assert result
is not True, "Testcase {} : Failed \n Error: {}".format(
1091 result
= verify_rib(
1092 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
1094 assert result
is not True, "Testcase {} : Failed \n Error: {}".format(
1098 write_test_footer(tc_name
)
1101 def test_ospf_routemaps_functionality_tc22_p0(request
):
1103 OSPF Route map - Multiple sequence numbers.
1105 Verify OSPF route map support functionality with multiple sequence
1106 numbers in a single route-map for different match/set clauses.
1109 tc_name
= request
.node
.name
1110 write_test_header(tc_name
)
1111 tgen
= get_topogen()
1113 step("Bring up the base config as per the topology")
1115 reset_config_on_routers(tgen
)
1118 "Configure route map with seq number 10 to with ip prefix"
1119 " permitting route 10.0.20.1/32 in R1"
1122 "Configure route map with seq number 20 to with ip prefix"
1123 " permitting route 10.0.20.2/32 in R1"
1134 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
1139 "match": {"ipv4": {"prefix_lists": "pf_list_2_ipv4"}},
1145 result
= create_route_maps(tgen
, input_dict_3
)
1146 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1148 # Create ip prefix list
1154 {"seqid": 10, "network": NETWORK
["ipv4"][0], "action": "permit"}
1160 result
= create_prefix_lists(tgen
, input_dict_2
)
1161 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1163 # Create ip prefix list
1169 {"seqid": 10, "network": NETWORK
["ipv4"][1], "action": "permit"}
1175 result
= create_prefix_lists(tgen
, input_dict_2
)
1176 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1178 step("Configure static routes 10.0.20.1/32 and 10.0.20.2 in R1")
1179 # Create Static routes
1184 "network": NETWORK
["ipv4"][0],
1186 "next_hop": "Null0",
1191 result
= create_static_routes(tgen
, input_dict
)
1192 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1194 step("Configure redistribute static route with route map.")
1198 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv4"}]
1202 result
= create_router_ospf(tgen
, topo
, ospf_red_r0
)
1203 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1209 "network": NETWORK
["ipv4"][0],
1211 "next_hop": "Null0",
1216 result
= create_static_routes(tgen
, input_dict
)
1217 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1219 step("Verify that both routes are learned in R1 and R2")
1222 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
1223 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1225 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
1226 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1230 result
= verify_ospf_rib(tgen
, dut
, input_dict
)
1231 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1233 result
= verify_rib(tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
)
1234 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1236 step("Change route map with seq number 20 to deny.")
1245 "match": {"ipv4": {"prefix_lists": "pf_list_2_ipv4"}},
1251 result
= create_route_maps(tgen
, input_dict_3
)
1252 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1255 "Verify the route 10.0.20.2/32 is withdrawn and not present "
1256 "in the routing table of R0 and R1."
1260 "r0": {"static_routes": [{"network": NETWORK
["ipv4"][1], "next_hop": "Null0"}]}
1265 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
1266 assert result
is not True, "Testcase {} : Failed \n Error: {}".format(
1270 result
= verify_rib(
1271 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
1273 assert result
is not True, "Testcase {} : Failed \n Error: {}".format(
1279 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
1280 assert result
is not True, "Testcase {} : Failed \n Error: {}".format(
1284 result
= verify_rib(
1285 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
1287 assert result
is not True, "Testcase {} : Failed \n Error: {}".format(
1291 write_test_footer(tc_name
)
1294 if __name__
== "__main__":
1295 args
= ["-s"] + sys
.argv
[1:]
1296 sys
.exit(pytest
.main(args
))