示例#1
0
def test_ft_ip_static_route_traffic_forward():
    # Objective - Verify the Ipv4 traffic forwarding over IPv4 static route.
    tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D2P1")
    tg = tg_handler["tg"]
    tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"])
    tg.tg_traffic_control(action="clear_stats",
                          port_handle=tg_handler["tg_ph_list"])

    dut_rt_int_mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1)
    h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config', intf_ip_addr=data.ip4_addr[0], \
                                gateway=data.ip4_addr[1], src_mac_addr=data.tg_mac1, arp_send_req='1')
    st.log("INTFCONF: " + str(h1))
    h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], mode='config', intf_ip_addr=data.ip4_addr[9], \
                                gateway=data.ip4_addr[8], src_mac_addr=data.tg_mac2, arp_send_req='1')
    st.log("INTFCONF: " + str(h2))
    # Ping from tgen to DUT.
    res = tgapi.verify_ping(src_obj=tg, port_handle=tg_handler["tg_ph_1"], dev_handle=h1['handle'], dst_ip=data.ip4_addr[1], \
                      ping_count='1', exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")
    tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst',
                               pkts_per_burst=2000, \
                               length_mode='fixed', rate_pps=2000, l3_protocol='ipv4', mac_src=data.tg_mac1, \
                               mac_dst=dut_rt_int_mac1, ip_src_addr=data.ip4_addr[0],
                               ip_dst_addr=data.ip4_addr[9])
    st.log("TRAFCONF: " + str(tr1))
    res = tg.tg_traffic_control(action='run', stream_handle=tr1['stream_id'])
    st.log("TR_CTRL: " + str(res))
    tg.tg_traffic_control(action='stop', stream_handle=tr1['stream_id'])
    st.log("Checking the stats and verifying the traffic flow")
    traffic_details = {
        '1': {
            'tx_ports': [vars.T1D1P1],
            'tx_obj': [tg_handler["tg"]],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D2P1],
            'rx_obj': [tg_handler["tg"]],
        }
    }
    #verify statistics
    aggrResult = tgapi.validate_tgen_traffic(traffic_details=traffic_details,
                                             mode='aggregate',
                                             comp_type='packet_count')
    if not aggrResult:
        st.report_fail("traffic_verification_failed")
    st.report_pass("test_case_passed")
示例#2
0
def adding_dynamic_arp():
    data.h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"],
                                     mode='config',
                                     intf_ip_addr=data.ipv4_address_tgen,
                                     gateway=data.ipv4_address,
                                     src_mac_addr=data.src_mac_addr,
                                     arp_send_req='1')
    st.log("INTFCONF: " + str(data.h1))
    st.log("Pinging from tgen to DUT's TGen connected IPV4 interface")
    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_1"],
                            dev_handle=data.h1['handle'],
                            dst_ip=data.ipv4_address,
                            ping_count='1',
                            exp_count='1')
    st.log("PING_RES: " + str(res))
    if res:
        st.log("Ping succeeded.")
    else:
        st.log("Ping failed.")
    st.wait(5)
    if not arp_obj.show_arp(vars.D1, data.ipv4_address_tgen):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.ipv4_address_tgen,
                       vars.D1)
