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 Summarisation 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 from time
import sleep
28 # Import topoJson from lib, to create topology and initial configuration
29 from lib
.common_config
import (
34 reset_config_on_routers
,
42 shutdown_bringup_interface
,
45 create_interfaces_cfg
,
47 from lib
.topolog
import logger
48 from lib
.topojson
import build_config_from_json
49 from lib
.ospf
import (
57 pytestmark
= [pytest
.mark
.ospfd
, pytest
.mark
.staticd
]
72 NETWORK_11
= {"ipv4": ["11.0.20.6/32", "11.0.20.7/32"]}
83 SUMMARY
= {"ipv4": ["11.0.0.0/8", "12.0.0.0/8", "11.0.0.0/24"]}
86 Please view in a fixed-width font such as Courier.
88 +R1 +------------+R2 |
97 +R0 +-------------+R3 |
101 1. OSPF summarisation functionality.
102 2. OSPF summarisation with metric type 2.
103 3. OSPF summarisation with Tag option
104 4. OSPF summarisation with advertise and no advertise option
105 5. OSPF summarisation Chaos.
106 6. OSPF summarisation with route map filtering.
107 7. OSPF summarisation with route map modification of metric type.
108 8. OSPF CLI Show verify ospf ASBR summary config and show commands behaviours.
112 def setup_module(mod
):
114 Sets up the pytest environment
118 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
119 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
120 logger
.info("=" * 40)
122 logger
.info("Running setup_module to create topology")
124 # This function initiates the topology build with Topogen...
125 json_file
= "{}/ospf_asbr_summary_topo1.json".format(CWD
)
126 tgen
= Topogen(json_file
, mod
.__name
__)
128 topo
= tgen
.json_topo
129 # ... and here it calls Mininet initialization functions.
131 # Starting topology, create tmp files which are loaded to routers
132 # to start daemons and then start routers
135 # Creating configuration from JSON
136 build_config_from_json(tgen
, topo
)
138 # Don't run this test if we have any failure.
139 if tgen
.routers_have_failure():
140 pytest
.skip(tgen
.errors
)
141 # Api call verify whether OSPF is converged
142 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
)
143 assert ospf_covergence
is True, "setup_module :Failed \n Error:" " {}".format(
147 logger
.info("Running setup_module() done")
150 def teardown_module(mod
):
152 Teardown the pytest environment.
157 logger
.info("Running teardown_module to delete topology")
161 # Stop toplogy and Remove tmp files
165 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
167 logger
.info("=" * 40)
170 def red_static(dut
, config
=True):
172 Local 'def' for Redstribute static routes inside ospf.
176 * `dut` : DUT on which configs have to be made.
177 * `config` : True or False, True by default for configure, set False for
183 ospf_red
= {dut
: {"ospf": {"redistribute": [{"redist_type": "static"}]}}}
186 dut
: {"ospf": {"redistribute": [{"redist_type": "static", "delete": True}]}}
188 result
= create_router_ospf(tgen
, topo
, ospf_red
)
189 assert result
is True, "Testcase : Failed \n Error: {}".format(result
)
192 def red_connected(dut
, config
=True):
194 Local 'def' for Redstribute connected routes inside ospf
198 * `dut` : DUT on which configs have to be made.
199 * `config` : True or False, True by default for configure, set False for
205 ospf_red
= {dut
: {"ospf": {"redistribute": [{"redist_type": "connected"}]}}}
209 "ospf": {"redistribute": [{"redist_type": "connected", "delete": True}]}
212 result
= create_router_ospf(tgen
, topo
, ospf_red
)
213 assert result
is True, "Testcase: Failed \n Error: {}".format(result
)
216 # ##################################
217 # Test cases start here.
218 # ##################################
221 def test_ospf_type5_summary_tc43_p0(request
):
222 """OSPF summarisation with metric type 2."""
223 tc_name
= request
.node
.name
224 write_test_header(tc_name
)
227 # Don't run this test if we have any failure.
228 if tgen
.routers_have_failure():
229 pytest
.skip(tgen
.errors
)
232 step("Bring up the base config as per the topology")
233 reset_config_on_routers(tgen
)
238 "Configure 5 static routes from the same network on R0"
239 "5 static routes from different networks and redistribute in R0"
241 input_dict_static_rtes
= {
244 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
245 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
249 result
= create_static_routes(tgen
, input_dict_static_rtes
)
250 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
255 step("Verify that routes are learnt on R1.")
258 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
259 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
260 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
263 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
266 "Configure External Route summary in R0 to summarise 5" " routes to one route."
272 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
277 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
278 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
280 "Verify that external routes are summarised to configured summary "
281 "address on R0 after 5 secs of delay timer expiry and only one "
282 "route is sent to R1."
284 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
287 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
288 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
290 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
293 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
295 step("Verify that show ip ospf summary should show the summaries.")
297 SUMMARY
["ipv4"][0]: {
298 "summaryAddress": SUMMARY
["ipv4"][0],
302 "externalRouteCount": 5,
306 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
309 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
311 step("Change the summary address mask to lower match (ex - 16 to 8)")
316 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "16"}
321 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
322 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
326 "summaryAddress": "11.0.0.0/16",
330 "externalRouteCount": 5,
334 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
337 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
340 "Verify that external routes(static / connected) are summarised"
341 " to configured summary address with newly configured mask."
344 input_dict_summary
= {"r0": {"static_routes": [{"network": "11.0.0.0/16"}]}}
347 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
348 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
350 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
353 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
355 step("Change the summary address mask to higher match (ex - 8 to 24)")
360 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "24"}
365 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
366 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
370 "summaryAddress": "11.0.0.0/24",
374 "externalRouteCount": 0,
378 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
381 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
384 "Verify that external routes(static / connected) are summarised"
385 " to configured summary address with newly configured mask."
387 step("Configure 2 summary address with different mask of same network.")
389 "Verify that external routes(static / connected) are summarised "
390 "to configured summary address with highest match."
393 input_dict_summary
= {"r0": {"static_routes": [{"network": "11.0.0.0/16"}]}}
396 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
397 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
399 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
402 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
404 step(" Un configure one of the summary address.")
410 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
418 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
419 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
422 "Verify that external routes(static / connected) are summarised"
423 " to configured summary address with newly configured mask."
426 input_dict_summary
= {"r0": {"static_routes": [{"network": "11.0.0.0/16"}]}}
429 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
430 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
432 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
435 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
441 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "24"}
446 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
447 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
450 "Verify that external routes(static / connected) are summarised "
451 "to configured summary address with highest match."
453 input_dict_summary
= {"r0": {"static_routes": [{"network": "11.0.0.0/16"}]}}
456 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
457 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
459 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
462 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
464 write_test_footer(tc_name
)
467 def test_ospf_type5_summary_tc48_p0(request
):
468 """OSPF summarisation with route map modification of metric type."""
469 tc_name
= request
.node
.name
470 write_test_header(tc_name
)
473 # Don't run this test if we have any failure.
474 if tgen
.routers_have_failure():
475 pytest
.skip(tgen
.errors
)
478 step("Bring up the base config as per the topology")
479 reset_config_on_routers(tgen
)
484 "Configure 5 static routes from the same network on R0"
485 "5 static routes from different networks and redistribute in R0"
487 input_dict_static_rtes
= {
490 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
491 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
495 result
= create_static_routes(tgen
, input_dict_static_rtes
)
496 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
501 step("Verify that routes are learnt on R1.")
504 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
505 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
506 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
509 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
512 "Configure External Route summary in R0 to summarise 5" " routes to one route."
519 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
524 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
525 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
528 "Verify that external routes are summarised to configured summary "
529 "address on R0 after 5 secs of delay timer expiry and only one "
530 "route is sent to R1."
532 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
535 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
536 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
538 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
541 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
543 step("Verify that show ip ospf summary should show the summaries.")
545 SUMMARY
["ipv4"][0]: {
546 "summaryAddress": SUMMARY
["ipv4"][0],
550 "externalRouteCount": 5,
554 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
557 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
559 step("Verify that originally advertised routes are withdraw from there" " peer.")
561 "r0": {"static_routes": [{"network": NETWORK
["ipv4"], "next_hop": "blackhole"}]}
564 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
567 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
572 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
576 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
579 "Configure route map and & rule to permit configured summary address,"
580 " redistribute static & connected routes with the route map."
582 step("Configure prefixlist to permit the static routes, add to route map.")
583 # Create ip prefix list
589 {"seqid": 10, "network": "any", "action": "permit"}
595 result
= create_prefix_lists(tgen
, pfx_list
)
596 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
604 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
610 result
= create_route_maps(tgen
, routemaps
)
611 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
616 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv4"}]
620 result
= create_router_ospf(tgen
, topo
, ospf_red_r1
)
621 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
624 "Verify that external routes are summarised to configured"
625 "summary address on R0 and only one route is sent to R1. Verify that "
626 "show ip ospf summary should show the configure summaries."
629 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
632 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
633 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
635 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
638 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
641 SUMMARY
["ipv4"][0]: {
642 "summaryAddress": SUMMARY
["ipv4"][0],
646 "externalRouteCount": 5,
650 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
653 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
655 write_test_footer(tc_name
)
658 def test_ospf_type5_summary_tc42_p0(request
):
659 """OSPF summarisation functionality."""
660 tc_name
= request
.node
.name
661 write_test_header(tc_name
)
664 # Don't run this test if we have any failure.
665 if tgen
.routers_have_failure():
666 pytest
.skip(tgen
.errors
)
669 step("Bring up the base config as per the topology")
670 reset_config_on_routers(tgen
)
675 "Configure 5 static routes from the same network on R0"
676 "5 static routes from different networks and redistribute in R0"
678 input_dict_static_rtes
= {
681 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
682 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
686 result
= create_static_routes(tgen
, input_dict_static_rtes
)
687 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
692 step("Verify that routes are learnt on R1.")
695 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
696 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
697 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
700 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
703 "Configure External Route summary in R0 to summarise 5"
704 " routes to one route. with aggregate timer as 6 sec"
711 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
717 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
718 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
721 "Verify that external routes are summarised to configured summary "
722 "address on R0 after 5 secs of delay timer expiry and only one "
723 "route is sent to R1."
725 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
728 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
729 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
731 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
734 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
736 step("Verify that show ip ospf summary should show the summaries.")
738 SUMMARY
["ipv4"][0]: {
739 "summaryAddress": SUMMARY
["ipv4"][0],
743 "externalRouteCount": 5,
747 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
750 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
752 step("Verify that originally advertised routes are withdraw from there" " peer.")
754 "r0": {"static_routes": [{"network": NETWORK
["ipv4"], "next_hop": "blackhole"}]}
757 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
760 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
765 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
769 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
771 step("Delete the configured summary")
777 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
779 "del_aggr_timer": True,
786 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
787 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
789 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
791 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
794 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
799 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
803 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
807 step("show ip ospf summary should not have any summary address.")
809 SUMMARY
["ipv4"][0]: {
810 "summaryAddress": SUMMARY
["ipv4"][0],
814 "externalRouteCount": 5,
818 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, expected
=False)
821 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
824 step("All 5 routes are advertised after deletion of configured summary.")
826 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
827 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
829 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
832 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
834 step("configure the summary again and delete static routes .")
839 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
844 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
845 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
848 SUMMARY
["ipv4"][0]: {
849 "summaryAddress": SUMMARY
["ipv4"][0],
853 "externalRouteCount": 5,
857 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
860 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
865 {"network": NETWORK
["ipv4"], "next_hop": "blackhole", "delete": True}
869 result
= create_static_routes(tgen
, input_dict
)
870 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
872 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
873 step("Verify that summary route is withdrawn from R1.")
876 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, expected
=False)
879 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
884 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
888 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
890 step("Add back static routes.")
891 input_dict_static_rtes
= {
892 "r0": {"static_routes": [{"network": NETWORK
["ipv4"], "next_hop": "blackhole"}]}
894 result
= create_static_routes(tgen
, input_dict_static_rtes
)
895 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
898 "Verify that external routes are summarised to configured summary"
899 " address on R0 and only one route is sent to R1."
903 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
, expected
=False)
906 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
911 tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
, expected
=False
915 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
917 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
920 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
921 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
923 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
926 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
928 step("Verify that show ip ospf summary should show configure summaries.")
931 SUMMARY
["ipv4"][0]: {
932 "summaryAddress": SUMMARY
["ipv4"][0],
936 "externalRouteCount": 5,
940 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
943 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
945 step("Configure new static route which is matching configured summary.")
946 input_dict_static_rtes
= {
948 "static_routes": [{"network": NETWORK_11
["ipv4"], "next_hop": "blackhole"}]
951 result
= create_static_routes(tgen
, input_dict_static_rtes
)
952 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
954 # step("verify that summary lsa is not refreshed.")
955 # show ip ospf database command is not working, waiting for DEV fix.
957 step("Delete one of the static route.")
958 input_dict_static_rtes
= {
961 {"network": NETWORK_11
["ipv4"], "next_hop": "blackhole", "delete": True}
965 result
= create_static_routes(tgen
, input_dict_static_rtes
)
966 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
968 # step("verify that summary lsa is not refreshed.")
969 # show ip ospf database command is not working, waiting for DEV fix.
971 # step("Verify that deleted static route is removed from ospf LSDB.")
972 # show ip ospf database command is not working, waiting for DEV fix.
975 "Configure redistribute connected and configure ospf external"
976 " summary address to summarise the connected routes."
981 clear_ospf(tgen
, dut
)
983 ip
= topo
["routers"]["r0"]["links"]["r3"]["ipv4"]
985 ip_net
= str(ipaddress
.ip_interface(u
"{}".format(ip
)).network
)
988 "ospf": {"summary-address": [{"prefix": ip_net
.split("/")[0], "mask": "8"}]}
991 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
992 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
995 "Verify that external routes are summarised to configured "
996 "summary address on R0 and only one route is sent to R1."
999 input_dict_summary
= {"r0": {"static_routes": [{"network": "10.0.0.0/8"}]}}
1001 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
1002 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1004 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
1007 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1009 step("Shut one of the interface")
1010 intf
= topo
["routers"]["r0"]["links"]["r3-link0"]["interface"]
1011 shutdown_bringup_interface(tgen
, dut
, intf
, False)
1013 # step("verify that summary lsa is not refreshed.")
1014 # show ip ospf database command is not working, waiting for DEV fix.
1016 # step("Verify that deleted connected route is removed from ospf LSDB.")
1017 # show ip ospf database command is not working, waiting for DEV fix.
1019 step("Un do shut the interface")
1020 shutdown_bringup_interface(tgen
, dut
, intf
, True)
1022 # step("verify that summary lsa is not refreshed.")
1023 # show ip ospf database command is not working, waiting for DEV fix.
1025 # step("Verify that deleted connected route is removed from ospf LSDB.")
1026 # show ip ospf database command is not working, waiting for DEV fix.
1028 step("Delete OSPF process.")
1029 ospf_del
= {"r0": {"ospf": {"delete": True}}}
1030 result
= create_router_ospf(tgen
, topo
, ospf_del
)
1031 assert result
is True, "Testcase : Failed \n Error: {}".format(result
)
1033 step("Reconfigure ospf process with summary")
1034 reset_config_on_routers(tgen
)
1036 input_dict_static_rtes
= {
1039 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
1040 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
1044 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1045 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1053 "summary-address": [
1054 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
1059 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1060 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1062 "Verify that external routes are summarised to configured summary "
1063 "address on R0 and only one route is sent to R1."
1067 SUMMARY
["ipv4"][0]: {
1068 "summaryAddress": SUMMARY
["ipv4"][0],
1072 "externalRouteCount": 5,
1076 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
1079 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1081 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
1084 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
1085 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1087 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
1090 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1095 "summary-address": [
1096 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
1101 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1102 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1104 # step("verify that summary lsa is not refreshed.")
1105 # show ip ospf database command is not working, waiting for DEV fix.
1107 step("Delete the redistribute command in ospf.")
1109 red_connected(dut
, config
=False)
1110 red_static(dut
, config
=False)
1112 step("Verify that summary route is withdrawn from the peer.")
1115 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1118 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1122 result
= verify_rib(
1123 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1127 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1132 "summary-address": [
1134 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
1142 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1143 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1145 write_test_footer(tc_name
)
1148 def test_ospf_type5_summary_tc45_p0(request
):
1149 """OSPF summarisation with Tag option"""
1150 tc_name
= request
.node
.name
1151 write_test_header(tc_name
)
1152 tgen
= get_topogen()
1154 # Don't run this test if we have any failure.
1155 if tgen
.routers_have_failure():
1156 pytest
.skip(tgen
.errors
)
1159 step("Bring up the base config as per the topology")
1160 step("Configure OSPF on all the routers of the topology.")
1161 reset_config_on_routers(tgen
)
1166 "Configure 5 static routes from the same network on R0"
1167 "5 static routes from different networks and redistribute in R0"
1169 input_dict_static_rtes
= {
1172 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
1173 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
1177 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1178 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1183 step("Verify that routes are learnt on R1.")
1186 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
1187 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1188 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
1191 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1194 "Configure External Route summary in R0 to summarise 5" " routes to one route."
1199 "summary-address": [
1201 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
1209 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1210 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1213 "Verify that external routes are summarised to configured summary"
1214 " address on R0 and only one route is sent to R1 with configured tag."
1216 input_dict_summary
= {
1217 "r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0], "tag": "1234"}]}
1221 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
1222 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1224 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
1227 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1229 step("Verify that show ip ospf summary should show the summaries with tag.")
1231 SUMMARY
["ipv4"][0]: {
1232 "summaryAddress": SUMMARY
["ipv4"][0],
1236 "externalRouteCount": 5,
1240 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
1243 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1245 step("Delete the configured summary")
1249 "summary-address": [
1251 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
1260 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1261 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1263 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1265 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1268 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1272 result
= verify_rib(
1273 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1277 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
1281 step("show ip ospf summary should not have any summary address.")
1283 SUMMARY
["ipv4"][0]: {
1284 "summaryAddress": SUMMARY
["ipv4"][0],
1288 "externalRouteCount": 5,
1292 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, expected
=False)
1295 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
1297 step("Configure Min tag value")
1301 "summary-address": [
1302 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8", "tag": 1}
1307 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1308 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1309 input_dict_summary
= {
1310 "r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0], "tag": "1"}]}
1314 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
1315 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1317 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
1320 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1322 step("Verify that show ip ospf summary should show the summaries with tag.")
1324 SUMMARY
["ipv4"][0]: {
1325 "summaryAddress": SUMMARY
["ipv4"][0],
1329 "externalRouteCount": 5,
1333 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
1336 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1338 step("Configure Max Tag Value")
1342 "summary-address": [
1344 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
1352 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1353 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1355 input_dict_summary
= {
1356 "r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0], "tag": "4294967295"}]}
1360 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
1361 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1363 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
1366 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1369 "Verify that boundary values tags are used for summary route"
1370 " using show ip ospf route command."
1373 SUMMARY
["ipv4"][0]: {
1374 "summaryAddress": SUMMARY
["ipv4"][0],
1378 "externalRouteCount": 5,
1382 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
1385 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1387 step("configure new static route with different tag.")
1388 input_dict_static_rtes_11
= {
1391 {"network": NETWORK_11
["ipv4"], "next_hop": "blackhole", "tag": "88888"}
1395 result
= create_static_routes(tgen
, input_dict_static_rtes_11
)
1396 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1398 step("New tag has not been used by summary address.")
1400 input_dict_summary
= {
1401 "r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0], "tag": "88888"}]}
1405 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, tag
="88888", expected
=False)
1408 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1412 result
= verify_rib(
1423 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1426 "Verify that boundary values tags are used for summary route"
1427 " using show ip ospf route command."
1430 SUMMARY
["ipv4"][0]: {
1431 "summaryAddress": SUMMARY
["ipv4"][0],
1435 "externalRouteCount": 5,
1439 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, expected
=False)
1442 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1444 step("Delete the configured summary address")
1448 "summary-address": [
1450 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
1459 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1460 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1463 "Verify that 6 routes are advertised to neighbour with 5 routes"
1464 " without any tag, 1 route with tag."
1468 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
1469 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1470 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
1473 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1475 step("Verify that summary address is flushed from neighbor.")
1478 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1481 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1485 result
= verify_rib(
1486 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1490 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1492 step("Configure summary first & then configure matching static route.")
1494 input_dict_static_rtes
= {
1497 {"network": NETWORK
["ipv4"], "next_hop": "blackhole", "delete": True},
1498 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole", "delete": True},
1502 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1503 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1508 "summary-address": [
1509 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
1514 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1515 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1517 input_dict_static_rtes
= {
1520 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
1521 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
1525 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1526 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1528 step("Repeat steps 1 to 10 of summarisation in non Back bone area.")
1529 reset_config_on_routers(tgen
)
1531 step("Change the area id on the interface on R0")
1536 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
1537 "ospf": {"area": "0.0.0.0"},
1544 result
= create_interfaces_cfg(tgen
, input_dict
)
1545 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1551 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
1552 "ospf": {"area": "0.0.0.1"},
1558 result
= create_interfaces_cfg(tgen
, input_dict
)
1559 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1561 step("Change the area id on the interface ")
1566 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
1567 "ospf": {"area": "0.0.0.0"},
1574 result
= create_interfaces_cfg(tgen
, input_dict
)
1575 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1581 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
1582 "ospf": {"area": "0.0.0.1"},
1588 result
= create_interfaces_cfg(tgen
, input_dict
)
1589 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1591 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
)
1592 assert ospf_covergence
is True, "setup_module :Failed \n Error:" " {}".format(
1597 "Configure 5 static routes from the same network on R0"
1598 "5 static routes from different networks and redistribute in R0"
1600 input_dict_static_rtes
= {
1603 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
1604 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
1608 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1609 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1614 step("Verify that routes are learnt on R1.")
1617 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
1618 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1619 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
1622 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1625 "Configure External Route summary in R0 to summarise 5" " routes to one route."
1630 "summary-address": [
1632 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
1640 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1641 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1644 "Verify that external routes are summarised to configured summary"
1645 " address on R0 and only one route is sent to R1 with configured tag."
1647 input_dict_summary
= {
1648 "r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0], "tag": "1234"}]}
1652 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
1653 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1655 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
1658 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1660 step("Verify that show ip ospf summary should show the summaries with tag.")
1662 SUMMARY
["ipv4"][0]: {
1663 "summaryAddress": SUMMARY
["ipv4"][0],
1667 "externalRouteCount": 5,
1671 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
1672 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1674 step("Delete the configured summary")
1678 "summary-address": [
1680 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
1688 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1689 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1691 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1693 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
1696 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1700 result
= verify_rib(
1701 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1705 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
1709 step("show ip ospf summary should not have any summary address.")
1711 SUMMARY
["ipv4"][0]: {
1712 "summaryAddress": SUMMARY
["ipv4"][0],
1716 "externalRouteCount": 5,
1720 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, expected
=False)
1723 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
1725 step("Configure Min tag value")
1729 "summary-address": [
1730 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8", "tag": 1}
1735 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1736 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1737 input_dict_summary
= {
1738 "r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0], "tag": "1"}]}
1742 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
1743 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1745 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
1748 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1750 step("Verify that show ip ospf summary should show the summaries with tag.")
1752 SUMMARY
["ipv4"][0]: {
1753 "summaryAddress": SUMMARY
["ipv4"][0],
1757 "externalRouteCount": 5,
1761 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
1764 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1766 step("Configure Max Tag Value")
1770 "summary-address": [
1772 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
1780 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1781 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1783 input_dict_summary
= {
1784 "r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0], "tag": "4294967295"}]}
1788 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
1789 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1791 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
1794 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1797 "Verify that boundary values tags are used for summary route"
1798 " using show ip ospf route command."
1801 SUMMARY
["ipv4"][0]: {
1802 "summaryAddress": SUMMARY
["ipv4"][0],
1806 "externalRouteCount": 5,
1810 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
1813 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1815 step("configure new static route with different tag.")
1816 input_dict_static_rtes_11
= {
1819 {"network": NETWORK_11
["ipv4"], "next_hop": "blackhole", "tag": "88888"}
1823 result
= create_static_routes(tgen
, input_dict_static_rtes_11
)
1824 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1826 step("New tag has not been used by summary address.")
1828 input_dict_summary
= {
1829 "r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0], "tag": "88888"}]}
1833 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, tag
="88888", expected
=False)
1836 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1840 result
= verify_rib(
1851 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1854 "Verify that boundary values tags are used for summary route"
1855 " using show ip ospf route command."
1858 SUMMARY
["ipv4"][0]: {
1859 "summaryAddress": SUMMARY
["ipv4"][0],
1863 "externalRouteCount": 5,
1867 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, expected
=False)
1870 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1872 step("Delete the configured summary address")
1876 "summary-address": [
1878 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
1887 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1888 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1891 "Verify that 6 routes are advertised to neighbour with 5 routes"
1892 " without any tag, 1 route with tag."
1896 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
1897 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1898 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
1901 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1903 step("Verify that summary address is flushed from neighbor.")
1906 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1909 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1913 result
= verify_rib(
1914 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1918 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1920 step("Configure summary first & then configure matching static route.")
1922 input_dict_static_rtes
= {
1925 {"network": NETWORK
["ipv4"], "next_hop": "blackhole", "delete": True},
1926 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole", "delete": True},
1930 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1931 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1936 "summary-address": [
1937 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
1942 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1943 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1945 input_dict_static_rtes
= {
1948 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
1949 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
1953 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1954 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1956 write_test_footer(tc_name
)
1959 def test_ospf_type5_summary_tc46_p0(request
):
1960 """OSPF summarisation with advertise and no advertise option"""
1961 tc_name
= request
.node
.name
1962 write_test_header(tc_name
)
1963 tgen
= get_topogen()
1965 # Don't run this test if we have any failure.
1966 if tgen
.routers_have_failure():
1967 pytest
.skip(tgen
.errors
)
1970 step("Bring up the base config as per the topology")
1971 step("Configure OSPF on all the routers of the topology.")
1972 reset_config_on_routers(tgen
)
1977 "Configure 5 static routes from the same network on R0"
1978 "5 static routes from different networks and redistribute in R0"
1980 input_dict_static_rtes
= {
1983 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
1984 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
1988 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1989 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1994 step("Verify that routes are learnt on R1.")
1997 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
1998 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1999 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
2002 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2005 "Configure External Route summary in R0 to summarise 5"
2006 " routes to one route with no advertise option."
2011 "summary-address": [
2013 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2021 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2022 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2025 "Verify that external routes are summarised to configured summary"
2026 " address on R0 and summary route is not advertised to neighbor as"
2027 " no advertise is configured.."
2030 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
2033 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, expected
=False)
2036 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2040 result
= verify_rib(
2041 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
2045 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2047 step("Verify that show ip ospf summary should show the " "configured summaries.")
2049 SUMMARY
["ipv4"][0]: {
2050 "summaryAddress": SUMMARY
["ipv4"][0],
2051 "externalRouteCount": 5,
2055 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
2058 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2060 step("Delete the configured summary")
2064 "summary-address": [
2066 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2074 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2075 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2077 step("Summary has 5 sec delay timer, sleep 5 secs...")
2080 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
2082 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
2085 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2089 result
= verify_rib(
2090 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
2094 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
2098 step("show ip ospf summary should not have any summary address.")
2100 SUMMARY
["ipv4"][0]: {
2101 "summaryAddress": SUMMARY
["ipv4"][0],
2105 "externalRouteCount": 5,
2109 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, expected
=False)
2112 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
2114 step("Reconfigure summary with no advertise.")
2118 "summary-address": [
2120 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2128 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2129 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2132 "Verify that external routes are summarised to configured summary"
2133 " address on R0 and summary route is not advertised to neighbor as"
2134 " no advertise is configured.."
2137 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
2140 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, expected
=False)
2143 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2147 result
= verify_rib(
2148 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
2152 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2154 step("Verify that show ip ospf summary should show the " "configured summaries.")
2156 SUMMARY
["ipv4"][0]: {
2157 "summaryAddress": SUMMARY
["ipv4"][0],
2158 "externalRouteCount": 5,
2162 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
2165 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2168 "Change summary address from no advertise to advertise "
2169 "(summary-address 10.0.0.0 255.255.0.0)"
2175 "summary-address": [
2177 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2185 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2186 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2191 "summary-address": [
2192 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
2197 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2198 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2201 "Verify that external routes are summarised to configured summary "
2202 "address on R0 after 5 secs of delay timer expiry and only one "
2203 "route is sent to R1."
2205 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
2208 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
2209 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2211 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
2214 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2216 step("Verify that show ip ospf summary should show the summaries.")
2218 SUMMARY
["ipv4"][0]: {
2219 "summaryAddress": SUMMARY
["ipv4"][0],
2223 "externalRouteCount": 5,
2227 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
2230 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2232 step("Verify that originally advertised routes are withdraw from there" " peer.")
2234 "r0": {"static_routes": [{"network": NETWORK
["ipv4"], "next_hop": "blackhole"}]}
2237 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
2240 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2244 result
= verify_rib(
2245 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
2249 ), "Testcase {} : Failed" "Error: Routes is present in RIB".format(tc_name
)
2251 write_test_footer(tc_name
)
2254 def test_ospf_type5_summary_tc47_p0(request
):
2255 """OSPF summarisation with route map filtering."""
2256 tc_name
= request
.node
.name
2257 write_test_header(tc_name
)
2258 tgen
= get_topogen()
2260 # Don't run this test if we have any failure.
2261 if tgen
.routers_have_failure():
2262 pytest
.skip(tgen
.errors
)
2265 step("Bring up the base config as per the topology")
2266 reset_config_on_routers(tgen
)
2271 "Configure 5 static routes from the same network on R0"
2272 "5 static routes from different networks and redistribute in R0"
2274 input_dict_static_rtes
= {
2277 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
2278 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
2282 result
= create_static_routes(tgen
, input_dict_static_rtes
)
2283 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2288 step("Verify that routes are learnt on R1.")
2291 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
2292 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2293 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
2296 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2299 "Configure External Route summary in R0 to summarise 5" " routes to one route."
2305 "summary-address": [
2306 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
2311 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2312 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2315 "Verify that external routes are summarised to configured summary "
2316 "address on R0 after 5 secs of delay timer expiry and only one "
2317 "route is sent to R1."
2319 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
2322 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
2323 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2325 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
2328 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2330 step("Verify that show ip ospf summary should show the summaries.")
2332 SUMMARY
["ipv4"][0]: {
2333 "summaryAddress": SUMMARY
["ipv4"][0],
2337 "externalRouteCount": 5,
2341 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
2344 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2346 step("Verify that originally advertised routes are withdraw from there" " peer.")
2348 "r0": {"static_routes": [{"network": NETWORK
["ipv4"], "next_hop": "blackhole"}]}
2351 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
2354 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2358 result
= verify_rib(
2359 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
2363 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2366 "configure route map and add rule to permit configured static "
2367 "routes, redistribute static & connected routes with the route map."
2370 # Create ip prefix list
2376 {"seqid": 10, "network": "any", "action": "permit"}
2382 result
= create_prefix_lists(tgen
, pfx_list
)
2383 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2391 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
2398 result
= create_route_maps(tgen
, routemaps
)
2399 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2404 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv4"}]
2408 result
= create_router_ospf(tgen
, topo
, ospf_red_r1
)
2409 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2412 "Verify that external routes are summarised to configured"
2413 "summary address on R0 and only one route is sent to R1. Verify that "
2414 "show ip ospf summary should show the configure summaries."
2417 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
2420 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
2421 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2423 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
2426 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2429 SUMMARY
["ipv4"][0]: {
2430 "summaryAddress": SUMMARY
["ipv4"][0],
2434 "externalRouteCount": 5,
2438 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
2439 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2441 step("Change the rule from permit to deny in configured route map.")
2449 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
2456 result
= create_route_maps(tgen
, routemaps
)
2457 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2459 step("summary route has 5 secs dealy, sleep 5 secs")
2461 step("Verify that advertised summary route is flushed from neighbor.")
2463 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, expected
=False)
2466 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2470 result
= verify_rib(
2471 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
2475 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2477 step("Delete the configured route map.")
2485 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
2492 result
= create_route_maps(tgen
, routemaps
)
2493 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2495 ospf_red_r1
= {"r0": {"ospf": {"redistribute": [{"redist_type": "static"}]}}}
2496 result
= create_router_ospf(tgen
, topo
, ospf_red_r1
)
2497 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2500 "Verify that external routes are summarised to configured"
2501 "summary address on R0 and only one route is sent to R1. Verify that "
2502 "show ip ospf summary should show the configure summaries."
2505 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
2508 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
2509 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2511 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
2514 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2517 SUMMARY
["ipv4"][0]: {
2518 "summaryAddress": SUMMARY
["ipv4"][0],
2522 "externalRouteCount": 5,
2526 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
2529 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2531 step("Reconfigure the route map with denying configure summary address.")
2539 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
2546 result
= create_route_maps(tgen
, routemaps
)
2547 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2549 # Create ip prefix list
2555 {"seqid": 10, "network": SUMMARY
["ipv4"][0], "action": "deny"}
2561 result
= create_prefix_lists(tgen
, pfx_list
)
2562 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2564 step("Verify that advertised summary route is not flushed from neighbor.")
2567 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
2568 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2570 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
2573 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2575 step("Redistribute static/connected routes without route map.")
2583 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
2591 result
= create_route_maps(tgen
, routemaps
)
2592 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2595 "Verify that external routes are summarised to configured"
2596 "summary address on R0 and only one route is sent to R1. Verify that "
2597 "show ip ospf summary should show the configure summaries."
2600 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
2603 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
2604 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2606 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
2609 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2612 SUMMARY
["ipv4"][0]: {
2613 "summaryAddress": SUMMARY
["ipv4"][0],
2617 "externalRouteCount": 5,
2621 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
2624 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2627 "Configure rule to deny all the routes in route map and configure"
2628 " redistribute command in ospf using route map."
2631 # Create ip prefix list
2637 {"seqid": 10, "network": "any", "action": "deny"}
2643 result
= create_prefix_lists(tgen
, pfx_list
)
2644 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2652 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
2659 result
= create_route_maps(tgen
, routemaps
)
2660 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2665 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv4"}]
2669 result
= create_router_ospf(tgen
, topo
, ospf_red_r1
)
2670 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2672 step("Verify that no summary route is originated.")
2674 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
, expected
=False)
2677 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2681 result
= verify_rib(
2682 tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
2686 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2694 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
2702 result
= create_route_maps(tgen
, routemaps
)
2703 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2706 "Configure cli in this order - 2 static routes, a route map to "
2707 "permit those routes, summary address in ospf to match the "
2708 "configured static route network, redistribute the static "
2709 "routes with route map"
2712 input_dict_static_rtes
= {
2714 "static_routes": [{"network": NETWORK2
["ipv4"], "next_hop": "blackhole"}]
2717 result
= create_static_routes(tgen
, input_dict_static_rtes
)
2718 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2726 "match": {"ipv4": {"prefix_lists": "pf_list_1_ipv4"}},
2732 result
= create_route_maps(tgen
, routemaps
)
2733 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2738 "summary-address": [
2739 {"prefix": SUMMARY
["ipv4"][1].split("/")[0], "mask": "8"}
2744 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2745 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2747 # Create ip prefix list
2753 {"seqid": 10, "network": "any", "action": "permit"}
2759 result
= create_prefix_lists(tgen
, pfx_list
)
2760 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2763 "Verify that external routes are summarised to configured summary "
2764 "address on R0 after 5 secs of delay timer expiry and only one "
2765 "route is sent to R1."
2767 input_dict_summary
= {"r0": {"static_routes": [{"network": "12.0.0.0/8"}]}}
2770 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
2771 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2773 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
2776 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2778 step("Verify that show ip ospf summary should show the summaries.")
2781 "summaryAddress": "12.0.0.0/8",
2785 "externalRouteCount": 5,
2789 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
2792 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2794 step("Change route map rule for 1 of the routes to deny.")
2795 # Create ip prefix list
2801 {"seqid": 10, "network": NETWORK2
["ipv4"][0], "action": "deny"},
2802 {"seqid": 20, "network": "any", "action": "permit"},
2808 result
= create_prefix_lists(tgen
, pfx_list
)
2809 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2812 "Verify that originated type 5 summary lsa is not refreshed because"
2813 "of the route map events."
2816 input_dict_summary
= {"r0": {"static_routes": [{"network": "12.0.0.0/8"}]}}
2819 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
2820 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2822 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
2825 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2827 step("add rule in route map to deny configured summary address.")
2828 # Create ip prefix list
2834 {"seqid": 10, "network": "12.0.0.0/8", "action": "deny"},
2835 {"seqid": 20, "network": "any", "action": "permit"},
2841 result
= create_prefix_lists(tgen
, pfx_list
)
2842 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2845 "Verify that summary route is not denied, summary route should be"
2846 " originated if matching prefixes are present."
2849 input_dict_summary
= {"r0": {"static_routes": [{"network": "12.0.0.0/8"}]}}
2852 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
2853 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2855 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
2858 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2860 write_test_footer(tc_name
)
2863 def test_ospf_type5_summary_tc51_p2(request
):
2866 verify ospf ASBR summary config and show commands behaviours.
2868 tc_name
= request
.node
.name
2869 write_test_header(tc_name
)
2870 tgen
= get_topogen()
2872 # Don't run this test if we have any failure.
2873 if tgen
.routers_have_failure():
2874 pytest
.skip(tgen
.errors
)
2877 step("Bring up the base config as per the topology")
2878 reset_config_on_routers(tgen
)
2880 step("Configure all the supported OSPF ASBR summary commands on DUT.")
2884 "summary-address": [
2886 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2891 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2896 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2901 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2909 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2910 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2912 step("Configure and re configure all the commands 10 times in a loop.")
2914 for itrate
in range(0, 10):
2918 "summary-address": [
2920 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2925 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2930 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2935 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2943 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2944 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2951 "summary-address": [
2953 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2959 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2965 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2971 "prefix": SUMMARY
["ipv4"][0].split("/")[0],
2980 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2981 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2983 step("Verify the show commands")
2986 SUMMARY
["ipv4"][2]: {
2987 "summaryAddress": SUMMARY
["ipv4"][2],
2991 "externalRouteCount": 0,
2995 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
2998 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
3000 write_test_footer(tc_name
)
3003 def test_ospf_type5_summary_tc49_p2(request
):
3004 """OSPF summarisation Chaos."""
3005 tc_name
= request
.node
.name
3006 write_test_header(tc_name
)
3007 tgen
= get_topogen()
3009 # Don't run this test if we have any failure.
3010 if tgen
.routers_have_failure():
3011 pytest
.skip(tgen
.errors
)
3014 step("Bring up the base config as per the topology")
3015 reset_config_on_routers(tgen
)
3020 "Configure 5 static routes from the same network on R0"
3021 "5 static routes from different networks and redistribute in R0"
3023 input_dict_static_rtes
= {
3026 {"network": NETWORK
["ipv4"], "next_hop": "blackhole"},
3027 {"network": NETWORK2
["ipv4"], "next_hop": "blackhole"},
3031 result
= create_static_routes(tgen
, input_dict_static_rtes
)
3032 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3037 step("Verify that routes are learnt on R1.")
3040 result
= verify_ospf_rib(tgen
, dut
, input_dict_static_rtes
)
3041 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3042 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_static_rtes
, protocol
=protocol
)
3045 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
3048 "Configure External Route summary in R0 to summarise 5" " routes to one route."
3054 "summary-address": [
3055 {"prefix": SUMMARY
["ipv4"][0].split("/")[0], "mask": "8"}
3060 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
3061 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3064 "Verify that external routes are summarised to configured summary "
3065 "address on R0 after 5 secs of delay timer expiry and only one "
3066 "route is sent to R1."
3068 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
3071 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
3072 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3074 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
3077 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
3079 step("Verify that show ip ospf summary should show the summaries.")
3081 SUMMARY
["ipv4"][0]: {
3082 "summaryAddress": SUMMARY
["ipv4"][0],
3086 "externalRouteCount": 5,
3090 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
3093 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
3095 step("Verify that originally advertised routes are withdraw from there" " peer.")
3097 "r0": {"static_routes": [{"network": NETWORK
["ipv4"], "next_hop": "blackhole"}]}
3100 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
3103 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
3107 result
= verify_rib(
3108 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
3112 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
3114 step("Reload the FRR router")
3115 # stop/start -> restart FRR router and verify
3116 stop_router(tgen
, "r0")
3117 start_router(tgen
, "r0")
3120 "Verify that external routes are summarised to configured summary "
3121 "address on R0 after 5 secs of delay timer expiry and only one "
3122 "route is sent to R1."
3124 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
3127 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
3128 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3130 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
3133 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
3135 step("Verify that show ip ospf summary should show the summaries.")
3137 SUMMARY
["ipv4"][0]: {
3138 "summaryAddress": SUMMARY
["ipv4"][0],
3142 "externalRouteCount": 5,
3146 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
3149 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
3151 step("Verify that originally advertised routes are withdraw from there" " peer.")
3153 "r0": {"static_routes": [{"network": NETWORK
["ipv4"], "next_hop": "blackhole"}]}
3156 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
3159 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
3163 result
= verify_rib(
3164 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
3168 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
3170 step("Kill OSPFd daemon on R0.")
3171 kill_router_daemons(tgen
, "r0", ["ospfd"])
3173 step("Bring up OSPFd daemon on R0.")
3174 start_router_daemons(tgen
, "r0", ["ospfd"])
3176 step("Verify OSPF neighbors are up after bringing back ospfd in R0")
3177 # Api call verify whether OSPF is converged
3178 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
)
3179 assert ospf_covergence
is True, "setup_module :Failed \n Error:" " {}".format(
3184 "Verify that external routes are summarised to configured summary "
3185 "address on R0 after 5 secs of delay timer expiry and only one "
3186 "route is sent to R1."
3188 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
3191 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
3192 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3194 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
3197 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
3199 step("Verify that show ip ospf summary should show the summaries.")
3201 SUMMARY
["ipv4"][0]: {
3202 "summaryAddress": SUMMARY
["ipv4"][0],
3206 "externalRouteCount": 5,
3210 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
3213 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
3215 step("Verify that originally advertised routes are withdraw from there" " peer.")
3217 "r0": {"static_routes": [{"network": NETWORK
["ipv4"], "next_hop": "blackhole"}]}
3220 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
3223 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
3227 result
= verify_rib(
3228 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
3232 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
3234 step("restart zebrad")
3235 kill_router_daemons(tgen
, "r0", ["zebra"])
3237 step("Bring up zebra daemon on R0.")
3238 start_router_daemons(tgen
, "r0", ["zebra"])
3241 "Verify that external routes are summarised to configured summary "
3242 "address on R0 after 5 secs of delay timer expiry and only one "
3243 "route is sent to R1."
3245 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv4"][0]}]}}
3248 result
= verify_ospf_rib(tgen
, dut
, input_dict_summary
)
3249 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3251 result
= verify_rib(tgen
, "ipv4", dut
, input_dict_summary
, protocol
=protocol
)
3254 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
3256 step("Verify that show ip ospf summary should show the summaries.")
3258 SUMMARY
["ipv4"][0]: {
3259 "summaryAddress": SUMMARY
["ipv4"][0],
3263 "externalRouteCount": 5,
3267 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
)
3270 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
3272 step("Verify that originally advertised routes are withdraw from there" " peer.")
3274 "r0": {"static_routes": [{"network": NETWORK
["ipv4"], "next_hop": "blackhole"}]}
3277 result
= verify_ospf_rib(tgen
, dut
, input_dict
, expected
=False)
3280 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
3284 result
= verify_rib(
3285 tgen
, "ipv4", dut
, input_dict
, protocol
=protocol
, expected
=False
3289 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
3291 write_test_footer(tc_name
)
3294 if __name__
== "__main__":
3295 args
= ["-s"] + sys
.argv
[1:]
3296 sys
.exit(pytest
.main(args
))