Пример #1
0
def test_RP_configured_as_FHR_2_p2(request):
    """
    TC_22_2_P2: Verify OIF and RFP for (*,G) and (S,G) when static RP configure
             in FHR router

    Topology used:
                ________r2_____
                |             |
      iperf     |             |     iperf
        r0-----r1-------------r3-----r5

    r1 : LHR
    r3 : FHR/RP
    """
    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    step("Creating configuration from JSON")
    reset_config_on_routers(tgen)
    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    clear_pim_interface_traffic(tgen, TOPO)

    step("Enable IGMP on r1 interface")
    step("Configure RP on r2 (loopback interface) for the group range"
         " 225.1.1.0/24")
    step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
    step("Send multicast traffic from r5")
    step("Send the IGMP join from r0")

    step("r1, r2, r3, r4: Delete existing RP configuration"
         "configure r3(FHR) as RP")
    input_dict = {
        "r1": {
            "pim": {
                "rp": [{
                    "rp_addr": "1.0.2.17",
                    "group_addr_range": GROUP_RANGE_ALL,
                    "delete": True,
                }]
            }
        },
        "r2": {
            "pim": {
                "rp": [{
                    "rp_addr": "1.0.2.17",
                    "group_addr_range": GROUP_RANGE_ALL,
                    "delete": True,
                }]
            }
        },
        "r3": {
            "pim": {
                "rp": [{
                    "rp_addr": "1.0.2.17",
                    "group_addr_range": GROUP_RANGE_ALL,
                    "delete": True,
                }]
            }
        },
        "r4": {
            "pim": {
                "rp": [{
                    "rp_addr": "1.0.2.17",
                    "group_addr_range": GROUP_RANGE_ALL,
                    "delete": True,
                }]
            }
        },
    }

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

    step("r1, r2, r3, r4: Configure r3(FHR) as RP")
    input_dict = {
        "r1": {
            "pim": {
                "rp": [{
                    "rp_addr": "1.0.3.17",
                    "group_addr_range": GROUP_RANGE_ALL,
                }]
            }
        },
        "r2": {
            "pim": {
                "rp": [{
                    "rp_addr": "1.0.3.17",
                    "group_addr_range": GROUP_RANGE_ALL,
                }]
            }
        },
        "r3": {
            "pim": {
                "rp": [{
                    "rp_addr": "1.0.3.17",
                    "group_addr_range": GROUP_RANGE_ALL,
                }]
            }
        },
        "r4": {
            "pim": {
                "rp": [{
                    "rp_addr": "1.0.3.17",
                    "group_addr_range": GROUP_RANGE_ALL,
                }]
            }
        },
    }

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

    step("r1: Verify RP info")
    dut = "r1"
    rp_address = "1.0.3.17"
    iif = "r1-r3-eth2"
    result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_RANGE_ALL, iif,
                                rp_address, SOURCE)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r5: Send multicast traffic for group 225.1.1.1")
    result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r0: Send IGMP join")
    result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r0: Verify IGMP groups")
    oif = "r1-r0-eth0"
    result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (*, G) upstream IIF interface")
    result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (*, G) upstream join state and join timer")
    result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (*, G) ip mroutes")
    result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (S, G) upstream IIF interface")
    iif = "r1-r3-eth2"
    result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (S, G) upstream join state and join timer")
    result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS,
                                         GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (S, G) ip mroutes")
    result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r3: Verify (S, G) upstream IIF interface")
    dut = "r3"
    iif = "r3-r5-eth3"
    result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r3: Verify (S, G) upstream join state and join timer")
    result = verify_join_state_and_timer(tgen,
                                         dut,
                                         iif,
                                         SOURCE_ADDRESS,
                                         GROUP_ADDRESS,
                                         expected=False)
    assert result is not True, (
        "Testcase {} : Failed \n "
        "r3: (S,G) upstream state is joined and join timer is running\n Error: {}"
        .format(tc_name, result))

    step("r3: Verify (S, G) ip mroutes")
    oif = "r3-r1-eth0"
    result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    # Uncomment next line for debugging
    # tgen.mininet_cli()

    write_test_footer(tc_name)
