4 # Copyright (c) 2021 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
6 # ("NetDEF") in this file.
8 # Permission to use, copy, modify, and/or distribute this software
9 # for any purpose with or without fee is hereby granted, provided
10 # that the above copyright notice and this permission notice appear
13 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 """OSPF Summarisation Functionality Automation."""
30 # Save the Current Working Directory to find configuration files.
31 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
32 sys
.path
.append(os
.path
.join(CWD
, "../"))
33 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
35 # pylint: disable=C0413
36 # Import topogen and topotest helpers
37 from lib
.topogen
import Topogen
, get_topogen
39 from time
import sleep
41 # Import topoJson from lib, to create topology and initial configuration
42 from lib
.common_config
import (
47 reset_config_on_routers
,
55 shutdown_bringup_interface
,
60 from lib
.topolog
import logger
61 from lib
.topojson
import build_config_from_json
62 from lib
.ospf
import (
63 verify_ospf6_neighbor
,
91 "ipv4": ["11.0.20.6/32", "11.0.20.7/32"],
92 "ipv6": ["2011:0:20::6/128", "2011:0:20::7/128"],
112 "ipv4": ["11.0.0.0/8", "12.0.0.0/8", "11.0.0.0/24"],
113 "ipv6": ["2011::/32", "2012::/32", "2011::/64", "2011::/24"],
117 Please view in a fixed-width font such as Courier.
119 +R1 +------------+R2 |
128 +R0 +-------------+R3 |
132 1. OSPF summarisation functionality.
133 2. OSPF summarisation with advertise and no advertise option
134 3. OSPF summarisation with route map modification of metric type.
135 4. OSPF CLI Show verify ospf ASBR summary config and show commands behaviours.
136 5. OSPF summarisation Chaos.
140 def setup_module(mod
):
142 Sets up the pytest environment
146 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
147 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
148 logger
.info("=" * 40)
150 logger
.info("Running setup_module to create topology")
152 # This function initiates the topology build with Topogen...
153 json_file
= "{}/ospfv3_asbr_summary_topo1.json".format(CWD
)
154 tgen
= Topogen(json_file
, mod
.__name
__)
156 topo
= tgen
.json_topo
157 # ... and here it calls Mininet initialization functions.
159 # get list of daemons needs to be started for this suite.
160 daemons
= topo_daemons(tgen
, topo
)
162 # Starting topology, create tmp files which are loaded to routers
163 # to start deamons and then start routers
164 start_topology(tgen
, daemons
)
166 # Creating configuration from JSON
167 build_config_from_json(tgen
, topo
)
169 # Don't run this test if we have any failure.
170 if tgen
.routers_have_failure():
171 pytest
.skip(tgen
.errors
)
172 # Api call verify whether OSPF is converged
173 ospf_covergence
= verify_ospf6_neighbor(tgen
, topo
)
174 assert ospf_covergence
is True, "setup_module :Failed \n Error:" " {}".format(
178 logger
.info("Running setup_module() done")
181 def teardown_module(mod
):
183 Teardown the pytest environment.
188 logger
.info("Running teardown_module to delete topology")
192 # Stop toplogy and Remove tmp files
196 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
198 logger
.info("=" * 40)
201 def red_static(dut
, config
=True):
203 Local 'def' for Redstribute static routes inside ospf.
207 * `dut` : DUT on which configs have to be made.
208 * `config` : True or False, True by default for configure, set False for
214 ospf_red
= {dut
: {"ospf6": {"redistribute": [{"redist_type": "static"}]}}}
218 "ospf6": {"redistribute": [{"redist_type": "static", "delete": True}]}
221 result
= create_router_ospf(tgen
, topo
, ospf_red
)
222 assert result
is True, "Testcase : Failed \n Error: {}".format(result
)
225 def red_connected(dut
, config
=True):
227 Local 'def' for Redstribute connected routes inside ospf
231 * `dut` : DUT on which configs have to be made.
232 * `config` : True or False, True by default for configure, set False for
238 ospf_red
= {dut
: {"ospf6": {"redistribute": [{"redist_type": "connected"}]}}}
243 "redistribute": [{"redist_type": "connected", "delete": True}]
247 result
= create_router_ospf(tgen
, topo
, ospf_red
)
248 assert result
is True, "Testcase: Failed \n Error: {}".format(result
)
251 # ##################################
252 # Test cases start here.
253 # ##################################
256 def test_ospfv3_type5_summary_tc42_p0(request
):
257 """OSPF summarisation functionality."""
258 tc_name
= request
.node
.name
259 write_test_header(tc_name
)
262 # Don't run this test if we have any failure.
263 if tgen
.routers_have_failure():
264 pytest
.skip(tgen
.errors
)
267 step("Bring up the base config as per the topology")
268 reset_config_on_routers(tgen
)
273 "Configure 5 static routes from the same network on R0"
274 "5 static routes from different networks and redistribute in R0"
276 input_dict_static_rtes
= {
279 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
280 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
284 result
= create_static_routes(tgen
, input_dict_static_rtes
)
285 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
290 step("Verify that routes are learnt on R1.")
293 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
294 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
295 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
298 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
301 "Configure External Route summary in R0 to summarise 5"
302 " routes to one route. with aggregate timer as 6 sec"
309 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
315 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
316 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
319 "Verify that external routes are summarised to configured summary "
320 "address on R0 after 5 secs of delay timer expiry and only one "
321 "route is sent to R1."
323 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
326 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
327 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
329 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
332 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
334 step("Verify that show ip ospf summary should show the summaries.")
336 SUMMARY
["ipv6"][0]: {
337 "Summary address": SUMMARY
["ipv6"][0],
341 "External route count": 5,
345 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
348 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
350 step("Verify that originally advertised routes are withdraw from there" " peer.")
352 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
355 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
358 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
363 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
367 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
369 step("Delete the configured summary")
375 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
377 "del_aggr_timer": True,
384 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
385 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
387 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
389 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
392 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
397 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
401 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
405 step("show ip ospf summary should not have any summary address.")
407 SUMMARY
["ipv6"][0]: {
408 "Summary address": SUMMARY
["ipv6"][0],
412 "External route count": 5,
416 result
= verify_ospf_summary(
417 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
421 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
424 step("All 5 routes are advertised after deletion of configured summary.")
426 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
427 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
429 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
432 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
434 step("configure the summary again and delete static routes .")
439 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
444 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
445 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
448 SUMMARY
["ipv6"][0]: {
449 "Summary address": SUMMARY
["ipv6"][0],
453 "External route count": 5,
457 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
460 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
465 {"network": NETWORK
["ipv6"], "next_hop": "blackhole", "delete": True}
469 result
= create_static_routes(tgen
, input_dict
)
470 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
472 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
473 step("Verify that summary route is withdrawn from R1.")
476 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
479 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
484 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
488 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
490 step("Add back static routes.")
491 input_dict_static_rtes
= {
492 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
494 result
= create_static_routes(tgen
, input_dict_static_rtes
)
495 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
498 "Verify that external routes are summarised to configured summary"
499 " address on R0 and only one route is sent to R1."
503 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
, expected
=False)
506 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
511 tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
, expected
=False
515 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
517 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
520 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
521 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
523 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
526 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
528 step("Verify that show ip ospf summary should show configure summaries.")
531 SUMMARY
["ipv6"][0]: {
532 "Summary address": SUMMARY
["ipv6"][0],
536 "External route count": 5,
540 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
543 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
545 step("Configure new static route which is matching configured summary.")
546 input_dict_static_rtes
= {
548 "static_routes": [{"network": NETWORK_11
["ipv6"], "next_hop": "blackhole"}]
551 result
= create_static_routes(tgen
, input_dict_static_rtes
)
552 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
554 # step("verify that summary lsa is not refreshed.")
555 # show ip ospf database command is not working, waiting for DEV fix.
557 step("Delete one of the static route.")
558 input_dict_static_rtes
= {
561 {"network": NETWORK_11
["ipv6"], "next_hop": "blackhole", "delete": True}
565 result
= create_static_routes(tgen
, input_dict_static_rtes
)
566 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
568 # step("verify that summary lsa is not refreshed.")
569 # show ip ospf database command is not working, waiting for DEV fix.
571 # step("Verify that deleted static route is removed from ospf LSDB.")
572 # show ip ospf database command is not working, waiting for DEV fix.
575 "Configure redistribute connected and configure ospf external"
576 " summary address to summarise the connected routes."
581 clear_ospf(tgen
, dut
, ospf
="ospf6")
583 ip
= topo
["routers"]["r0"]["links"]["r3"]["ipv6"]
585 ip_net
= str(ipaddress
.ip_interface(u
"{}".format(ip
)).network
)
589 "summary-address": [{"prefix": ip_net
.split("/")[0], "mask": "8"}]
593 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
594 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
597 "Verify that external routes are summarised to configured "
598 "summary address on R0 and only one route is sent to R1."
601 input_dict_summary
= {"r0": {"static_routes": [{"network": "fd00::/64"}]}}
603 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
604 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
606 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
609 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
611 step("Shut one of the interface")
612 intf
= topo
["routers"]["r0"]["links"]["r3-link0"]["interface"]
613 shutdown_bringup_interface(tgen
, dut
, intf
, False)
615 # step("verify that summary lsa is not refreshed.")
616 # show ip ospf database command is not working, waiting for DEV fix.
618 # step("Verify that deleted connected route is removed from ospf LSDB.")
619 # show ip ospf database command is not working, waiting for DEV fix.
621 step("Un do shut the interface")
622 shutdown_bringup_interface(tgen
, dut
, intf
, True)
624 # step("verify that summary lsa is not refreshed.")
625 # show ip ospf database command is not working, waiting for DEV fix.
627 # step("Verify that deleted connected route is removed from ospf LSDB.")
628 # show ip ospf database command is not working, waiting for DEV fix.
630 step("Delete OSPF process.")
631 ospf_del
= {"r0": {"ospf6": {"delete": True}}}
632 result
= create_router_ospf(tgen
, topo
, ospf_del
)
633 assert result
is True, "Testcase : Failed \n Error: {}".format(result
)
635 step("Reconfigure ospf process with summary")
636 reset_config_on_routers(tgen
)
638 input_dict_static_rtes
= {
641 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
642 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
646 result
= create_static_routes(tgen
, input_dict_static_rtes
)
647 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
656 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
661 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
662 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
664 "Verify that external routes are summarised to configured summary "
665 "address on R0 and only one route is sent to R1."
669 SUMMARY
["ipv6"][0]: {
670 "Summary address": SUMMARY
["ipv6"][0],
674 "External route count": 5,
678 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
681 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
683 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
686 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
687 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
689 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
692 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
698 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
703 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
704 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
706 # step("verify that summary lsa is not refreshed.")
707 # show ip ospf database command is not working, waiting for DEV fix.
709 step("Delete the redistribute command in ospf.")
711 red_connected(dut
, config
=False)
712 red_static(dut
, config
=False)
714 step("Verify that summary route is withdrawn from the peer.")
717 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
720 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
725 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
729 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
736 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
744 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
745 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
747 write_test_footer(tc_name
)
750 def test_ospfv3_type5_summary_tc46_p0(request
):
751 """OSPF summarisation with advertise and no advertise option"""
752 tc_name
= request
.node
.name
753 write_test_header(tc_name
)
756 # Don't run this test if we have any failure.
757 if tgen
.routers_have_failure():
758 pytest
.skip(tgen
.errors
)
761 step("Bring up the base config as per the topology")
762 step("Configure OSPF on all the routers of the topology.")
763 reset_config_on_routers(tgen
)
768 "Configure 5 static routes from the same network on R0"
769 "5 static routes from different networks and redistribute in R0"
771 input_dict_static_rtes
= {
774 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
775 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
779 result
= create_static_routes(tgen
, input_dict_static_rtes
)
780 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
785 step("Verify that routes are learnt on R1.")
788 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
789 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
790 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
793 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
796 "Configure External Route summary in R0 to summarise 5"
797 " routes to one route with no advertise option."
804 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
812 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
813 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
816 "Verify that external routes are summarised to configured summary"
817 " address on R0 and summary route is not advertised to neighbor as"
818 " no advertise is configured.."
821 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
824 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
827 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
832 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
836 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
838 step("Verify that show ip ospf summary should show the " "configured summaries.")
840 SUMMARY
["ipv6"][0]: {
841 "Summary address": SUMMARY
["ipv6"][0],
842 "External route count": 5,
846 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
849 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
851 step("Delete the configured summary")
857 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
865 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
866 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
868 step("Summary has 5 sec delay timer, sleep 5 secs...")
871 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
873 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
876 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
881 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
885 ), "Testcase {} : Failed" "Error: Summary Route still present in RIB".format(
889 step("show ip ospf summary should not have any summary address.")
891 SUMMARY
["ipv6"][0]: {
892 "Summary address": SUMMARY
["ipv6"][0],
896 "External route count": 5,
900 result
= verify_ospf_summary(
901 tgen
, topo
, dut
, input_dict
, ospf
="ospf6", expected
=False
905 ), "Testcase {} : Failed" "Error: Summary still present in DB".format(tc_name
)
907 step("Reconfigure summary with no advertise.")
913 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
921 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
922 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
925 "Verify that external routes are summarised to configured summary"
926 " address on R0 and summary route is not advertised to neighbor as"
927 " no advertise is configured.."
930 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
933 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
936 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
941 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
945 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
947 step("Verify that show ip ospf summary should show the " "configured summaries.")
949 SUMMARY
["ipv6"][0]: {
950 "Summary address": SUMMARY
["ipv6"][0],
951 "External route count": 5,
955 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
958 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
961 "Change summary address from no advertise to advertise "
962 "(summary-address 10.0.0.0 255.255.0.0)"
970 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
978 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
979 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
985 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
990 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
991 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
994 "Verify that external routes are summarised to configured summary "
995 "address on R0 after 5 secs of delay timer expiry and only one "
996 "route is sent to R1."
998 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1001 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1002 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1004 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1007 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1009 step("Verify that show ip ospf summary should show the summaries.")
1011 SUMMARY
["ipv6"][0]: {
1012 "Summary address": SUMMARY
["ipv6"][0],
1013 "Metric-type": "E2",
1016 "External route count": 5,
1020 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1023 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1025 step("Verify that originally advertised routes are withdraw from there" " peer.")
1027 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
1030 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1033 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1037 result
= verify_rib(
1038 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
1042 ), "Testcase {} : Failed" "Error: Routes is present in RIB".format(tc_name
)
1044 write_test_footer(tc_name
)
1047 def test_ospfv3_type5_summary_tc48_p0(request
):
1048 """OSPF summarisation with route map modification of metric type."""
1049 tc_name
= request
.node
.name
1050 write_test_header(tc_name
)
1051 tgen
= get_topogen()
1053 # Don't run this test if we have any failure.
1054 if tgen
.routers_have_failure():
1055 pytest
.skip(tgen
.errors
)
1058 step("Bring up the base config as per the topology")
1059 reset_config_on_routers(tgen
)
1064 "Configure 5 static routes from the same network on R0"
1065 "5 static routes from different networks and redistribute in R0"
1067 input_dict_static_rtes
= {
1070 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1071 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1075 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1076 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1081 step("Verify that routes are learnt on R1.")
1084 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1085 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1086 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1089 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1092 "Configure External Route summary in R0 to summarise 5" " routes to one route."
1098 "summary-address": [
1099 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
1104 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1105 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1108 "Verify that external routes are summarised to configured summary "
1109 "address on R0 after 5 secs of delay timer expiry and only one "
1110 "route is sent to R1."
1112 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1115 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1116 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1118 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1121 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1123 step("Verify that show ip ospf summary should show the summaries.")
1125 SUMMARY
["ipv6"][0]: {
1126 "Summary address": SUMMARY
["ipv6"][0],
1127 "Metric-type": "E2",
1130 "External route count": 5,
1134 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1137 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1139 step("Verify that originally advertised routes are withdraw from there" " peer.")
1141 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
1144 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1147 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1151 result
= verify_rib(
1152 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
1156 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1159 "Configure route map and & rule to permit configured summary address,"
1160 " redistribute static & connected routes with the route map."
1162 step("Configure prefixlist to permit the static routes, add to route map.")
1163 # Create ip prefix list
1169 {"seqid": 10, "network": "any", "action": "permit"}
1175 result
= create_prefix_lists(tgen
, pfx_list
)
1176 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1185 "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
1191 result
= create_route_maps(tgen
, routemaps
)
1192 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1197 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
1201 result
= create_router_ospf(tgen
, topo
, ospf_red_r1
)
1202 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1205 "Verify that external routes are summarised to configured"
1206 "summary address on R0 and only one route is sent to R1. Verify that "
1207 "show ip ospf summary should show the configure summaries."
1210 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1213 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1214 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1216 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1219 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1222 SUMMARY
["ipv6"][0]: {
1223 "Summary address": SUMMARY
["ipv6"][0],
1224 "Metric-type": "E2",
1227 "External route count": 5,
1231 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1234 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1236 step("Configure metric type as 1 in route map.")
1245 "set": {"metric-type": "type-1"},
1251 result
= create_route_maps(tgen
, routemaps
)
1252 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1255 "Verify that external routes(static / connected) are summarised"
1256 " to configured summary address with metric type 2."
1259 SUMMARY
["ipv6"][0]: {
1260 "Summary address": SUMMARY
["ipv6"][0],
1261 "Metric-type": "E2",
1264 "External route count": 5,
1268 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1271 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1273 step("Un configure metric type from route map.")
1282 "set": {"metric-type": "type-1", "delete": True},
1288 result
= create_route_maps(tgen
, routemaps
)
1289 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1292 "Verify that external routes(static / connected) are summarised"
1293 " to configured summary address with metric type 2."
1296 SUMMARY
["ipv6"][0]: {
1297 "Summary address": SUMMARY
["ipv6"][0],
1298 "Metric-type": "E2",
1301 "External route count": 5,
1305 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1308 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1310 step("Change rule from permit to deny in prefix list.")
1316 {"seqid": 10, "network": "any", "action": "deny"}
1322 result
= create_prefix_lists(tgen
, pfx_list
)
1323 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1326 "Verify that previously originated summary lsa "
1327 "is withdrawn from the neighbor."
1329 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1332 step("summary route has delay of 5 secs, wait for 5 secs")
1336 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
, expected
=False)
1339 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1343 result
= verify_rib(
1344 tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
, expected
=False
1348 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1350 write_test_footer(tc_name
)
1353 def test_ospfv3_type5_summary_tc51_p2(request
):
1356 verify ospf ASBR summary config and show commands behaviours.
1358 tc_name
= request
.node
.name
1359 write_test_header(tc_name
)
1360 tgen
= get_topogen()
1362 # Don't run this test if we have any failure.
1363 if tgen
.routers_have_failure():
1364 pytest
.skip(tgen
.errors
)
1367 step("Bring up the base config as per the topology")
1368 reset_config_on_routers(tgen
)
1370 step("Configure all the supported OSPF ASBR summary commands on DUT.")
1374 "summary-address": [
1376 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1381 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1386 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1391 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1399 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1400 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1402 step("Configure and re configure all the commands 10 times in a loop.")
1404 for itrate
in range(0, 10):
1408 "summary-address": [
1410 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1415 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1420 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1425 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1433 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1434 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1441 "summary-address": [
1443 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1449 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1455 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1461 "prefix": SUMMARY
["ipv6"][0].split("/")[0],
1470 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1471 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1473 step("Verify the show commands")
1476 SUMMARY
["ipv6"][3]: {
1477 "Summary address": SUMMARY
["ipv6"][3],
1478 "Metric-type": "E2",
1481 "External route count": 0,
1485 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1488 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1490 write_test_footer(tc_name
)
1493 def test_ospfv3_type5_summary_tc49_p2(request
):
1494 """OSPF summarisation Chaos."""
1495 tc_name
= request
.node
.name
1496 write_test_header(tc_name
)
1497 tgen
= get_topogen()
1499 # Don't run this test if we have any failure.
1500 if tgen
.routers_have_failure():
1501 pytest
.skip(tgen
.errors
)
1504 step("Bring up the base config as per the topology")
1505 reset_config_on_routers(tgen
)
1510 "Configure 5 static routes from the same network on R0"
1511 "5 static routes from different networks and redistribute in R0"
1513 input_dict_static_rtes
= {
1516 {"network": NETWORK
["ipv6"], "next_hop": "blackhole"},
1517 {"network": NETWORK2
["ipv6"], "next_hop": "blackhole"},
1521 result
= create_static_routes(tgen
, input_dict_static_rtes
)
1522 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1527 step("Verify that routes are learnt on R1.")
1530 result
= verify_ospf6_rib(tgen
, dut
, input_dict_static_rtes
)
1531 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1532 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_static_rtes
, protocol
=protocol
)
1535 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1538 "Configure External Route summary in R0 to summarise 5" " routes to one route."
1544 "summary-address": [
1545 {"prefix": SUMMARY
["ipv6"][0].split("/")[0], "mask": "32"}
1550 result
= create_router_ospf(tgen
, topo
, ospf_summ_r1
)
1551 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1554 "Verify that external routes are summarised to configured summary "
1555 "address on R0 after 5 secs of delay timer expiry and only one "
1556 "route is sent to R1."
1558 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1561 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1562 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1564 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1567 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1569 step("Verify that show ip ospf summary should show the summaries.")
1571 SUMMARY
["ipv6"][0]: {
1572 "Summary address": SUMMARY
["ipv6"][0],
1573 "Metric-type": "E2",
1576 "External route count": 5,
1580 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1583 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1585 step("Verify that originally advertised routes are withdraw from there" " peer.")
1587 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
1590 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1593 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1597 result
= verify_rib(
1598 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
1602 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1604 step("Reload the FRR router")
1605 # stop/start -> restart FRR router and verify
1606 stop_router(tgen
, "r0")
1607 start_router(tgen
, "r0")
1610 "Verify that external routes are summarised to configured summary "
1611 "address on R0 after 5 secs of delay timer expiry and only one "
1612 "route is sent to R1."
1614 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1617 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1618 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1620 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1623 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1625 step("Verify that show ip ospf summary should show the summaries.")
1627 SUMMARY
["ipv6"][0]: {
1628 "Summary address": SUMMARY
["ipv6"][0],
1629 "Metric-type": "E2",
1632 "External route count": 5,
1636 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1639 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1641 step("Verify that originally advertised routes are withdraw from there" " peer.")
1643 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
1646 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1649 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1653 result
= verify_rib(
1654 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
1658 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1660 step("Kill OSPF6d daemon on R0.")
1661 kill_router_daemons(tgen
, "r0", ["ospf6d"])
1663 step("Bring up OSPF6d daemon on R0.")
1664 start_router_daemons(tgen
, "r0", ["ospf6d"])
1666 step("Verify OSPF neighbors are up after bringing back ospf6d in R0")
1667 # Api call verify whether OSPF is converged
1668 ospf_covergence
= verify_ospf6_neighbor(tgen
, topo
)
1669 assert ospf_covergence
is True, "setup_module :Failed \n Error:" " {}".format(
1674 "Verify that external routes are summarised to configured summary "
1675 "address on R0 after 5 secs of delay timer expiry and only one "
1676 "route is sent to R1."
1678 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1681 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1682 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1684 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1687 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1689 step("Verify that show ip ospf summary should show the summaries.")
1691 SUMMARY
["ipv6"][0]: {
1692 "Summary address": SUMMARY
["ipv6"][0],
1693 "Metric-type": "E2",
1696 "External route count": 5,
1700 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1703 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1705 step("Verify that originally advertised routes are withdraw from there" " peer.")
1707 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
1710 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1713 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1717 result
= verify_rib(
1718 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
1722 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1724 step("restart zebrad")
1725 kill_router_daemons(tgen
, "r0", ["zebra"])
1727 step("Bring up zebra daemon on R0.")
1728 start_router_daemons(tgen
, "r0", ["zebra"])
1731 "Verify that external routes are summarised to configured summary "
1732 "address on R0 after 5 secs of delay timer expiry and only one "
1733 "route is sent to R1."
1735 input_dict_summary
= {"r0": {"static_routes": [{"network": SUMMARY
["ipv6"][0]}]}}
1738 result
= verify_ospf6_rib(tgen
, dut
, input_dict_summary
)
1739 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1741 result
= verify_rib(tgen
, "ipv6", dut
, input_dict_summary
, protocol
=protocol
)
1744 ), "Testcase {} : Failed" "Error: Routes is missing in RIB".format(tc_name
)
1746 step("Verify that show ip ospf summary should show the summaries.")
1748 SUMMARY
["ipv6"][0]: {
1749 "Summary address": SUMMARY
["ipv6"][0],
1750 "Metric-type": "E2",
1753 "External route count": 5,
1757 result
= verify_ospf_summary(tgen
, topo
, dut
, input_dict
, ospf
="ospf6")
1760 ), "Testcase {} : Failed" "Error: Summary missing in OSPF DB".format(tc_name
)
1762 step("Verify that originally advertised routes are withdraw from there" " peer.")
1764 "r0": {"static_routes": [{"network": NETWORK
["ipv6"], "next_hop": "blackhole"}]}
1767 result
= verify_ospf6_rib(tgen
, dut
, input_dict
, expected
=False)
1770 ), "Testcase {} : Failed \n Error: " "Routes still present in OSPF RIB {}".format(
1774 result
= verify_rib(
1775 tgen
, "ipv6", dut
, input_dict
, protocol
=protocol
, expected
=False
1779 ), "Testcase {} : Failed" "Error: Routes still present in RIB".format(tc_name
)
1781 write_test_footer(tc_name
)
1784 if __name__
== "__main__":
1785 args
= ["-s"] + sys
.argv
[1:]
1786 sys
.exit(pytest
.main(args
))