]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/ospf_basic_functionality/test_ospf_single_area.py
2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2020 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
7 # ("NetDEF") in this file.
11 """OSPF Basic Functionality Automation."""
16 from copy
import deepcopy
17 from ipaddress
import IPv4Address
18 from lib
.topotest
import frr_unicode
20 # Save the Current Working Directory to find configuration files.
21 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
22 sys
.path
.append(os
.path
.join(CWD
, "../"))
23 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
25 # pylint: disable=C0413
26 # Import topogen and topotest helpers
27 from lib
.topogen
import Topogen
, get_topogen
30 # Import topoJson from lib, to create topology and initial configuration
31 from lib
.common_config
import (
35 reset_config_on_routers
,
37 create_interfaces_cfg
,
39 from lib
.topolog
import logger
40 from lib
.topojson
import build_config_from_json
42 from lib
.ospf
import (
44 config_ospf_interface
,
47 verify_ospf_interface
,
50 pytestmark
= [pytest
.mark
.ospfd
, pytest
.mark
.staticd
]
57 Please view in a fixed-width font such as Courier.
59 +R1 +------------+R2 |
68 +R0 +-------------+R3 |
72 1. OSPF IFSM -Verify state change events on p2p network.
73 2. OSPF Timers - Verify OSPF interface timer hello interval functionality
74 3. OSPF Timers - Verify OSPF interface timer dead interval functionality
75 4. Verify ospf show commands with json output.
76 5. Verify NFSM events when ospf nbr changes with different MTU values.
80 def setup_module(mod
):
82 Sets up the pytest environment
86 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
87 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
90 logger
.info("Running setup_module to create topology")
92 # This function initiates the topology build with Topogen...
93 json_file
= "{}/ospf_single_area.json".format(CWD
)
94 tgen
= Topogen(json_file
, mod
.__name
__)
97 # ... and here it calls Mininet initialization functions.
99 # Starting topology, create tmp files which are loaded to routers
100 # to start daemons and then start routers
103 # Creating configuration from JSON
104 build_config_from_json(tgen
, topo
)
106 # Don't run this test if we have any failure.
107 if tgen
.routers_have_failure():
108 pytest
.skip(tgen
.errors
)
110 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
)
111 assert ospf_covergence
is True, "setup_module :Failed \n Error {}".format(
115 logger
.info("Running setup_module() done")
118 def teardown_module(mod
):
120 Teardown the pytest environment.
125 logger
.info("Running teardown_module to delete topology")
129 # Stop toplogy and Remove tmp files
133 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
135 logger
.info("=" * 40)
138 # ##################################
139 # Test cases start here.
140 # ##################################
143 def test_ospf_p2p_tc3_p0(request
):
144 """OSPF IFSM -Verify state change events on p2p network."""
145 tc_name
= request
.node
.name
146 write_test_header(tc_name
)
149 # Don't run this test if we have any failure.
150 if tgen
.routers_have_failure():
151 pytest
.skip(tgen
.errors
)
154 step("Bring up the base config as per the topology")
155 reset_config_on_routers(tgen
)
157 "Verify that OSPF is subscribed to multi cast services "
158 "(All SPF, all DR Routers)."
160 step("Verify that interface is enabled in ospf.")
161 step("Verify that config is successful.")
166 "r3": {"ospf": {"mcastMemberOspfAllRouters": True, "ospfEnabled": True}}
170 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
171 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
173 step("Delete the ip address")
178 "ipv4": topo
["routers"]["r0"]["links"]["r3"]["ipv4"],
179 "interface": topo
["routers"]["r0"]["links"]["r3"]["interface"],
186 result
= create_interfaces_cfg(tgen
, topo1
)
187 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
189 step("Change the ip on the R0 interface")
191 topo_modify_change_ip
= deepcopy(topo
)
192 intf_ip
= topo_modify_change_ip
["routers"]["r0"]["links"]["r3"]["ipv4"]
193 topo_modify_change_ip
["routers"]["r0"]["links"]["r3"]["ipv4"] = str(
194 IPv4Address(frr_unicode(intf_ip
.split("/")[0])) + 3
195 ) + "/{}".format(intf_ip
.split("/")[1])
197 build_config_from_json(tgen
, topo_modify_change_ip
, save_bkup
=False)
198 step("Verify that interface is enabled in ospf.")
205 "ipAddress": topo_modify_change_ip
["routers"]["r0"]["links"][
207 ]["ipv4"].split("/")[0],
208 "ipAddressPrefixlen": int(
209 topo_modify_change_ip
["routers"]["r0"]["links"]["r3"][
218 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
219 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
221 step("Modify the mask on the R0 interface")
222 ip_addr
= topo_modify_change_ip
["routers"]["r0"]["links"]["r3"]["ipv4"]
223 mask
= topo_modify_change_ip
["routers"]["r0"]["links"]["r3"]["ipv4"]
224 step("Delete the ip address")
230 "interface": topo
["routers"]["r0"]["links"]["r3"]["interface"],
237 result
= create_interfaces_cfg(tgen
, topo1
)
238 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
240 step("Change the ip on the R0 interface")
242 topo_modify_change_ip
= deepcopy(topo
)
243 intf_ip
= topo_modify_change_ip
["routers"]["r0"]["links"]["r3"]["ipv4"]
244 topo_modify_change_ip
["routers"]["r0"]["links"]["r3"]["ipv4"] = str(
245 IPv4Address(frr_unicode(intf_ip
.split("/")[0])) + 3
246 ) + "/{}".format(int(intf_ip
.split("/")[1]) + 1)
248 build_config_from_json(tgen
, topo_modify_change_ip
, save_bkup
=False)
249 step("Verify that interface is enabled in ospf.")
256 "ipAddress": topo_modify_change_ip
["routers"]["r0"]["links"][
258 ]["ipv4"].split("/")[0],
259 "ipAddressPrefixlen": int(
260 topo_modify_change_ip
["routers"]["r0"]["links"]["r3"][
269 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
270 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
276 "ipv4": topo_modify_change_ip
["routers"]["r0"]["links"]["r3"][
279 "interface": topo_modify_change_ip
["routers"]["r0"]["links"]["r3"][
288 result
= create_interfaces_cfg(tgen
, topo1
)
289 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
291 build_config_from_json(tgen
, topo
, save_bkup
=False)
293 step("Change the area id on the interface")
298 "interface": topo
["routers"]["r0"]["links"]["r3"]["interface"],
299 "ospf": {"area": "0.0.0.0"},
306 result
= create_interfaces_cfg(tgen
, input_dict
)
307 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
313 "interface": topo
["routers"]["r0"]["links"]["r3"]["interface"],
314 "ospf": {"area": "0.0.0.1"},
320 result
= create_interfaces_cfg(tgen
, input_dict
)
321 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
322 step("Verify that interface is enabled in ospf.")
325 "r0": {"links": {"r3": {"ospf": {"area": "0.0.0.1", "ospfEnabled": True}}}}
327 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
328 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
334 "interface": topo
["routers"]["r0"]["links"]["r3"]["interface"],
335 "ospf": {"area": "0.0.0.1"},
342 result
= create_interfaces_cfg(tgen
, input_dict
)
343 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
349 "interface": topo
["routers"]["r0"]["links"]["r3"]["interface"],
350 "ospf": {"area": "0.0.0.0"},
356 result
= create_interfaces_cfg(tgen
, input_dict
)
357 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
359 # Api call verify whether BGP is converged
360 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
)
361 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
365 write_test_footer(tc_name
)
368 def test_ospf_hello_tc10_p0(request
):
372 Verify OSPF interface timer hello interval functionality
374 tc_name
= request
.node
.name
375 write_test_header(tc_name
)
378 # Don't run this test if we have any failure.
379 if tgen
.routers_have_failure():
380 pytest
.skip(tgen
.errors
)
383 step("Bring up the base config as per the topology")
384 reset_config_on_routers(tgen
)
386 step("modify hello timer from default value to some other value on r1")
392 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
393 "ospf": {"hello_interval": 11, "dead_interval": 12},
399 result
= create_interfaces_cfg(tgen
, topo1
)
400 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
403 "verify that new timer value is configured and applied using "
404 "the show ip ospf interface command."
409 "links": {"r0": {"ospf": {"timerMsecs": 11 * 1000, "timerDeadSecs": 12}}}
412 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
413 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
415 step("modify hello timer from default value to r1 hello timer on r2")
421 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
422 "ospf": {"hello_interval": 11, "dead_interval": 12},
428 result
= create_interfaces_cfg(tgen
, topo1
)
429 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
431 step("verify that new timer value is configured.")
434 "links": {"r1": {"ospf": {"timerMsecs": 11 * 1000, "timerDeadSecs": 12}}}
438 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
439 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
441 step("verify that ospf neighbours are full")
442 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
, dut
=dut
)
443 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
447 step("reconfigure the default hello timer value to default on r1 and r2")
453 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
454 "ospf": {"hello_interval": 10, "dead_interval": 40},
460 result
= create_interfaces_cfg(tgen
, topo1
)
461 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
467 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
468 "ospf": {"hello_interval": 10, "dead_interval": 40},
474 result
= create_interfaces_cfg(tgen
, topo1
)
475 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
477 step("verify that new timer value is configured.")
480 "links": {"r1": {"ospf": {"timerMsecs": 10 * 1000, "timerDeadSecs": 40}}}
484 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
485 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
487 step("verify that ospf neighbours are full")
488 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
, dut
=dut
)
489 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
493 step("reconfigure the default hello timer value to default on r1 and r2")
499 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
500 "ospf": {"hello_interval": 10, "dead_interval": 40},
506 result
= create_interfaces_cfg(tgen
, topo1
)
507 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
513 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
514 "ospf": {"hello_interval": 10, "dead_interval": 40},
520 result
= create_interfaces_cfg(tgen
, topo1
)
521 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
523 step("verify that new timer value is configured.")
526 "links": {"r1": {"ospf": {"timerMsecs": 10 * 1000, "timerDeadSecs": 40}}}
530 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
531 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
533 step("verify that ospf neighbours are full")
534 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
, dut
=dut
)
535 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
539 step("configure hello timer = 1 on r1 and r2")
544 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
545 "ospf": {"hello_interval": 1, "dead_interval": 4},
551 result
= create_interfaces_cfg(tgen
, topo1
)
552 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
558 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
559 "ospf": {"hello_interval": 1, "dead_interval": 4},
565 result
= create_interfaces_cfg(tgen
, topo1
)
566 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
568 step("verify that new timer value is configured.")
570 "r0": {"links": {"r1": {"ospf": {"timerMsecs": 1 * 1000, "timerDeadSecs": 4}}}}
573 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
574 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
576 step("verify that ospf neighbours are full")
577 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
, dut
=dut
)
578 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
582 write_test_footer(tc_name
)
585 def test_ospf_show_p1(request
):
586 """Verify ospf show commands with json output."""
587 tc_name
= request
.node
.name
588 write_test_header(tc_name
)
591 # Don't run this test if we have any failure.
592 if tgen
.routers_have_failure():
593 pytest
.skip(tgen
.errors
)
596 step(" Bring up the base config as per the topology")
597 reset_config_on_routers(tgen
)
599 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
)
600 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
610 "ifFlags": "<UP,BROADCAST,RUNNING,MULTICAST>",
612 "ipAddressPrefixlen": 24,
613 "ospfIfType": "Broadcast",
615 "networkType": "BROADCAST",
617 "transmitDelaySecs": 1,
620 "mcastMemberOspfAllRouters": True,
624 "timerRetransmitSecs": 5,
626 "nbrAdjacentCount": 1,
632 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
633 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
636 ip
= topo
["routers"]["r0"]["links"]["r3"]["ipv4"]
637 ip_net
= str(ipaddress
.ip_interface(u
"{}".format(ip
)).network
)
638 nh
= topo
["routers"]["r0"]["links"]["r1"]["ipv4"].split("/")[0]
640 "r1": {"static_routes": [{"network": ip_net
, "no_of_ip": 1, "routeType": "N"}]}
644 result
= verify_ospf_rib(tgen
, dut
, input_dict
, next_hop
=nh
)
645 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
647 write_test_footer(tc_name
)
650 def test_ospf_dead_tc11_p0(request
):
654 Verify OSPF interface timer dead interval functionality
656 tc_name
= request
.node
.name
657 write_test_header(tc_name
)
660 # Don't run this test if we have any failure.
661 if tgen
.routers_have_failure():
662 pytest
.skip(tgen
.errors
)
665 step("Bring up the base config as per the topology")
666 reset_config_on_routers(tgen
)
668 step("modify dead interval from default value to some other value on r1")
674 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
675 "ospf": {"hello_interval": 12, "dead_interval": 48},
681 result
= create_interfaces_cfg(tgen
, topo1
)
682 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
685 "verify that new timer value is configured and applied using "
686 "the show ip ospf interface command."
689 input_dict
= {"r1": {"links": {"r0": {"ospf": {"timerDeadSecs": 48}}}}}
690 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
691 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
693 step("modify dead interval from default value to r1 dead interval timer on r2")
699 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
700 "ospf": {"dead_interval": 48, "hello_interval": 12},
706 result
= create_interfaces_cfg(tgen
, topo1
)
707 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
709 step("verify that new timer value is configured.")
710 input_dict
= {"r0": {"links": {"r1": {"ospf": {"timerDeadSecs": 48}}}}}
712 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
713 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
715 step("verify that ospf neighbours are full")
716 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
, dut
=dut
)
717 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
721 step("reconfigure the default dead interval timer value to default on r1 and r2")
726 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
727 "ospf": {"dead_interval": 40},
733 result
= create_interfaces_cfg(tgen
, topo1
)
734 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
740 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
741 "ospf": {"dead_interval": 40},
747 result
= create_interfaces_cfg(tgen
, topo1
)
748 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
750 step("verify that new timer value is configured.")
751 input_dict
= {"r0": {"links": {"r1": {"ospf": {"timerDeadSecs": 40}}}}}
753 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
754 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
756 step("verify that ospf neighbours are full")
757 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
, dut
=dut
)
758 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
762 step(" Configure dead timer = 65535 on r1 and r2")
768 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
769 "ospf": {"dead_interval": 65535},
775 result
= create_interfaces_cfg(tgen
, topo1
)
776 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
782 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
783 "ospf": {"dead_interval": 65535},
789 result
= create_interfaces_cfg(tgen
, topo1
)
790 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
792 step("verify that new timer value is configured.")
793 input_dict
= {"r0": {"links": {"r1": {"ospf": {"timerDeadSecs": 65535}}}}}
795 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
796 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
798 step("verify that ospf neighbours are full")
799 ospf_covergence
= verify_ospf_neighbor(tgen
, topo
, dut
=dut
)
800 assert ospf_covergence
is True, "Testcase Failed \n Error {}".format(
804 step(" Try configuring timer values outside range for example 65536")
809 "interface": topo
["routers"]["r0"]["links"]["r1"]["interface"],
810 "ospf": {"dead_interval": 65536},
816 result
= create_interfaces_cfg(tgen
, topo1
)
817 assert result
is not True, "Testcase {} : Failed \n Error: {}".format(
821 step("Unconfigure the dead timer from the interface from r1 and r2.")
827 "interface": topo
["routers"]["r1"]["links"]["r0"]["interface"],
828 "ospf": {"dead_interval": 65535},
835 result
= create_interfaces_cfg(tgen
, topo1
)
836 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
838 step("Verify that timer value is deleted from intf & set to default value 40 sec.")
839 input_dict
= {"r1": {"links": {"r0": {"ospf": {"timerDeadSecs": 40}}}}}
841 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
842 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
844 write_test_footer(tc_name
)
847 def test_ospf_tc4_mtu_ignore_p0(request
):
849 OSPF NFSM - MTU change
851 Verify NFSM events when ospf nbr changes with different MTU values
853 tc_name
= request
.node
.name
854 write_test_header(tc_name
)
857 # Don't run this test if we have any failure.
858 if tgen
.routers_have_failure():
859 pytest
.skip(tgen
.errors
)
862 step(" Bring up the base config as per the topology")
863 step("Configure OSPF on all the routers of the topology.")
864 step("Verify that OSPF neighbors are FULL.")
865 reset_config_on_routers(tgen
)
866 result
= verify_ospf_neighbor(tgen
, topo
)
867 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
870 "Modify the MTU to non default Value on R0 to R1 interface. "
871 "Reset ospf neighbors on R0."
874 rtr0
= tgen
.routers()["r0"]
875 rtr1
= tgen
.routers()["r1"]
877 r0_r1_intf
= topo
["routers"]["r0"]["links"]["r1"]["interface"]
878 r1_r0_intf
= topo
["routers"]["r1"]["links"]["r0"]["interface"]
880 rtr0
.run("ip link set {} mtu 1200".format(r0_r1_intf
))
882 clear_ospf(tgen
, "r0")
884 step("Verify that OSPF neighborship between R0 and R1 is stuck in Exstart State.")
885 result
= verify_ospf_neighbor(tgen
, topo
, expected
=False)
886 assert result
is not True, (
887 "Testcase {} : Failed \n OSPF nbrs are Full "
888 "instead of Exstart. Error: {}".format(tc_name
, result
)
891 step("Verify that configured MTU value is updated in the show ip ospf interface.")
894 input_dict
= {"r0": {"links": {"r1": {"ospf": {"mtuBytes": 1200}}}}}
895 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
896 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
899 "Modify the MTU to non default Value on R0 to R1 interface. "
900 "Reset ospf neighbors on R0."
902 rtr0
.run("ip link set {} mtu 1500".format(r0_r1_intf
))
904 clear_ospf(tgen
, "r0")
906 step("Verify that OSPF neighborship between R0 and R1 becomes full.")
907 result
= verify_ospf_neighbor(tgen
, topo
)
908 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
911 "Configure mtu ignore and change the value of the mtu to non default"
912 " on R0 to R1 interface. Reset ospf neighbors on R0."
914 r0_ospf_mtu
= {"r0": {"links": {"r1": {"ospf": {"mtu_ignore": True}}}}}
915 result
= config_ospf_interface(tgen
, topo
, r0_ospf_mtu
)
916 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
919 input_dict
= {"r0": {"links": {"r1": {"ospf": {"mtuMismatchDetect": True}}}}}
920 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
921 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
923 r1_ospf_mtu
= {"r1": {"links": {"r0": {"ospf": {"mtu_ignore": True}}}}}
924 result
= config_ospf_interface(tgen
, topo
, r1_ospf_mtu
)
925 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
927 rtr0
.run("ip link set {} mtu 1200".format(r0_r1_intf
))
929 clear_ospf(tgen
, "r0")
931 step("Verify that OSPF neighborship between R0 and R1 becomes full.")
932 result
= verify_ospf_neighbor(tgen
, topo
)
933 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
936 "Unconfigure mtu-ignore command from the interface. "
937 "Reset ospf neighbors on R0."
941 "r1": {"links": {"r0": {"ospf": {"mtu_ignore": True, "del_action": True}}}}
943 result
= config_ospf_interface(tgen
, topo
, r1_ospf_mtu
)
944 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
946 clear_ospf(tgen
, "r0")
948 step("Verify that OSPF neighborship between R0 and R1 is stuck in Exstart State.")
949 result
= verify_ospf_neighbor(tgen
, topo
, expected
=False)
950 assert result
is not True, (
951 "Testcase {} : Failed \n OSPF nbrs are Full "
952 "instead of Exstart. Error: {}".format(tc_name
, result
)
955 step("Modify the MTU to again default valaue on R0 to R1 interface.")
957 rtr0
.run("ip link set {} mtu 1500".format(r0_r1_intf
))
959 clear_ospf(tgen
, "r0")
961 step("Verify that OSPF neighborship between R0 and R1 becomes full.")
962 result
= verify_ospf_neighbor(tgen
, topo
)
963 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
965 step("Configure ospf interface with jumbo MTU (9216). Reset ospf neighbors on R0.")
967 rtr0
.run("ip link set {} mtu 9216".format(r0_r1_intf
))
968 rtr1
.run("ip link set {} mtu 9216".format(r1_r0_intf
))
970 clear_ospf(tgen
, "r0")
971 clear_ospf(tgen
, "r1")
973 step("Verify that OSPF neighborship between R0 and R1 becomes full.")
974 result
= verify_ospf_neighbor(tgen
, topo
)
975 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
977 step("Verify that jumbo MTU is updated in the show ip ospf interface.")
979 input_dict
= {"r0": {"links": {"r1": {"ospf": {"mtuBytes": 9216}}}}}
980 result
= verify_ospf_interface(tgen
, topo
, dut
=dut
, input_dict
=input_dict
)
981 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
983 write_test_footer(tc_name
)
986 if __name__
== "__main__":
987 args
= ["-s"] + sys
.argv
[1:]
988 sys
.exit(pytest
.main(args
))