def test_pim_source_dr_functionality_while_rebooting_dr_non_dr_nodes_p1(
        request):
    """
    Verify mroute while rebooting DR /Non DR nodes( r1, r2 , r3 on all the nodes)
    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Creating configuration from JSON
    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    check_router_status(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    result = pre_config_for_source_dr_tests(tgen, topo, tc_name, "r1", "r3")
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    step("R1 is the DR , verify using 'show ip pim interface json'")

    vlan_intf_r1_s1 = "{}.{}".format(intf_r1_s1, VLAN_1)
    input_dict_dr = {
        "r1": {
            "pim": {
                "interfaces": {
                    vlan_intf_r1_s1: {
                        "drAddress": SAME_VLAN_IP_3["ip"]
                    }
                }
            }
        }
    }
    result = verify_pim_config(tgen, input_dict_dr)
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    step(
        "R2 is transit router for R3 to reach R4, mroute should have (s, g) mroute with "
        "OIL towards R4, using 'show ip mroute json'")
    step("R2 (s, g) upstream should be in join state verify using "
         "'show ip pim upstream json'")
    step(
        "R1 has (S, G) mroute with NONE OIL and upstream as not joined, verify using "
        "'show ip mroute json' 'show ip pim upstream json'")

    source_i1 = SAME_VLAN_IP_4["ip"]
    input_dict_r1_r2 = [
        {
            "dut":
            "r1",
            "src_address":
            source_i1,
            "oil":
            "none",
            "iif":
            "{}.{}".format(topo["routers"]["r1"]["links"]["s1"]["interface"],
                           VLAN_1),
        },
        {
            "dut":
            "r2",
            "src_address":
            source_i1,
            "oil":
            topo["routers"]["r2"]["links"]["r4"]["interface"],
            "iif":
            "{}.{}".format(topo["routers"]["r2"]["links"]["s1"]["interface"],
                           VLAN_1),
        },
    ]

    for data in input_dict_r1_r2:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

        if data["dut"] == "r2":
            result = verify_upstream_iif(tgen, data["dut"], data["iif"],
                                         data["src_address"],
                                         IGMP_JOIN_RANGE_1)
            assert result is True, "Testcase {} : Failed Error: {}".format(
                tc_name, result)
        else:
            result = verify_upstream_iif(
                tgen,
                data["dut"],
                data["iif"],
                data["src_address"],
                IGMP_JOIN_RANGE_1,
                expected=False,
            )
            assert result is not True, (
                "Testcase {} : Failed \n "
                "Upstream is still joined state \n Error: {}".format(
                    tc_name, result))

    step("Reboot R3 node")
    stop_router(tgen, "r3")

    step(
        "After reboot of R3 verify R1 became DR, using 'show ip pim interface json'"
    )

    result = verify_pim_config(tgen, input_dict_dr)
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    step("R3 should not have any mroute and upstream")
    step(
        "R2 has mroute with OIL towards R4 /R1 , verify using 'show ip mroute'"
    )
    step(
        "R2 has upstream with Join RejP state verify using 'show ip pim upstream json'"
    )
    step("R1 has mroute with none OIL and upstream with Not Join")

    for data in input_dict_r1_r2:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

        if data["dut"] == "r2":
            result = verify_upstream_iif(tgen, data["dut"], data["iif"],
                                         data["src_address"],
                                         IGMP_JOIN_RANGE_1)
            assert result is True, "Testcase {} : Failed Error: {}".format(
                tc_name, result)
        else:
            result = verify_upstream_iif(
                tgen,
                data["dut"],
                data["iif"],
                data["src_address"],
                IGMP_JOIN_RANGE_1,
                expected=False,
            )
            assert result is not True, (
                "Testcase {} : Failed \n "
                "Upstream is still joined state \n Error: {}".format(
                    tc_name, result))

    step("Reboot R2 node")
    stop_router(tgen, "r2")

    step(
        "After reboot of R2, R1 became DR verify using 'show ip pim interface json'"
    )

    result = verify_pim_config(tgen, input_dict_dr)
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    step("R3 and R2 should not have any mroute and upstream , verify using "
         "'show ip mroute json' 'show ip pim upstream json'")
    step(
        "R1 has mroute created with OIL towards R4 , using 'show ip mroute json'"
    )
    step(
        "R1 has upstream with Join Rej Prune , verify using 'show ip pim upstream json'"
    )

    for data in input_dict_r1_r2:
        if data["dut"] == "r1":
            result = verify_mroutes(
                tgen,
                data["dut"],
                data["src_address"],
                IGMP_JOIN_RANGE_1,
                data["iif"],
                data["oil"],
            )
            assert result is True, "Testcase {} : Failed Error: {}".format(
                tc_name, result)

            result = verify_upstream_iif(
                tgen,
                data["dut"],
                data["iif"],
                data["src_address"],
                IGMP_JOIN_RANGE_1,
                expected=False,
            )
            assert result is not True, (
                "Testcase {} : Failed \n "
                "Upstream is still joined state \n Error: {}".format(
                    tc_name, result))

    step("Reboot R1 node using FRR stop")
    stop_router(tgen, "r1")

    step("After stop of all the routers, verify upstream and mroutes should "
         "not present in any of them")

    for data in input_dict_r1_r2:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
            expected=False,
        )
        assert (
            result is not True
        ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
            tc_name, result)

    step("start FRR for all the nodes")
    start_router(tgen, "r1")
    start_router(tgen, "r2")
    start_router(tgen, "r3")

    step("After start of all the routers, R1 became DR")

    result = verify_pim_config(tgen, input_dict_dr)
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    for data in input_dict_r1_r2:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

        if data["dut"] == "r2":
            result = verify_upstream_iif(tgen, data["dut"], data["iif"],
                                         data["src_address"],
                                         IGMP_JOIN_RANGE_1)
            assert result is True, "Testcase {} : Failed Error: {}".format(
                tc_name, result)

    write_test_footer(tc_name)
Пример #3
0
def test_SPT_RPT_path_different_p1(request):
    """
    TC_23_P1: Verify (*,G) and (S,G) populated correctly when RPT and SPT path
              are different

    Topology used:
                ________r2_____
                |             |
      iperf     |             |     iperf
        r0-----r1-------------r3-----r5

    r1: LHR
    r2: RP
    r3: FHR
    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    step("Creating configuration from JSON")
    reset_config_on_routers(tgen)
    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    clear_pim_interface_traffic(tgen, TOPO)

    step("Enable IGMP on r1 interface and send IGMP join (225.1.1.1) to r1")
    step("Configure RP on r2 (loopback interface) for the group range"
         " 224.0.0.0/4")
    step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
    step("Send multicast traffic from r3")

    step("r2: Verify RP info")
    dut = "r2"
    rp_address = "1.0.2.17"
    iif = "lo"
    result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_ADDRESS, iif,
                                rp_address, SOURCE)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r0: Send IGMP join")
    result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify IGMP groups")
    dut = "r1"
    oif = "r1-r0-eth0"
    result = verify_igmp_groups(tgen, dut, oif, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r5: Send multicast traffic for group 225.1.1.1")
    result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (*, G) upstream IIF interface")
    iif = "r1-r2-eth1"
    result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (*, G) upstream join state and join timer")
    result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (*, G) ip mroutes")
    result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (S, G) upstream IIF interface")
    iif = "r1-r3-eth2"
    result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (S, G) upstream join state and join timer")
    result = verify_join_state_and_timer(tgen, dut, iif, SOURCE_ADDRESS,
                                         GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (S, G) ip mroutes")
    result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r2: Verify (*, G) upstream IIF interface")
    dut = "r2"
    iif = "lo"
    result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r2: Verify (*, G) upstream join state and join timer")
    result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r2: Verify (*, G) ip mroutes")
    oif = "r2-r1-eth0"
    result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r3: Verify (S, G) upstream IIF interface")
    dut = "r3"
    iif = "r3-r5-eth3"
    result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r3: Verify (S, G) upstream join state and join timer")
    result = verify_join_state_and_timer(tgen,
                                         dut,
                                         iif,
                                         SOURCE_ADDRESS,
                                         GROUP_ADDRESS,
                                         expected=False)
    assert result is not True, (
        "Testcase {} : Failed \n "
        "r3: (S,G) upstream state is joined and join timer is running\n Error: {}"
        .format(tc_name, result))

    step("r3: Verify (S, G) ip mroutes")
    oif = "r3-r1-eth0"
    result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r2: Verify (S, G) upstream IIF interface")
    dut = "r2"
    iif = "r2-r3-eth1"
    result = verify_upstream_iif(tgen,
                                 dut,
                                 iif,
                                 SOURCE_ADDRESS,
                                 GROUP_ADDRESS,
                                 joinState="NotJoined")
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r2: Verify (S, G) upstream join state and join timer")
    result = verify_join_state_and_timer(tgen,
                                         dut,
                                         iif,
                                         SOURCE_ADDRESS,
                                         GROUP_ADDRESS,
                                         expected=False)
    assert result is not True, (
        "Testcase {} : Failed \n "
        "r2: (S,G) upstream state is joined and join timer is running\n Error: {}"
        .format(tc_name, result))

    step("r2: Verify (S, G) ip mroutes")
    oif = "none"
    result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS, iif, oif)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    # Uncomment next line for debugging
    # tgen.mininet_cli()

    write_test_footer(tc_name)
Пример #4
0
def test_clear_pim_configuration_p1(request):
    """
    TC_25_P1: Verify (*,G) and (S,G) populated correctly after clearing the
              PIM,IGMP and mroutes joins

    Topology used:
                ________r2_____
                |             |
      iperf     |             |     iperf
        r0-----r1-------------r3-----r5
                |             |
                |_____________|
                        r4
    r1 : LHR
    r2 : RP
    r3 : FHR
    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    step("Creating configuration from JSON")
    reset_config_on_routers(tgen)
    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    clear_pim_interface_traffic(tgen, TOPO)

    step("Enable IGMP on r1 interface")
    step("Configure RP on r2 (loopback interface) for the group range"
         " 224.0.0.0/4")
    step("Enable the PIM on all the interfaces of r1, r2, r3 and r4 routers")
    step("Send the IGMP join from r0")
    step("Send multicast traffic from r5")

    step("r2: Verify RP info")
    dut = "r2"
    rp_address = "1.0.2.17"
    oif = "lo"
    result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_RANGE_ALL, oif,
                                rp_address, SOURCE)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r0: Send IGMP join")
    result = app_helper.run_join("r0", GROUP_ADDRESS, "r1")
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify IGMP groups")
    dut = "r1"
    iif = "r1-r0-eth0"
    result = verify_igmp_groups(tgen, dut, iif, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r5: Send multicast traffic for group 225.1.1.1")
    result = app_helper.run_traffic("r5", GROUP_ADDRESS, "r3")
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (*, G) upstream IIF interface")
    dut = "r1"
    iif = "r1-r2-eth1"
    result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (*, G) upstream join state and join timer")
    result = verify_join_state_and_timer(tgen, dut, iif, STAR, GROUP_ADDRESS)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify (*, G) ip mroutes")
    oif = "r1-r0-eth0"
    result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS, iif, oif)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify IGMP groups timer restarted")
    result = clear_igmp_interfaces(tgen, dut)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify PIM neighbor timer restarted")
    result = clear_pim_interfaces(tgen, dut)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    step("r1: Verify PIM mroute timer restarted")
    result = clear_mroute_verify(tgen, dut)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    # Uncomment next line for debugging
    # tgen.mininet_cli()

    write_test_footer(tc_name)
Пример #5
0
def test_mroute_when_transit_router_present_between_rp_and_source_dr_p1(request):
    """
    Verify mroutes when transit router present between RP and Source DR
    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Creating configuration from JSON
    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    check_router_status(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    result = pre_config_for_source_dr_tests(tgen, topo, tc_name, "r1", "r2")
    assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)

    step("Taken care in base config: Add router R6 between RP and R1 , R2")

    step("R1 is the DR, mroute and upstream created on R1")

    vlan_intf_r1_s1 = "{}.{}".format(intf_r1_s1, VLAN_1)
    input_dict_dr = {
        "r1": {
            "pim": {
                "interfaces": {vlan_intf_r1_s1: {"drAddress": SAME_VLAN_IP_2["ip"]}}
            }
        }
    }
    result = verify_pim_config(tgen, input_dict_dr)
    assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)

    step("On R1 Mroute OIL towards R6, upstream in join Rej Prune state")

    source_i1 = SAME_VLAN_IP_4["ip"]
    input_dict_r1 = [
        {
            "dut": "r1",
            "src_address": source_i1,
            "oil": topo["routers"]["r1"]["links"]["r6"]["interface"],
            "iif": "{}.{}".format(
                topo["routers"]["r1"]["links"]["s1"]["interface"], VLAN_1
            ),
        }
    ]

    for data in input_dict_r1:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)

        result = verify_upstream_iif(
            tgen, data["dut"], data["iif"], data["src_address"], IGMP_JOIN_RANGE_1
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)

    step(
        "R5 have mroute created and traffic is received, verify using "
        "'show ip mroute json' 'show ip multicast json'"
    )

    input_dict_r5 = [
        {
            "dut": "r5",
            "src_address": "*",
            "iif": topo["routers"]["r5"]["links"]["r4"]["interface"],
            "oil": topo["routers"]["r5"]["links"]["i2"]["interface"],
        },
        {
            "dut": "r5",
            "src_address": source_i1,
            "iif": topo["routers"]["r5"]["links"]["r4"]["interface"],
            "oil": topo["routers"]["r5"]["links"]["i2"]["interface"],
        },
    ]

    for data in input_dict_r5:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)

    input_dict_traffic_r5 = {
        "r5": {
            "traffic_received": [topo["routers"]["r5"]["links"]["r4"]["interface"]],
            "traffic_sent": [topo["routers"]["r5"]["links"]["i2"]["interface"]],
        }
    }

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

    step("Make R2 as DR configuring higher priority value")

    raw_config = {
        "r1": {
            "raw_config": [
                "interface {}.{}".format(intf_r1_s1, VLAN_1),
                "no ip address {}/{}".format(
                    SAME_VLAN_IP_2["ip"], SAME_VLAN_IP_1["cidr"]
                ),
                "ip address {}/{}".format(SAME_VLAN_IP_1["ip"], SAME_VLAN_IP_1["cidr"]),
            ]
        },
        "r2": {
            "raw_config": [
                "interface {}.{}".format(intf_r2_s1, VLAN_1),
                "no ip address {}/{}".format(
                    SAME_VLAN_IP_1["ip"], SAME_VLAN_IP_1["cidr"]
                ),
                "ip address {}/{}".format(SAME_VLAN_IP_2["ip"], SAME_VLAN_IP_2["cidr"]),
            ]
        },
    }

    result = apply_raw_config(tgen, raw_config)
    assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)

    step("R2 is the DR, mroute and upstream created on R2")

    vlan_intf_r2_s1 = "{}.{}".format(intf_r2_s1, VLAN_1)
    input_dict_dr = {
        "r2": {
            "pim": {
                "interfaces": {vlan_intf_r2_s1: {"drAddress": SAME_VLAN_IP_2["ip"]}}
            }
        }
    }
    result = verify_pim_config(tgen, input_dict_dr)
    assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)

    step(
        "R5 have mroute created and traffic is received, verify using "
        "'show ip mroute json' 'show ip multicast json'"
    )

    for data in input_dict_r5:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)

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

    write_test_footer(tc_name)
