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)

    kill_iperf(tgen)
    clear_ip_mroute(tgen)
    reset_config_on_routers(tgen)
    clear_ip_pim_interface_traffic(tgen, topo)

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

    reset_config_on_routers(tgen)

    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 = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1)
    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_ip_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_ip_mroutes(tgen,
                               dut,
                               src_addr,
                               GROUP_ADDRESS,
                               iif,
                               oil,
                               wait=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_ip_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)
def test_pimv6_add_delete_static_RP_p0(request):
    """
    TC_1: Verify upstream interfaces(IIF) and join state are updated
        properly after adding and deleting the static RP
    TC_2: Verify IIF and OIL in "show ip pim state" updated properly
        after adding and deleting the static RP
    TC_3: (*, G) Mroute entry are cleared when static RP gets deleted
    TC_4: Verify (*,G) prune is send towards the RP after deleting the
        static RP

    TOPOlogy used:
         r0------r1-----r2
       iperf    DUT     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():
        check_router_status(tgen)

    step("Shut link b/w R1 and R3 and R1 and R4 as per tescase topology")
    intf_r1_r3 = TOPO["routers"]["r1"]["links"]["r3"]["interface"]
    intf_r1_r4 = TOPO["routers"]["r1"]["links"]["r4"]["interface"]
    for intf in [intf_r1_r3, intf_r1_r4]:
        shutdown_bringup_interface(tgen, "r1", intf, ifaceaction=False)

    step("Enable PIM between r1 and r2")
    step("Enable MLD on r1 interface and send IGMP " "join (FF08::1) to r1")
    step("Configure r2 loopback interface as RP")
    input_dict = {
        "r2": {
            "pim6": {
                "rp": [{
                    "rp_addr":
                    TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split("/")[0],
                    "group_addr_range":
                    GROUP_RANGE_V6,
                }]
            }
        }
    }

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

    step("Verify show ip pim interface traffic without any mld join")
    state_dict = {
        "r1": {
            TOPO["routers"]["r1"]["links"]["r2"]["interface"]: ["pruneTx"]
        }
    }

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

    step("send mld join (FF08::1) to R1")
    intf = TOPO["routers"]["r0"]["links"]["r1"]["interface"]
    intf_ip = TOPO["routers"]["r0"]["links"]["r1"]["ipv6"].split("/")[0]
    result = socat_send_igmp_join_traffic(tgen,
                                          "r0",
                                          "UDP6-RECV",
                                          IGMP_JOIN_V6,
                                          intf,
                                          intf_ip,
                                          join=True)
    assert result is True, "Testcase {}: Failed Error: {}".format(
        tc_name, result)

    step("r1: Verify RP info")
    dut = "r1"
    oif = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
    iif = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
    rp_address = TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split("/")[0]
    result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_RANGE_V6, oif,
                                rp_address, SOURCE)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

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

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

    step("r1: Verify PIM state")
    result = verify_pim_state(tgen, dut, oif, iif, IGMP_JOIN_V6)
    assert result is True, "Testcase {} :Failed \n Error: {}".format(
        tc_name, result)

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

    step("r1: Delete RP configuration")
    input_dict = {
        "r2": {
            "pim6": {
                "rp": [{
                    "rp_addr":
                    TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split("/")[0],
                    "group_addr_range":
                    GROUP_RANGE_V6,
                    "delete":
                    True,
                }]
            }
        }
    }

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

    step("r1: Verify RP info")
    result = verify_pim_rp_info(tgen,
                                TOPO,
                                dut,
                                GROUP_RANGE_V6,
                                oif,
                                rp_address,
                                SOURCE,
                                expected=False)
    assert (
        result is not True
    ), "Testcase {} :Failed \n " "RP: {} info is still present \n Error: {}".format(
        tc_name, rp_address, result)

    step("r1: Verify upstream IIF interface")
    result = verify_upstream_iif(tgen,
                                 dut,
                                 oif,
                                 STAR,
                                 IGMP_JOIN_V6,
                                 expected=False)
    assert result is not True, (
        "Testcase {} :Failed \n "
        "Upstream ({}, {}) is still in join state \n Error: {}".format(
            tc_name, STAR, IGMP_JOIN_V6, result))

    step("r1: Verify upstream join state and join timer")
    result = verify_join_state_and_timer(tgen,
                                         dut,
                                         oif,
                                         STAR,
                                         IGMP_JOIN_V6,
                                         expected=False)
    assert result is not True, (
        "Testcase {} :Failed \n "
        "Upstream ({}, {}) timer is still running \n Error: {}".format(
            tc_name, STAR, IGMP_JOIN_V6, result))

    step("r1: Verify PIM state")
    result = verify_pim_state(tgen,
                              dut,
                              oif,
                              iif,
                              IGMP_JOIN_V6,
                              expected=False)
    assert result is not True, (
        "Testcase {} :Failed \n "
        "PIM state for group: {} is still Active \n Error: {}".format(
            tc_name, IGMP_JOIN_V6, result))

    step("r1: Verify ip mroutes")
    result = verify_mroutes(tgen,
                            dut,
                            STAR,
                            IGMP_JOIN_V6,
                            oif,
                            iif,
                            expected=False)
    assert result is not True, (
        "Testcase {} :Failed \n "
        "mroute ({}, {}) is still present \n Error: {}".format(
            tc_name, STAR, IGMP_JOIN_V6, result))

    step("r1: Verify show ip pim interface traffic without any IGMP join")
    state_after = verify_pim_interface_traffic(tgen,
                                               state_dict,
                                               addr_type="ipv6")
    assert isinstance(
        state_after, dict
    ), "Testcase{} : Failed \n state_before is not dictionary \n " "Error: {}".format(
        tc_name, result)

    result = verify_state_incremented(state_before, state_after)
    assert result is True, "Testcase{} : Failed Error: {}".format(
        tc_name, result)

    write_test_footer(tc_name)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
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)