def test_ospfv3_bit_mismatch(request): """OSPF verify E-bit and N-bit mismatch.""" tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) global topo step("Bring up the base config as per the topology") reset_config_on_routers(tgen) input_dict = {"r3": {"ospf6": {"neighbors": []}}} step("Configure r3 as stub router") stub = {"r3": {"ospf6": {"area": [{"id": "1.1.1.1", "type": "stub"}]}}} result = create_router_ospf(tgen, topo, stub) assert result is True, "Testcase {}: Failed \n Error: {}".format( tc_name, result) # Verify r3 lost its adjacency with r2 due to E-bit mismatch result = verify_ospf6_neighbor(tgen, topo, dut="r3", input_dict=input_dict) assert result is True, "Testcase {}: Failed \n Error: {}".format( tc_name, result) step("Configure r2 as stub router") stub = {"r2": {"ospf6": {"area": [{"id": "1.1.1.1", "type": "stub"}]}}} result = create_router_ospf(tgen, topo, stub) assert result is True, "Testcase {}: Failed \n Error: {}".format( tc_name, result) # Verify r3 has an adjacency up with r2 again result = verify_ospf6_neighbor(tgen, topo, dut="r3") assert result is True, "Testcase {}: Failed \n Error: {}".format( tc_name, result) step("Configure r3 as NSSA router") nssa = {"r3": {"ospf6": {"area": [{"id": "1.1.1.1", "type": "nssa"}]}}} result = create_router_ospf(tgen, topo, nssa) # Verify r3 lost its adjacency with r2 due to N-bit mismatch result = verify_ospf6_neighbor(tgen, topo, dut="r3", input_dict=input_dict) assert result is True, "Testcase {}: Failed \n Error: {}".format( tc_name, result) step("Configure r2 as NSSA router") nssa = {"r2": {"ospf6": {"area": [{"id": "1.1.1.1", "type": "nssa"}]}}} result = create_router_ospf(tgen, topo, nssa) # Verify r3 has an adjacency up with r2 again result = verify_ospf6_neighbor(tgen, topo, dut="r3") assert result is True, "Testcase {}: Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_ospf6_auth_trailer_tc10_no_auth_trailer(request): """ OSPFv3 Neighborship without Authentication Trailer - Verify ospfv3 neighborship when no authentication trailer is configured. """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() global topo step("Bring up the base config.") reset_config_on_routers(tgen) router1 = tgen.gears["r1"] router2 = tgen.gears["r2"] step("Verify that the neighbour is FULL between R1 and R2 " "using show ipv6 ospf6 neighbor cmd.") dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) write_test_footer(tc_name)
def setup_module(mod): """ Sets up the pytest environment * `mod`: module name """ global topo, switch_name testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("=" * 40) logger.info("Running setup_module to create topology") # This function initiates the topology build with Topogen... json_file = "{}/ospfv3_ecmp_lan.json".format(CWD) tgen = Topogen(json_file, mod.__name__) global topo topo = tgen.json_topo # ... and here it calls Mininet initialization functions. # get list of daemons needs to be started for this suite. daemons = topo_daemons(tgen, topo) # Starting topology, create tmp files which are loaded to routers # to start daemons and then start routers start_topology(tgen, daemons) # Creating configuration from JSON build_config_from_json(tgen, topo) # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf6_neighbor(tgen, topo, lan=True) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence) switch_name = [k for k in topo["switches"].keys()][0] logger.info("Running setup_module() done")
def setup_module(mod): """Sets up the pytest environment.""" global topo testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: {}".format(testsuite_run_time)) logger.info("=" * 40) logger.info("Running setup_module to create topology") # This function initiates the topology build with Topogen... tgen = Topogen(CreateTopo, mod.__name__) # ... and here it calls Mininet initialization functions. # get list of daemons needs to be started for this suite. daemons = topo_daemons(tgen, topo) # Starting topology, create tmp files which are loaded to routers # to start daemons and then start routers start_topology(tgen, daemons) # Creating configuration from JSON build_config_from_json(tgen, topo) # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) # Api call verify whether OSPF converged ospf_covergence_ipv4 = verify_ospf_neighbor(tgen, topo) assert ospf_covergence_ipv4 is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence_ipv4 ) # Api call verify whether OSPF6 converged ospf_covergence_ipv6 = verify_ospf6_neighbor(tgen, topo) assert ospf_covergence_ipv6 is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence_ipv6 ) logger.info("Running setup_module() done")
def test_ospfv3_dead_tc11_p0(request): """ OSPF timers. Verify OSPF interface timer dead interval functionality """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) global topo step("Bring up the base config as per the topology") reset_config_on_routers(tgen) step("modify dead interval from default value to some other value on r1") topo1 = { "r1": { "links": { "r0": { "interface": topo["routers"]["r1"]["links"]["r0"]["interface"], "ospf6": { "hello_interval": 12, "dead_interval": 48 }, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("verify that new timer value is configured and applied using " "the show ip ospf interface command.") dut = "r1" input_dict = { "r1": { "links": { "r0": { "ospf6": { "timerIntervalsConfigDead": 48 } } } } } result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("modify dead interval from default value to r1" "dead interval timer on r2") topo1 = { "r0": { "links": { "r1": { "interface": topo["routers"]["r0"]["links"]["r1"]["interface"], "ospf6": { "dead_interval": 48, "hello_interval": 12 }, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("verify that new timer value is configured.") input_dict = { "r0": { "links": { "r1": { "ospf6": { "timerIntervalsConfigDead": 48 } } } } } dut = "r0" result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("verify that ospf neighbours are full") ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf_covergence is True, "Testcase {} : Failed \n Error: {}".format( tc_name, ospf_covergence) step("remove ospf on R0") ospf_del = {"r0": {"ospf6": {"delete": True}}} result = create_router_ospf(tgen, topo, ospf_del) assert result is True, "Testcase : Failed \n Error: {}".format(result) # reconfiguring deleted ospf process by resetting the configs. reset_config_on_routers(tgen) step("reconfigure the default dead interval timer value to " "default on r1 and r2") topo1 = { "r0": { "links": { "r1": { "interface": topo["routers"]["r0"]["links"]["r1"]["interface"], "ospf6": { "dead_interval": 40 }, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) topo1 = { "r1": { "links": { "r0": { "interface": topo["routers"]["r1"]["links"]["r0"]["interface"], "ospf6": { "dead_interval": 40 }, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("verify that new timer value is configured.") input_dict = { "r0": { "links": { "r1": { "ospf6": { "timerIntervalsConfigDead": 40 } } } } } dut = "r0" result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("verify that ospf neighbours are full") ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf_covergence is True, "Testcase {} : Failed \n Error: {}".format( tc_name, ospf_covergence) step(" Configure dead timer = 65535 on r1 and r2") topo1 = { "r0": { "links": { "r1": { "interface": topo["routers"]["r0"]["links"]["r1"]["interface"], "ospf6": { "dead_interval": 65535 }, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) topo1 = { "r1": { "links": { "r0": { "interface": topo["routers"]["r1"]["links"]["r0"]["interface"], "ospf6": { "dead_interval": 65535 }, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("verify that new timer value is configured.") input_dict = { "r0": { "links": { "r1": { "ospf6": { "timerIntervalsConfigDead": 65535 } } } } } dut = "r0" result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("verify that ospf neighbours are full") ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf_covergence is True, "Testcase {} : Failed \n Error: {}".format( tc_name, ospf_covergence) step(" Try configuring timer values outside range for example 65536") topo1 = { "r0": { "links": { "r1": { "interface": topo["routers"]["r0"]["links"]["r1"]["interface"], "ospf6": { "dead_interval": 65536 }, } } } } result = create_interfaces_cfg(tgen, topo1) assert ( result is not True ), "Testcase {} : Failed \n Create interface config failed. Error: {}".format( tc_name, result) step("Unconfigure the dead timer from the interface from r1 and r2.") topo1 = { "r1": { "links": { "r0": { "interface": topo["routers"]["r1"]["links"]["r0"]["interface"], "ospf6": { "dead_interval": 65535 }, "delete": True, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Verify that timer value is deleted from intf & " "set to default value 40 sec.") input_dict = { "r1": { "links": { "r0": { "ospf6": { "timerIntervalsConfigDead": 40 } } } } } dut = "r1" result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_ospfv3_p2p_tc3_p0(request): """OSPF IFSM -Verify state change events on p2p network.""" tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) global topo step("Bring up the base config as per the topology") reset_config_on_routers(tgen) step("Verify that OSPF is subscribed to multi cast services " "(All SPF, all DR Routers).") step("Verify that interface is enabled in ospf.") step("Verify that config is successful.") dut = "r0" input_dict = {"r0": {"links": {"r3": {"ospf6": {"ospf6Enabled": True}}}}} result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Delete the ip address") topo1 = { "r0": { "links": { "r3": { "ipv6": topo["routers"]["r0"]["links"]["r3"]["ipv6"], "interface": topo["routers"]["r0"]["links"]["r3"]["interface"], "delete": True, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Change the ip on the R0 interface") topo_modify_change_ip = deepcopy(topo) intf_ip = topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv6"] topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv6"] = str( IPv6Address(frr_unicode(intf_ip.split("/")[0])) + 3) + "/{}".format( intf_ip.split("/")[1]) build_config_from_json(tgen, topo_modify_change_ip, save_bkup=False) step("Verify that interface is enabled in ospf.") dut = "r0" input_dict = { "r0": { "links": { "r3": { "ospf6": { "internetAddress": [{ "type": "inet6", "address": topo_modify_change_ip["routers"]["r0"]["links"] ["r3"]["ipv6"].split("/")[0], }], } } } } } result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Modify the mask on the R0 interface") ip_addr = topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv6"] mask = topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv6"] step("Delete the ip address") topo1 = { "r0": { "links": { "r3": { "ipv6": ip_addr, "interface": topo["routers"]["r0"]["links"]["r3"]["interface"], "delete": True, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Change the ip on the R0 interface") topo_modify_change_ip = deepcopy(topo) intf_ip = topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv6"] topo_modify_change_ip["routers"]["r0"]["links"]["r3"]["ipv6"] = str( IPv6Address(frr_unicode(intf_ip.split("/")[0])) + 3) + "/{}".format(int(intf_ip.split("/")[1]) + 1) build_config_from_json(tgen, topo_modify_change_ip, save_bkup=False) step("Verify that interface is enabled in ospf.") dut = "r0" input_dict = { "r0": { "links": { "r3": { "ospf6": { "internetAddress": [{ "type": "inet6", "address": topo_modify_change_ip["routers"]["r0"]["links"] ["r3"]["ipv6"].split("/")[0], }], } } } } } result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) topo1 = { "r0": { "links": { "r3": { "ipv6": topo_modify_change_ip["routers"]["r0"]["links"]["r3"] ["ipv6"], "interface": topo_modify_change_ip["routers"]["r0"]["links"]["r3"] ["interface"], "delete": True, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) build_config_from_json(tgen, topo, save_bkup=False) step("Change the area id on the interface") input_dict = { "r0": { "links": { "r3": { "interface": topo["routers"]["r0"]["links"]["r3"]["interface"], "ospf6": { "area": "0.0.0.0" }, "delete": True, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) input_dict = { "r0": { "links": { "r3": { "interface": topo["routers"]["r0"]["links"]["r3"]["interface"], "ospf6": { "area": "0.0.0.1" }, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that interface is enabled in ospf.") dut = "r0" input_dict = {"r0": {"links": {"r3": {"ospf6": {"ospf6Enabled": True}}}}} result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) input_dict = { "r0": { "links": { "r3": { "interface": topo["routers"]["r0"]["links"]["r3"]["interface"], "ospf6": { "area": "0.0.0.1" }, "delete": True, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) input_dict = { "r0": { "links": { "r3": { "interface": topo["routers"]["r0"]["links"]["r3"]["interface"], "ospf6": { "area": "0.0.0.0" }, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that interface is enabled in ospf.") dut = "r0" input_dict = {"r0": {"links": {"r3": {"ospf6": {"ospf6Enabled": True}}}}} result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("verify the all neighbors are up after clearing the process.") for rtr in topo["routers"]: clear_ospf(tgen, rtr, ospf="ospf6") ospf_covergence = verify_ospf6_neighbor(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def ospfv3_router_id_tc14_p2(request): """OSPF Router ID - Verify OSPF router id changes.""" tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) global topo step(" Bring up the base config as per the topology") reset_config_on_routers(tgen) step("Configure system router id as 1.1.1.1 on R1 , clear ospf router") ospf_rid = {"r0": {"ospf6": {"router_id": "1.1.1.1"}}} result = create_router_ospf(tgen, topo, ospf_rid) assert result is True, "Testcase : Failed \n Error: {}".format(result) step("configure ospf router id as 1.1.1.2 on R1, clear ospf router") ospf_rid = {"r1": {"ospf6": {"router_id": "1.1.1.2"}}} result = create_router_ospf(tgen, topo, ospf_rid) assert result is True, "Testcase : Failed \n Error: {}".format(result) topo1 = deepcopy(topo) step("Verify that OSPF takes system router ID as ospf router id.") topo1["routers"]["r0"]["ospf6"]["router_id"] = "1.1.1.1" topo1["routers"]["r1"]["ospf6"]["router_id"] = "1.1.1.2" for rtr in topo["routers"]: clear_ospf(tgen, rtr, ospf="ospf6") ospf_covergence = verify_ospf6_neighbor(tgen, topo1) assert ospf_covergence is True, "OSPF NBRs not up.Failed \n Error:" " {}".format( ospf_covergence) step(" delete ospf router id and clear ospf process.") ospf_rid = {"r0": {"ospf6": {"del_router_id": "1.1.1.1"}}} result = create_router_ospf(tgen, topo, ospf_rid) assert result is True, "Testcase : Failed \n Error: {}".format(result) ospf_rid = {"r1": {"ospf6": {"del_router_id": "1.1.1.2"}}} result = create_router_ospf(tgen, topo, ospf_rid) assert result is True, "Testcase : Failed \n Error: {}".format(result) reset_config_on_routers(tgen) step(" Configure R0 R1 R2 with same router ids") ospf_rid = {"r0": {"ospf6": {"router_id": "1.1.1.1"}}} result = create_router_ospf(tgen, topo, ospf_rid) assert result is True, "Testcase : Failed \n Error: {}".format(result) step("configure ospf router id as 1.1.1.2 on R1, reboot router") ospf_rid = {"r1": {"ospf6": {"router_id": "1.1.1.1"}}} result = create_router_ospf(tgen, topo, ospf_rid) assert result is True, "Testcase : Failed \n Error: {}".format(result) ospf_covergence = verify_ospf6_neighbor(tgen, topo, expected=False) assert (ospf_covergence is not True), "OSPF NBRs are up.Failed \n Error:" " {}".format( ospf_covergence) topo1 = {} topo1 = deepcopy(topo) for rtr in ["r1", "r2", "r3", "r0"]: topo1["routers"][rtr]["ospf6"].pop("router_id") build_config_from_json(tgen, topo1, save_bkup=False) ospf_covergence = verify_ospf6_neighbor(tgen, topo) assert ospf_covergence is not True, ( "Testcase {} :Failed \n Neighborship " "should not up as no router id is configured. Error: {}".format( tc_name, result)) step("Clear ospf process and check nbrs should not be up.") for rtr in topo["routers"]: clear_ospf(tgen, rtr, ospf="ospf6") ospf_covergence = verify_ospf6_neighbor(tgen, topo) assert ospf_covergence is not True, ( "Testcase {} :Failed \n Neighborship " "should not up as no router id is configured. Error: {}".format( tc_name, result)) topo1 = deepcopy(topo) step("Configure system router id on routers , clear ospf router") ospf_rid = { "r0": { "ospf6": { "router_id": "1.1.1.1" } }, "r1": { "ospf6": { "router_id": "1.1.1.2" } }, "r2": { "ospf6": { "router_id": "1.1.1.3" } }, "r3": { "ospf6": { "router_id": "1.1.1.4" } }, } result = create_router_ospf(tgen, topo1, ospf_rid) assert result is True, "Testcase : Failed \n Error: {}".format(result) topo1["routers"]["r0"]["ospf6"]["router_id"] = "1.1.1.1" topo1["routers"]["r1"]["ospf6"]["router_id"] = "1.1.1.2" topo1["routers"]["r2"]["ospf6"]["router_id"] = "1.1.1.3" topo1["routers"]["r3"]["ospf6"]["router_id"] = "1.1.1.4" ospf_covergence = verify_ospf6_neighbor(tgen, topo1) assert ospf_covergence is True, "OSPF NBRs not up.Failed \n Error:" " {}".format( ospf_covergence) step(" Bring up the base config as per the topology") reset_config_on_routers(tgen) ospf_covergence = verify_ospf6_neighbor(tgen, topo) assert ospf_covergence is True, "OSPF NBRs not up.Failed \n Error:" " {}".format( ospf_covergence) write_test_footer(tc_name)
def test_ospfv3_tc4_mtu_ignore_p0(request): """ OSPF NFSM - MTU change Verify NFSM events when ospf nbr changes with different MTU values """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) global topo step(" Bring up the base config as per the topology") step("Configure OSPF on all the routers of the topology.") step("Verify that OSPF neighbors are FULL.") reset_config_on_routers(tgen) step("Modify the MTU to non default Value on R0 to R1 interface. " "Reset ospf neighbors on R0.") rtr0 = tgen.routers()["r0"] rtr1 = tgen.routers()["r1"] r0_r1_intf = topo["routers"]["r0"]["links"]["r1"]["interface"] r1_r0_intf = topo["routers"]["r1"]["links"]["r0"]["interface"] rtr0.run("ifconfig {} mtu 1400".format(r0_r1_intf)) clear_ospf(tgen, "r0", ospf="ospf6") clear_ospf(tgen, "r1", ospf="ospf6") step("Verify that OSPF neighborship between R0 and R1 is stuck in Exstart" " State.") result = verify_ospf6_neighbor(tgen, topo, expected=False) assert result is not True, ("Testcase {} : Failed \n OSPF nbrs are Full " "instead of Exstart. Error: {}".format( tc_name, result)) step("Verify that configured MTU value is updated in the show ip " "ospf interface.") dut = "r0" input_dict = {"r0": {"links": {"r1": {"ospf6": {"interfaceMtu": 1400}}}}} result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Modify the MTU to non default Value on R0 to R1 interface. " "Reset ospf neighbors on R0.") rtr0.run("ifconfig {} mtu 1500".format(r0_r1_intf)) clear_ospf(tgen, "r0", ospf="ospf6") step("Verify that OSPF neighborship between R0 and R1 becomes full.") result = verify_ospf6_neighbor(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Configure mtu ignore and change the value of the mtu to non default" " on R0 to R1 interface. Reset ospf neighbors on R0.") r0_ospf_mtu = {"r0": {"links": {"r1": {"ospf6": {"mtu_ignore": True}}}}} result = config_ospf6_interface(tgen, topo, r0_ospf_mtu) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) dut = "r0" input_dict = { "r0": { "links": { "r1": { "ospf6": { "mtuMismatchDetection": True } } } } } result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) r1_ospf_mtu = {"r1": {"links": {"r0": {"ospf6": {"mtu_ignore": True}}}}} result = config_ospf6_interface(tgen, topo, r1_ospf_mtu) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) rtr0.run("ifconfig {} mtu 1400".format(r0_r1_intf)) clear_ospf(tgen, "r0", ospf="ospf6") step("Verify that OSPF neighborship between R0 and R1 becomes full.") result = verify_ospf6_neighbor(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Unconfigure mtu-ignore command from the interface. " "Reset ospf neighbors on R0.") r1_ospf_mtu = { "r1": { "links": { "r0": { "ospf6": { "mtu_ignore": True, "delete": True } } } } } result = config_ospf6_interface(tgen, topo, r1_ospf_mtu) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) clear_ospf(tgen, "r0", ospf="ospf6") step("Verify that OSPF neighborship between R0 and R1 is stuck in Exstart" " State.") result = verify_ospf6_neighbor(tgen, topo, expected=False) assert result is not True, ("Testcase {} : Failed \n OSPF nbrs are Full " "instead of Exstart. Error: {}".format( tc_name, result)) step("Modify the MTU to again default valaue on R0 to R1 interface.") rtr0.run("ifconfig {} mtu 1500".format(r0_r1_intf)) clear_ospf(tgen, "r0", ospf="ospf6") step("Verify that OSPF neighborship between R0 and R1 becomes full.") result = verify_ospf6_neighbor(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Configure ospf interface with jumbo MTU (9216)." "Reset ospf neighbors on R0.") rtr0.run("ifconfig {} mtu 9216".format(r0_r1_intf)) rtr1.run("ifconfig {} mtu 9216".format(r1_r0_intf)) clear_ospf(tgen, "r0", ospf="ospf6") clear_ospf(tgen, "r1", ospf="ospf6") step("Verify that OSPF neighborship between R0 and R1 becomes full.") result = verify_ospf6_neighbor(tgen, topo) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Verify that jumbo MTU is updated in the show ip ospf interface.") dut = "r0" input_dict = {"r0": {"links": {"r1": {"ospf6": {"interfaceMtu": 9216}}}}} result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_ospfv3_redistribution_tc6_p0(request): """Test OSPF inter area route calculations.""" tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) global topo step("Bring up the base config.") reset_config_on_routers(tgen) step("Verify that OSPF neighbors are FULL.") ospf_covergence = verify_ospf6_neighbor(tgen, topo) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence ) step("verify intra area route is calculated for r0-r3 interface ip in R1") ip = topo["routers"]["r0"]["links"]["r3"]["ipv6"] ip_net = str(ipaddress.ip_interface(u"{}".format(ip)).network) llip = get_llip("r0", "r1") assert llip is not None, "Testcase {} : Failed \n Error: {}".format(tc_name, llip) nh = llip input_dict = { "r1": {"static_routes": [{"network": ip_net, "no_of_ip": 1, "routeType": "N"}]} } dut = "r1" result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) protocol = "ospf" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) step("Delete the ip address on newly configured loopback of R0") topo1 = { "r0": { "links": { "r3": { "ipv6": topo["routers"]["r0"]["links"]["r3"]["ipv6"], "interface": topo["routers"]["r0"]["links"]["r3"]["interface"], "delete": True, } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) dut = "r1" result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh, expected=False) assert ( result is not True ), "Testcase {} : Failed \n Route present in RIB. Error: {}".format(tc_name, result) protocol = "ospf" result = verify_rib( tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh, expected=False ) assert ( result is not True ), "Testcase {} : Failed \n Route present in RIB. Error: {}".format(tc_name, result) step("Add back the deleted ip address on newly configured interface of R0") topo1 = { "r0": { "links": { "r3": { "ipv6": topo["routers"]["r0"]["links"]["r3"]["ipv6"], "interface": topo["routers"]["r0"]["links"]["r3"]["interface"], } } } } result = create_interfaces_cfg(tgen, topo1) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) dut = "r1" result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) protocol = "ospf" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) step("Shut no shut interface on R0") dut = "r0" intf = topo["routers"]["r0"]["links"]["r3"]["interface"] shutdown_bringup_interface(tgen, dut, intf, False) step("Verify that intraroute calculated for R1 intf on R0 is deleted.") dut = "r1" step("un shut the OSPF interface on R0") dut = "r0" shutdown_bringup_interface(tgen, dut, intf, True) dut = "r1" result = verify_ospf6_rib(tgen, dut, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) protocol = "ospf" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) write_test_footer(tc_name)
def test_ospfv3_ecmp_tc17_p0(request): """ Verify OSPF ECMP. Verify OSPF ECMP with max path configured as 2 (Edge having 2 uplink ports) """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) global topo step("Bring up the base config as per the topology") step("Configure 2 interfaces between R1 and R2 & enable ospf in area 0.") reset_config_on_routers(tgen) step("Verify that OSPF is up with 2 neighborship sessions.") dut = "r1" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence) step("Configure a static route in R0 and redistribute in OSPF.") input_dict = { "r0": { "static_routes": [{ "network": NETWORK["ipv6"][0], "no_of_ip": 5, "next_hop": "Null0", }] } } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) dut = "r0" red_static(dut) step("Verify that route in R2 in stalled with 2 next hops.") llip = get_llip("r0", "r1-link1") assert llip is not None, "Testcase {} : Failed \n Error: {}".format( tc_name, result) nh1 = llip llip = get_llip("r0", "r1") assert llip is not None, "Testcase {} : Failed \n Error: {}".format( tc_name, result) nh2 = llip nh = [nh1, nh2] dut = "r1" result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) protocol = "ospf" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Configure ECMP value as 1.") max_path = {"r1": {"ospf6": {"maximum-paths": 1}}} result = create_router_ospf(tgen, topo, max_path) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh2) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) dut = "r1" max_path = {"r1": {"ospf6": {"maximum-paths": 2}}} result = create_router_ospf(tgen, topo, max_path) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Configure cost on R0 as 100") r0_ospf_cost = {"r0": {"links": {"r1": {"ospf6": {"cost": 100}}}}} result = config_ospf6_interface(tgen, topo, r0_ospf_cost) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) dut = "r1" result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) protocol = "ospf" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_ospfv3_ecmp_tc16_p0(request): """ Verify OSPF ECMP. Verify OSPF ECMP with max path configured as 8 (ECMP configured at FRR level) """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) global topo step("Bring up the base config as per the topology") step("Configure 8 interfaces between R1 and R2 and enable ospf in area 0.") reset_config_on_routers(tgen) step("Verify that OSPF is up with 8 neighborship sessions.") dut = "r1" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence) step("Configure a static route in R0 and redistribute in OSPF.") input_dict = { "r0": { "static_routes": [{ "network": NETWORK["ipv6"][0], "no_of_ip": 5, "next_hop": "Null0", }] } } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) dut = "r0" red_static(dut) llip = get_llip("r0", "r1-link1") assert llip is not None, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Verify that route in R2 in stalled with 8 next hops.") nh = [] for item in range(1, 7): nh.append(llip) llip = get_llip("r0", "r1") assert llip is not None, "Testcase {} : Failed \n Error: {}".format( tc_name, result) nh2 = llip nh.append(nh2) dut = "r1" result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) protocol = "ospf" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("shut no shut all the interfaces on the remote router - R2") dut = "r1" for intfr in range(1, 7): intf = topo["routers"]["r1"]["links"]["r0-link{}".format( intfr)]["interface"] shutdown_bringup_interface(tgen, dut, intf, False) result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh, expected=False) assert ( result is not True ), "Testcase {} : Failed \n Route present in OSPF RIB. Error: {}".format( tc_name, result) protocol = "ospf" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh, expected=False) assert ( result is not True ), "Testcase {} : Failed \n Route present in RIB. Error: {}".format( tc_name, result) for intfr in range(1, 7): intf = topo["routers"]["r1"]["links"]["r0-link{}".format( intfr)]["interface"] shutdown_bringup_interface(tgen, dut, intf, True) result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) protocol = "ospf" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("shut no shut on all the interfaces on DUT (r1)") for intfr in range(1, 7): intf = topo["routers"]["r1"]["links"]["r0-link{}".format( intfr)]["interface"] shutdown_bringup_interface(tgen, dut, intf, False) for intfr in range(1, 7): intf = topo["routers"]["r1"]["links"]["r0-link{}".format( intfr)]["interface"] shutdown_bringup_interface(tgen, dut, intf, True) step("Verify that all the neighbours are up and routes are installed" " with 8 next hop in ospf and ip route tables on R1.") step("Verify that OSPF is up with 8 neighborship sessions.") dut = "r1" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence) dut = "r1" result = verify_ospf6_rib(tgen, dut, input_dict, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) protocol = "ospf" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_ospf6_auth_trailer_tc6_sha256_mismatch(request): """ OSPFv3 Authentication Trailer - Verify ospfv3 authentication trailer using HMAC-SHA-256 manual key configuration. """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() global topo step("Bring up the base config.") reset_config_on_routers(tgen) step( "Configure ospf6 between R1 and R2, enable ospf6 auth on R1 interface " "connected to R2 with auth trailer") r1_ospf6_auth = { "r1": { "links": { "r2": { "ospf6": { "hash-algo": "hmac-sha-256", "key": "ospf6", "key-id": "10", } } } } } result = config_ospf6_interface(tgen, topo, r1_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is not FULL between R1 and R2.") # wait for dead time expiry. sleep(6) dut = "r1" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False, retry_timeout=3) assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) step("Configure ospf6 with on R1 and R2, enable ospf6 on R2 interface " "connected to R1 with auth trailer wrong key") r2_ospf6_auth = { "r2": { "links": { "r1": { "ospf6": { "hash-algo": "hmac-sha-256", "key": "ospf6-missmatch", "key-id": "10", } } } } } result = config_ospf6_interface(tgen, topo, r2_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is not FULL between R1 and R2.") # wait for dead time expiry. sleep(6) dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False, retry_timeout=3) assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) step("Configure ospf6 with on R1 and R2, enable ospf6 on R2 interface " "connected to R1 with auth trailer wrong key") r2_ospf6_auth = { "r2": { "links": { "r1": { "ospf6": { "hash-algo": "hmac-sha-256", "key": "ospf6", "key-id": "10", } } } } } result = config_ospf6_interface(tgen, topo, r2_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is FULL between R1 and R2 " "using show ipv6 ospf6 neighbor cmd.") dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) write_test_footer(tc_name)
def test_ospf6_auth_trailer_tc4_keychain_sha256(request): """ OSPFv3 Authentication Trailer - Verify ospfv3 authentication trailer using HMAC-SHA-256 keychain configuration. """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() global topo step("Bring up the base config.") reset_config_on_routers(tgen) step( "Configure ospf6 between R1 and R2, enable ospf6 auth on R1 interface " "connected to R2 with auth trailer") router1 = tgen.gears["r1"] router2 = tgen.gears["r2"] router1.vtysh_cmd("""configure terminal key chain auth key 10 key-string ospf6 cryptographic-algorithm hmac-sha-256""") router2.vtysh_cmd("""configure terminal key chain auth key 10 key-string ospf6 cryptographic-algorithm hmac-sha-256""") r1_ospf6_auth = { "r1": { "links": { "r2": { "ospf6": { "keychain": "auth", } } } } } result = config_ospf6_interface(tgen, topo, r1_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is not FULL between R1 and R2.") # wait for dead time expiry. sleep(6) dut = "r1" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False, retry_timeout=3) assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) step("Configure ospf6 between R1 and R2, enable ospf6 on R2 interface " "connected to R1 with auth trailer") r2_ospf6_auth = { "r2": { "links": { "r1": { "ospf6": { "keychain": "auth", } } } } } result = config_ospf6_interface(tgen, topo, r2_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is FULL between R1 and R2 " "using show ipv6 ospf6 neighbor cmd.") dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) step("Disable authentication on R2 ") r2_ospf6_auth = { "r2": { "links": { "r1": { "ospf6": { "keychain": "auth", "del_action": True } } } } } result = config_ospf6_interface(tgen, topo, r2_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify on R1 ,nbr is deleted for R2 after dead interval expiry") # wait till the dead timer expiry sleep(6) dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False, retry_timeout=5) assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) step("Again On R2 enable ospf6 on interface with message-digest auth") r2_ospf6_auth = { "r2": { "links": { "r1": { "ospf6": { "keychain": "auth", } } } } } result = config_ospf6_interface(tgen, topo, r2_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is FULL between R1 and R2 using" " show ip ospf6 neighbor cmd.") dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) step("Shut no shut interface on R1") dut = "r1" intf = topo["routers"]["r1"]["links"]["r2"]["interface"] shutdown_bringup_interface(tgen, dut, intf, False) dut = "r2" step("Verify that the neighbour is not FULL between R1 and R2 using " "show ip ospf6 neighbor cmd.") ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False) assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) dut = "r1" shutdown_bringup_interface(tgen, dut, intf, True) step("Verify that the neighbour is FULL between R1 and R2 using " "show ip ospf6 neighbor cmd.") dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) write_test_footer(tc_name)
def test_ospfv3_lan_ecmp_tc18_p0(request): """ OSPF ECMP. Verify OSPF ECMP with max path configured as 8 (Edge having 1 uplink port as broadcast network, connect to 8 TORs - LAN case) """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) global topo step("Bring up the base config as per the topology") step(". Configure ospf in all the routers on LAN interface.") reset_config_on_routers(tgen) step("Verify that OSPF is up with 8 neighborship sessions.") ospf_covergence = verify_ospf6_neighbor(tgen, topo, lan=True) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence) step("Configure a static route in all the routes and " "redistribute static/connected in OSPF.") for rtr in topo["routers"]: input_dict = { rtr: { "static_routes": [{ "network": NETWORK["ipv6"][0], "no_of_ip": 5, "next_hop": "Null0" }] } } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) dut = rtr red_static(dut) step("Verify that route in R0 in stalled with 8 hops. " "Verify ospf route table and ip route table.") nh = [] for rtr in topo["routers"]: llip = get_llip(rtr, switch_name) assert llip is not None, "Testcase {} : Failed \n Error: {}".format( tc_name, result) nh.append(llip) llip = get_llip("r1", switch_name) assert llip is not None, "Testcase {} : Failed \n Error: {}".format( tc_name, result) nh.remove(llip) dut = "r1" result = verify_ospf6_rib(tgen, dut, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) protocol = "ospf6" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step(" clear ip ospf interface on DUT(r0)") clear_ospf(tgen, "r0", ospf="ospf6") step("Verify that after clearing the ospf interface all the " "neighbours are up and routes are installed with 8 next hop " "in ospf and ip route tables on R0") dut = "r0" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, lan=True) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence) step(" clear ip ospf interface on R2") clear_ospf(tgen, "r2") dut = "r2" ospf_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, lan=True) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence) step("Delete static/connected cmd in ospf in all the routes one by one.") for rtr in topo["routers"]: input_dict = { rtr: { "static_routes": [{ "network": NETWORK["ipv6"][0], "no_of_ip": 5, "next_hop": "Null0", "delete": True, }] } } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_ospf6_auth_trailer_tc9_keychain_not_configured(request): """ OSPFv3 Neighborship without Authentication Trailer - Verify ospfv3 neighborship when no authentication trailer is configured. """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() global topo step("Bring up the base config.") reset_config_on_routers(tgen) step( "Configure ospf6 between R1 and R2, enable ospf6 auth on R1 interface " "connected to R2 with auth trailer") router1 = tgen.gears["r1"] router2 = tgen.gears["r2"] r1_ospf6_auth = { "r1": { "links": { "r2": { "ospf6": { "keychain": "auth", } } } } } result = config_ospf6_interface(tgen, topo, r1_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is not FULL between R1 and R2.") # wait for dead time expiry. sleep(6) dut = "r1" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False, retry_timeout=3) assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) step("Configure ospf6 between R1 and R2, enable ospf6 on R2 interface " "connected to R1 with auth trailer non existing keychain") r2_ospf6_auth = { "r2": { "links": { "r1": { "ospf6": { "keychain": "auth", } } } } } result = config_ospf6_interface(tgen, topo, r2_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is not FULL between R1 and R2.") # wait for dead time expiry. sleep(6) dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False, retry_timeout=3) assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) write_test_footer(tc_name)
def test_ospf6_auth_trailer_tc8_keychain_sha256_missmatch(request): """ OSPFv3 Authentication Trailer - Verify ospfv3 authentication trailer using HMAC-SHA-256 keychain configuration. """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() global topo step("Bring up the base config.") reset_config_on_routers(tgen) step( "Configure ospf6 between R1 and R2, enable ospf6 auth on R1 interface " "connected to R2 with auth trailer") router1 = tgen.gears["r1"] router2 = tgen.gears["r2"] router1.vtysh_cmd("""configure terminal key chain auth key 10 key-string ospf6 cryptographic-algorithm hmac-sha-256""") router2.vtysh_cmd("""configure terminal key chain auth key 10 key-string ospf6 cryptographic-algorithm hmac-sha-256""") router2.vtysh_cmd("""configure terminal key chain auth-missmatch key 10 key-string ospf6-missmatch cryptographic-algorithm hmac-sha-256""") r1_ospf6_auth = { "r1": { "links": { "r2": { "ospf6": { "keychain": "auth", } } } } } result = config_ospf6_interface(tgen, topo, r1_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is not FULL between R1 and R2.") # wait for dead time expiry. sleep(6) dut = "r1" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False, retry_timeout=3) assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) step("Configure ospf6 between R1 and R2, enable ospf6 on R2 interface " "connected to R1 with auth trailer wrong keychain") r2_ospf6_auth = { "r2": { "links": { "r1": { "ospf6": { "keychain": "auth-missmatch", } } } } } result = config_ospf6_interface(tgen, topo, r2_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is not FULL between R1 and R2.") # wait for dead time expiry. sleep(6) dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut, expected=False, retry_timeout=3) assert ospf6_covergence is not True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) step("Configure ospf6 between R1 and R2, enable ospf6 on R2 interface " "connected to R1 with auth trailer correct keychain") r2_ospf6_auth = { "r2": { "links": { "r1": { "ospf6": { "keychain": "auth", } } } } } result = config_ospf6_interface(tgen, topo, r2_ospf6_auth) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that the neighbour is FULL between R1 and R2 " "using show ipv6 ospf6 neighbor cmd.") dut = "r2" ospf6_covergence = verify_ospf6_neighbor(tgen, topo, dut=dut) assert ospf6_covergence is True, "Testcase {} :Failed \n Error:" " {}".format( tc_name, ospf6_covergence) write_test_footer(tc_name)
def test_ospfv3_routemaps_functionality_tc25_p0(request): """ OSPF route map support functionality. Verify OSPF route map support functionality when route map actions are toggled. """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() global topo step("Bring up the base config as per the topology") reset_config_on_routers(tgen) step( "Create static routes(10.0.20.1/32) in R1 and redistribute " "to OSPF using route map." ) # Create Static routes input_dict = { "r0": { "static_routes": [ { "network": NETWORK["ipv6"][0], "no_of_ip": 5, "next_hop": "Null0", } ] } } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) ospf_red_r0 = { "r0": { "ospf6": { "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}] } } } result = create_router_ospf(tgen, topo, ospf_red_r0) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) step("Configure route map with permit rule") # Create route map routemaps = {"r0": {"route_maps": {"rmap_ipv6": [{"action": "permit"}]}}} result = create_route_maps(tgen, routemaps) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) step("Verify that route is advertised to R1.") dut = "r1" protocol = "ospf" result = verify_ospf6_rib(tgen, dut, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) step("Configure route map with deny rule") # Create route map routemaps = { "r0": {"route_maps": {"rmap_ipv6": [{"seq_id": 10, "action": "deny"}]}} } result = create_route_maps(tgen, routemaps) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) # Api call verify whether OSPF is converged ospf_covergence = verify_ospf6_neighbor(tgen, topo) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence ) step("Verify that route is not advertised to R1.") dut = "r1" protocol = "ospf" result = verify_ospf6_rib(tgen, dut, input_dict, expected=False) assert ( result is not True ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format( tc_name, result ) result = verify_rib( tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False ) assert ( result is not True ), "Testcase {} : Failed \n Route found in the RIB, Error: {}".format( tc_name, result ) write_test_footer(tc_name)
def test_ospfv3_nssa_tc26_p0(request): """Verify that ospf non back bone area can be configured as NSSA area""" tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() # Don't run this test if we have any failure. if tgen.routers_have_failure(): check_router_status(tgen) global topo step("Bring up the base config as per the topology") step("Configure ospf area 2 on r0 , r1 & r4, make the area 2 as NSSA area") reset_config_on_routers(tgen) input_dict = { "r2": { "static_routes": [{ "network": NETWORK["ipv6"][0], "no_of_ip": 5, "next_hop": "Null0" }] } } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Redistribute static route in R2 ospf.") dut = "r2" red_static(dut) step("Verify that Type 5 LSA is originated by R2.") dut = "r0" protocol = "ospf6" result = verify_rib(tgen, "ipv6", dut, input_dict, protocol=protocol) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Un configure redistribute command in R4") dut = "r2" red_static(dut, config=False) input_dict = { "r1": { "static_routes": [{ "network": NETWORK["ipv6"][0], "no_of_ip": 1, "routeType": "Network" }] } } step("Configure area 0 on interface of r2 connecting to r1") input_dict = { "r2": { "links": { "r1": { "interface": topo["routers"]["r2"]["links"]["r1"]["interface"], "ospf6": { "area": "0.0.0.2" }, "delete": True, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) input_dict = { "r2": { "links": { "r1": { "interface": topo["routers"]["r2"]["links"]["r1"]["interface"], "ospf6": { "area": "0.0.0.0" }, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("verify that ospf neighbor goes down between r2 and r1.") result = verify_ospf6_neighbor(tgen, topo, dut="r2", expected=False) assert (result is not True ), "Testcase {} : Failed \n Nbrs are not down" "Error: {}".format( tc_name, result) step("Now configure area 0 on interface of r1 connecting to r2.") input_dict = { "r1": { "links": { "r2": { "interface": topo["routers"]["r1"]["links"]["r2"]["interface"], "ospf6": { "area": "0.0.0.2" }, "delete": True, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) input_dict = { "r1": { "links": { "r2": { "interface": topo["routers"]["r1"]["links"]["r2"]["interface"], "ospf6": { "area": "0.0.0.0" }, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that ospf neighbour comes up between r2 and r1.") result = verify_ospf6_neighbor(tgen, topo, dut="r2") assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Configure area 2 on interface of r2 connecting to r1.") input_dict = { "r2": { "links": { "r1": { "interface": topo["routers"]["r2"]["links"]["r1"]["interface"], "ospf6": { "area": "0.0.0.0" }, "delete": True, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) input_dict = { "r2": { "links": { "r1": { "interface": topo["routers"]["r2"]["links"]["r1"]["interface"], "ospf6": { "area": "0.0.0.2" }, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("verify that ospf neighbor goes down between r2 and r1.") result = verify_ospf6_neighbor(tgen, topo, dut="r2", expected=False) assert (result is not True ), "Testcase {} : Failed \n Nbrs are not down" "Error: {}".format( tc_name, result) step("Now configure area 2 on interface of r1 connecting to r2.") input_dict = { "r1": { "links": { "r2": { "interface": topo["routers"]["r1"]["links"]["r2"]["interface"], "ospf6": { "area": "0.0.0.0" }, "delete": True, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) input_dict = { "r1": { "links": { "r2": { "interface": topo["routers"]["r1"]["links"]["r2"]["interface"], "ospf6": { "area": "0.0.0.2" }, } } } } result = create_interfaces_cfg(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that ospf neighbour comes up between r2 and r1.") result = verify_ospf6_neighbor(tgen, topo, dut="r2") assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)
def test_ospfv3_redistribution_tc8_p1(request): """ Test OSPF redistribution of connected routes. Verify OSPF redistribution of connected routes when bgp multi hop neighbor is configured using ospf routes """ tc_name = request.node.name write_test_header(tc_name) tgen = get_topogen() global topo step("Bring up the base config.") step("Configure loopback interface on all routers, and redistribut" "e connected routes into ospf") if tgen.routers_have_failure(): check_router_status(tgen) reset_config_on_routers(tgen) step("verify that connected routes -loopback is found in all routers" "advertised/exchaged via ospf") for rtr in topo["routers"]: red_static(rtr) red_connected(rtr) for node in topo["routers"]: input_dict = { "r0": { "static_routes": [{ "network": topo["routers"][node]["links"]["lo"]["ipv6"], "no_of_ip": 1, }] } } for rtr in topo["routers"]: result = verify_rib(tgen, "ipv6", rtr, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Configure E BGP multi hop using the loopback addresses.") as_num = 100 for node in topo["routers"]: as_num += 1 topo["routers"][node].update({ "bgp": { "local_as": as_num, "address_family": { "ipv6": { "unicast": { "neighbor": {} } } }, } }) for node in topo["routers"]: for rtr in topo["routers"]: if node is not rtr: topo["routers"][node]["bgp"]["address_family"]["ipv6"][ "unicast"]["neighbor"].update({ rtr: { "dest_link": { "lo": { "source_link": "lo", "ebgp_multihop": 2 } } } }) result = create_router_bgp(tgen, topo, topo["routers"]) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Modify router id input_dict = { "r0": { "bgp": { "router_id": "11.11.11.11" } }, "r1": { "bgp": { "router_id": "22.22.22.22" } }, "r2": { "bgp": { "router_id": "33.33.33.33" } }, "r3": { "bgp": { "router_id": "44.44.44.44" } }, } result = create_router_bgp(tgen, topo, input_dict) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Verify that BGP neighbor is ESTABLISHED") result = verify_bgp_convergence(tgen, topo) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) step("Configure couple of static routes in R0 and " "Redistribute static routes in R1 bgp.") for rtr in topo["routers"]: ospf_red = { rtr: { "ospf6": { "redistribute": [{ "redist_type": "static", "delete": True }] } } } result = create_router_ospf(tgen, topo, ospf_red) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) input_dict = { "r0": { "static_routes": [{ "network": NETWORK["ipv6"][0], "no_of_ip": 5, "next_hop": "Null0", }] } } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) configure_bgp_on_r0 = { "r0": { "bgp": { "address_family": { "ipv6": { "unicast": { "redistribute": [{ "redist_type": "static" }] } } } } } } result = create_router_bgp(tgen, topo, configure_bgp_on_r0) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) protocol = "bgp" for rtr in ["r1", "r2", "r3"]: result = verify_rib(tgen, "ipv6", rtr, input_dict, protocol=protocol) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) step("Clear ospf neighbours in R0") for rtr in topo["routers"]: clear_ospf(tgen, rtr) step("Verify that OSPF neighbours are reset and forms new adjacencies.") # Api call verify whether OSPF is converged ospf_covergence = verify_ospf6_neighbor(tgen, topo) assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format( ospf_covergence) step("Verify that BGP neighbours are reset and forms new adjacencies.") result = verify_bgp_convergence(tgen, topo) assert result is True, "Testcase {} :Failed \n Error: {}".format( tc_name, result) protocol = "bgp" for rtr in ["r1", "r2", "r3"]: result = verify_rib(tgen, "ipv6", rtr, input_dict, protocol=protocol) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name)