def test_configuring_igmp_local_join_on_reciever_dr_non_dr_nodes_p1(request):
    """
    Configure IGMP local join on DR and non DR
    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Creating configuration from JSON
    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    check_router_status(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    step("Configure IGMP and PIM on switch connected receiver nodes")
    step("Configure PIM on all upstream interfaces")

    step("Configure link between R1, R2 ,R3 and receiver on" " same vlan")
    step("Make sure R1 is DR initially configuring highest IP on R1 and R2 "
         "second highest, R1 is lower")

    intf_r1_s1 = topo["routers"]["r1"]["links"]["s1"]["interface"]
    intf_r1_s1_addr = topo["routers"]["r1"]["links"]["s1"]["ipv4"]

    intf_r2_s1 = topo["routers"]["r2"]["links"]["s1"]["interface"]
    intf_r2_s1_addr = topo["routers"]["r2"]["links"]["s1"]["ipv4"]

    intf_i1_s1 = topo["routers"]["i1"]["links"]["s1"]["interface"]
    intf_i1_s1_addr = topo["routers"]["i1"]["links"]["s1"]["ipv4"]

    vlan_input = {
        "r1": {
            "vlan": {
                VLAN_1: [{
                    intf_r1_s1: {
                        "ip": SAME_VLAN_IP_1["ip"],
                        "subnet": SAME_VLAN_IP_1["subnet"],
                    }
                }]
            }
        },
        "r2": {
            "vlan": {
                VLAN_1: [{
                    intf_r2_s1: {
                        "ip": SAME_VLAN_IP_2["ip"],
                        "subnet": SAME_VLAN_IP_2["subnet"],
                    }
                }]
            }
        },
        "i1": {
            "vlan": {
                VLAN_1: [{
                    intf_i1_s1: {
                        "ip": SAME_VLAN_IP_4["ip"],
                        "subnet": SAME_VLAN_IP_4["subnet"],
                    }
                }]
            }
        },
    }

    add_interfaces_to_vlan(tgen, vlan_input)

    raw_config = {
        "r1": {
            "raw_config": [
                "interface {}".format(intf_r1_s1),
                "no ip address {}".format(intf_r1_s1_addr),
                "no ip pim",
            ]
        },
        "r2": {
            "raw_config": [
                "interface {}".format(intf_r2_s1),
                "no ip address {}".format(intf_r2_s1_addr),
                "no ip pim",
            ]
        },
        "i1": {
            "raw_config": [
                "interface {}".format(intf_i1_s1),
                "no ip address {}".format(intf_i1_s1_addr),
            ]
        },
    }

    result = apply_raw_config(tgen, raw_config)
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    raw_config = {
        "r1": {
            "raw_config": [
                "interface {}.{}".format(intf_r1_s1, VLAN_1),
                "ip address {}/{}".format(SAME_VLAN_IP_1["ip"],
                                          SAME_VLAN_IP_1["cidr"]),
                "ip pim",
                "ip igmp",
                "ip igmp version 2",
            ]
        },
        "r2": {
            "raw_config": [
                "interface {}.{}".format(intf_r2_s1, VLAN_1),
                "ip address {}/{}".format(SAME_VLAN_IP_2["ip"],
                                          SAME_VLAN_IP_2["cidr"]),
                "ip pim",
                "ip igmp",
                "ip igmp version 2",
            ]
        },
        "i1": {
            "raw_config": [
                "interface {}.{}".format(intf_i1_s1, VLAN_1),
                "ip address {}/{}".format(SAME_VLAN_IP_4["ip"],
                                          SAME_VLAN_IP_4["cidr"]),
            ]
        },
    }

    result = apply_raw_config(tgen, raw_config)
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]):
        raw_config = {
            dut: {
                "raw_config": [
                    "interface {}.{}".format(intf, VLAN_1),
                    "ip pim hello {} {}".format(HELLO_TIMER, HOLD_TIMER),
                ]
            }
        }
        result = apply_raw_config(tgen, raw_config)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    step("Configure R4 as RP on all the nodes for group range 224.0.0.0/24")

    input_dict = {
        "r4": {
            "pim": {
                "rp": [{
                    "rp_addr":
                    topo["routers"]["r4"]["links"]["lo"]["ipv4"].split("/")[0],
                    "group_addr_range":
                    GROUP_RANGE_1 + GROUP_RANGE_3,
                }]
            }
        }
    }

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

    step("Send IGMP local join for groups 226.1.1.1 to 226.1.1.5")

    vlan_intf_r1_s1 = "{}.{}".format(intf_r1_s1, VLAN_1)
    input_dict = {
        "r1": {
            "igmp": {
                "interfaces": {
                    vlan_intf_r1_s1: {
                        "igmp": {
                            "version": "2",
                            "join": IGMP_JOIN_RANGE_1
                        }
                    }
                }
            }
        }
    }

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

    step("Enable OSPF between all the nodes")

    step("Configure local join on R1 for group range (227.1.1.1)")

    vlan_intf_r1_s1 = "{}.{}".format(intf_r1_s1, VLAN_1)
    input_dict = {
        "r1": {
            "igmp": {
                "interfaces": {
                    vlan_intf_r1_s1: {
                        "igmp": {
                            "version": "2",
                            "join": IGMP_JOIN_RANGE_3
                        }
                    }
                }
            }
        }
    }

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

    step("Start traffic from R4 connected source")

    input_src = {"i2": topo["routers"]["i2"]["links"]["r5"]["interface"]}

    result = app_helper.run_traffic("i2",
                                    IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3,
                                    "r5")
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    step("R1, R2 and R2 has IGMP groups for 226.x.x.x and 227.1.1.1 groups")

    intf_r1_s1 = "{}.{}".format(
        topo["routers"]["r1"]["links"]["s1"]["interface"], VLAN_1)
    intf_r2_s1 = "{}.{}".format(
        topo["routers"]["r2"]["links"]["s1"]["interface"], VLAN_1)

    for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]):
        result = verify_igmp_groups(tgen, dut, intf,
                                    IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    step("R1 is DR, R2 has 226.x.x.x and 227.1.1.1 (*,G) mroute with SC flag")
    step("(S,G) mroute for 226.1.1.1 group present on R2")

    source_i2 = topo["routers"]["i2"]["links"]["r5"]["ipv4"].split("/")[0]
    input_dict_r2 = [{
        "dut":
        "r2",
        "src_address":
        "*",
        "iif":
        topo["routers"]["r2"]["links"]["r4"]["interface"],
        "oil":
        "{}.{}".format(topo["routers"]["r2"]["links"]["s1"]["interface"],
                       VLAN_1),
    }]

    for data in input_dict_r2:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    for dut, flag in zip(["r2"], ["SC"]):
        step("{} has (*,G) flag as {}".format(dut, flag))
        result = verify_multicast_flag_state(tgen, dut, "*", IGMP_JOIN_RANGE_1,
                                             flag)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    step("Delete local join from DR node")
    for _join in IGMP_JOIN_RANGE_3:
        input_dict = {
            "r1": {
                "igmp": {
                    "interfaces": {
                        vlan_intf_r1_s1: {
                            "igmp": {
                                "join": [_join],
                                "delete_attr": True,
                            }
                        }
                    }
                }
            }
        }

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

        step(
            "After removing local join 227.1.1.1 group removed from IGMP join "
            "of R1, R2 node , using 'show ip igmp groups json'")

        for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]):
            result = verify_igmp_groups(tgen,
                                        dut,
                                        intf,
                                        IGMP_JOIN_RANGE_3,
                                        expected=False)
            assert result is not True, (
                "Testcase {} : Failed \n "
                "IGMP groups are still present \n Error: {}".format(
                    tc_name, result))

    step("(*,G) mroute for 227.1.1.1 group removed from R1 node")
    step(
        "After remove of local join from R1 and R2 node verify (*,G) and (S,G) "
        "mroutes should not present on R1, R2 and R3 nodes")

    for data in input_dict_r2:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_3,
            data["iif"],
            data["oil"],
            expected=False,
        )
        assert (
            result is not True
        ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
            tc_name, result)

    step("Configure local join on R2 for group range (227.1.1.1)")

    input_dict = {
        "r2": {
            "igmp": {
                "interfaces": {
                    intf_r2_s1: {
                        "igmp": {
                            "version": "2",
                            "join": IGMP_JOIN_RANGE_3
                        }
                    }
                }
            }
        }
    }

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

    step(
        "After configuring local join on R2 non DR node, IGMP groups for 26.x.x.x and "
        "227.1.1.1 present on all the nodes")

    for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]):
        result = verify_igmp_groups(tgen, dut, intf,
                                    IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    step("R2 has 227.1.1.1 (*,G) mroute with SC flag")

    for dut, flag in zip(["r2"], ["SC"]):
        step("{} has (*,G) flag as {}".format(dut, flag))
        result = verify_multicast_flag_state(tgen, dut, "*", IGMP_JOIN_RANGE_3,
                                             flag)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    step("Configure local join on R1 for group range (227.1.1.1)")

    input_dict = {
        "r1": {
            "igmp": {
                "interfaces": {
                    vlan_intf_r1_s1: {
                        "igmp": {
                            "version": "2",
                            "join": IGMP_JOIN_RANGE_3
                        }
                    }
                }
            }
        }
    }

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

    step(
        "After configuring 227.1.1.1 on R1 node, verify no change on IGMP groups on all the nodes"
    )

    for dut, intf in zip(["r1", "r2"], [intf_r1_s1, intf_r2_s1]):
        result = verify_igmp_groups(tgen, dut, intf,
                                    IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    step("R2 has 227.1.1.1 (*,G) mroute with SC flag")

    step("r2 has (*,G) flag as SC")
    result = verify_multicast_flag_state(tgen, "r2", "*", IGMP_JOIN_RANGE_3,
                                         "SC")
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    step("R1 should not have (*,G) join and (S,G) join present")

    input_dict_r1 = [
        {
            "dut":
            "r1",
            "src_address":
            "*",
            "iif":
            topo["routers"]["r1"]["links"]["r4"]["interface"],
            "oil":
            "{}.{}".format(topo["routers"]["r1"]["links"]["s1"]["interface"],
                           VLAN_1),
        },
        {
            "dut":
            "r1",
            "src_address":
            source_i2,
            "iif":
            topo["routers"]["r1"]["links"]["r4"]["interface"],
            "oil":
            "{}.{}".format(topo["routers"]["r1"]["links"]["s1"]["interface"],
                           VLAN_1),
        },
    ]

    for data in input_dict_r1:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3,
            data["iif"],
            data["oil"],
            expected=False,
        )
        assert (
            result is not True
        ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
            tc_name, result)

    step("Remove local join from DR and Non DR node")

    input_dict = {
        "r1": {
            "igmp": {
                "interfaces": {
                    vlan_intf_r1_s1: {
                        "igmp": {
                            "version": "2",
                            "join": IGMP_JOIN_RANGE_3,
                            "delete_attr": True,
                        }
                    }
                }
            }
        },
        "r2": {
            "igmp": {
                "interfaces": {
                    intf_r2_s1: {
                        "igmp": {
                            "version": "2",
                            "join": IGMP_JOIN_RANGE_3,
                            "delete_attr": True,
                        }
                    }
                }
            }
        },
    }

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

    step(
        "After remove of local join from R1 and R2 node verify (*,G) and (S,G) mroutes "
        "should not present on R1, R2 nodes")

    for data in input_dict_r1:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3,
            data["iif"],
            data["oil"],
            expected=False,
        )
        assert (
            result is not True
        ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
            tc_name, result)

    for data in input_dict_r2:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1 + IGMP_JOIN_RANGE_3,
            data["iif"],
            data["oil"],
            expected=False,
        )
        assert (
            result is not True
        ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
            tc_name, result)

    write_test_footer(tc_name)
Пример #7
0
def test_BSR_election_p0(request):
    """
    Verify group to RP mapping in FRR node when 2 BSR are present in the network
    and both are having same BSR priority

    Topology used:
      b1_____
             |
             |
      s1-----f1-----i1-----l1----r1
             |
       ______|
      b2

      b1 - BSR 1
      b2 - BSR 2
      s1 - Source
      f1 - FHR
      i1 - Intermediate Router (also RP)
      r1 - Receiver

    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b1", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b2", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    GROUP_ADDRESS = "225.1.1.1"

    # Use scapy to send pre-defined packet from senser to receiver
    step("Send BSR packet from b1 to FHR")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet3")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    bsr_ip1 = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"][
        "bsr"].split("/")[0]
    time.sleep(1)

    result = app_helper.run_join("r1", GROUP_ADDRESS, "l1")
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify bsr state in FHR
    step("Verify if b1 is chosen as bsr in f1")
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip1)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    dut = "l1"
    group = "225.1.1.0/24"
    # Find the elected rp from bsrp-info
    step("Find the elected rp from bsrp-info in LHR in l1")
    rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip1, group)
    assert rp is not {}, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Check RP detail in LHR
    step("Verify RP in LHR l1")
    result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group])
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Send BSR packet from b2 with same priority
    step("Send BSR packet from b2 to FHR with same priority")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b2", "f1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    bsr_ip2 = topo["routers"]["b2"]["bsm"]["bsr_packets"]["packet2"][
        "bsr"].split("/")[0]
    time.sleep(1)

    logger.info("BSR b1:" + bsr_ip1 + " BSR b2:" + bsr_ip2)
    # Verify bsr state in FHR
    step("Verify if b2 is not chosen as bsr in f1")
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip2, expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n " "b2 is chosen as bsr in f1 \n Error: {}".format(
        tc_name, result)

    # Verify if b1 is still chosen as bsr
    step("Verify if b1 is still chosen as bsr in f1")
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip1)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Verify if that rp is installed
    step("Verify that same RP in istalled in LHR l1")
    result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group])
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    step("clear  BSM database before moving to next case")
    clear_bsrp_data(tgen, topo)

    write_test_footer(tc_name)