示例#3
0
def create_v6_route(route_count):
    vars = st.get_testbed_vars()
    dut = vars.D1

    ipfeature.show_ip_route(dut, family='ipv6')
    ipfeature.get_interface_ip_address(dut, family='ipv6')

    bgpfeature.create_bgp_router(dut, data.as_num, '')
    bgpfeature.create_bgp_neighbor(dut,
                                   data.as_num,
                                   data.ip6_addr[0],
                                   data.remote_as_num,
                                   family="ipv6")
    create_bgp_neighbor_route_map_config(dut, data.as_num, data.ip6_addr[0],
                                         data.routemap)

    tg_handler = tgapi.get_handles_byname("T1D1P2", "T1D2P2")
    tg = tg_handler["tg"]
    tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"])
    tg.tg_traffic_control(action="clear_stats",
                          port_handle=tg_handler["tg_ph_list"])

    dut_rt_int_mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1)
    h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config', ipv6_intf_addr=data.ip6_addr[0], \
                                ipv6_prefix_length='64', ipv6_gateway=data.ip6_addr[1],
                                src_mac_addr=data.tg_mac1, arp_send_req='1')
    st.log("INTFCONF: " + str(h1))
    h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], mode='config', ipv6_intf_addr=data.ip6_addr[9], \
                                ipv6_prefix_length='64', ipv6_gateway=data.ip6_addr[8],
                                src_mac_addr=data.tg_mac2, arp_send_req='1')
    st.log("INTFCONF: " + str(h2))

    # Ping from tgen to DUT.
    res = tgapi.verify_ping(src_obj=tg, port_handle=tg_handler["tg_ph_1"], dev_handle=h1['handle'], dst_ip=data.ip6_addr[1], \
                      ping_count='1', exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    bgp_conf = tg.tg_emulation_bgp_config(handle=h1['handle'],
                                          mode='enable',
                                          ip_version='6',
                                          active_connect_enable='1',
                                          local_as=data.as_num,
                                          remote_as=data.remote_as_num,
                                          remote_ipv6_addr=data.ip6_addr[1])

    tg.tg_emulation_bgp_route_config(handle=bgp_conf['handle'],
                                     mode='add',
                                     ip_version='6',
                                     num_routes=route_count,
                                     prefix='3300:1::',
                                     as_path='as_seq:1')
    tg.tg_emulation_bgp_control(handle=bgp_conf['handle'], mode='start')

    # Configuring the BGP router.
    st.log("BGP neighborship established.")
    tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst',
                               pkts_per_burst=2000, \
                               length_mode='fixed', rate_pps=2000, l3_protocol='ipv6', mac_src=data.tg_mac1, \
                               mac_dst=dut_rt_int_mac1, ipv6_src_addr=data.ip6_addr[0],
                               ipv6_dst_addr=data.ip6_addr[9])
    st.log("TRAFCONF: " + str(tr1))

    res = tg.tg_traffic_control(action='run', stream_handle=tr1['stream_id'])
    st.log("TR_CTRL: " + str(res))
    tg.tg_traffic_control(action='stop', stream_handle=tr1['stream_id'])
    st.log("Checking the stats and verifying the traffic flow")
    traffic_details = {
        '1': {
            'tx_ports': [vars.T1D1P2],
            'tx_obj': [tg_handler["tg"]],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D2P2],
            'rx_obj': [tg_handler["tg"]],
        }
    }
    # verify statistics
    aggrResult = tgapi.validate_tgen_traffic(traffic_details=traffic_details,
                                             mode='aggregate',
                                             comp_type='packet_count')
    if not aggrResult:
        return False
    else:
        return True
示例#4
0
def create_v4_route(route_count):
    vars = st.get_testbed_vars()
    dut = vars.D1

    ipfeature.show_ip_route(dut)
    ipfeature.get_interface_ip_address(dut)
    intf_obj.interface_status_show(dut)

    bgpfeature.create_bgp_router(dut, data.as_num, '')
    bgpfeature.create_bgp_neighbor(dut, data.as_num, data.ip4_addr[0],
                                   data.remote_as_num)

    tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D2P1")
    tg = tg_handler["tg"]
    tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"])
    tg.tg_traffic_control(action="clear_stats",
                          port_handle=tg_handler["tg_ph_list"])

    dut_rt_int_mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1)
    h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config', intf_ip_addr=data.ip4_addr[0], \
                                gateway=data.ip4_addr[1], src_mac_addr=data.tg_mac1, arp_send_req='1')
    st.log("INTFCONF: " + str(h1))
    h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], mode='config', intf_ip_addr=data.ip4_addr[9], \
                                gateway=data.ip4_addr[8], src_mac_addr=data.tg_mac2, arp_send_req='1')
    st.log("INTFCONF: " + str(h2))
    # Ping from tgen to DUT.
    res = tgapi.verify_ping(src_obj=tg, port_handle=tg_handler["tg_ph_1"], dev_handle=h1['handle'], dst_ip=data.ip4_addr[1], \
                      ping_count='1', exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    conf_var = {
        'mode': 'enable',
        'active_connect_enable': '1',
        'local_as': '200',
        'remote_as': '100',
        'remote_ip_addr': data.ip4_addr[1]
    }
    route_var = {
        'mode': 'add',
        'num_routes': route_count,
        'prefix': '121.1.1.0',
        'as_path': 'as_seq:1'
    }
    ctrl_start = {'mode': 'start'}

    # Configuring the BGP router.
    bgp_rtr1 = tgapi.tg_bgp_config(tg=tg,
                                   handle=h1['handle'],
                                   conf_var=conf_var,
                                   route_var=route_var,
                                   ctrl_var=ctrl_start)

    st.log("BGP_HANDLE: " + str(bgp_rtr1))
    st.log(
        "waiting for 10 sec to get the BGP neighbor started before going for another TG operation"
    )
    st.wait(10)
    # Verified at neighbor.
    tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst',
                               pkts_per_burst=2000, \
                               length_mode='fixed', rate_pps=2000, l3_protocol='ipv4', mac_src=data.tg_mac1, \
                               mac_dst=dut_rt_int_mac1, ip_src_addr=data.ip4_addr[0],
                               ip_dst_addr=data.ip4_addr[9])
    st.log("TRAFCONF: " + str(tr1))
    res = tg.tg_traffic_control(action='run', stream_handle=tr1['stream_id'])
    st.log("TR_CTRL: " + str(res))
    tg.tg_traffic_control(action='stop', stream_handle=tr1['stream_id'])
    st.log("Checking the stats and verifying the traffic flow")
    traffic_details = {
        '1': {
            'tx_ports': [vars.T1D1P1],
            'tx_obj': [tg_handler["tg"]],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D2P1],
            'rx_obj': [tg_handler["tg"]],
        }
    }
    #verify statistics
    aggrResult = tgapi.validate_tgen_traffic(traffic_details=traffic_details,
                                             mode='aggregate',
                                             comp_type='packet_count')
    if not aggrResult:
        return False

    return True
