2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2021 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 (
50 verify_ospf6_neighbor
,
57 pytestmark
= [pytest
.mark
.ospfd
, pytest
.mark
.staticd
]
79 "ipv4": ["11.0.20.6/32", "11.0.20.7/32"],
80 "ipv6": ["2011:0:20::6/128", "2011:0:20::7/128"],
100 "ipv4": ["11.0.0.0/8", "12.0.0.0/8", "11.0.0.0/24"],
101 "ipv6": ["2011::/32", "2012::/32", "2011::/64", "2011::/24"],
105 Please view in a fixed-width font such as Courier.
107 +R1 +------------+R2 |
116 +R0 +-------------+R3 |
120 1. OSPF summarisation functionality.
121 2. OSPF summarisation with advertise and no advertise option
122 3. OSPF summarisation with route map modification of metric type.
123 4. OSPF CLI Show verify ospf ASBR summary config and show commands behaviours.
124 5. OSPF summarisation Chaos.
128 def setup_module(mod
):
130 Sets up the pytest environment
134 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
135 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
136 logger
.info("=" * 40)
138 logger
.info("Running setup_module to create topology")
140 # This function initiates the topology build with Topogen...
141 json_file
= "{}/ospfv3_asbr_summary_topo1.json".format(CWD
)
142 tgen
= Topogen(json_file
, mod
.__name
__)
144 topo
= tgen
.json_topo
145 # ... and here it calls Mininet initialization functions.
147 # Starting topology, create tmp files which are loaded to routers
148 # to start daemons and then start routers
151 # Creating configuration from JSON
152 build_config_from_json(tgen
, topo
)
154 # Don't run this test if we have any failure.
155 if tgen
.routers_have_failure():
156 pytest
.skip(tgen
.errors
)
157 # Api call verify whether OSPF is converged
158 ospf_covergence
= verify_ospf6_neighbor(tgen
, topo
)
159 assert ospf_covergence
is True, "setup_module :Failed \n Error:" " {}".format(
163 logger
.info("Running setup_module() done")
166 def teardown_module(mod
):
168 Teardown the pytest environment.
173 logger
.info("Running teardown_module to delete topology")
177 # Stop toplogy and Remove tmp files
181 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
183 logger
.info("=" * 40)
186 def red_static(dut
, config
=True):
188 Local 'def' for Redstribute static routes inside ospf.
192 * `dut` : DUT on which configs have to be made.
193 * `config` : True or False, True by default for configure, set False for
199 ospf_red
= {dut
: {"ospf6": {"redistribute": [{"redist_type": "static"}]}}}
203 "ospf6": {"redistribute": [{"redist_type": "static", "delete": True}]}
206 result
= create_router_ospf(tgen
, topo
, ospf_red
)
207 assert result
is True, "Testcase : Failed \n Error: {}".format(result
)
210 def red_connected(dut
, config
=True):
212 Local 'def' for Redstribute connected routes inside ospf
216 * `dut` : DUT on which configs have to be made.
217 * `config` : True or False, True by default for configure, set False for
223 ospf_red
= {dut
: {"ospf6": {"redistribute": [{"redist_type": "connected"}]}}}
228 "redistribute": [{"redist_type": "connected", "delete": True}]
232 result
= create_router_ospf(tgen
, topo
, ospf_red
)
233 assert result
is True, "Testcase: Failed \n Error: {}".format(result
)
236 # ##################################
237 # Test cases start here.
238 # ##################################
241 def test_ospfv3_type5_summary_tc42_p0(request
):
242 """OSPF summarisation functionality."""
243 tc_name
= request
.node
.name
244 write_test_header(tc_name
)
247 # Don't run this test if we have any failure.
248 if tgen
.routers_have_failure():
249 pytest
.skip(tgen
.errors
)
252 step("Bring up the base config as per the topology")
253 reset_config_on_routers(tgen
)
258 "Configure 5 static routes from the same network on R0"
259 "5 static routes from different networks and redistribute in R0"
261 input_dict_static_rtes
= {
264 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
265 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
269 result
= create_static_routes(tgen
, input_dict_static_rtes
)
270 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
275 step("Verify that routes are learnt on R1.")
278 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
279 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
280 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
283 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
286 "Configure External Route summary in R0 to summarise 5"
287 " routes to one route. with aggregate timer as 6 sec"
294 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
300 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
301 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
304 "Verify that external routes are summarised to configured summary "
305 "address on R0 after 5 secs of delay timer expiry and only one "
306 "route is sent to R1."
308 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
311 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
312 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
314 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
317 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
319 step("Verify that show ip ospf summary should show the summaries.")
321 SUMMARY
["ipv6"][0]: {
322 "summaryAddress": SUMMARY
["ipv6"][0],
326 "externalRouteCount": 5,
330 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
333 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
335 step("Verify that originally advertised routes are withdraw from there" " peer.")
337 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
340 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
343 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
348 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
352 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
354 step("Delete the configured summary")
360 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
362 "del_aggr_timer": True,
369 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
370 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
372 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
374 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
377 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
382 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
386 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
390 step("show ip ospf summary should not have any summary address.")
392 SUMMARY
["ipv6"][0]: {
393 "summaryAddress": SUMMARY
["ipv6"][0],
397 "externalRouteCount": 5,
401 result
= verify_ospf_summary(
402 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
406 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
409 step("All 5 routes are advertised after deletion of configured summary.")
411 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
412 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
414 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
417 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
419 step("configure the summary again and delete static routes .")
424 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
429 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
430 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
433 SUMMARY
["ipv6"][0]: {
434 "summaryAddress": SUMMARY
["ipv6"][0],
438 "externalRouteCount": 5,
442 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
445 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
450 {"network": NETWORK
["ipv6"], "next_hop": "blackhole", "delete": True}
454 result
= create_static_routes(tgen
, input_dict
)
455 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
457 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
458 step("Verify that summary route is withdrawn from R1.")
461 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
464 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
469 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
473 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
475 step("Add back static routes.")
476 input_dict_static_rtes
= {
477 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
479 result
= create_static_routes(tgen
, input_dict_static_rtes
)
480 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
483 "Verify that external routes are summarised to configured summary"
484 " address on R0 and only one route is sent to R1."
488 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
, expected
=False)
491 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
496 tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
, expected
=False
500 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
502 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
505 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
506 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
508 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
511 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
513 step("Verify that show ip ospf summary should show configure summaries.")
516 SUMMARY
["ipv6"][0]: {
517 "summaryAddress": SUMMARY
["ipv6"][0],
521 "externalRouteCount": 5,
525 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
528 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
530 step("Configure new static route which is matching configured summary.")
531 input_dict_static_rtes
= {
533 "static_routes": [{"network": NETWORK_11
["ipv6"], "next_hop": "blackhole"}]
536 result
= create_static_routes(tgen
, input_dict_static_rtes
)
537 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
539 # step("verify that summary lsa is not refreshed.")
540 # show ip ospf database command is not working, waiting for DEV fix.
542 step("Delete one of the static route.")
543 input_dict_static_rtes
= {
546 {"network": NETWORK_11
["ipv6"], "next_hop": "blackhole", "delete": True}
550 result
= create_static_routes(tgen
, input_dict_static_rtes
)
551 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
553 # step("verify that summary lsa is not refreshed.")
554 # show ip ospf database command is not working, waiting for DEV fix.
556 # step("Verify that deleted static route is removed from ospf LSDB.")
557 # show ip ospf database command is not working, waiting for DEV fix.
560 "Configure redistribute connected and configure ospf external"
561 " summary address to summarise the connected routes."
566 clear_ospf(tgen
, dut
, ospf
="ospf6")
568 ip
= topo
["routers"]["r0"]["links"]["r3"]["ipv6"]
570 ip_net
= str(ipaddress
.ip_interface(u
"{}".format(ip
)).network
)
574 "summary-address": [{"prefix": ip_net
.split("/")[0], "mask": "8"}]
578 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
579 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
582 "Verify that external routes are summarised to configured "
583 "summary address on R0 and only one route is sent to R1."
586 input_dict_summary
= {"r0": {"static_routes": [{"network": "fd00::/64"}]}}
588 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
589 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
591 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
594 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
596 step("Shut one of the interface")
597 intf
= topo
["routers"]["r0"]["links"]["r3-link0"]["interface"]
598 shutdown_bringup_interface(tgen
, dut
, intf
, False)
600 # step("verify that summary lsa is not refreshed.")
601 # show ip ospf database command is not working, waiting for DEV fix.
603 # step("Verify that deleted connected route is removed from ospf LSDB.")
604 # show ip ospf database command is not working, waiting for DEV fix.
606 step("Un do shut the interface")
607 shutdown_bringup_interface(tgen
, dut
, intf
, True)
609 # step("verify that summary lsa is not refreshed.")
610 # show ip ospf database command is not working, waiting for DEV fix.
612 # step("Verify that deleted connected route is removed from ospf LSDB.")
613 # show ip ospf database command is not working, waiting for DEV fix.
615 step("Delete OSPF process.")
616 ospf_del
= {"r0": {"ospf6": {"delete": True}}}
617 result
= create_router_ospf(tgen
, topo
, ospf_del
)
618 assert result
is True, "Testcase : Failed \n Error: {}".format(result
)
620 step("Reconfigure ospf process with summary")
621 reset_config_on_routers(tgen
)
623 input_dict_static_rtes
= {
626 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
627 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
631 result
= create_static_routes(tgen
, input_dict_static_rtes
)
632 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
641 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
646 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
647 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
649 "Verify that external routes are summarised to configured summary "
650 "address on R0 and only one route is sent to R1."
654 SUMMARY
["ipv6"][0]: {
655 "summaryAddress": SUMMARY
["ipv6"][0],
659 "externalRouteCount": 5,
663 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
666 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
668 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
671 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
672 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
674 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
677 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
683 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
688 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
689 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
691 # step("verify that summary lsa is not refreshed.")
692 # show ip ospf database command is not working, waiting for DEV fix.
694 step("Delete the redistribute command in ospf.")
696 red_connected(dut
, config
=False)
697 red_static(dut
, config
=False)
699 step("Verify that summary route is withdrawn from the peer.")
702 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
705 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
710 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
714 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
721 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
729 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
730 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
732 write_test_footer(tc_name
)
735 def test_ospfv3_type5_summary_tc43_p0(request
):
736 """OSPF summarisation with metric type 2."""
737 tc_name
= request
.node
.name
738 write_test_header(tc_name
)
741 # Don't run this test if we have any failure.
742 if tgen
.routers_have_failure():
743 pytest
.skip(tgen
.errors
)
746 step("Bring up the base config as per the topology")
747 reset_config_on_routers(tgen
)
752 "Configure 5 static routes from the same network on R0"
753 "5 static routes from different networks and redistribute in R0"
755 input_dict_static_rtes
= {
758 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
759 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
763 result
= create_static_routes(tgen
, input_dict_static_rtes
)
764 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
769 step("Verify that routes are learnt on R1.")
772 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
773 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
774 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
777 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
780 "Configure External Route summary in R0 to summarise 5" " routes to one route."
786 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
791 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
792 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
794 "Verify that external routes are summarised to configured summary "
795 "address on R0 after 5 secs of delay timer expiry and only one "
796 "route is sent to R1."
798 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
801 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
802 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
804 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
807 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
809 step("Verify that show ip ospf summary should show the summaries.")
811 SUMMARY
["ipv6"][0]: {
812 "summaryAddress": SUMMARY
["ipv6"][0],
816 "externalRouteCount": 5,
820 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
823 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
825 step("Change the summary address mask to lower match (ex - 16 to 8)")
830 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "16"},
832 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
840 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
841 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
847 "summaryAddress": "2011::/16",
851 "externalRouteCount": 5,
855 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
858 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
861 "Verify that external routes(static / connected) are summarised"
862 " to configured summary address with newly configured mask."
865 input_dict_summary
= {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
868 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
869 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
871 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
874 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
876 step("Change the summary address mask to higher match (ex - 8 to 24)")
881 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
886 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
887 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
891 "summaryAddress": "2011::/32",
895 "externalRouteCount": 0,
899 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
902 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
905 "Verify that external routes(static / connected) are summarised"
906 " to configured summary address with newly configured mask."
908 step("Configure 2 summary address with different mask of same network.")
910 "Verify that external routes(static / connected) are summarised "
911 "to configured summary address with highest match."
914 input_dict_summary
= {"r0": {"static_routes": [{"network": "2011::0/32"}]}}
917 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
918 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
920 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
923 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
925 step(" Un configure one of the summary address.")
931 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
939 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
940 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
945 "Verify that external routes(static / connected) are summarised"
946 " to configured summary address with newly configured mask."
949 input_dict_summary
= {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
952 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
953 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
955 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
958 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
964 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "16"}
969 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
970 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
973 "Verify that external routes(static / connected) are summarised "
974 "to configured summary address with highest match."
976 input_dict_summary
= {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
979 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
980 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
982 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
985 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
987 write_test_footer(tc_name
)
990 def ospfv3_type5_summary_tc45_p0(request
):
991 """OSPF summarisation with Tag option"""
992 tc_name
= request
.node
.name
993 write_test_header(tc_name
)
996 # Don't run this test if we have any failure.
997 if tgen
.routers_have_failure():
998 pytest
.skip(tgen
.errors
)
1001 step("Bring up the base config as per the topology")
1002 step("Configure OSPF on all the routers of the topology.")
1003 reset_config_on_routers(tgen
)
1008 "Configure 5 static routes from the same network on R0"
1009 "5 static routes from different networks and redistribute in R0"
1011 input_dict_static_rtes
= {
1014 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1015 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1019 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1020 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1025 step("Verify that routes are learnt on R1.")
1028 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1029 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1030 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1033 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1036 "Configure External Route summary in R0 to summarise 5" " routes to one route."
1041 "summary-address": [
1043 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1051 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1052 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1055 "Verify that external routes are summarised to configured summary"
1056 " address on R0 and only one route is sent to R1 with configured tag."
1058 input_dict_summary
= {
1059 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "1234"}]}
1063 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1064 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1066 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1069 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1071 step("Verify that show ip ospf summary should show the summaries with tag.")
1073 SUMMARY
["ipv6"][0]: {
1074 "summaryAddress": SUMMARY
["ipv6"][0],
1078 "externalRouteCount": 5,
1082 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1085 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1087 step("Delete the configured summary")
1091 "summary-address": [
1093 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1102 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1103 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1105 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1107 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1110 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1114 result
= verify_rib(
1115 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1119 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
1123 step("show ip ospf summary should not have any summary address.")
1125 SUMMARY
["ipv6"][0]: {
1126 "summaryAddress": SUMMARY
["ipv6"][0],
1130 "externalRouteCount": 5,
1134 result
= verify_ospf_summary(
1135 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1139 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
1141 step("Configure Min tag value")
1145 "summary-address": [
1146 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32", "tag": 1}
1151 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1152 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1153 input_dict_summary
= {
1154 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "1"}]}
1158 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1159 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1161 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1164 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1166 step("Verify that show ip ospf summary should show the summaries with tag.")
1168 SUMMARY
["ipv6"][0]: {
1169 "summaryAddress": SUMMARY
["ipv6"][0],
1173 "externalRouteCount": 5,
1177 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1180 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1182 step("Configure Max Tag Value")
1186 "summary-address": [
1188 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1196 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1197 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1199 input_dict_summary
= {
1200 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "4294967295"}]}
1204 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1205 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1207 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1210 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1213 "Verify that boundary values tags are used for summary route"
1214 " using show ip ospf route command."
1217 SUMMARY
["ipv6"][0]: {
1218 "summaryAddress": SUMMARY
["ipv6"][0],
1222 "externalRouteCount": 5,
1226 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1229 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1231 step("configure new static route with different tag.")
1232 input_dict_static_rtes_11
= {
1235 {"network": NETWORK_11
["ipv6"], "next_hop": "blackhole", "tag": "88888"}
1239 result
= create_static_routes(tgen
, input_dict_static_rtes_11
)
1240 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1242 step("New tag has not been used by summary address.")
1244 input_dict_summary
= {
1245 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "88888"}]}
1249 result
= verify_ospf6_rib(
1250 tgen
, dut
, input_dict_summary
, tag
="88888", expected
=False
1254 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1258 result
= verify_rib(
1269 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1272 "Verify that boundary values tags are used for summary route"
1273 " using show ip ospf route command."
1276 SUMMARY
["ipv6"][0]: {
1277 "summaryAddress": SUMMARY
["ipv6"][0],
1281 "externalRouteCount": 5,
1285 result
= verify_ospf_summary(
1286 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1290 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1292 step("Delete the configured summary address")
1296 "summary-address": [
1298 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1307 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1308 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1311 "Verify that 6 routes are advertised to neighbour with 5 routes"
1312 " without any tag, 1 route with tag."
1316 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1317 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1318 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1321 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1323 step("Verify that summary address is flushed from neighbor.")
1326 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1329 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1333 result
= verify_rib(
1334 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1338 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1340 step("Configure summary first & then configure matching static route.")
1342 input_dict_static_rtes
= {
1345 {"network": NETWORK
["ipv6"], "next_hop": "blackhole", "delete": True},
1346 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole", "delete": True},
1350 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1351 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1356 "summary-address": [
1357 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
1362 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1363 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1365 input_dict_static_rtes
= {
1368 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1369 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1373 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1374 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1376 step("Repeat steps 1 to 10 of summarisation in non Back bone area.")
1377 reset_config_on_routers(tgen
)
1379 step("Change the area id on the interface on R0")
1384 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
1385 "ospf6": {"area": "0.0.0.0"},
1392 result
= create_interfaces_cfg(tgen
, input_dict
)
1393 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1399 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
1400 "ospf6": {"area": "0.0.0.1"},
1406 result
= create_interfaces_cfg(tgen
, input_dict
)
1407 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1409 step("Change the area id on the interface ")
1414 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
1415 "ospf6": {"area": "0.0.0.0"},
1422 result
= create_interfaces_cfg(tgen
, input_dict
)
1423 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1429 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
1430 "ospf6": {"area": "0.0.0.1"},
1436 result
= create_interfaces_cfg(tgen
, input_dict
)
1437 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1439 ospf_covergence
= verify_ospf6_neighbor(tgen
, topo
)
1440 assert ospf_covergence
is True, "Testcase {} :Failed \n Error: {}".format(
1441 tc_name
, ospf_covergence
1445 "Configure 5 static routes from the same network on R0"
1446 "5 static routes from different networks and redistribute in R0"
1448 input_dict_static_rtes
= {
1451 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1452 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1456 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1457 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1462 step("Verify that routes are learnt on R1.")
1465 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1466 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1467 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1470 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1473 "Configure External Route summary in R0 to summarise 5" " routes to one route."
1478 "summary-address": [
1480 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1488 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1489 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1492 "Verify that external routes are summarised to configured summary"
1493 " address on R0 and only one route is sent to R1 with configured tag."
1495 input_dict_summary
= {
1496 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "1234"}]}
1500 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1501 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1503 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1506 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1508 step("Verify that show ip ospf summary should show the summaries with tag.")
1510 SUMMARY
["ipv6"][0]: {
1511 "summaryAddress": SUMMARY
["ipv6"][0],
1515 "externalRouteCount": 5,
1519 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1520 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1522 step("Delete the configured summary")
1526 "summary-address": [
1528 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1536 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1537 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1539 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1541 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1544 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1548 result
= verify_rib(
1549 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1553 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
1557 step("show ip ospf summary should not have any summary address.")
1559 SUMMARY
["ipv6"][0]: {
1560 "summaryAddress": SUMMARY
["ipv6"][0],
1564 "externalRouteCount": 5,
1568 result
= verify_ospf_summary(
1569 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1573 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
1575 step("Configure Min tag value")
1579 "summary-address": [
1580 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32", "tag": 1}
1585 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1586 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1587 input_dict_summary
= {
1588 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "1"}]}
1592 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1593 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1595 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1598 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1600 step("Verify that show ip ospf summary should show the summaries with tag.")
1602 SUMMARY
["ipv6"][0]: {
1603 "summaryAddress": SUMMARY
["ipv6"][0],
1607 "externalRouteCount": 5,
1611 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1614 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1616 step("Configure Max Tag Value")
1620 "summary-address": [
1622 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1630 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1631 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1633 input_dict_summary
= {
1634 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "4294967295"}]}
1638 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1639 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1641 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1644 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1647 "Verify that boundary values tags are used for summary route"
1648 " using show ip ospf route command."
1651 SUMMARY
["ipv6"][0]: {
1652 "summaryAddress": SUMMARY
["ipv6"][0],
1656 "externalRouteCount": 5,
1660 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1663 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1665 step("configure new static route with different tag.")
1666 input_dict_static_rtes_11
= {
1669 {"network": NETWORK_11
["ipv6"], "next_hop": "blackhole", "tag": "88888"}
1673 result
= create_static_routes(tgen
, input_dict_static_rtes_11
)
1674 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1676 step("New tag has not been used by summary address.")
1678 input_dict_summary
= {
1679 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "88888"}]}
1683 result
= verify_ospf6_rib(
1684 tgen
, dut
, input_dict_summary
, tag
="88888", expected
=False
1688 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1692 result
= verify_rib(
1703 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1706 "Verify that boundary values tags are used for summary route"
1707 " using show ip ospf route command."
1710 SUMMARY
["ipv6"][0]: {
1711 "summaryAddress": SUMMARY
["ipv6"][0],
1715 "externalRouteCount": 5,
1719 result
= verify_ospf_summary(
1720 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1724 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1726 step("Delete the configured summary address")
1730 "summary-address": [
1732 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1741 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1742 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1745 "Verify that 6 routes are advertised to neighbour with 5 routes"
1746 " without any tag, 1 route with tag."
1750 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1751 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1752 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1755 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1757 step("Verify that summary address is flushed from neighbor.")
1760 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1763 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1767 result
= verify_rib(
1768 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1772 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1774 step("Configure summary first & then configure matching static route.")
1776 input_dict_static_rtes
= {
1779 {"network": NETWORK
["ipv6"], "next_hop": "blackhole", "delete": True},
1780 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole", "delete": True},
1784 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1785 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1790 "summary-address": [
1791 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
1796 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1797 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1799 input_dict_static_rtes
= {
1802 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1803 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1807 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1808 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1810 write_test_footer(tc_name
)
1813 def test_ospfv3_type5_summary_tc46_p0(request
):
1814 """OSPF summarisation with advertise and no advertise option"""
1815 tc_name
= request
.node
.name
1816 write_test_header(tc_name
)
1817 tgen
= get_topogen()
1819 # Don't run this test if we have any failure.
1820 if tgen
.routers_have_failure():
1821 pytest
.skip(tgen
.errors
)
1824 step("Bring up the base config as per the topology")
1825 step("Configure OSPF on all the routers of the topology.")
1826 reset_config_on_routers(tgen
)
1831 "Configure 5 static routes from the same network on R0"
1832 "5 static routes from different networks and redistribute in R0"
1834 input_dict_static_rtes
= {
1837 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1838 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1842 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1843 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1848 step("Verify that routes are learnt on R1.")
1851 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1852 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1853 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1856 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1859 "Configure External Route summary in R0 to summarise 5"
1860 " routes to one route with no advertise option."
1865 "summary-address": [
1867 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1875 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1876 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1879 "Verify that external routes are summarised to configured summary"
1880 " address on R0 and summary route is not advertised to neighbor as"
1881 " no advertise is configured.."
1884 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1887 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1890 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1894 result
= verify_rib(
1895 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1899 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1901 step("Verify that show ip ospf summary should show the " "configured summaries.")
1903 SUMMARY
["ipv6"][0]: {
1904 "summaryAddress": SUMMARY
["ipv6"][0],
1905 "externalRouteCount": 5,
1909 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1912 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1914 step("Delete the configured summary")
1918 "summary-address": [
1920 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1928 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1929 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1931 step("Summary has 5 sec delay timer, sleep 5 secs...")
1934 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1936 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1939 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1943 result
= verify_rib(
1944 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1948 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
1952 step("show ip ospf summary should not have any summary address.")
1954 SUMMARY
["ipv6"][0]: {
1955 "summaryAddress": SUMMARY
["ipv6"][0],
1959 "externalRouteCount": 5,
1963 result
= verify_ospf_summary(
1964 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1968 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
1970 step("Reconfigure summary with no advertise.")
1974 "summary-address": [
1976 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1984 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1985 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1988 "Verify that external routes are summarised to configured summary"
1989 " address on R0 and summary route is not advertised to neighbor as"
1990 " no advertise is configured.."
1993 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1996 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1999 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2003 result
= verify_rib(
2004 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
2008 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2010 step("Verify that show ip ospf summary should show the " "configured summaries.")
2012 SUMMARY
["ipv6"][0]: {
2013 "summaryAddress": SUMMARY
["ipv6"][0],
2014 "externalRouteCount": 5,
2018 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2021 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2024 "Change summary address from no advertise to advertise "
2025 "(summary-address 10.0.0.0 255.255.0.0)"
2031 "summary-address": [
2033 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2041 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2042 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2047 "summary-address": [
2048 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
2053 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2054 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2057 "Verify that external routes are summarised to configured summary "
2058 "address on R0 after 5 secs of delay timer expiry and only one "
2059 "route is sent to R1."
2061 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2064 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2065 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2067 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2070 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2072 step("Verify that show ip ospf summary should show the summaries.")
2074 SUMMARY
["ipv6"][0]: {
2075 "summaryAddress": SUMMARY
["ipv6"][0],
2079 "externalRouteCount": 5,
2083 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2086 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2088 step("Verify that originally advertised routes are withdraw from there" " peer.")
2089 output
= tgen
.gears
["r0"].vtysh_cmd(
2090 "show ipv6 ospf6 database as-external json", isjson
=True
2093 output
= tgen
.gears
["r1"].vtysh_cmd(
2094 "show ipv6 ospf6 database as-external json", isjson
=True
2098 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
2101 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
2104 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2108 result
= verify_rib(
2109 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
2113 ), "Testcase {} : Failed" "Error: Routes is present in RIB".format(tc_name
)
2115 write_test_footer(tc_name
)
2118 def test_ospfv3_type5_summary_tc48_p0(request
):
2119 """OSPF summarisation with route map modification of metric type."""
2120 tc_name
= request
.node
.name
2121 write_test_header(tc_name
)
2122 tgen
= get_topogen()
2124 # Don't run this test if we have any failure.
2125 if tgen
.routers_have_failure():
2126 pytest
.skip(tgen
.errors
)
2129 step("Bring up the base config as per the topology")
2130 reset_config_on_routers(tgen
)
2135 "Configure 5 static routes from the same network on R0"
2136 "5 static routes from different networks and redistribute in R0"
2138 input_dict_static_rtes
= {
2141 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
2142 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
2146 result
= create_static_routes(tgen
, input_dict_static_rtes
)
2147 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2152 step("Verify that routes are learnt on R1.")
2155 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
2156 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2157 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
2160 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2163 "Configure External Route summary in R0 to summarise 5" " routes to one route."
2169 "summary-address": [
2170 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
2175 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2176 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2179 "Verify that external routes are summarised to configured summary "
2180 "address on R0 after 5 secs of delay timer expiry and only one "
2181 "route is sent to R1."
2183 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2186 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2187 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2189 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2192 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2194 step("Verify that show ip ospf summary should show the summaries.")
2196 SUMMARY
["ipv6"][0]: {
2197 "summaryAddress": SUMMARY
["ipv6"][0],
2201 "externalRouteCount": 5,
2205 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2208 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2210 step("Verify that originally advertised routes are withdraw from there" " peer.")
2212 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
2215 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
2218 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2222 result
= verify_rib(
2223 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
2227 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2230 "Configure route map and & rule to permit configured summary address,"
2231 " redistribute static & connected routes with the route map."
2233 step("Configure prefixlist to permit the static routes, add to route map.")
2234 # Create ip prefix list
2240 {"seqid": 10, "network": "any", "action": "permit"}
2246 result
= create_prefix_lists(tgen
, pfx_list
)
2247 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2256 "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
2262 result
= create_route_maps(tgen
, routemaps
)
2263 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2268 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
2272 result
= create_router_ospf(tgen
, topo
, ospf_red_r1
)
2273 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2276 "Verify that external routes are summarised to configured"
2277 "summary address on R0 and only one route is sent to R1. Verify that "
2278 "show ip ospf summary should show the configure summaries."
2281 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2284 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2285 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2287 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2290 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2293 SUMMARY
["ipv6"][0]: {
2294 "summaryAddress": SUMMARY
["ipv6"][0],
2298 "externalRouteCount": 5,
2302 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2305 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2307 step("Configure metric type as 1 in route map.")
2316 "set": {"metric-type": "type-1"},
2322 result
= create_route_maps(tgen
, routemaps
)
2323 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2326 "Verify that external routes(static / connected) are summarised"
2327 " to configured summary address with metric type 2."
2330 SUMMARY
["ipv6"][0]: {
2331 "summaryAddress": SUMMARY
["ipv6"][0],
2335 "externalRouteCount": 5,
2339 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2342 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2344 step("Un configure metric type from route map.")
2353 "set": {"metric-type": "type-1", "delete": True},
2359 result
= create_route_maps(tgen
, routemaps
)
2360 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2363 "Verify that external routes(static / connected) are summarised"
2364 " to configured summary address with metric type 2."
2367 SUMMARY
["ipv6"][0]: {
2368 "summaryAddress": SUMMARY
["ipv6"][0],
2372 "externalRouteCount": 5,
2376 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2379 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2381 step("Change rule from permit to deny in prefix list.")
2387 {"seqid": 10, "network": "any", "action": "deny"}
2393 result
= create_prefix_lists(tgen
, pfx_list
)
2394 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2397 "Verify that previously originated summary lsa "
2398 "is withdrawn from the neighbor."
2400 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2403 step("summary route has delay of 5 secs, wait for 5 secs")
2407 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
2410 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2414 result
= verify_rib(
2415 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
2419 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2421 write_test_footer(tc_name
)
2424 def test_ospfv3_type5_summary_tc51_p2(request
):
2427 verify ospf ASBR summary config and show commands behaviours.
2429 tc_name
= request
.node
.name
2430 write_test_header(tc_name
)
2431 tgen
= get_topogen()
2433 # Don't run this test if we have any failure.
2434 if tgen
.routers_have_failure():
2435 pytest
.skip(tgen
.errors
)
2438 step("Bring up the base config as per the topology")
2439 reset_config_on_routers(tgen
)
2441 step("Configure all the supported OSPF ASBR summary commands on DUT.")
2445 "summary-address": [
2447 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2452 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2457 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2462 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2470 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2471 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2473 step("Configure and re configure all the commands 10 times in a loop.")
2475 for itrate
in range(0, 10):
2479 "summary-address": [
2481 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2486 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2491 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2496 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2504 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2505 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2512 "summary-address": [
2514 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2520 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2526 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2532 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2541 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2542 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2544 step("Verify the show commands")
2547 SUMMARY
["ipv6"][3]: {
2548 "summaryAddress": SUMMARY
["ipv6"][3],
2552 "externalRouteCount": 0,
2556 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2559 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2561 write_test_footer(tc_name
)
2564 def test_ospfv3_type5_summary_tc49_p2(request
):
2565 """OSPF summarisation Chaos."""
2566 tc_name
= request
.node
.name
2567 write_test_header(tc_name
)
2568 tgen
= get_topogen()
2570 # Don't run this test if we have any failure.
2571 if tgen
.routers_have_failure():
2572 pytest
.skip(tgen
.errors
)
2575 step("Bring up the base config as per the topology")
2576 reset_config_on_routers(tgen
)
2581 "Configure 5 static routes from the same network on R0"
2582 "5 static routes from different networks and redistribute in R0"
2584 input_dict_static_rtes
= {
2587 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
2588 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
2592 result
= create_static_routes(tgen
, input_dict_static_rtes
)
2593 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2598 step("Verify that routes are learnt on R1.")
2601 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
2602 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2603 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
2606 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2609 "Configure External Route summary in R0 to summarise 5" " routes to one route."
2615 "summary-address": [
2616 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
2621 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2622 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2625 "Verify that external routes are summarised to configured summary "
2626 "address on R0 after 5 secs of delay timer expiry and only one "
2627 "route is sent to R1."
2629 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2632 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2633 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2635 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2638 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2640 step("Verify that show ip ospf summary should show the summaries.")
2642 SUMMARY
["ipv6"][0]: {
2643 "summaryAddress": SUMMARY
["ipv6"][0],
2647 "externalRouteCount": 5,
2651 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2654 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2656 step("Verify that originally advertised routes are withdraw from there" " peer.")
2658 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
2661 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
2664 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2668 result
= verify_rib(
2669 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
2673 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2675 step("Reload the FRR router")
2676 # stop/start -> restart FRR router and verify
2677 stop_router(tgen
, "r0")
2678 start_router(tgen
, "r0")
2681 "Verify that external routes are summarised to configured summary "
2682 "address on R0 after 5 secs of delay timer expiry and only one "
2683 "route is sent to R1."
2685 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2688 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2689 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2691 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2694 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
2696 step("Verify that show ip ospf summary should show the summaries.")
2698 SUMMARY
["ipv6"][0]: {
2699 "summaryAddress": SUMMARY
["ipv6"][0],
2703 "externalRouteCount": 5,
2707 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2710 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
2712 step("Verify that originally advertised routes are withdraw from there" " peer.")
2714 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
2717 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
2720 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
2724 result
= verify_rib(
2725 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
2729 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
2731 write_test_footer(tc_name
)
2734 if __name__
== "__main__":
2735 args
= ["-s"] + sys
.argv
[1:]
2736 sys
.exit(pytest
.main(args
))