Пример #8
0
def test_RP_hash_p0(request):
    """
    Verify RP is selected based on hash function, when BSR advertising the group
    to RP mapping with same priority

    Topology used:
      b1_____
             |
             |
      s1-----f1-----i1-----l1----r1
             |
       ______|
      b2

      b1 - BSR 1
      b2 - BSR 2
      s1 - Source
      f1 - FHR
      i1 - Intermediate Router (also RP)
      r1 - Receiver

    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b1", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b2", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    GROUP_ADDRESS = "225.1.1.1"

    # Use scapy to send pre-defined packet from senser to receiver
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet7")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"][
        "bsr"].split("/")[0]
    time.sleep(1)

    result = app_helper.run_join("r1", GROUP_ADDRESS, "l1")
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    dut = "l1"

    # Verify bsr state in FHR
    step("Verify if b1 chosen as BSR in f1")
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    group = "225.1.1.0/24"

    # Find the elected rp from bsrp-info
    step("Find the elected rp from bsrp-info in LHR l1")
    rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group)
    assert rp is not {}, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Verify if RP with highest hash value is chosen
    step("Verify if RP(2.2.2.2) with highest hash value is chosen in l1")
    if rp[group] == "2.2.2.2":
        result = True
    else:
        result = "rp expected: 2.2.2.2 got:" + rp[group]

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

    # Check RP detail in LHR
    step("Verify RP in LHR")
    result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group])
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    step("clear  BSM database before moving to next case")
    clear_bsrp_data(tgen, topo)

    write_test_footer(tc_name)
Пример #9
0
def test_overlapping_group_p0(request):
    """
    Verify group to RP updated correctly on FRR router, when BSR advertising
    the overlapping group address

    Topology used:
      b1_____
             |
             |
      s1-----f1-----i1-----l1----r1
             |
       ______|
      b2

      b1 - BSR 1
      b2 - BSR 2
      s1 - Source
      f1 - FHR
      i1 - Intermediate Router (also RP)
      r1 - Receiver

    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b1", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b2", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    GROUP_ADDRESS = "225.1.1.1"

    # Use scapy to send pre-defined packet from senser to receiver
    step("Send BSR packet from b1 to FHR")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet4")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"][
        "bsr"].split("/")[0]
    time.sleep(1)

    result = app_helper.run_join("r1", GROUP_ADDRESS, "l1")
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify bsr state in FHR
    step("Verify if b1 is chosen as bsr in f1")
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    dut = "l1"
    group1 = "225.1.1.1/32"
    # Find the elected rp from bsrp-info fro group 225.1.1.1/32
    step("Find the elected rp from bsrp-info in LHR for 225.1.1.1/32")
    rp1 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group1)
    assert rp1 is not {}, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    group2 = "225.1.1.0/24"
    # Find the elected rp from bsrp-info fro group 225.1.1.0/24
    step("Find the elected rp from bsrp-info in LHR for 225.1.1.0/24")
    rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group2)
    assert rp2 is not {}, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    iif = "l1-i1-eth0"
    # Verify upstream rpf for 225.1.1.1 is chosen as rp1
    step("Verify upstream rpf for 225.1.1.1 is chosen as rp1 in l1")
    result = verify_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, rp1)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Send BSR packet from b1 with rp for 225.1.1.1/32 removed
    step("Send BSR packet from b1 with rp for 225.1.1.1/32 removed")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet5")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Verify upstream rpf for 225.1.1.1 is chosen as rp1
    step("Verify upstream rpf for 225.1.1.1 is chosen as rp2 in l1")
    result = verify_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, rp2)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify IIF/OIL in pim state
    step("Verify iif is installed after rp change in l1")
    oil = "l1-r1-eth1"
    result = verify_pim_state(tgen, dut, iif, oil, GROUP_ADDRESS)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    step("clear  BSM database before moving to next case")
    clear_bsrp_data(tgen, topo)

    write_test_footer(tc_name)