示例#5
0
def test_ft_arp_entry_link_failure():
    ################# Author Details ################
    # Name: Rakesh Kumar Vooturi
    # Email:  [email protected]
    #################################################
    #
    # Objective - Verify an ARP table entry learned on port based routing interface is
    #               removed from ARP table after link failure on which that entry is learned.
    # Objective - Verify an ARP table entry learned on vlan based routing interface is
    #               removed from ARP table after link failure on which that entry is learned
    #
    ############### Test bed details ################
    #  DUT-----TG
    #################################################
    # Ping from tgen to DUT.
    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_1"],
                            dev_handle=h1['handle'],
                            dst_ip=data.d1t1_ip_addr,
                            ping_count='1',
                            exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_2"],
                            dev_handle=h2['handle'],
                            dst_ip=data.d1t2_ip_addr,
                            ping_count='1',
                            exp_count='1')
    st.log("PING_RES: " + str(res))
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    # Verify dynamic arp entries
    st.log("Verifying the arp entries on the DUT.")
    if not arp_obj.verify_arp(dut1, data.t1d1_ip_addr, data.t1d1_mac_addr,
                              vars.D1T1P1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t1d1_ip_addr, dut1)
    st.log("Verifying the arp entries on the DUT")
    if not arp_obj.verify_arp(dut1, data.t2d1_ip_addr, data.t2d1_mac_addr,
                              vars.D1T1P2, data.vlan_1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t2d1_ip_addr, dut1)

    # Shutdown the routing interface link.
    st.log("Shutdown the routing interface links.")
    if not interface_obj.interface_operation(dut1, [vars.D1T1P1, vars.D1T1P2],
                                             "shutdown"):
        st.report_fail('interface_admin_shut_down_fail',
                       [vars.D1T1P1, vars.D1T1P2])

    # Verify dynamic arp entries
    st.log("Verifying the arp entries on the DUT.")
    if arp_obj.verify_arp(dut1, data.t1d1_ip_addr, data.t1d1_mac_addr,
                          vars.D1T1P1):
        st.report_fail("ARP_dynamic_entry_removal_fail", data.t1d1_ip_addr,
                       vars.D1T1P1)
    st.log("Verifying the arp entries on the DUT")
    if arp_obj.verify_arp(dut1, data.t2d1_ip_addr):
        st.report_fail("ARP_dynamic_entry_removal_fail", data.t2d1_ip_addr,
                       vars.D1T1P2)

    # Startup the routing interface link.
    st.log("Startup the routing interface link.")
    if not interface_obj.interface_operation(dut1, [vars.D1T1P1, vars.D1T1P2],
                                             "startup"):
        st.report_fail('interface_admin_startup_fail',
                       [vars.D1T1P1, vars.D1T1P2])

    st.wait(5)

    # Verify dynamic arp entries
    st.log("Verifying the arp entries on the DUT.")
    if not arp_obj.verify_arp(dut1, data.t1d1_ip_addr, data.t1d1_mac_addr,
                              vars.D1T1P1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t1d1_ip_addr, dut1)
    st.log("Verifying the arp entries on the DUT")
    if not arp_obj.verify_arp(dut1, data.t2d1_ip_addr, data.t2d1_mac_addr,
                              vars.D1T1P2, data.vlan_1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t2d1_ip_addr, dut1)

    st.report_pass("test_case_passed")
