Example #1
0
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)
Example #2
0
def test_ospf_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")
    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"]:
        redistribute_ospf(tgen, topo, rtr, "static")
        redistribute_ospf(tgen, topo, rtr, "connected")
    for node in topo["routers"]:
        input_dict = {
            "r0": {
                "static_routes": [{
                    "network":
                    topo["routers"][node]["links"]["lo"]["ipv4"],
                    "no_of_ip":
                    1,
                }]
            }
        }
        for rtr in topo["routers"]:
            result = verify_rib(tgen, "ipv4", 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": {
                    "ipv4": {
                        "unicast": {
                            "neighbor": {}
                        }
                    }
                },
            }
        })
    for node in topo["routers"]:
        for rtr in topo["routers"]:
            if node is not rtr:
                topo["routers"][node]["bgp"]["address_family"]["ipv4"][
                    "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)

    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"]:
        redistribute_ospf(tgen, topo, rtr, "static", delete=True)

    input_dict = {
        "r0": {
            "static_routes": [{
                "network": NETWORK["ipv4"][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": {
                    "ipv4": {
                        "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, "ipv4", 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_ospf_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, "ipv4", rtr, input_dict, protocol=protocol)
        assert result is True, "Testcase {} : Failed \n Error: {}".format(
            tc_name, result)

    write_test_footer(tc_name)
Example #3
0
def test_ospfv3_show_p1(request):
    """Verify ospf show commands with json output."""
    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)

    input_dict = {
        "r2": {
            "debug": {
                "log_file": "debug.log",
                "enable": ["ospf6"]
            }
        }
    }

    result = create_debug_log_config(tgen, input_dict)

    # Code coverage steps #Do Not upstream
    input_dict_config = {
        "r1": {
            "raw_config": [
                "end",
                "debug ospf6 event",
                "debug ospf6 gr helper",
                "debug ospf6 ism events",
                "debug ospf6 ism status",
                "debug ospf6 ism timers",
                "debug ospf6 nsm events",
                "debug ospf6 nsm status",
                "debug ospf6 nsm timers ",
                "debug ospf6 nssa",
                "debug ospf6 lsa aggregate",
                "debug ospf6 lsa flooding ",
                "debug ospf6 lsa generate",
                "debug ospf6 lsa install ",
                "debug ospf6 lsa refresh",
                "debug ospf6 packet all detail",
                "debug ospf6 packet all recv",
                "debug ospf6 packet all send",
                "debug ospf6 packet dd detail",
                "debug ospf6 packet dd recv",
                "debug ospf6 packet dd send ",
                "debug ospf6 packet hello detail",
                "debug ospf6 packet hello recv",
                "debug ospf6 packet hello send",
                "debug ospf6 packet ls-ack detail",
                "debug ospf6 packet ls-ack recv",
                "debug ospf6 packet ls-ack send",
                "debug ospf6 packet ls-request detail",
                "debug ospf6 packet ls-request recv",
                "debug ospf6 packet ls-request send",
                "debug ospf6 packet ls-update detail",
                "debug ospf6 packet ls-update recv",
                "debug ospf6 packet ls-update send",
                "debug ospf6 sr",
                "debug ospf6 te ",
                "debug ospf6 zebra interface",
                "debug ospf6 zebra redistribute",
            ]
        }
    }

    apply_raw_config(tgen, input_dict_config)

    for rtr in topo["routers"]:
        clear_ospf(tgen, rtr, ospf="ospf6")

    step(" Bring up the base config as per the topology")
    reset_config_on_routers(tgen)

    for rtr in topo["routers"]:
        clear_ospf(tgen, rtr, ospf="ospf6")

    dut = "r1"
    input_dict = {
        "r1": {
            "links": {
                "r0": {
                    "ospf6": {
                        "status": "up",
                        "type": "BROADCAST",
                        "ospf6Enabled": True,
                        "attachedToArea": True,
                        "instanceId": 0,
                        "interfaceMtu": 1500,
                        "autoDetect": 1500,
                        "mtuMismatchDetection": "enabled",
                        "areaId": "0.0.0.0",
                        "cost": 10,
                        "transmitDelaySec": 1,
                        "priority": 1,
                        "timerIntervalsConfigHello": 1,
                        "timerIntervalsConfigDead": 4,
                        "timerIntervalsConfigRetransmit": 5,
                        "dr": "0.0.0.0",
                        "bdr": "0.0.0.0",
                        "numberOfInterfaceScopedLsa": 2,
                        "pendingLsaLsUpdateCount": 0,
                        "lsUpdateSendThread": "off",
                        "pendingLsaLsAckCount": 0,
                        "lsAckSendThread": "off",
                    }
                }
            }
        }
    }
    result = verify_ospf6_interface(tgen, topo, dut=dut, input_dict=input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    ip = topo["routers"]["r0"]["links"]["r3"]["ipv6"]
    ip_net = str(ipaddress.ip_interface(u"{}".format(ip)).network)
    nh = topo["routers"]["r0"]["links"]["r1"]["ipv6"].split("/")[0]
    input_dict = {
        "r1": {
            "static_routes": [{
                "network": ip_net,
                "no_of_ip": 1,
                "routeType": "Network"
            }]
        }
    }

    dut = "r1"
    result = verify_ospf6_rib(tgen, dut, input_dict)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
Example #4
0
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)
Example #5
0
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)
Example #6
0
def test_ospf_lan_tc1_p0(request):
    """
    OSPF Hello protocol - Verify DR BDR Elections

    """
    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 DR BDR DRother are elected in the LAN.")
    input_dict = {
        "r0": {
            "ospf": {
                "neighbors": {
                    "r1": {
                        "state": "Full",
                        "role": "DR"
                    },
                    "r2": {
                        "state": "Full",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "Full",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    dut = "r0"
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Verify that all the routers are in FULL state with DR and BDR "
         "in the topology")

    input_dict = {
        "r1": {
            "ospf": {
                "neighbors": {
                    "r0": {
                        "state": "Full",
                        "role": "Backup"
                    },
                    "r2": {
                        "state": "Full",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "Full",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    dut = "r1"
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Configure DR pririty 100 on R0 and clear ospf neighbors "
         "on all the routers.")

    input_dict = {
        "r0": {
            "links": {
                "s1": {
                    "interface":
                    topo["routers"]["r0"]["links"]["s1"]["interface"],
                    "ospf": {
                        "priority": 100
                    },
                }
            }
        }
    }

    result = create_interfaces_cfg(tgen, input_dict)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("Clear ospf neighbours in all routers")
    for rtr in ["r0", "r1", "r2", "r3"]:
        clear_ospf(tgen, rtr)

    step("Verify that DR election is triggered and R0 is elected as DR")
    input_dict = {
        "r0": {
            "ospf": {
                "neighbors": {
                    "r1": {
                        "state": "Full",
                        "role": "Backup"
                    },
                    "r2": {
                        "state": "Full",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "Full",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    dut = "r0"
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Configure DR pririty 150 on R0 and clear ospf neighbors "
         "on all the routers.")

    input_dict = {
        "r0": {
            "links": {
                "s1": {
                    "interface":
                    topo["routers"]["r0"]["links"]["s1"]["interface"],
                    "ospf": {
                        "priority": 150
                    },
                }
            }
        }
    }

    result = create_interfaces_cfg(tgen, input_dict)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("Clear ospf neighbours in all routers")
    for rtr in ["r0", "r1"]:
        clear_ospf(tgen, rtr)

    step("Verify that DR election is triggered and R0 is elected as DR")
    input_dict = {
        "r0": {
            "ospf": {
                "neighbors": {
                    "r1": {
                        "state": "Full",
                        "role": "Backup"
                    },
                    "r2": {
                        "state": "Full",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "Full",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    dut = "r0"
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Configure DR priority 0 on R0 & Clear ospf nbrs on all the routers")

    input_dict = {
        "r0": {
            "links": {
                "s1": {
                    "interface":
                    topo["routers"]["r0"]["links"]["s1"]["interface"],
                    "ospf": {
                        "priority": 0
                    },
                }
            }
        }
    }

    result = create_interfaces_cfg(tgen, input_dict)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("Clear ospf neighbours in all routers")
    for rtr in ["r1"]:
        clear_ospf(tgen, rtr)

    step("Verify that DR election is triggered and R0 is elected as DRother")
    input_dict = {
        "r0": {
            "ospf": {
                "neighbors": {
                    "r1": {
                        "state": "Full",
                        "role": "DR"
                    },
                    "r2": {
                        "state": "2-Way",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "2-Way",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    dut = "r0"
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Configure DR priority to default on R0 and Clear ospf neighbors"
         " on all the routers")

    input_dict = {
        "r0": {
            "links": {
                "s1": {
                    "interface":
                    topo["routers"]["r0"]["links"]["s1"]["interface"],
                    "ospf": {
                        "priority": 100
                    },
                }
            }
        }
    }

    result = create_interfaces_cfg(tgen, input_dict)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("Clear ospf neighbours in all routers")
    for rtr in ["r0", "r1"]:
        clear_ospf(tgen, rtr)

    step("Verify that DR election is triggered and R0 is elected as DR")
    input_dict = {
        "r0": {
            "ospf": {
                "neighbors": {
                    "r1": {
                        "state": "Full",
                        "role": "Backup"
                    },
                    "r2": {
                        "state": "Full",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "Full",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    dut = "r0"
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Shut interface on R0")
    dut = "r0"
    intf = topo["routers"]["r0"]["links"]["s1"]["interface"]
    shutdown_bringup_interface(tgen, dut, intf, False)

    result = verify_ospf_neighbor(tgen, topo, dut, lan=True, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n " "r0: OSPF neighbors-hip is up \n Error: {}".format(
        tc_name, result)

    step("No Shut interface on R0")
    dut = "r0"
    intf = topo["routers"]["r0"]["links"]["s1"]["interface"]
    shutdown_bringup_interface(tgen, dut, intf, True)

    input_dict = {
        "r0": {
            "ospf": {
                "neighbors": {
                    "r1": {
                        "state": "Full",
                        "role": "DR"
                    },
                    "r2": {
                        "state": "Full",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "Full",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    step("Verify that after no shut ospf neighbours are full on R0.")
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Clear ospf on DR router in the topology.")
    clear_ospf(tgen, "r0")

    step("Verify that BDR is getting promoted to DR after clear.")
    step("Verify that all the nbrs are in FULL state with the elected DR.")
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Change the ip on LAN intf on R0 to other ip from the same subnet.")
    topo_modify_change_ip = deepcopy(topo)
    intf_ip = topo_modify_change_ip["routers"]["r0"]["links"]["s1"]["ipv4"]
    topo_modify_change_ip["routers"]["r0"]["links"]["s1"]["ipv4"] = str(
        IPv4Address(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 OSPF is in FULL state with other routers with "
         "newly configured IP.")
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Change the ospf router id on the R0 and clear ip ospf interface.")
    change_rid = {"r0": {"ospf": {"router_id": "100.1.1.100"}}}

    result = create_router_ospf(tgen, topo, change_rid)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)
    topo["routers"]["r0"]["ospf"]["router_id"] = "100.1.1.100"
    step("Reload the FRR router")

    stop_router(tgen, "r0")
    start_router(tgen, "r0")

    step("Verify that OSPF is in FULL state with other routers with"
         " newly configured router id.")
    input_dict = {
        "r1": {
            "ospf": {
                "neighbors": {
                    "r0": {
                        "state": "Full",
                        "role": "Backup"
                    },
                    "r2": {
                        "state": "Full",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "Full",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    dut = "r1"
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Reconfigure the original router id and clear ip ospf interface.")
    change_rid = {"r0": {"ospf": {"router_id": "100.1.1.0"}}}
    result = create_router_ospf(tgen, topo, change_rid)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)
    topo["routers"]["r0"]["ospf"]["router_id"] = "100.1.1.0"
    step("Reload the FRR router")
    # stop/start -> restart FRR router and verify
    stop_router(tgen, "r0")
    start_router(tgen, "r0")

    step("Verify that OSPF is enabled with router id previously configured.")
    input_dict = {
        "r1": {
            "ospf": {
                "neighbors": {
                    "r0": {
                        "state": "Full",
                        "role": "Backup"
                    },
                    "r2": {
                        "state": "Full",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "Full",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    dut = "r1"
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
Example #7
0
def test_ospf_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_ospf_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["ipv4"][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
        redistribute_ospf(tgen, topo, dut, "static")

    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"]:
        nh.append(topo["routers"][rtr]["links"]["s1"]["ipv4"].split("/")[0])
    nh.remove(topo["routers"]["r1"]["links"]["s1"]["ipv4"].split("/")[0])
    dut = "r1"
    result = verify_ospf_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,
                        "ipv4",
                        dut,
                        input_dict,
                        protocol=protocol,
                        next_hop=nh)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step(" clear ip ospf interface on DUT(r0)")
    clear_ospf(tgen, "r0")

    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_ospf_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_ospf_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["ipv4"][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)

    step("Verify that all the routes are withdrawn from R0")
    dut = "r1"
    result = verify_ospf_rib(tgen,
                             dut,
                             input_dict,
                             next_hop=nh,
                             retry_timeout=10,
                             expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n " "r1: OSPF routes are present \n Error: {}".format(
        tc_name, result)

    protocol = "ospf"
    result = verify_rib(
        tgen,
        "ipv4",
        dut,
        input_dict,
        protocol=protocol,
        next_hop=nh,
        retry_timeout=10,
        expected=False,
    )
    assert (
        result is not True
    ), "Testcase {} : Failed \n " "r1: routes are still present \n Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
Example #8
0
def test_ospf_authentication_md5_tc29_p1(request):
    """
    OSPF Authentication - Verify ospf authentication with MD5 authentication.

    """
    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 ospf with on R1 and R2, enable ospf on R1 interface "
         "connected to R2 with message-digest authentication using  ip "
         "ospf authentication  message-digest cmd.")

    r1_ospf_auth = {
        "r1": {
            "links": {
                "r2": {
                    "ospf": {
                        "authentication": "message-digest",
                        "authentication-key": "ospf",
                        "message-digest-key": "10",
                    }
                }
            }
        }
    }
    result = config_ospf_interface(tgen, topo, r1_ospf_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"
    ospf_covergence = verify_ospf_neighbor(tgen,
                                           topo,
                                           dut=dut,
                                           expected=False,
                                           attempts=3)
    assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    step("On R2 enable ospf on interface with message-digest authentication"
         "  using  ip ospf authentication  message-digest password cmd.")

    r2_ospf_auth = {
        "r2": {
            "links": {
                "r1": {
                    "ospf": {
                        "authentication": "message-digest",
                        "authentication-key": "ospf",
                        "message-digest-key": "10",
                    }
                }
            }
        }
    }
    result = config_ospf_interface(tgen, topo, r2_ospf_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 ospf neighbor cmd.")

    dut = "r2"
    ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    step("Disable message-digest authentication on R2  using no ip ospf "
         "authentication  message-digest password cmd.")

    r2_ospf_auth = {
        "r2": {
            "links": {
                "r1": {
                    "ospf": {
                        "authentication": "message-digest",
                        "authentication-key": "ospf",
                        "message-digest-key": "10",
                        "del_action": True,
                    }
                }
            }
        }
    }
    result = config_ospf_interface(tgen, topo, r2_ospf_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"
    ospf_covergence = verify_ospf_neighbor(tgen,
                                           topo,
                                           dut=dut,
                                           expected=False,
                                           attempts=5)
    assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    step("Again On R2 enable ospf on interface with  message-digest auth")
    r2_ospf_auth = {
        "r2": {
            "links": {
                "r1": {
                    "ospf": {
                        "authentication": "message-digest",
                        "authentication-key": "ospf",
                        "message-digest-key": "10",
                    }
                }
            }
        }
    }
    result = config_ospf_interface(tgen, topo, r2_ospf_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 ospf neighbor cmd.")

    dut = "r2"
    ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_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 ospf neighbor cmd.")
    ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut, expected=False)
    assert ospf_covergence is not True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    dut = "r1"
    shutdown_bringup_interface(tgen, dut, intf, True)

    step("Verify that the neighbour is FULL between R1 and R2 using "
         "show ip ospf neighbor cmd.")

    dut = "r2"
    ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    step("Change Ip address on R1 and R2")

    topo_modify_change_ip = deepcopy(topo)

    intf_ip = topo_modify_change_ip["routers"]["r1"]["links"]["r2"]["ipv4"]

    topo_modify_change_ip["routers"]["r1"]["links"]["r2"]["ipv4"] = str(
        IPv4Address(unicode(intf_ip.split("/")[0])) + 3) + "/{}".format(
            intf_ip.split("/")[1])

    build_config_from_json(tgen, topo_modify_change_ip, save_bkup=False)

    reset_config_on_routers(tgen, routerName="r1")
    dut = "r1"
    intf = topo["routers"]["r1"]["links"]["r2"]["interface"]
    shutdown_bringup_interface(tgen, dut, intf, False)
    shutdown_bringup_interface(tgen, dut, intf, True)
    clear_ospf(tgen, "r1")
    r1_ospf_auth = {
        "r1": {
            "links": {
                "r2": {
                    "ospf": {
                        "authentication": "message-digest",
                        "authentication-key": "ospf",
                        "message-digest-key": "10",
                    }
                }
            }
        }
    }
    result = config_ospf_interface(tgen, topo, r1_ospf_auth)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("Verify that the neighbour is FULL between R1 and R2 with new "
         "ip address using show ip ospf ")

    dut = "r1"
    ospf_covergence = verify_ospf_neighbor(tgen, topo, dut=dut)
    assert ospf_covergence is True, "setup_module :Failed \n Error:" " {}".format(
        ospf_covergence)

    write_test_footer(tc_name)
Example #9
0
def test_ospf_gr_helper_tc4_p1(request):
    """
    OSPF GR on Broadcast : Verify DUT enters Helper mode when neighbor
    sends grace lsa, helps RR to restart gracefully (RR = DRother)
    """
    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, intf, intf1, pkt

    step("Bring up the base config as per the topology")
    step("Configure DR priority as 99 in RR , DUT dr priority = 98 "
         "& reset ospf process in all the routers")
    reset_config_on_routers(tgen)
    ospf_covergence = verify_ospf_neighbor(tgen, topo, lan=True)
    assert (
        ospf_covergence is True
    ), "OSPF is not after reset config \n Error:" " {}".format(ospf_covergence)
    step("Configure DR pririty 100 on R0 and clear ospf neighbors "
         "on all the routers.")

    input_dict = {
        "r0": {
            "links": {
                sw_name: {
                    "interface":
                    topo["routers"]["r0"]["links"][sw_name]["interface"],
                    "ospf": {
                        "priority": 0
                    },
                }
            }
        }
    }

    result = create_interfaces_cfg(tgen, input_dict)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("Clear ospf neighbours in all routers")
    for rtr in topo["routers"]:
        clear_ospf(tgen, rtr)

    step("Verify that DR election is triggered and R0 is elected as 2-Way")
    input_dict = {
        "r0": {
            "ospf": {
                "neighbors": {
                    "r1": {
                        "state": "Full",
                        "role": "DR"
                    },
                    "r2": {
                        "state": "2-Way",
                        "role": "DROther"
                    },
                    "r3": {
                        "state": "2-Way",
                        "role": "DROther"
                    },
                }
            }
        }
    }
    dut = "r0"
    result = verify_ospf_neighbor(tgen, topo, dut, input_dict, lan=True)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    ospf_gr_r0 = {
        "r0": {
            "ospf": {
                "graceful-restart": {
                    "helper enable": [],
                    "opaque": True
                }
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_gr_r0)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    ospf_gr_r1 = {
        "r1": {
            "ospf": {
                "graceful-restart": {
                    "helper enable": [],
                    "opaque": True
                }
            }
        }
    }
    result = create_router_ospf(tgen, topo, ospf_gr_r1)
    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    step("Verify that DUT enters into helper mode.")

    input_dict = {"activeRestarterCnt": 1}
    gracelsa_sent = False
    repeat = 0
    dut = "r0"
    while not gracelsa_sent and repeat < Iters:
        gracelsa_sent = scapy_send_raw_packet(tgen, topo, "r1", intf1, pkt)
        result = verify_ospf_gr_helper(tgen, topo, dut, input_dict)
        if isinstance(result, str):
            repeat += 1
            gracelsa_sent = False

    assert result is True, "Testcase {} : Failed \n Error: {}".format(
        tc_name, result)

    delete_ospf()

    write_test_footer(tc_name)