Пример #10
0
def test_RP_priority_p0(request):
    """
    Verify group to RP info is updated correctly, when BSR advertising the
    same RP with different priority

    Topology used:
      b1_____
             |
             |
      s1-----f1-----i1-----l1----r1
             |
       ______|
      b2

      b1 - BSR 1
      b2 - BSR 2
      s1 - Source
      f1 - FHR
      i1 - Intermediate Router (also RP)
      r1 - Receiver
    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b1", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b2", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    GROUP_ADDRESS = "225.1.1.1"

    # Use scapy to send pre-defined packet from senser to receiver
    step("Send BSR packet from b1 to FHR")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"][
        "bsr"].split("/")[0]
    time.sleep(1)

    result = app_helper.run_join("r1", GROUP_ADDRESS, "l1")
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify bsr state in FHR
    step("Verify if b1 is chosen as bsr in f1")
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    dut = "l1"
    group = "225.1.1.0/24"
    # Find the elected rp from bsrp-info
    step("Find the elected rp from bsrp-info in LHR l1")
    rp1 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group)
    assert rp1 is not {}, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Check RP detail in LHR
    step("Verify RP in LHR l1")
    result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR",
                                      rp1[group])
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24
    step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet6")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Find the elected rp from bsrp-info
    step("Find the elected rp from bsrp-info in LHR l1")
    rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group)
    assert rp2 is not {}, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)
    logger.info("RP old: {} RP2 new: {} ".format(rp1[group], rp2[group]))

    # Verify is the rp is different now
    assert rp1[group] != rp2[group], "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    rp_add1 = rp1[group]
    rp_add2 = rp2[group]

    # Verify if that rp is installed
    step("Verify new RP in LHR installed")
    result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add2)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Send BSR packet from b1 after putting back high prio rp for 225.1.1.0/24
    step("Send BSM from b1 to FHR put back old high prio rp for 225.1.1.0/24")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Find the elected rp from bsrp-info
    step("Find the elected rp from bsrp-info in LHR")
    rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group)
    assert rp2 is not {}, "Testcase {} :Failed \n Error : RP not Found".format(
        tc_name)

    # Verify is the rp is different now
    step("Verify now old RP is elected again")
    assert (
        rp_add1 == rp2[group]
    ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format(
        tc_name, rp_add1, rp2[group] if group in rp2 else None)

    # Verify if that rp is installed
    step("Verify new RP in LHR installed")
    result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add1)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    step("clear  BSM database before moving to next case")
    clear_bsrp_data(tgen, topo)

    write_test_footer(tc_name)
Пример #11
0
def test_starg_mroute_p0(request):
    """
    1. Verify (*,G) mroute detail on FRR router after BSM rp installed

    Topology used:
      b1_____
             |
             |
      s1-----f1-----i1-----l1----r1
             |
       ______|
      b2

      b1 - BSR 1
      b2 - BSR 2
      s1 - Source
      f1 - FHR
      i1 - Intermediate Router (also RP)
      r1 - Receiver

    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b1", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b2", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    GROUP_ADDRESS = "226.1.1.1"

    # Use scapy to send pre-defined packet from senser to receiver
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"][
        "bsr"].split("/")[0]
    time.sleep(1)

    result = app_helper.run_join("r1", GROUP_ADDRESS, "l1")
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify bsr state in FHR
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Check igmp groups
    step("Verify IGMP groups in LHR l1")
    dut = "l1"
    intf = "l1-r1-eth1"
    result = verify_igmp_groups(tgen, dut, intf, GROUP_ADDRESS)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    group = "226.1.1.1/32"
    src_addr = "*"

    # Find the elected rp from bsrp-info
    step("Find the elected rp from bsrp-info in LHR in l1")
    rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group)
    assert rp is not {}, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Check RP detail in LHR
    step("Verify RP in LHR in l1")
    result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group])
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify join state and join timer
    step("Verify join state and join timer in l1")
    iif = "l1-i1-eth0"
    result = verify_join_state_and_timer(tgen, dut, iif, src_addr,
                                         GROUP_ADDRESS)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify upstream IIF interface
    step("Verify upstream IIF interface in l1")
    result = verify_upstream_iif(tgen, dut, iif, src_addr, GROUP_ADDRESS)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify IIF/OIL in pim state
    oil = "l1-r1-eth1"
    result = verify_pim_state(tgen, dut, iif, oil, GROUP_ADDRESS)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify ip mroute
    step("Verify ip mroute in l1")
    src_addr = "*"
    result = verify_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Remove the group rp mapping and send bsm
    step(
        "Remove the grp-rp mapping by sending bsm with hold time 0 for grp-rp")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Check RP unreachable
    step("Check RP unreachability in l1")
    iif = "Unknown"
    result = verify_upstream_iif(tgen,
                                 dut,
                                 iif,
                                 src_addr,
                                 GROUP_ADDRESS,
                                 joinState="NotJoined")
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify that it is not installed
    step("Verify that iif is not installed in l1")
    iif = "<iif?>"
    result = verify_pim_state(tgen,
                              dut,
                              iif,
                              oil,
                              GROUP_ADDRESS,
                              installed_fl=0)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify mroute not installed
    step("Verify mroute not installed in l1")
    result = verify_mroutes(tgen,
                            dut,
                            src_addr,
                            GROUP_ADDRESS,
                            iif,
                            oil,
                            retry_timeout=20,
                            expected=False)
    assert (
        result is not True
    ), "Testcase {} : Failed \n " "mroute installed in l1 \n Error: {}".format(
        tc_name, result)

    # Send BSM again to configure rp
    step("Add back RP by sending BSM from b1")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Verify that (*,G) installed in mroute again
    iif = "l1-i1-eth0"
    result = verify_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil)
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    step("clear  BSM database before moving to next case")
    clear_bsrp_data(tgen, topo)

    write_test_footer(tc_name)