示例#6
0
def test_ft_arp_clear_cache_static_and_dynamic_entries(
        fixture_ft_arp_clear_cache_static_and_dynamic_entries):
    ################## Author Details ###############
    # Name: Rakesh Kumar Vooturi
    # Email: [email protected]
    #################################################
    #
    # Objective - Verify that the clearing the ARP cache,
    #             all dynamic entries are removed and static entries are not cleared.
    #
    ############### Test bed details ################
    #  TG-----DUT-----TG
    #################################################
    # Adding static arp entries
    arp_obj.add_static_arp(dut1, data.static_arp_ip_1, data.static_arp_mac_1,
                           vars.D1T1P1)
    arp_obj.add_static_arp(dut1, data.static_arp_ip, data.static_arp_mac,
                           data.vlan_int_1)

    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_1"],
                            dev_handle=h1['handle'],
                            dst_ip=data.d1t1_ip_addr,
                            ping_count='1',
                            exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_2"],
                            dev_handle=h2['handle'],
                            dst_ip=data.d1t2_ip_addr,
                            ping_count='1',
                            exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    # Verify static and dynamic arp entries
    st.log("Verifying the arp entries on the DUT")
    if not arp_obj.verify_arp(dut1, data.t1d1_ip_addr, data.t1d1_mac_addr,
                              vars.D1T1P1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t1d1_ip_addr, dut1)
    if not arp_obj.verify_arp(dut1, data.t2d1_ip_addr, data.t2d1_mac_addr,
                              vars.D1T1P2, data.vlan_1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t2d1_ip_addr, dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip_1,
                              data.static_arp_mac_1, vars.D1T1P1):
        st.report_fail("static_arp_create_fail", dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip, data.static_arp_mac,
                              "", data.vlan_1):
        st.report_fail("static_arp_create_fail", dut1)

    st.banner(
        "Start - Verifying dynamic and static arp entries behavior on issuing sonic-clear arp command *WITH* traffic flowing"
    )

    # TG ports reset
    st.log("Resetting the TG ports")
    tg.tg_traffic_control(action="clear_stats",
                          port_handle=tg_handler["tg_ph_list"])

    #TG stream formation
    s1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_2"],
                              mode='create',
                              rate_pps=10,
                              mac_src=data.t2d1_mac_addr,
                              transmit_mode="continuous",
                              mac_dst=d1_mac_addr,
                              l2_encap='ethernet_ii_vlan',
                              l3_protocol="ipv4",
                              ip_dst_addr=data.t1d1_ip_addr,
                              ip_src_addr=data.t2d1_ip_addr,
                              vlan_id=data.vlan_1,
                              vlan="enable")
    s2 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"],
                              mode='create',
                              rate_pps=10,
                              mac_src=data.t1d1_mac_addr,
                              transmit_mode="continuous",
                              mac_dst=d1_mac_addr,
                              l2_encap='ethernet_ii_vlan',
                              l3_protocol="ipv4",
                              ip_dst_addr=data.t2d1_ip_addr,
                              ip_src_addr=data.t1d1_ip_addr)

    tg.tg_traffic_control(action="run",
                          stream_handle=[s1['stream_id'], s2['stream_id']])

    # Adding wait for traffic to flow.
    st.wait(5)

    # Issuing sonic-clear arp command and veryfying the entries behavior.
    arp_obj.clear_arp_table(dut1)

    # Adding wait for traffic to flow.
    st.wait(5)

    # Verify static and dynamic arp entries after clear arp
    st.log(
        "Verifying the arp entries on the DUT after issuing sonic-clear arp command with traffic flowing."
    )
    if not arp_obj.verify_arp(dut1, data.t1d1_ip_addr, data.t1d1_mac_addr,
                              vars.D1T1P1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t1d1_ip_addr, dut1)
    if not arp_obj.verify_arp(dut1, data.t2d1_ip_addr, data.t2d1_mac_addr,
                              vars.D1T1P2, data.vlan_1):
        st.report_fail("ARP_entry_dynamic_entry_fail", data.t2d1_ip_addr, dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip_1,
                              data.static_arp_mac_1, vars.D1T1P1):
        st.report_fail("static_arp_delete_fail", dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip, data.static_arp_mac,
                              "", data.vlan_1):
        st.report_fail("static_arp_delete_fail", dut1)

    # Stop the traffic
    tg.tg_traffic_control(action="stop",
                          stream_handle=[s1['stream_id'], s2['stream_id']])

    st.log("Verifying the TG stats")

    traffic_details = {
        '1': {
            'tx_ports': [vars.T1D1P2],
            'tx_obj': [tg],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D1P1],
            'rx_obj': [tg],
        }
    }
    if not tgapi.validate_tgen_traffic(traffic_details=traffic_details,
                                       mode='aggregate',
                                       comp_type='packet_count'):
        st.report_fail("traffic_verification_failed")
    else:
        st.log("traffic verification passed")

    st.banner(
        "End - Verified dynamic and static arp entries behavior on issuing sonic-clear arp command *WITH* traffic flowing"
    )

    st.banner(
        "Start - Verifying dynamic and static arp entries behavior on issuing sonic-clear arp command *WITHOUT* traffic flowing"
    )
    # Issuing sonic-clear arp command and veryfying the entries behavior.
    arp_obj.clear_arp_table(dut1)

    # Verify static and dynamic arp entries after clear arp
    st.log(
        "Verifying the arp entries on the DUT after issuing sonic-clear arp command"
    )
    if arp_obj.verify_arp(dut1, data.t1d1_ip_addr, data.t1d1_mac_addr,
                          vars.D1T1P1):
        st.report_fail("ARP_dynamic_entry_clear_arp_fail", data.t1d1_ip_addr,
                       dut1)
    if arp_obj.verify_arp(dut1, data.t2d1_ip_addr, data.t2d1_mac_addr,
                          vars.D1T1P2, data.vlan_1):
        st.report_fail("ARP_dynamic_entry_clear_arp_fail", data.t2d1_ip_addr,
                       dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip_1,
                              data.static_arp_mac_1, vars.D1T1P1):
        st.report_fail("static_arp_delete_fail", dut1)
    if not arp_obj.verify_arp(dut1, data.static_arp_ip, data.static_arp_mac,
                              "", data.vlan_1):
        st.report_fail("static_arp_delete_fail", dut1)

    st.banner(
        "End - Verified dynamic and static arp entries behavior on issuing sonic-clear arp command *WITHOUT* traffic flowing"
    )

    st.report_pass("test_case_passed")
