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) 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 = "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 = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) 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)
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) 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 = "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 = 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 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)
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) 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 = "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 = 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 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, ) # 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)
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) 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 = "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 = 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 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_ip_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_ip_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)
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_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) 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) 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 = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) 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)