Пример #12
0
def test_RP_with_all_ip_octet_p1(request):
    """
    Verify when candidate RP advertised with 32 mask length
     and contain all the contacts

    Topology used:
      b1_____
             |
             |
      s1-----f1-----i1-----l1----r1
             |
       ______|
      b2

      b1 - BSR 1
      b2 - BSR 2
      s1 - Source
      f1 - FHR
      i1 - Intermediate Router (also RP)
      r1 - Receiver

    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    step("pre-configure BSM packet")
    result = pre_config_to_bsm(tgen, topo, tc_name, "b1", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    step(
        "Send the IGMP group (225.100.100.100) from receiver connected to FRR")
    GROUP_ADDRESS = "225.200.100.100"

    # Use scapy to send pre-defined packet from senser to receiver
    step("Configure cisco-1 as BSR1")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet8")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet8"][
        "bsr"].split("/")[0]
    time.sleep(1)

    result = app_helper.run_join("r1", GROUP_ADDRESS, "l1")
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    dut = "l1"
    step(
        "Groups are shown with candidate RP with correct mask length 'show ip pim bsrp-info'"
    )
    step("Verify if b1 chosen as BSR in f1")
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
    step("Find the elected rp from bsrp-info in LHR l1")
    rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group)
    assert rp is not {}, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    step("Verify RP in LHR")
    result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group])
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    step("clear  BSM database before moving to next case")
    clear_bsrp_data(tgen, topo)

    write_test_footer(tc_name)
Пример #13
0
def test_BSM_fragmentation_p1(request):
    """
    Verify fragmentation of bootstrap message

    Topology used:
      b1_____
             |
             |
      s1-----f1-----i1-----l1----r1
             |
       ______|
      b2

      b1 - BSR 1
      b2 - BSR 2
      s1 - Source
      f1 - FHR
      i1 - Intermediate Router (also RP)
      r1 - Receiver

    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b1", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    result = pre_config_to_bsm(tgen, topo, tc_name, "b2", "s1", "r1", "f1",
                               "i1", "l1", "packet1")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    GROUP_ADDRESS = "225.1.1.1"

    bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"][
        "bsr"].split("/")[0]

    step("Send BSM and verify if all routers have same bsrp before fragment")
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1")
    # Verify bsr state in FHR
    step("Verify if b1 chosen as BSR in f1")
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    fhr_node = tgen.routers()["f1"]
    inter_node = tgen.routers()["i1"]
    lhr_node = tgen.routers()["l1"]

    # Verify if bsrp list is same across f1, i1 and l1
    step("Verify if bsrp list is same across f1, i1 and l1")
    bsrp_f1 = fhr_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True)
    logger.info("show_ip_pim_bsrp_info_json f1: \n %s", bsrp_f1)
    bsrp_i1 = inter_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True)
    logger.info("show_ip_pim_bsrp_info_json i1: \n %s", bsrp_i1)
    bsrp_l1 = lhr_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True)
    logger.info("show_ip_pim_bsrp_info_json l1: \n %s", bsrp_l1)

    if bsrp_f1 == bsrp_l1:
        result = True
    else:
        result = "bsrp info in f1 is not same in l1"

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

    # set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments
    step("set mtu of fhr(f1) to i1 interface to 100 so that bsm fragments")
    fhr_node.run("ip link set f1-i1-eth2 mtu 100")
    inter_node.run("ip link set i1-f1-eth0 mtu 100")

    # Use scapy to send pre-defined packet from senser to receiver
    result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2")
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    result = app_helper.run_join("r1", GROUP_ADDRESS, "l1")
    assert result is True, "Testcase {}:Failed \n Error: {}".format(
        tc_name, result)

    # Verify bsr state in FHR
    step("Verify if b1 chosen as BSR")
    result = verify_pim_bsr(tgen, topo, "f1", bsr_ip)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    # Verify if bsrp list is same across f1, i1 and l1
    step(
        "Verify if bsrp list is same across f1, i1 and l1 after fragmentation")
    bsrp_f1 = fhr_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True)
    logger.info("show_ip_pim_bsrp_info_json f1: \n %s", bsrp_f1)
    bsrp_i1 = inter_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True)
    logger.info("show_ip_pim_bsrp_info_json i1: \n %s", bsrp_i1)
    bsrp_l1 = lhr_node.vtysh_cmd("show ip pim bsrp-info json", isjson=True)
    logger.info("show_ip_pim_bsrp_info_json l1: \n %s", bsrp_l1)

    if bsrp_f1 == bsrp_l1:
        result = True
    else:
        result = "bsrp info in f1 is not same in l1"

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

    step("clear  BSM database before moving to next case")
    clear_bsrp_data(tgen, topo)

    write_test_footer(tc_name)