示例#7
0
def test_ft_arp_dynamic_renew_traffic_test(
        fixture_ft_arp_dynamic_renew_traffic_test):
    ################## Author Details ################
    # Name: Rakesh Kumar Vooturi
    # Email: [email protected]
    ##################################################
    #
    # Objective - Verify a dynamic ARP table entry can be created.
    # Objective - Verify that there is no data traffic loss during ARP dynamic review.
    #
    ############### Test bed details ################
    #  TG-----DUT-----TG
    #################################################
    # Set DUT values
    st.log("Setting the DUT values")
    arp_obj.set_arp_ageout_time(dut1, 5)

    # Ping from tgen to DUT.
    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_1"],
                            dev_handle=h1['handle'],
                            dst_ip=data.d1t1_ip_addr,
                            ping_count='1',
                            exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_2"],
                            dev_handle=h2['handle'],
                            dst_ip=data.d1t2_ip_addr,
                            ping_count='1',
                            exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    # TG ports reset
    st.log("Resetting the TG ports")
    tg.tg_traffic_control(action="clear_stats",
                          port_handle=tg_handler["tg_ph_list"])

    #TG stream formation
    s1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_2"],
                              mode='create',
                              rate_pps=10,
                              mac_src=data.t2d1_mac_addr,
                              transmit_mode="continuous",
                              mac_dst=d1_mac_addr,
                              l2_encap='ethernet_ii_vlan',
                              l3_protocol="ipv4",
                              ip_dst_addr=data.t1d1_ip_addr,
                              ip_src_addr=data.t2d1_ip_addr,
                              vlan_id=data.vlan_1,
                              vlan="enable")
    tg.tg_traffic_control(action="run", stream_handle=s1['stream_id'])

    # Waiting for more than arp ageout time
    st.wait(10)
    tg.tg_traffic_control(action="stop", stream_handle=s1['stream_id'])

    # Adding sleep
    st.wait(2)

    st.log("Checking the stats and verifying the traffic flow")
    traffic_details = {
        '1': {
            'tx_ports': [vars.T1D1P2],
            'tx_obj': [tg],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D1P1],
            'rx_obj': [tg],
        }
    }
    if not tgapi.validate_tgen_traffic(traffic_details=traffic_details,
                                       mode='aggregate',
                                       comp_type='packet_count'):
        st.report_fail("traffic_verification_failed")
    else:
        st.log("traffic verification passed")
    st.report_pass("test_case_passed")
