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(tc_name
)
388 step("show ip ospf summary should not have any summary address.")
390 SUMMARY
["ipv6"][0]: {
391 "summaryAddress": SUMMARY
["ipv6"][0],
395 "externalRouteCount": 5,
399 result
= verify_ospf_summary(
400 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
404 ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name
)
407 step("All 5 routes are advertised after deletion of configured summary.")
409 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
410 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
412 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
415 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
417 step("configure the summary again and delete static routes .")
422 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
427 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
428 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
431 SUMMARY
["ipv6"][0]: {
432 "summaryAddress": SUMMARY
["ipv6"][0],
436 "externalRouteCount": 5,
440 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
443 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
448 {"network": NETWORK
["ipv6"], "next_hop": "blackhole", "delete": True}
452 result
= create_static_routes(tgen
, input_dict
)
453 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
455 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
456 step("Verify that summary route is withdrawn from R1.")
459 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
462 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
467 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
471 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
473 step("Add back static routes.")
474 input_dict_static_rtes
= {
475 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
477 result
= create_static_routes(tgen
, input_dict_static_rtes
)
478 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
481 "Verify that external routes are summarised to configured summary"
482 " address on R0 and only one route is sent to R1."
486 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
, expected
=False)
489 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
494 tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
, expected
=False
498 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
500 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
503 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
504 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
506 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
509 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
511 step("Verify that show ip ospf summary should show configure summaries.")
514 SUMMARY
["ipv6"][0]: {
515 "summaryAddress": SUMMARY
["ipv6"][0],
519 "externalRouteCount": 5,
523 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
526 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
528 step("Configure new static route which is matching configured summary.")
529 input_dict_static_rtes
= {
531 "static_routes": [{"network": NETWORK_11
["ipv6"], "next_hop": "blackhole"}]
534 result
= create_static_routes(tgen
, input_dict_static_rtes
)
535 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
537 # step("verify that summary lsa is not refreshed.")
538 # show ip ospf database command is not working, waiting for DEV fix.
540 step("Delete one of the static route.")
541 input_dict_static_rtes
= {
544 {"network": NETWORK_11
["ipv6"], "next_hop": "blackhole", "delete": True}
548 result
= create_static_routes(tgen
, input_dict_static_rtes
)
549 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
551 # step("verify that summary lsa is not refreshed.")
552 # show ip ospf database command is not working, waiting for DEV fix.
554 # step("Verify that deleted static route is removed from ospf LSDB.")
555 # show ip ospf database command is not working, waiting for DEV fix.
558 "Configure redistribute connected and configure ospf external"
559 " summary address to summarise the connected routes."
564 clear_ospf(tgen
, dut
, ospf
="ospf6")
566 ip
= topo
["routers"]["r0"]["links"]["r3"]["ipv6"]
568 ip_net
= str(ipaddress
.ip_interface(u
"{}".format(ip
)).network
)
572 "summary-address": [{"prefix": ip_net
.split("/")[0], "mask": "8"}]
576 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
577 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
580 "Verify that external routes are summarised to configured "
581 "summary address on R0 and only one route is sent to R1."
584 input_dict_summary
= {"r0": {"static_routes": [{"network": "fd00::/64"}]}}
586 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
587 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
589 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
592 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
594 step("Shut one of the interface")
595 intf
= topo
["routers"]["r0"]["links"]["r3-link0"]["interface"]
596 shutdown_bringup_interface(tgen
, dut
, intf
, False)
598 # step("verify that summary lsa is not refreshed.")
599 # show ip ospf database command is not working, waiting for DEV fix.
601 # step("Verify that deleted connected route is removed from ospf LSDB.")
602 # show ip ospf database command is not working, waiting for DEV fix.
604 step("Un do shut the interface")
605 shutdown_bringup_interface(tgen
, dut
, intf
, True)
607 # step("verify that summary lsa is not refreshed.")
608 # show ip ospf database command is not working, waiting for DEV fix.
610 # step("Verify that deleted connected route is removed from ospf LSDB.")
611 # show ip ospf database command is not working, waiting for DEV fix.
613 step("Delete OSPF process.")
614 ospf_del
= {"r0": {"ospf6": {"delete": True}}}
615 result
= create_router_ospf(tgen
, topo
, ospf_del
)
616 assert result
is True, "Testcase : Failed \n Error: {}".format(result
)
618 step("Reconfigure ospf process with summary")
619 reset_config_on_routers(tgen
)
621 input_dict_static_rtes
= {
624 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
625 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
629 result
= create_static_routes(tgen
, input_dict_static_rtes
)
630 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
639 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
644 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
645 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
647 "Verify that external routes are summarised to configured summary "
648 "address on R0 and only one route is sent to R1."
652 SUMMARY
["ipv6"][0]: {
653 "summaryAddress": SUMMARY
["ipv6"][0],
657 "externalRouteCount": 5,
661 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
664 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
666 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
669 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
670 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
672 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
675 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
681 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
686 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
687 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
689 # step("verify that summary lsa is not refreshed.")
690 # show ip ospf database command is not working, waiting for DEV fix.
692 step("Delete the redistribute command in ospf.")
694 red_connected(dut
, config
=False)
695 red_static(dut
, config
=False)
697 step("Verify that summary route is withdrawn from the peer.")
700 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
703 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
708 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
712 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
719 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
727 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
728 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
730 write_test_footer(tc_name
)
733 def test_ospfv3_type5_summary_tc43_p0(request
):
734 """OSPF summarisation with metric type 2."""
735 tc_name
= request
.node
.name
736 write_test_header(tc_name
)
739 # Don't run this test if we have any failure.
740 if tgen
.routers_have_failure():
741 pytest
.skip(tgen
.errors
)
744 step("Bring up the base config as per the topology")
745 reset_config_on_routers(tgen
)
750 "Configure 5 static routes from the same network on R0"
751 "5 static routes from different networks and redistribute in R0"
753 input_dict_static_rtes
= {
756 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
757 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
761 result
= create_static_routes(tgen
, input_dict_static_rtes
)
762 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
767 step("Verify that routes are learnt on R1.")
770 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
771 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
772 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
775 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
777 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
782 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
787 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
788 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
790 "Verify that external routes are summarised to configured summary "
791 "address on R0 after 5 secs of delay timer expiry and only one "
792 "route is sent to R1."
794 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
797 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
798 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
800 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
803 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
805 step("Verify that show ip ospf summary should show the summaries.")
807 SUMMARY
["ipv6"][0]: {
808 "summaryAddress": SUMMARY
["ipv6"][0],
812 "externalRouteCount": 5,
816 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
819 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
821 step("Change the summary address mask to lower match (ex - 16 to 8)")
826 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "16"},
828 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
836 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
837 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
843 "summaryAddress": "2011::/16",
847 "externalRouteCount": 5,
851 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
854 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
857 "Verify that external routes(static / connected) are summarised"
858 " to configured summary address with newly configured mask."
861 input_dict_summary
= {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
864 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
865 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
867 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
870 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
872 step("Change the summary address mask to higher match (ex - 8 to 24)")
877 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
882 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
883 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
887 "summaryAddress": "2011::/32",
891 "externalRouteCount": 0,
895 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
898 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
901 "Verify that external routes(static / connected) are summarised"
902 " to configured summary address with newly configured mask."
904 step("Configure 2 summary address with different mask of same network.")
906 "Verify that external routes(static / connected) are summarised "
907 "to configured summary address with highest match."
910 input_dict_summary
= {"r0": {"static_routes": [{"network": "2011::0/32"}]}}
913 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
914 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
916 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
919 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
921 step(" Un configure one of the summary address.")
927 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
935 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
936 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
941 "Verify that external routes(static / connected) are summarised"
942 " to configured summary address with newly configured mask."
945 input_dict_summary
= {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
948 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
949 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
951 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
954 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
960 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "16"}
965 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
966 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
969 "Verify that external routes(static / connected) are summarised "
970 "to configured summary address with highest match."
972 input_dict_summary
= {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
975 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
976 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
978 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
981 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
983 write_test_footer(tc_name
)
986 def ospfv3_type5_summary_tc45_p0(request
):
987 """OSPF summarisation with Tag option"""
988 tc_name
= request
.node
.name
989 write_test_header(tc_name
)
992 # Don't run this test if we have any failure.
993 if tgen
.routers_have_failure():
994 pytest
.skip(tgen
.errors
)
997 step("Bring up the base config as per the topology")
998 step("Configure OSPF on all the routers of the topology.")
999 reset_config_on_routers(tgen
)
1004 "Configure 5 static routes from the same network on R0"
1005 "5 static routes from different networks and redistribute in R0"
1007 input_dict_static_rtes
= {
1010 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1011 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1015 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1016 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1021 step("Verify that routes are learnt on R1.")
1024 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1025 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1026 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1029 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1031 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
1035 "summary-address": [
1037 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1045 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1046 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1049 "Verify that external routes are summarised to configured summary"
1050 " address on R0 and only one route is sent to R1 with configured tag."
1052 input_dict_summary
= {
1053 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "1234"}]}
1057 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1058 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1060 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1063 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1065 step("Verify that show ip ospf summary should show the summaries with tag.")
1067 SUMMARY
["ipv6"][0]: {
1068 "summaryAddress": SUMMARY
["ipv6"][0],
1072 "externalRouteCount": 5,
1076 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1079 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
1081 step("Delete the configured summary")
1085 "summary-address": [
1087 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1096 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1097 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1099 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1101 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1104 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1108 result
= verify_rib(
1109 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1113 ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name
)
1115 step("show ip ospf summary should not have any summary address.")
1117 SUMMARY
["ipv6"][0]: {
1118 "summaryAddress": SUMMARY
["ipv6"][0],
1122 "externalRouteCount": 5,
1126 result
= verify_ospf_summary(
1127 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1131 ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name
)
1133 step("Configure Min tag value")
1137 "summary-address": [
1138 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32", "tag": 1}
1143 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1144 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1145 input_dict_summary
= {
1146 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "1"}]}
1150 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1151 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1153 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1156 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1158 step("Verify that show ip ospf summary should show the summaries with tag.")
1160 SUMMARY
["ipv6"][0]: {
1161 "summaryAddress": SUMMARY
["ipv6"][0],
1165 "externalRouteCount": 5,
1169 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1172 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
1174 step("Configure Max Tag Value")
1178 "summary-address": [
1180 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1188 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1189 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1191 input_dict_summary
= {
1192 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "4294967295"}]}
1196 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1197 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1199 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1202 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1205 "Verify that boundary values tags are used for summary route"
1206 " using show ip ospf route command."
1209 SUMMARY
["ipv6"][0]: {
1210 "summaryAddress": SUMMARY
["ipv6"][0],
1214 "externalRouteCount": 5,
1218 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1221 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
1223 step("configure new static route with different tag.")
1224 input_dict_static_rtes_11
= {
1227 {"network": NETWORK_11
["ipv6"], "next_hop": "blackhole", "tag": "88888"}
1231 result
= create_static_routes(tgen
, input_dict_static_rtes_11
)
1232 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1234 step("New tag has not been used by summary address.")
1236 input_dict_summary
= {
1237 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "88888"}]}
1241 result
= verify_ospf6_rib(
1242 tgen
, dut
, input_dict_summary
, tag
="88888", expected
=False
1246 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1250 result
= verify_rib(
1261 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
1264 "Verify that boundary values tags are used for summary route"
1265 " using show ip ospf route command."
1268 SUMMARY
["ipv6"][0]: {
1269 "summaryAddress": SUMMARY
["ipv6"][0],
1273 "externalRouteCount": 5,
1277 result
= verify_ospf_summary(
1278 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1282 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
1284 step("Delete the configured summary address")
1288 "summary-address": [
1290 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1299 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1300 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1303 "Verify that 6 routes are advertised to neighbour with 5 routes"
1304 " without any tag, 1 route with tag."
1308 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1309 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1310 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1313 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1315 step("Verify that summary address is flushed from neighbor.")
1318 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1321 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1325 result
= verify_rib(
1326 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1330 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
1332 step("Configure summary first & then configure matching static route.")
1334 input_dict_static_rtes
= {
1337 {"network": NETWORK
["ipv6"], "next_hop": "blackhole", "delete": True},
1338 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole", "delete": True},
1342 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1343 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1348 "summary-address": [
1349 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
1354 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1355 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1357 input_dict_static_rtes
= {
1360 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1361 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1365 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1366 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1368 step("Repeat steps 1 to 10 of summarisation in non Back bone area.")
1369 reset_config_on_routers(tgen
)
1371 step("Change the area id on the interface on R0")
1376 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
1377 "ospf6": {"area": "0.0.0.0"},
1384 result
= create_interfaces_cfg(tgen
, input_dict
)
1385 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1391 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
1392 "ospf6": {"area": "0.0.0.1"},
1398 result
= create_interfaces_cfg(tgen
, input_dict
)
1399 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1401 step("Change the area id on the interface ")
1406 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
1407 "ospf6": {"area": "0.0.0.0"},
1414 result
= create_interfaces_cfg(tgen
, input_dict
)
1415 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1421 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
1422 "ospf6": {"area": "0.0.0.1"},
1428 result
= create_interfaces_cfg(tgen
, input_dict
)
1429 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1431 ospf_covergence
= verify_ospf6_neighbor(tgen
, topo
)
1432 assert ospf_covergence
is True, "Testcase {} :Failed \n Error: {}".format(
1433 tc_name
, ospf_covergence
1437 "Configure 5 static routes from the same network on R0"
1438 "5 static routes from different networks and redistribute in R0"
1440 input_dict_static_rtes
= {
1443 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1444 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1448 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1449 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1454 step("Verify that routes are learnt on R1.")
1457 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1458 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1459 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1462 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1464 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
1468 "summary-address": [
1470 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1478 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1479 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1482 "Verify that external routes are summarised to configured summary"
1483 " address on R0 and only one route is sent to R1 with configured tag."
1485 input_dict_summary
= {
1486 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "1234"}]}
1490 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1491 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1493 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1496 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1498 step("Verify that show ip ospf summary should show the summaries with tag.")
1500 SUMMARY
["ipv6"][0]: {
1501 "summaryAddress": SUMMARY
["ipv6"][0],
1505 "externalRouteCount": 5,
1509 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1510 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1512 step("Delete the configured summary")
1516 "summary-address": [
1518 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1526 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1527 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1529 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1531 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1534 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1538 result
= verify_rib(
1539 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1543 ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name
)
1545 step("show ip ospf summary should not have any summary address.")
1547 SUMMARY
["ipv6"][0]: {
1548 "summaryAddress": SUMMARY
["ipv6"][0],
1552 "externalRouteCount": 5,
1556 result
= verify_ospf_summary(
1557 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1561 ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name
)
1563 step("Configure Min tag value")
1567 "summary-address": [
1568 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32", "tag": 1}
1573 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1574 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1575 input_dict_summary
= {
1576 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "1"}]}
1580 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1581 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1583 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1586 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1588 step("Verify that show ip ospf summary should show the summaries with tag.")
1590 SUMMARY
["ipv6"][0]: {
1591 "summaryAddress": SUMMARY
["ipv6"][0],
1595 "externalRouteCount": 5,
1599 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1602 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
1604 step("Configure Max Tag Value")
1608 "summary-address": [
1610 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1618 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1619 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1621 input_dict_summary
= {
1622 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "4294967295"}]}
1626 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1627 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1629 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1632 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1635 "Verify that boundary values tags are used for summary route"
1636 " using show ip ospf route command."
1639 SUMMARY
["ipv6"][0]: {
1640 "summaryAddress": SUMMARY
["ipv6"][0],
1644 "externalRouteCount": 5,
1648 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1651 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
1653 step("configure new static route with different tag.")
1654 input_dict_static_rtes_11
= {
1657 {"network": NETWORK_11
["ipv6"], "next_hop": "blackhole", "tag": "88888"}
1661 result
= create_static_routes(tgen
, input_dict_static_rtes_11
)
1662 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1664 step("New tag has not been used by summary address.")
1666 input_dict_summary
= {
1667 "r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0], "tag": "88888"}]}
1671 result
= verify_ospf6_rib(
1672 tgen
, dut
, input_dict_summary
, tag
="88888", expected
=False
1676 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1680 result
= verify_rib(
1691 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
1694 "Verify that boundary values tags are used for summary route"
1695 " using show ip ospf route command."
1698 SUMMARY
["ipv6"][0]: {
1699 "summaryAddress": SUMMARY
["ipv6"][0],
1703 "externalRouteCount": 5,
1707 result
= verify_ospf_summary(
1708 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1712 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
1714 step("Delete the configured summary address")
1718 "summary-address": [
1720 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1729 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1730 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1733 "Verify that 6 routes are advertised to neighbour with 5 routes"
1734 " without any tag, 1 route with tag."
1738 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1739 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1740 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1743 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1745 step("Verify that summary address is flushed from neighbor.")
1748 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1751 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1755 result
= verify_rib(
1756 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1760 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
1762 step("Configure summary first & then configure matching static route.")
1764 input_dict_static_rtes
= {
1767 {"network": NETWORK
["ipv6"], "next_hop": "blackhole", "delete": True},
1768 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole", "delete": True},
1772 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1773 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1778 "summary-address": [
1779 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
1784 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1785 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1787 input_dict_static_rtes
= {
1790 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1791 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1795 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1796 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1798 write_test_footer(tc_name
)
1801 def test_ospfv3_type5_summary_tc46_p0(request
):
1802 """OSPF summarisation with advertise and no advertise option"""
1803 tc_name
= request
.node
.name
1804 write_test_header(tc_name
)
1805 tgen
= get_topogen()
1807 # Don't run this test if we have any failure.
1808 if tgen
.routers_have_failure():
1809 pytest
.skip(tgen
.errors
)
1812 step("Bring up the base config as per the topology")
1813 step("Configure OSPF on all the routers of the topology.")
1814 reset_config_on_routers(tgen
)
1819 "Configure 5 static routes from the same network on R0"
1820 "5 static routes from different networks and redistribute in R0"
1822 input_dict_static_rtes
= {
1825 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1826 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1830 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1831 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1836 step("Verify that routes are learnt on R1.")
1839 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1840 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1841 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1844 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
1847 "Configure External Route summary in R0 to summarise 5"
1848 " routes to one route with no advertise option."
1853 "summary-address": [
1855 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1863 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1864 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1867 "Verify that external routes are summarised to configured summary"
1868 " address on R0 and summary route is not advertised to neighbor as"
1869 " no advertise is configured.."
1872 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1875 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1878 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1882 result
= verify_rib(
1883 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1887 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
1889 step("Verify that show ip ospf summary should show the configured summaries.")
1891 SUMMARY
["ipv6"][0]: {
1892 "summaryAddress": SUMMARY
["ipv6"][0],
1893 "externalRouteCount": 5,
1897 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1900 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
1902 step("Delete the configured summary")
1906 "summary-address": [
1908 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1916 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1917 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1919 step("Summary has 5 sec delay timer, sleep 5 secs...")
1922 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1924 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1927 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1931 result
= verify_rib(
1932 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1936 ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name
)
1938 step("show ip ospf summary should not have any summary address.")
1940 SUMMARY
["ipv6"][0]: {
1941 "summaryAddress": SUMMARY
["ipv6"][0],
1945 "externalRouteCount": 5,
1949 result
= verify_ospf_summary(
1950 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
1954 ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name
)
1956 step("Reconfigure summary with no advertise.")
1960 "summary-address": [
1962 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1970 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1971 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1974 "Verify that external routes are summarised to configured summary"
1975 " address on R0 and summary route is not advertised to neighbor as"
1976 " no advertise is configured.."
1979 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1982 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1985 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1989 result
= verify_rib(
1990 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1994 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
1996 step("Verify that show ip ospf summary should show the configured summaries.")
1998 SUMMARY
["ipv6"][0]: {
1999 "summaryAddress": SUMMARY
["ipv6"][0],
2000 "externalRouteCount": 5,
2004 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2007 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
2010 "Change summary address from no advertise to advertise "
2011 "(summary-address 10.0.0.0 255.255.0.0)"
2017 "summary-address": [
2019 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2027 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2028 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2033 "summary-address": [
2034 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
2039 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2040 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2043 "Verify that external routes are summarised to configured summary "
2044 "address on R0 after 5 secs of delay timer expiry and only one "
2045 "route is sent to R1."
2047 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2050 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2051 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2053 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2056 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
2058 step("Verify that show ip ospf summary should show the summaries.")
2060 SUMMARY
["ipv6"][0]: {
2061 "summaryAddress": SUMMARY
["ipv6"][0],
2065 "externalRouteCount": 5,
2069 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2072 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
2074 step("Verify that originally advertised routes are withdraw from there peer.")
2075 output
= tgen
.gears
["r0"].vtysh_cmd(
2076 "show ipv6 ospf6 database as-external json", isjson
=True
2079 output
= tgen
.gears
["r1"].vtysh_cmd(
2080 "show ipv6 ospf6 database as-external json", isjson
=True
2084 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
2087 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
2090 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2094 result
= verify_rib(
2095 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
2099 ), "Testcase {} : Failed Error: Routes is present in RIB".format(tc_name
)
2101 write_test_footer(tc_name
)
2104 def test_ospfv3_type5_summary_tc48_p0(request
):
2105 """OSPF summarisation with route map modification of metric type."""
2106 tc_name
= request
.node
.name
2107 write_test_header(tc_name
)
2108 tgen
= get_topogen()
2110 # Don't run this test if we have any failure.
2111 if tgen
.routers_have_failure():
2112 pytest
.skip(tgen
.errors
)
2115 step("Bring up the base config as per the topology")
2116 reset_config_on_routers(tgen
)
2121 "Configure 5 static routes from the same network on R0"
2122 "5 static routes from different networks and redistribute in R0"
2124 input_dict_static_rtes
= {
2127 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
2128 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
2132 result
= create_static_routes(tgen
, input_dict_static_rtes
)
2133 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2138 step("Verify that routes are learnt on R1.")
2141 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
2142 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2143 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
2146 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
2148 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
2153 "summary-address": [
2154 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
2159 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2160 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2163 "Verify that external routes are summarised to configured summary "
2164 "address on R0 after 5 secs of delay timer expiry and only one "
2165 "route is sent to R1."
2167 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2170 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2171 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2173 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2176 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
2178 step("Verify that show ip ospf summary should show the summaries.")
2180 SUMMARY
["ipv6"][0]: {
2181 "summaryAddress": SUMMARY
["ipv6"][0],
2185 "externalRouteCount": 5,
2189 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2192 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
2194 step("Verify that originally advertised routes are withdraw from there peer.")
2196 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
2199 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
2202 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2206 result
= verify_rib(
2207 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
2211 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
2214 "Configure route map and & rule to permit configured summary address,"
2215 " redistribute static & connected routes with the route map."
2217 step("Configure prefixlist to permit the static routes, add to route map.")
2218 # Create ip prefix list
2224 {"seqid": 10, "network": "any", "action": "permit"}
2230 result
= create_prefix_lists(tgen
, pfx_list
)
2231 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2240 "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
2246 result
= create_route_maps(tgen
, routemaps
)
2247 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2252 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
2256 result
= create_router_ospf(tgen
, topo
, ospf_red_r1
)
2257 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2260 "Verify that external routes are summarised to configured"
2261 "summary address on R0 and only one route is sent to R1. Verify that "
2262 "show ip ospf summary should show the configure summaries."
2265 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2268 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2269 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2271 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2274 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
2277 SUMMARY
["ipv6"][0]: {
2278 "summaryAddress": SUMMARY
["ipv6"][0],
2282 "externalRouteCount": 5,
2286 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2289 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
2291 step("Configure metric type as 1 in route map.")
2300 "set": {"metric-type": "type-1"},
2306 result
= create_route_maps(tgen
, routemaps
)
2307 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2310 "Verify that external routes(static / connected) are summarised"
2311 " to configured summary address with metric type 2."
2314 SUMMARY
["ipv6"][0]: {
2315 "summaryAddress": SUMMARY
["ipv6"][0],
2319 "externalRouteCount": 5,
2323 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2326 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
2328 step("Un configure metric type from route map.")
2337 "set": {"metric-type": "type-1", "delete": True},
2343 result
= create_route_maps(tgen
, routemaps
)
2344 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2347 "Verify that external routes(static / connected) are summarised"
2348 " to configured summary address with metric type 2."
2351 SUMMARY
["ipv6"][0]: {
2352 "summaryAddress": SUMMARY
["ipv6"][0],
2356 "externalRouteCount": 5,
2360 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2363 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
2365 step("Change rule from permit to deny in prefix list.")
2371 {"seqid": 10, "network": "any", "action": "deny"}
2377 result
= create_prefix_lists(tgen
, pfx_list
)
2378 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2381 "Verify that previously originated summary lsa "
2382 "is withdrawn from the neighbor."
2384 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2387 step("summary route has delay of 5 secs, wait for 5 secs")
2391 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
2394 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2398 result
= verify_rib(
2399 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
2403 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
2405 write_test_footer(tc_name
)
2408 def test_ospfv3_type5_summary_tc51_p2(request
):
2411 verify ospf ASBR summary config and show commands behaviours.
2413 tc_name
= request
.node
.name
2414 write_test_header(tc_name
)
2415 tgen
= get_topogen()
2417 # Don't run this test if we have any failure.
2418 if tgen
.routers_have_failure():
2419 pytest
.skip(tgen
.errors
)
2422 step("Bring up the base config as per the topology")
2423 reset_config_on_routers(tgen
)
2425 step("Configure all the supported OSPF ASBR summary commands on DUT.")
2429 "summary-address": [
2431 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2436 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2441 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2446 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2454 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2455 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2457 step("Configure and re configure all the commands 10 times in a loop.")
2459 for itrate
in range(0, 10):
2463 "summary-address": [
2465 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2470 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2475 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2480 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2488 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2489 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2496 "summary-address": [
2498 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2504 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2510 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2516 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
2525 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2526 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2528 step("Verify the show commands")
2531 SUMMARY
["ipv6"][3]: {
2532 "summaryAddress": SUMMARY
["ipv6"][3],
2536 "externalRouteCount": 0,
2540 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2543 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
2545 write_test_footer(tc_name
)
2548 def test_ospfv3_type5_summary_tc49_p2(request
):
2549 """OSPF summarisation Chaos."""
2550 tc_name
= request
.node
.name
2551 write_test_header(tc_name
)
2552 tgen
= get_topogen()
2554 # Don't run this test if we have any failure.
2555 if tgen
.routers_have_failure():
2556 pytest
.skip(tgen
.errors
)
2559 step("Bring up the base config as per the topology")
2560 reset_config_on_routers(tgen
)
2565 "Configure 5 static routes from the same network on R0"
2566 "5 static routes from different networks and redistribute in R0"
2568 input_dict_static_rtes
= {
2571 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
2572 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
2576 result
= create_static_routes(tgen
, input_dict_static_rtes
)
2577 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2582 step("Verify that routes are learnt on R1.")
2585 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
2586 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2587 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
2590 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
2592 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
2597 "summary-address": [
2598 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
2603 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
2604 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2607 "Verify that external routes are summarised to configured summary "
2608 "address on R0 after 5 secs of delay timer expiry and only one "
2609 "route is sent to R1."
2611 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2614 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2615 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2617 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2620 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
2622 step("Verify that show ip ospf summary should show the summaries.")
2624 SUMMARY
["ipv6"][0]: {
2625 "summaryAddress": SUMMARY
["ipv6"][0],
2629 "externalRouteCount": 5,
2633 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2636 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
2638 step("Verify that originally advertised routes are withdraw from there peer.")
2640 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
2643 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
2646 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2650 result
= verify_rib(
2651 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
2655 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
2657 step("Reload the FRR router")
2658 # stop/start -> restart FRR router and verify
2659 stop_router(tgen
, "r0")
2660 start_router(tgen
, "r0")
2663 "Verify that external routes are summarised to configured summary "
2664 "address on R0 after 5 secs of delay timer expiry and only one "
2665 "route is sent to R1."
2667 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
2670 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
2671 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2673 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
2676 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name
)
2678 step("Verify that show ip ospf summary should show the summaries.")
2680 SUMMARY
["ipv6"][0]: {
2681 "summaryAddress": SUMMARY
["ipv6"][0],
2685 "externalRouteCount": 5,
2689 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
2692 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name
)
2694 step("Verify that originally advertised routes are withdraw from there peer.")
2696 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
2699 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
2702 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2706 result
= verify_rib(
2707 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
2711 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name
)
2713 write_test_footer(tc_name
)
2716 if __name__
== "__main__":
2717 args
= ["-s"] + sys
.argv
[1:]
2718 sys
.exit(pytest
.main(args
))