Пример #14
0
def test_PIM_hello_tx_rx_p1(request):
    """
    TC_54 Verify received and transmit hello stats
        are getting cleared after PIM nbr reset
    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    # Creating configuration from JSON
    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    step("Remove c1-c2 connected link to simulate topo "
         "c1(LHR)---l1(RP)----r2---f1-----c2(FHR)")

    intf_c1_c2 = topo["routers"]["c1"]["links"]["c2"]["interface"]
    intf_c2_c1 = topo["routers"]["c2"]["links"]["c1"]["interface"]
    shutdown_bringup_interface(tgen, "c1", intf_c1_c2, False)
    shutdown_bringup_interface(tgen, "c2", intf_c2_c1, False)

    step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3")
    step("Enable IGMP of FRR1 interface and send IGMP joins "
         " from FRR1 node for group range (225.1.1.1-5)")

    intf_c1_i4 = topo["routers"]["c1"]["links"]["i4"]["interface"]
    input_dict = {
        "c1": {
            "igmp": {
                "interfaces": {
                    intf_c1_i4: {
                        "igmp": {
                            "version": "2"
                        }
                    }
                }
            }
        }
    }
    result = create_igmp_config(tgen, topo, input_dict)
    assert result is True, "Testcase {}: Failed Error: {}".format(
        tc_name, result)

    input_join = {"i4": topo["routers"]["i4"]["links"]["c1"]["interface"]}

    for recvr, recvr_intf in input_join.items():
        result = app_helper.run_join(recvr,
                                     IGMP_JOIN_RANGE_1,
                                     join_intf=recvr_intf)
        assert result is True, "Testcase {}: Failed Error: {}".format(
            tc_name, result)

    step("Configure static RP for (225.1.1.1-5) as R2")

    input_dict = {
        "l1": {
            "pim": {
                "rp": [{
                    "rp_addr":
                    topo["routers"]["l1"]["links"]["lo"]["ipv4"].split("/")[0],
                    "group_addr_range":
                    GROUP_RANGE,
                }]
            }
        }
    }

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

    step(
        "Send Mcast traffic from C2 to all the groups ( 225.1.1.1 to 225.1.1.5)"
    )

    input_src = {"i5": topo["routers"]["i5"]["links"]["c2"]["interface"]}

    for src, src_intf in input_src.items():
        result = app_helper.run_traffic(src,
                                        IGMP_JOIN_RANGE_1,
                                        bind_intf=src_intf)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    source_i5 = topo["routers"]["i5"]["links"]["c2"]["ipv4"].split("/")[0]

    input_dict_starg = [{
        "dut":
        "c1",
        "src_address":
        "*",
        "iif":
        topo["routers"]["c1"]["links"]["l1"]["interface"],
        "oil":
        topo["routers"]["c1"]["links"]["i4"]["interface"],
    }]

    input_dict_sg = [{
        "dut": "c1",
        "src_address": source_i5,
        "iif": topo["routers"]["c1"]["links"]["l1"]["interface"],
        "oil": topo["routers"]["c1"]["links"]["i4"]["interface"],
    }]

    step(
        "(*,G) and (S,G) created on f1 and node verify using 'show ip mroute'")
    for data in input_dict_sg:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    for data in input_dict_starg:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["interface"]
    intf_c1_l1 = topo["routers"]["c1"]["links"]["l1"]["interface"]

    state_dict = {
        "c1": {
            intf_c1_l1: ["helloTx", "helloRx"],
        }
    }

    c1_state_before = get_pim_interface_traffic(tgen, state_dict)
    assert isinstance(
        c1_state_before, dict
    ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
        tc_name, result)

    step(
        "Flap PIM nbr while doing interface c1-l1 interface shut from f1 side")
    shutdown_bringup_interface(tgen, "c1", intf_c1_l1, False)
    """ Resetting the stats here since shutdown resets the stats.
    """
    reset_stats(c1_state_before)
    shutdown_bringup_interface(tgen, "c1", intf_c1_l1, True)

    step("verify stats after no shutdown on c1 and that they are incremented")

    count = 0
    done = False
    while not done and count <= 7:
        c1_state_after = get_pim_interface_traffic(tgen, state_dict)
        assert isinstance(
            c1_state_after, dict
        ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
            tc_name, result)

        result = verify_state_incremented(c1_state_before, c1_state_after)
        if result is not True:
            sleep(5)
            count += 1
        else:
            done = True

    assert (
        result is True
    ), "Testcase{} : Failed Error: {}" "stats is not incremented".format(
        tc_name, result)

    step("verify before stats on l1")
    l1_state_dict = {
        "l1": {
            intf_l1_c1: ["helloTx", "helloRx"],
        }
    }

    l1_state_before = get_pim_interface_traffic(tgen, l1_state_dict)
    assert isinstance(
        l1_state_before, dict
    ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
        tc_name, result)

    step("Flap PIM nbr while doing interface r2-c1 shut from r2 side")
    shutdown_bringup_interface(tgen, "l1", intf_l1_c1, False)

    step(
        "After shut the interface from r2 side , verify r2 side rx and tx of hello"
        "counters are resetted show ip pim interface traffic")
    shutdown_bringup_interface(tgen, "l1", intf_l1_c1, True)

    step("verify stats after on l1 are incremented")
    count = 0
    done = False
    while not done and count <= 7:
        l1_state_after = get_pim_interface_traffic(tgen, l1_state_dict)
        assert isinstance(
            l1_state_after, dict
        ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
            tc_name, result)

        result = verify_state_incremented(l1_state_before, l1_state_after)
        if result is True:
            sleep(5)
            count += 1
        else:
            done = True

    assert (result is not True
            ), "Testcase{} : Failed Error: {}" "stats incremented".format(
                tc_name, result)

    step("Reinit the dict")
    c1_state_before = {}
    l1_state_before = {}
    c1_state_after = {}
    l1_state_after = {}

    step("verify before stats on C1")
    state_dict = {
        "c1": {
            intf_c1_l1: ["helloTx", "helloRx"],
        }
    }

    c1_state_before = get_pim_interface_traffic(tgen, state_dict)
    assert isinstance(
        c1_state_before, dict
    ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
        tc_name, result)

    step("Flap c1-r2 pim nbr while changing ip address from c1 side")
    c1_l1_ip_subnet = topo["routers"]["c1"]["links"]["l1"]["ipv4"]

    raw_config = {
        "c1": {
            "raw_config": [
                "interface {}".format(intf_c1_l1),
                "no ip address {}".format(c1_l1_ip_subnet),
                "ip address {}".format(NEW_ADDRESS_2_SUBNET),
            ]
        }
    }

    result = apply_raw_config(tgen, raw_config)
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    step("verify stats after on c1 are incremented")
    count = 0
    done = False
    while not done and count <= 7:
        c1_state_after = get_pim_interface_traffic(tgen, state_dict)
        assert isinstance(
            c1_state_after, dict
        ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
            tc_name, result)

        result = verify_state_incremented(c1_state_before, c1_state_after)
        if result is not True:
            sleep(5)
            count += 1
        else:
            done = True

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

    write_test_footer(tc_name)
Пример #15
0
def test_mroute_with_RP_default_route_all_nodes_p2(request):
    """
    TC_50 Verify mroute when LHR,FHR,RP and transit routers reachable
    using default routes
    """

    tgen = get_topogen()
    tc_name = request.node.name
    write_test_header(tc_name)

    # Don"t run this test if we have any failure.
    if tgen.routers_have_failure():
        pytest.skip(tgen.errors)

    # Creating configuration from JSON
    app_helper.stop_all_hosts()
    clear_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_pim_interface_traffic(tgen, topo)

    step("Remove c1-c2 connected link to simulate topo "
         "c1(LHR)---l1(RP)----r2---f1-----c2(FHR)")

    intf_c1_c2 = topo["routers"]["c1"]["links"]["c2"]["interface"]
    intf_c2_c1 = topo["routers"]["c2"]["links"]["c1"]["interface"]
    shutdown_bringup_interface(tgen, "c1", intf_c1_c2, False)
    shutdown_bringup_interface(tgen, "c2", intf_c2_c1, False)

    step("Enable the PIM on all the interfaces of FRR1, FRR2, FRR3")
    step("Enable IGMP of FRR1 interface and send IGMP joins "
         " from FRR1 node for group range (225.1.1.1-5)")

    intf_c1_i4 = topo["routers"]["c1"]["links"]["i4"]["interface"]
    input_dict = {
        "c1": {
            "igmp": {
                "interfaces": {
                    intf_c1_i4: {
                        "igmp": {
                            "version": "2"
                        }
                    }
                }
            }
        }
    }
    result = create_igmp_config(tgen, topo, input_dict)
    assert result is True, "Testcase {}: Failed Error: {}".format(
        tc_name, result)

    input_join = {"i4": topo["routers"]["i4"]["links"]["c1"]["interface"]}

    for recvr, recvr_intf in input_join.items():
        result = app_helper.run_join(recvr,
                                     IGMP_JOIN_RANGE_1,
                                     join_intf=recvr_intf)
        assert result is True, "Testcase {}: Failed Error: {}".format(
            tc_name, result)

    step("Configure static RP for (225.1.1.1-5) as R2")

    input_dict = {
        "l1": {
            "pim": {
                "rp": [{
                    "rp_addr":
                    topo["routers"]["l1"]["links"]["lo"]["ipv4"].split("/")[0],
                    "group_addr_range":
                    GROUP_RANGE,
                }]
            }
        }
    }

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

    step("Send traffic from C2 to all the groups ( 225.1.1.1 to 225.1.1.5)")

    input_src = {"i5": topo["routers"]["i5"]["links"]["c2"]["interface"]}

    for src, src_intf in input_src.items():
        result = app_helper.run_traffic(src,
                                        IGMP_JOIN_RANGE_1,
                                        bind_intf=src_intf)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    source_i5 = topo["routers"]["i5"]["links"]["c2"]["ipv4"].split("/")[0]

    input_dict_starg = [{
        "dut":
        "c1",
        "src_address":
        "*",
        "iif":
        topo["routers"]["c1"]["links"]["l1"]["interface"],
        "oil":
        topo["routers"]["c1"]["links"]["i4"]["interface"],
    }]

    input_dict_sg = [{
        "dut": "c1",
        "src_address": source_i5,
        "iif": topo["routers"]["c1"]["links"]["l1"]["interface"],
        "oil": topo["routers"]["c1"]["links"]["i4"]["interface"],
    }]

    step("Verify mroutes and iff upstream")

    for data in input_dict_sg:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

        result = verify_upstream_iif(tgen, data["dut"], data["iif"],
                                     data["src_address"], IGMP_JOIN_RANGE_1)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    for data in input_dict_starg:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

        result = verify_upstream_iif(tgen, data["dut"], data["iif"],
                                     data["src_address"], IGMP_JOIN_RANGE_1)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    step("Delete static routes RP on all the nodes")
    input_dict = {
        "c2": {
            "static_routes": [{
                "network": ["1.0.4.11/32"],
                "next_hop": "10.0.3.2",
                "delete": True
            }]
        },
        "c1": {
            "static_routes": [{
                "network": ["1.0.4.11/32"],
                "next_hop": "10.0.2.2",
                "delete": True
            }]
        },
        "r2": {
            "static_routes": [{
                "network": ["1.0.4.11/32"],
                "next_hop": "10.0.12.1",
                "delete": True
            }]
        },
        "f1": {
            "static_routes": [{
                "network": ["1.0.4.11/32"],
                "next_hop": "10.0.7.2",
                "delete": True
            }]
        },
    }

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

    step("Verify RP info unknown after removing static route from c2 ")
    dut = "c2"
    rp_address = topo["routers"]["l1"]["links"]["lo"]["ipv4"].split("/")[0]
    SOURCE = "Static"
    result = verify_pim_rp_info(tgen, topo, dut, GROUP_RANGE_1, "Unknown",
                                rp_address, SOURCE)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

    for data in input_dict_starg:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
            expected=False,
        )
        assert (
            result is not True
        ), "Testcase {} : Failed \n " "mroutes are still present \n Error: {}".format(
            tc_name, result)

        result = verify_upstream_iif(
            tgen,
            data["dut"],
            data["iif"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            expected=False,
        )
        assert (
            result is not True
        ), "Testcase {} : Failed \n " "upstream is still present \n Error: {}".format(
            tc_name, result)

    step("Configure default routes on all the nodes")

    intf_f1_c2 = topo["routers"]["f1"]["links"]["c2"]["ipv4"].split("/")[0]
    intf_l1_c1 = topo["routers"]["l1"]["links"]["c1"]["ipv4"].split("/")[0]
    intf_l1_r2 = topo["routers"]["l1"]["links"]["r2"]["ipv4"].split("/")[0]
    intf_r2_f1 = topo["routers"]["r2"]["links"]["f1"]["ipv4"].split("/")[0]

    input_dict = {
        "c1": {
            "static_routes": [{
                "network": "0.0.0.0/0",
                "next_hop": intf_l1_c1
            }]
        },
        "c2": {
            "static_routes": [{
                "network": "0.0.0.0/0",
                "next_hop": intf_f1_c2
            }]
        },
        "r2": {
            "static_routes": [{
                "network": "0.0.0.0/0",
                "next_hop": intf_l1_r2
            }]
        },
        "f1": {
            "static_routes": [{
                "network": "0.0.0.0/0",
                "next_hop": intf_r2_f1
            }]
        },
    }
    result = create_static_routes(tgen, input_dict)
    assert result is True, "Testcase {} :Failed \n Error {}".format(
        tc_name, result)

    step("applying ip nht config  on c2")

    raw_config = {
        "c1": {
            "raw_config": ["ip nht resolve-via-default"]
        },
        "c2": {
            "raw_config": ["ip nht resolve-via-default"]
        },
        "r2": {
            "raw_config": ["ip nht resolve-via-default"]
        },
        "f1": {
            "raw_config": ["ip nht resolve-via-default"]
        },
        "l1": {
            "raw_config": ["ip nht resolve-via-default"]
        },
    }

    result = apply_raw_config(tgen, raw_config)
    assert result is True, "Testcase {} : Failed Error: {}".format(
        tc_name, result)

    step("Verify RP info Not unknown after removing static route from c2 ")
    dut = "c2"
    step("Verify RP info is NOT unknown after removing static route from c2 ")
    result = verify_pim_rp_info(tgen,
                                topo,
                                dut,
                                GROUP_RANGE_1,
                                "Unknown",
                                rp_address,
                                SOURCE,
                                expected=False)
    assert result is not True, (
        "Testcase {} : Failed \n "
        "RP info is unknown after removing static route from c2 \n Error: {}".
        format(tc_name, result))

    step("Verify (s,g) populated after adding default route ")

    for data in input_dict_sg:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

        result = verify_upstream_iif(tgen, data["dut"], data["iif"],
                                     data["src_address"], IGMP_JOIN_RANGE_1)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    step("Verify (*,g) populated after adding default route ")

    for data in input_dict_starg:
        result = verify_mroutes(
            tgen,
            data["dut"],
            data["src_address"],
            IGMP_JOIN_RANGE_1,
            data["iif"],
            data["oil"],
        )
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

        result = verify_upstream_iif(tgen, data["dut"], data["iif"],
                                     data["src_address"], IGMP_JOIN_RANGE_1)
        assert result is True, "Testcase {} : Failed Error: {}".format(
            tc_name, result)

    write_test_footer(tc_name)