示例#8
0
def test_ft_l3_fwding():
    """
    Testcase : verify the basic L3 traffic validation
    Author : Praveen Kumar Kota <*****@*****.**>
    """
    sub_intf = 0
    operation_tg1 = {
        "openconfig-if-ip:config": {
            "ip": "192.168.1.1",
            "prefix-length": 24
        }
    }
    operation_tg2 = {
        "openconfig-if-ip:config": {
            "ip": "192.168.2.1",
            "prefix-length": 24
        }
    }
    rest_urls = st.get_datastore(vars.D1, "rest_urls")
    url = rest_urls['ip_config'].format(vars.D1T1P1, sub_intf,
                                        data.ip4_addr_t1)
    url2 = rest_urls['ip_config'].format(vars.D1T1P2, sub_intf,
                                         data.ip4_addr_t2)

    config_rest(vars.D1,
                http_method="rest-patch",
                rest_url=url,
                json_data=operation_tg1)
    get_rest(vars.D1, rest_url=url)
    config_rest(vars.D1,
                http_method="rest-patch",
                rest_url=url2,
                json_data=operation_tg2)
    get_rest(vars.D1, rest_url=url2)

    h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"],
                                mode='config',
                                intf_ip_addr=data.ip4_addr_t1_tg,
                                gateway=data.ip4_addr_t1,
                                src_mac_addr=data.tg_mac1,
                                arp_send_req='1')
    tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"],
                           mode='config',
                           intf_ip_addr=data.ip4_addr_t2_tg,
                           gateway=data.ip4_addr_t2,
                           src_mac_addr=data.tg_mac2,
                           arp_send_req='1')
    res = tgapi.verify_ping(src_obj=tg,
                            port_handle=tg_handler["tg_ph_1"],
                            dev_handle=h1['handle'],
                            dst_ip=data.ip4_addr_t2_tg,
                            ping_count='1',
                            exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")
    dut_rt_int_mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1)
    tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst',
                               pkts_per_burst=1000, length_mode='fixed', rate_pps=1000, l3_protocol='ipv4', mac_src=data.tg_mac1, \
                               mac_dst=dut_rt_int_mac1, ip_src_addr=data.ip4_addr_t1_tg, ip_dst_addr=data.ip4_addr_t2_tg)
    ifapi.clear_interface_counters(vars.D1, interface_type="all")
    ifapi.show_interface_counters_all(vars.D1)
    tg.tg_traffic_control(action='run', stream_handle=tr1['stream_id'])
    st.wait(2)
    tg.tg_traffic_control(action='stop', stream_handle=tr1['stream_id'])
    st.wait(2)
    ifapi.show_interface_counters_all(vars.D1)
    tg_1_stats = tgapi.get_traffic_stats(tg,
                                         mode='aggregate',
                                         port_handle=tg_handler["tg_ph_1"])
    tg_2_stats = tgapi.get_traffic_stats(tg,
                                         mode='aggregate',
                                         port_handle=tg_handler["tg_ph_2"])
    counter1 = tg_2_stats.rx.total_packets
    counter2 = tg_1_stats.tx.total_packets
    if not counter1 >= counter2:
        ifapi.show_interface_counters_all(vars.D1)
        st.report_fail("test_case_failed")
    st.report_pass("test_case_passed")