Esempio n. 1
0
    def test_confed_route_distribution_with_rmap(self):
        st.banner("Verify the behavior of Route-Maps over confederation peers")
        result = False

        network1 = '134.5.6.0/24'
        network2 = '134.5.7.0/24'
        network3 = '134.5.8.0'
        as_path = '200'
        access_list1 = 'test-access-list1'
        access_list2 = 'test-access-list2'
        access_list3 = 'test-access-list3'

        st.log(
            "Create access-lists and a route-map in DUT1, add to it permit, deny and AS-path prepending policies"
        )
        # Create access-list test-access-list1
        ipapi.config_access_list(topo['dut_list'][0],
                                 access_list1,
                                 network3 + '/24',
                                 'permit',
                                 seq_num="1")
        # Create route-map and permit network3
        ipapi.config_route_map_match_ip_address(topo['dut_list'][0],
                                                'test-rmap', 'permit', '10',
                                                access_list1)

        # Add set option to prepend as-path 200
        ipapi.config_route_map_set_aspath(topo['dut_list'][0], 'test-rmap',
                                          'permit', '10', as_path)

        # Create access-list test-access-list2
        ipapi.config_access_list(topo['dut_list'][0],
                                 access_list2,
                                 network1,
                                 'deny',
                                 seq_num="2")
        # In route-map, deny network1
        ipapi.config_route_map_match_ip_address(topo['dut_list'][0],
                                                'test-rmap', 'deny', '20',
                                                access_list2)

        # Create access-list test-access-list3
        ipapi.config_access_list(topo['dut_list'][0],
                                 access_list3,
                                 network2,
                                 'permit',
                                 seq_num="3")
        # In route-map, permit network2
        ipapi.config_route_map_match_ip_address(topo['dut_list'][0],
                                                'test-rmap', 'permit', '30',
                                                access_list3)

        # Advertise three networks from leaf
        st.log(
            "Advertise the networks from DUT1 through BGP and associate with the route-map"
        )
        bgpapi.advertise_bgp_network(topo['dut_list'][0],
                                     topo['D1_as'],
                                     network1,
                                     'test-rmap',
                                     network_import_check=True)
        bgpapi.advertise_bgp_network(topo['dut_list'][0],
                                     topo['D1_as'],
                                     network2,
                                     'test-rmap',
                                     network_import_check=True)
        bgpapi.advertise_bgp_network(topo['dut_list'][0],
                                     topo['D1_as'],
                                     network3 + '/24',
                                     'test-rmap',
                                     network_import_check=True)

        st.log(
            "Verify in peer DUT2 the network configured in {} has the AS-path prepended"
            .format(access_list1))
        # Verify that the neighbor has the as-path prepended
        output = bgpapi.show_bgp_ipvx_prefix(topo['dut_list'][1],
                                             prefix=network3,
                                             masklen=topo['D1_as'])
        for x in output:  # type: basestring
            peer_asn = x['peerasn']
            peer_asn = peer_asn.split()
            for each in peer_asn:
                if each == as_path:
                    result = True
        if result:
            st.log("Pass: AS-Path {} found to be prepended with network {}/24".
                   format(as_path, network3))
        else:
            st.error(
                "Fail: AS-Path {} not found to be prepended".format(as_path))

        # Verify that network1 is not present in ip route table
        st.log(
            "Verify that peer DUT2 not learnt the network configured as 'deny' in {}"
            .format(access_list2))
        n1 = ipapi.verify_ip_route(topo['dut_list'][1], ip_address=network1)
        if n1 is False:
            result = result & True
            st.log("Pass: DUT2 did not learn network {}".format(network1))
        else:
            result = result & False
            st.error("Fail: DUT2 learned the network {}".format(network1))

        # Verify that network2 is present in ip route table
        st.log(
            "Verify that peer DUT2 learnt the network configured as 'permit' in {}"
            .format(access_list3))
        n2 = ipapi.verify_ip_route(topo['dut_list'][1], ip_address=network2)
        if n2:
            result = result & True
            st.log("Pass: DUT2 learned the network {}".format(network2))
        else:
            result = result & False
            st.error("Fail: DUT2 did not learn network {}".format(network2))

        if not result:
            st.banner("Collecting techsupport")
            exec_all(True, [[
                st.generate_tech_support, topo['dut_list'][0],
                "test_confed_route_distribution_with_rmap"
            ],
                            [
                                st.generate_tech_support, topo['dut_list'][1],
                                "test_confed_route_distribution_with_rmap"
                            ]])

        ipapi.config_route_map_mode(topo['dut_list'][0],
                                    'test-rmap',
                                    'permit',
                                    '10',
                                    config='no')

        # Clear applied configurations
        st.banner("Cleanup for TestFunction")
        ipapi.config_access_list(topo['dut_list'][0],
                                 'test-access-list3',
                                 network2,
                                 'permit',
                                 config='no',
                                 seq_num="3")
        ipapi.config_access_list(topo['dut_list'][0],
                                 'test-access-list2',
                                 network1,
                                 'deny',
                                 config='no',
                                 seq_num="2")
        ipapi.config_access_list(topo['dut_list'][0],
                                 'test-access-list1',
                                 network3 + '/24',
                                 'permit',
                                 config='no',
                                 seq_num="1")

        bgpapi.advertise_bgp_network(topo['dut_list'][0],
                                     topo['D1_as'],
                                     network1,
                                     'test-rmap',
                                     config='no')
        bgpapi.advertise_bgp_network(topo['dut_list'][0],
                                     topo['D1_as'],
                                     network2,
                                     'test-rmap',
                                     config='no')
        bgpapi.advertise_bgp_network(topo['dut_list'][0],
                                     topo['D1_as'],
                                     network3 + '/24',
                                     'test-rmap',
                                     config='no')

        if result:
            st.report_pass("test_case_passed")
        else:
            st.report_fail("test_case_failed")
Esempio n. 2
0
    def test_ipv6_confed_with_rr(self):
        st.banner(
            "Verify Route Reflector behavior within a confederation of BGP v6 peers"
        )
        st.banner(
            "Consider the right confederation iBGP AS and check Route Reflector functionality between the 3 iBGP Routers"
        )

        network_ipv4 = '131.6.6.0/24'
        network_ipv6 = '3000:1::0/64'
        # iBGP AS is one of D2/D3/D4 ASN
        iBGP_as = topo['D2_as']

        st.log("Advertise an IPv4 and an IPv6 network from DUT2 through BGP")
        bgpapi.config_bgp_network_advertise(topo['dut_list'][1],
                                            iBGP_as,
                                            network_ipv4,
                                            network_import_check=True)
        bgpapi.config_bgp_network_advertise(topo['dut_list'][1],
                                            iBGP_as,
                                            network_ipv6,
                                            addr_family='ipv6',
                                            config='yes',
                                            network_import_check=True)

        st.log(
            "Check the network on the 3rd iBGP peer DUT4 is not learnt because Route Reflector is not configured on peer DUT3"
        )
        entries = bgpapi.get_ip_bgp_route(topo['dut_list'][3],
                                          family="ipv4",
                                          network=network_ipv4)
        entries1 = bgpapi.get_ip_bgp_route(topo['dut_list'][3],
                                           family="ipv6",
                                           network="3000:1::/64")

        if not entries and not entries1:
            st.log(
                "Pass: DUT4 did not learn routes without configuring Route Reflector on peer DUT3"
            )
        else:
            st.error(
                "Fail: DUT4 learned route without configuring Route Reflector on peer DUT3"
            )
            st.banner("Collecting techsupport")
            exec_all(True, [[
                st.generate_tech_support, topo['dut_list'][1],
                "test_ipv6_confed_with_rr"
            ],
                            [
                                st.generate_tech_support, topo['dut_list'][2],
                                "test_ipv6_confed_with_rr"
                            ],
                            [
                                st.generate_tech_support, topo['dut_list'][3],
                                "test_ipv6_confed_with_rr"
                            ]])
            # Clear applied configurations
            st.banner("Cleanup for TestFunction")
            bgpapi.config_bgp_network_advertise(topo['dut_list'][1],
                                                iBGP_as,
                                                network_ipv4,
                                                config='no')
            bgpapi.config_bgp_network_advertise(topo['dut_list'][1],
                                                iBGP_as,
                                                network_ipv6,
                                                addr_family='ipv6',
                                                config='no')
            st.report_fail("test_case_failed")

        st.log("Now configure Route Reflector on DUT3")
        bgpapi.create_bgp_route_reflector_client(topo.dut_list[2], iBGP_as,
                                                 'ipv4',
                                                 topo['D3D4P1_neigh_ipv4'],
                                                 'yes')
        bgpapi.create_bgp_route_reflector_client(topo.dut_list[2], iBGP_as,
                                                 'ipv6',
                                                 topo['D3D4P1_neigh_ipv6'],
                                                 'yes')

        st.wait(10)
        st.log("Now the routes should be learnt on the 3rd IBGP peer DUT4")
        entries2 = bgpapi.get_ip_bgp_route(topo['dut_list'][3],
                                           family="ipv4",
                                           network=network_ipv4)
        entries3 = bgpapi.get_ip_bgp_route(topo['dut_list'][3],
                                           family="ipv6",
                                           network="3000:1::/64")
        if entries2 and entries3:
            st.log("Pass: DUT4 learned the routes advertised by peer DUT2")
        else:
            st.error(
                "Fail: DUT4 did not learn the routes advertised by peer DUT2")
            st.banner("Collecting techsupport")
            exec_all(True, [[
                st.generate_tech_support, topo['dut_list'][1],
                "test_ipv6_confed_with_rr"
            ],
                            [
                                st.generate_tech_support, topo['dut_list'][2],
                                "test_ipv6_confed_with_rr"
                            ],
                            [
                                st.generate_tech_support, topo['dut_list'][3],
                                "test_ipv6_confed_with_rr"
                            ]])

        # Clear applied configurations
        st.banner("Cleanup for TestFunction")
        bgpapi.config_bgp_network_advertise(topo['dut_list'][1],
                                            iBGP_as,
                                            network_ipv4,
                                            config='no')
        bgpapi.config_bgp_network_advertise(topo['dut_list'][1],
                                            iBGP_as,
                                            network_ipv6,
                                            addr_family='ipv6',
                                            config='no')
        bgpapi.create_bgp_route_reflector_client(topo.dut_list[2], iBGP_as,
                                                 'ipv4',
                                                 topo['D3D4P1_neigh_ipv4'],
                                                 'no')
        bgpapi.create_bgp_route_reflector_client(topo.dut_list[2], iBGP_as,
                                                 'ipv6',
                                                 topo['D3D4P1_neigh_ipv6'],
                                                 'no')

        if entries2 and entries3:
            st.report_pass("test_case_passed")
        else:
            st.report_fail("test_case_failed")
Esempio n. 3
0
def bgp_pre_config_cleanup():
    st.banner("BGP MODULE CONFIG CLEANUP - START")
    bgp4nodelib.l3_ipv4v6_address_config_unconfig(config='no')
    st.banner("BGP MODULE CONFIG CLEANUP - END")
Esempio n. 4
0
def bgp_confed_pre_config_cleanup():
    st.banner("BGP CONFED CLASS CONFIG CLEANUP - START")
    bgp4nodelib.l3tc_vrfipv4v6_confed_bgp_config(config='no')
    st.banner("BGP RIF CLASS CONFIG CLEANUP - END")
Esempio n. 5
0
    def test_ipv6_confed_route_distribution(self):
        st.banner(
            "Verify the config of BGP v6 confederation and router advertisement"
        )

        st.log(
            "Advertise a network from DUT1 and check if it is learnt on confederation peer DUT3"
        )
        dut1_name = topo['dut_list'][0]
        dut3_name = topo['dut_list'][2]
        network_ipv4 = '131.5.6.0/24'
        network_ipv6 = '2000:1::0/64'

        # Advertise a network to peer

        bgpapi.config_bgp_network_advertise(dut1_name,
                                            topo['D1_as'],
                                            network_ipv4,
                                            network_import_check=True)
        bgpapi.config_bgp_network_advertise(dut1_name,
                                            topo['D1_as'],
                                            network_ipv6,
                                            addr_family='ipv6',
                                            config='yes',
                                            network_import_check=True)
        entries = bgpapi.get_ip_bgp_route(dut3_name,
                                          family="ipv4",
                                          network=network_ipv4)
        entries1 = bgpapi.get_ip_bgp_route(dut3_name,
                                           family="ipv6",
                                           network="2000:1::/64")
        if entries and entries1:
            st.log("Pass: Routes advertised by DUT1 found on DUT3")
        else:
            st.error("Fail: Route advertised by DUT1 not found on DUT3")
            st.banner("Collecting techsupport")
            exec_all(True, [[
                st.generate_tech_support, topo['dut_list'][0],
                "test_ipv6_confed_route_distribution"
            ],
                            [
                                st.generate_tech_support, topo['dut_list'][1],
                                "test_ipv6_confed_route_distribution"
                            ],
                            [
                                st.generate_tech_support, topo['dut_list'][2],
                                "test_ipv6_confed_route_distribution"
                            ]])

        # Clear applied configs
        st.banner("Cleanup for TestFunction")
        bgpapi.config_bgp_network_advertise(dut1_name,
                                            topo['D1_as'],
                                            network_ipv4,
                                            config='no')
        bgpapi.config_bgp_network_advertise(dut1_name,
                                            topo['D1_as'],
                                            network_ipv6,
                                            addr_family='ipv6',
                                            config='no')

        if entries and entries1:
            st.report_pass("test_case_passed")
        else:
            st.report_fail("test_case_failed")
Esempio n. 6
0
def test_ft_l3_performance_enhancements_v4_bgp_session_failover_convergence_time(
        fixture_v4):
    ################# Author Details ################
    # Name: Rakesh Kumar Vooturi
    # Email:  [email protected]
    #################################################
    #
    # Objective - FtOpSoRtPerfFn032 : Performance measurement for BGP Session Failover case
    #  Measure time taken for the traffic ( corresponding to BGP routes ) to resume fully
    #  (i.e RX rate = TX rate) after the BGP session flaps ( i.e BGP session goes down and then comes up
    #  This is triggered using "clear ip bgp * " CLI command ).
    #
    ############### Test bed details ################
    #  TG --- DUT --- TG
    #################################################
    # Configuring traffic stream on the TG interface
    tr1 = tg.tg_traffic_config(
        port_handle=tg_handler["tg_ph_2"],
        emulation_src_handle=h2['handle'],
        emulation_dst_handle=bgp_rtr1['route'][0]['handle'],
        circuit_endpoint_type='ipv4',
        mode='create',
        transmit_mode='continuous',
        length_mode='fixed',
        rate_pps=data.traffic_rate_pps,
        enable_stream_only_gen='0')

    # Verify the total route count using bcmcmd
    if not check_bcmcmd_route_count(dut, 50, "ipv4", def_v4_route_count,
                                    data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    # Verify the total route count
    count = verify_bgp_route_count(dut,
                                   family='ipv4',
                                   neighbor=data.neigh_ip_addr,
                                   state='Established')
    st.log("Route count: " + str(count))
    if int(count) != int(data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    # Starting the TG traffic after clearing the DUT counters
    papi.clear_interface_counters(dut)
    tg.tg_traffic_control(action="run", handle=tr1['stream_id'])

    st.wait(25)

    # Verifying the BGP route count on the DUT
    if not check_intf_traffic_counters(dut, 20, "install"):
        st.report_fail("ingress_traffic_rate_not_matching_with_egress_rate")

    # Clearing the BGP session.
    st.log("Clearing the BGP session.")
    bgpfeature.clear_ip_bgp(dut)

    st.banner(
        "# Measuring Convergence time ( control plane + data plane ) taken for BGP session failover scenario on HWSKU {}"
        .format(hwsku_under_test))
    # Taking the start time timestamp
    start_time = datetime.datetime.now()
    bgpfeature.config_bgp(dut=vars.D1,
                          local_as=data.as_num,
                          config='yes',
                          neighbor=data.neigh_ip_addr,
                          config_type_list=["connect"],
                          connect='1')

    # Verify the total route count using bcmcmd
    if not check_bcmcmd_route_count(dut, 50, "ipv4", def_v4_route_count,
                                    data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    # Verify the total route count
    count = verify_bgp_route_count(dut,
                                   family='ipv4',
                                   neighbor=data.neigh_ip_addr,
                                   state='Established')
    st.log("Route count: " + str(count))
    if int(count) != int(data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    # Taking the end time timestamp
    end_time = datetime.datetime.now()

    # Time taken for route installation
    st.log("Start Time: {}".format(start_time))
    st.log("End Time: {}".format(end_time))
    time_in_secs = end_time - start_time

    st.banner(
        "Convergence time ( control plane + data plane ) taken for BGP session failover scenario (After session up, time taken for BGP to re establish, learn and install the routes to hardware) on HWSKU {} = "
        .format(hwsku_under_test) + str(time_in_secs.seconds))

    # Stopping the TG traffic
    tg.tg_traffic_control(action='stop', handle=tr1['stream_id'])
    st.report_pass("test_case_passed")
Esempio n. 7
0
def test_ft_l3_performance_enhancements_v6_route_intstall_withdraw(fixture_v6):
    ################# Author Details ################
    # Name: Rakesh Kumar Vooturi
    # Email:  [email protected]
    #################################################
    #
    # Objective - FtOpSoRtPerfFn042 : Performance measurement for IPv6 route installation in hardware
    #  Measure time taken for routes to get installed into the hardware
    #  (with fresh advertisement of routes ...but not due to any other trigger).
    # Objective - FtOpSoRtPerfFn043 : Performance measurement for IPv6 route withdraw in hardware
    #  Measure time taken for routes to get removed from the hardware by stop advertising the Routes from neighbor.
    #
    ############### Test bed details ################
    #  TG --- DUT --- TG
    #################################################
    # Withdraw the routes.
    ctrl1 = tg.tg_bgp_routes_control(
        handle=bgp_rtr2['conf']['handle'],
        route_handle=bgp_rtr2['route'][0]['handle'],
        mode='withdraw')
    st.log("TR_CTRL: " + str(ctrl1))

    # Verify the total route count using bcmcmd
    if not check_bcmcmd_route_count(dut, 50, "ipv6", def_v6_route_count, 0):
        st.report_fail("route_table_not_cleared_by_withdraw_from_tg")

    # Verify the total route count
    count = verify_bgp_route_count(dut,
                                   family='ipv6',
                                   neighbor=data.neigh_ipv6_addr,
                                   state='Established')
    st.log("Route count: " + str(count))
    if int(count) != 0:
        st.report_fail("route_table_not_cleared_by_withdraw_from_tg")

    if data.includeTraffic:
        # Configuring traffic stream on the TG interface
        tr2 = tg.tg_traffic_config(
            port_handle=tg_handler["tg_ph_2"],
            emulation_src_handle=h2['handle'],
            emulation_dst_handle=bgp_rtr2['route'][0]['handle'],
            circuit_endpoint_type='ipv6',
            mode='create',
            transmit_mode='continuous',
            length_mode='fixed',
            rate_pps=data.traffic_rate_pps,
            enable_stream_only_gen='0')

        # Starting the TG traffic after clearing the DUT counters
        papi.clear_interface_counters(dut)
        tg.tg_traffic_control(action="run", handle=tr2['stream_id'])

    st.banner(
        "# Measuring time taken for route installation of {} ipv6 routes on HWSKU {}"
        .format(data.test_bgp_route_count, hwsku_under_test))

    # Taking the start time timestamp
    start_time = datetime.datetime.now()

    # Readvertise the routes.
    ctrl1 = tg.tg_bgp_routes_control(
        handle=bgp_rtr2['conf']['handle'],
        route_handle=bgp_rtr2['route'][0]['handle'],
        mode='readvertise')
    st.log("TR_CTRL: " + str(ctrl1))

    # Verify the total route count using bcmcmd
    if not check_bcmcmd_route_count(dut, 50, "ipv6", def_v6_route_count,
                                    data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    if data.includeTraffic:
        st.wait(25)
        # Verifying the BGP route count on the DUT
        if not check_intf_traffic_counters(dut, 20, "install"):
            st.report_fail(
                "ingress_traffic_rate_not_matching_with_egress_rate")

    # Taking the end time timestamp
    end_time = datetime.datetime.now()

    # Verify the total route count
    count = verify_bgp_route_count(dut,
                                   family='ipv6',
                                   neighbor=data.neigh_ipv6_addr,
                                   state='Established')
    st.log("Route count: " + str(count))
    if int(count) != int(data.test_bgp_route_count):
        st.report_fail("route_table_not_updated_by_advertise_from_tg")

    # Time taken for route installation
    st.log("Start Time: {}".format(start_time))
    st.log("End Time: {}".format(end_time))
    time_in_secs = end_time - start_time

    st.banner("Time taken for intsalling {} v6 routes on HWSKU {} = ".format(
        data.test_bgp_route_count, hwsku_under_test) +
              str(time_in_secs.seconds))
    st.banner(
        "# Measuring time taken for route withdraw of {} ipv4 routes on HWSKU {}"
        .format(data.test_bgp_route_count, hwsku_under_test))

    # Taking the start time timestamp
    start_time = datetime.datetime.now()

    # Withdraw the routes.
    ctrl1 = tg.tg_bgp_routes_control(
        handle=bgp_rtr2['conf']['handle'],
        route_handle=bgp_rtr2['route'][0]['handle'],
        mode='withdraw')
    st.log("TR_CTRL: " + str(ctrl1))

    # Verify the total route count using bcmcmd
    if not check_bcmcmd_route_count(dut, 50, "ipv6", def_v6_route_count, 0):
        st.report_fail("route_table_not_cleared_by_withdraw_from_tg")

    if data.includeTraffic:
        # Verifying the BGP route count on the DUT
        if not check_intf_traffic_counters(dut, 20, "withdraw"):
            st.report_fail("egress_traffic_rate_not_zero")

    # Taking the end time timestamp
    end_time = datetime.datetime.now()

    # Verify the total route count
    count = verify_bgp_route_count(dut,
                                   family='ipv6',
                                   neighbor=data.neigh_ipv6_addr,
                                   state='Established')
    st.log("Route count: " + str(count))
    if int(count) != 0:
        st.report_fail("route_table_not_cleared_by_withdraw_from_tg")

    # Time taken for route withdraw
    st.log("Start Time: {}".format(start_time))
    st.log("End Time: {}".format(end_time))
    time_in_secs = end_time - start_time

    st.banner("Time taken for withdrawing {} v6 routes on HWSKU {} = ".format(
        data.test_bgp_route_count, hwsku_under_test) +
              str(time_in_secs.seconds))

    if data.includeTraffic:
        # Stopping the TG traffic
        tg.tg_traffic_control(action='stop', handle=tr2['stream_id'])
    st.report_pass("test_case_passed")
def verify_bum_traffic_mode(mode,
                            tg_stream,
                            skip_traffic_verify=False,
                            duration=10):
    """
    :param mode:
    :param tg_stream:
    :param skip_traffic_verify:
    :param duration:
    :return:
    """
    if mode not in ["unknown-unicast", "unknown-multicast", "broadcast"]:
        st.log("Unsupported mode provided")
        return False
    st.banner("verifying  {} traffic ".format(mode))
    st.log("Clearing stats before sending traffic ...")
    tg.tg_traffic_control(action="clear_stats",
                          port_handle=tg_handler["tg_ph_list"])
    st.wait(2)
    if mode == 'broadcast':
        st.log("Enabling {} traffic ".format(mode))
        tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"],
                             mode='modify',
                             duration=10,
                             stream_id=tg_stream,
                             mac_src="00:00:00:00:00:01",
                             mac_dst="ff:ff:ff:ff:ff:ff",
                             rate_pps=5000)
    elif mode == 'unknown-multicast':
        st.log("Enabling {} traffic ".format(mode))
        tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"],
                             mode='modify',
                             duration=10,
                             stream_id=tg_stream,
                             mac_src="00:00:00:00:00:01",
                             mac_dst="01:00:5e:01:02:03",
                             rate_pps=5000)
    elif mode == 'unknown-unicast':
        st.log("Enabling {} traffic ".format(mode))
        tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"],
                             duration=10,
                             mode='modify',
                             stream_id=tg_stream,
                             mac_src="00:00:00:00:00:01",
                             mac_dst="00:00:00:00:00:02",
                             rate_pps=5000)
    if not skip_traffic_verify:
        st.log("Starting of traffic from TGen")
        tg.tg_traffic_control(action='run',
                              stream_handle=tg_stream,
                              duration=10)
        st.wait(data.wait_stream_run)
        st.log("Stopping of traffic from TGen to get interface counters")
        tg.tg_traffic_control(action='stop', stream_handle=tg_stream)
        st.wait(data.wait_for_stats)
        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"])
        counter = tg_2_stats.rx.total_packets
        counter2 = tg_1_stats.tx.total_packets
        if counter2 == 0:
            st.report_fail("storm_control_traffic_verification_failed")
        counters_avg = counter / duration
        st.log("Average of counters are : {}".format(counters_avg))
        st.log("Higher packet count value is : {}".format(
            data.higher_pkt_count))
        st.log("Lower packet count value is : {}".format(data.lower_pkt_count))
        if counters_avg > data.higher_pkt_count or counters_avg < data.lower_pkt_count:
            st.report_fail("storm_control_traffic_verification_failed")
    return True
Esempio n. 9
0
def test_ft_tf_config_multi_threshold_rest():
    """
    Author : Prudvi Mangadu ([email protected])
    """
    tf_rest_support_checker()
    result = 1
    e_pg_sh_port1, e_pg_sh_queue1, e_pg_sh_queue_name1, e_pg_sh_th_value1 = dut_port[
        0], 3, 'pg3', 59
    _, _, e_pg_hr_queue_name1, e_pg_hr_th_value1 = dut_port[0], 3, 'pg3', 14
    e_uc_port1, e_uc_queue1, e_uc_queue_name1, e_uc_th_value1 = dut_port[
        0], 4, 'uc4', 50
    e_mc_port1, e_mc_queue1, e_mc_queue_name1, e_mc_th_value1 = dut_port[
        0], 1, 'mc1', 30
    e_cpu_port1, e_cpu_queue1, e_cpu_queue_name1, e_cpu_th_value1 = 'CPU', 1, 'mc1', 10

    set_rest_data = [{
        "data": [{
            "data": [[e_pg_sh_queue1, e_pg_sh_th_value1, e_pg_hr_th_value1]],
            "port":
            e_pg_sh_port1
        }],
        "realm":
        "ingress-port-priority-group"
    }, {
        "data": [[e_uc_port1, e_uc_queue1, e_uc_th_value1]],
        "realm": "egress-uc-queue"
    }, {
        "data": [[e_mc_port1, e_mc_queue1, e_mc_th_value1]],
        "realm": "egress-mc-queue"
    }, {
        "data": [[e_cpu_queue1, e_cpu_th_value1]],
        "realm": "egress-cpu-queue"
    }]

    # REST SET
    st.banner("Configuring Threshold {} via REST".format(
        tf_rest_data.configure_bst_multi_thresholds))
    if not rtapi.send_rest_request(vars.D1, tf_rest_data.feature,
                                   tf_rest_data.configure_bst_multi_thresholds,
                                   set_rest_data):
        st.error("Failed to SET {} via REST".format(
            tf_rest_data.configure_bst_multi_thresholds))
        result = 0
    else:
        st.log("--> Success: Configuring Threshold {} via REST".format(
            tf_rest_data.configure_bst_multi_thresholds))

    # REST GET and Verify
    if not tf_config_common_call('REST_GET',
                                 e_pg_sh_th_value1,
                                 dut=vars.D1,
                                 threshold_type="priority-group",
                                 buffer_type='shared',
                                 index_name=e_pg_sh_queue_name1,
                                 port_alias=e_pg_sh_port1):
        result = 0
    if not tf_config_common_call('REST_GET',
                                 e_pg_hr_th_value1,
                                 dut=vars.D1,
                                 threshold_type="priority-group",
                                 buffer_type='headroom',
                                 index_name=e_pg_hr_queue_name1,
                                 port_alias=e_pg_sh_port1):
        result = 0
    if not tf_config_common_call('REST_GET',
                                 e_uc_th_value1,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='unicast',
                                 index_name=e_uc_queue_name1,
                                 port_alias=e_uc_port1):
        result = 0
    if not tf_config_common_call('REST_GET',
                                 e_mc_th_value1,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='multicast',
                                 index_name=e_mc_queue_name1,
                                 port_alias=e_mc_port1):
        result = 0
    if not tf_config_common_call('REST_GET',
                                 e_cpu_th_value1,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='multicast',
                                 index_name=e_cpu_queue_name1,
                                 port_alias=e_cpu_port1):
        result = 0

    # CLI GET and Verify
    if not tf_config_common_call('CLI_GET',
                                 e_pg_sh_th_value1,
                                 dut=vars.D1,
                                 threshold_type="priority-group",
                                 buffer_type='shared',
                                 index_name=e_pg_sh_queue_name1,
                                 port_alias=e_pg_sh_port1):
        result = 0
    if not tf_config_common_call('CLI_GET',
                                 e_pg_hr_th_value1,
                                 dut=vars.D1,
                                 threshold_type="priority-group",
                                 buffer_type='headroom',
                                 index_name=e_pg_hr_queue_name1,
                                 port_alias=e_pg_sh_port1):
        result = 0
    if not tf_config_common_call('CLI_GET',
                                 e_uc_th_value1,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='unicast',
                                 index_name=e_uc_queue_name1,
                                 port_alias=e_uc_port1):
        result = 0
    if not tf_config_common_call('CLI_GET',
                                 e_mc_th_value1,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='multicast',
                                 index_name=e_mc_queue_name1,
                                 port_alias=e_mc_port1):
        result = 0
    if not tf_config_common_call('CLI_GET',
                                 e_cpu_th_value1,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='multicast',
                                 index_name=e_cpu_queue_name1,
                                 port_alias=e_cpu_port1):
        result = 0
    # REST Clear
    if not tf_config_common_call('REST_CLEAR', 0, dut=vars.D1):
        result = 0

    # REST GET and Verify
    if not tf_config_common_call('REST_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="priority-group",
                                 buffer_type='shared',
                                 index_name=e_pg_sh_queue_name1,
                                 port_alias=e_pg_sh_port1):
        result = 0
    if not tf_config_common_call('REST_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="priority-group",
                                 buffer_type='headroom',
                                 index_name=e_pg_hr_queue_name1,
                                 port_alias=e_pg_sh_port1):
        result = 0
    if not tf_config_common_call('REST_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='unicast',
                                 index_name=e_uc_queue_name1,
                                 port_alias=e_uc_port1):
        result = 0
    if not tf_config_common_call('REST_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='multicast',
                                 index_name=e_mc_queue_name1,
                                 port_alias=e_mc_port1):
        result = 0
    if not tf_config_common_call('REST_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='multicast',
                                 index_name=e_cpu_queue_name1,
                                 port_alias=e_cpu_port1):
        result = 0

    # CLI GET and Verify
    if not tf_config_common_call('CLI_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="priority-group",
                                 buffer_type='shared',
                                 index_name=e_pg_sh_queue_name1,
                                 port_alias=e_pg_sh_port1):
        result = 0
    if not tf_config_common_call('CLI_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="priority-group",
                                 buffer_type='headroom',
                                 index_name=e_pg_hr_queue_name1,
                                 port_alias=e_pg_sh_port1):
        result = 0
    if not tf_config_common_call('CLI_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='unicast',
                                 index_name=e_uc_queue_name1,
                                 port_alias=e_uc_port1):
        result = 0
    if not tf_config_common_call('CLI_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='multicast',
                                 index_name=e_mc_queue_name1,
                                 port_alias=e_mc_port1):
        result = 0

    if not tf_config_common_call('CLI_GET',
                                 tf_rest_data.default_threshold_value,
                                 dut=vars.D1,
                                 threshold_type="queue",
                                 buffer_type='multicast',
                                 index_name=e_cpu_queue_name1,
                                 port_alias=e_cpu_port1):
        result = 0
    tf_unconfig()
    report_result(result)
Esempio n. 10
0
def tf_config_common_call(call_type, th_value, **kwargs):
    """
    Common function to make both CLI and REST threshold feature calls
    """
    result2 = 1
    dut = kwargs['dut']
    if call_type != "REST_CLEAR":
        threshold_type = kwargs['threshold_type']
        buffer_type = kwargs['buffer_type']
        index_name = kwargs['index_name']
        port_alias = kwargs['port_alias']
        index = int(re.findall(r"\d+", kwargs['index_name'])[0])

    if call_type == "REST_GET" or call_type == 'REST_GET_PORTS_CHECK':
        st.banner("Verifying Threshold {} {} config via REST".format(
            threshold_type, buffer_type))
        if any("/" in interface for interface in make_list(port_alias)):
            port_alias = st.get_other_names(vars.D1, make_list(port_alias))[0]
        get_rest_data = tfapi.get_threshold_rest_data(
            threshold_type=threshold_type,
            buffer_type=buffer_type,
            port=port_alias)
        rv_data = rtapi.send_rest_request(dut, tf_rest_data.feature,
                                          tf_rest_data.get_bst_thresholds,
                                          get_rest_data)
        if not rv_data:
            st.error("Failed to GET Threshold {} {} via REST".format(
                threshold_type, buffer_type))
            return 0
        if rv_data:
            resp = json.loads(rv_data.text)
            if call_type == 'REST_GET_PORTS_CHECK':
                st.banner("Validating interfaces in {} {} REST Data ".format(
                    threshold_type, buffer_type))
                if not check_ports_from_rest_output(resp, threshold_type,
                                                    buffer_type,
                                                    tf_rest_data.all_ports):
                    result2 = 0
                if result2:
                    st.log(
                        "--> Success: Interface Validation of {} {}  REST DATA"
                        .format(threshold_type, buffer_type))
            get_value = get_threshold_from_rest_output(resp, threshold_type,
                                                       buffer_type, port_alias,
                                                       index)
            if get_value is None:
                return 0
            st.log(
                "REST GET Threshold Value {} {} on Port:{}, Index:{}".format(
                    get_value, type(get_value), port_alias, index))
            st.log("Configured Threshold Value {} {}".format(
                th_value, type(th_value)))
            if not get_value == int(th_value):
                st.error("Failed to Verify Threshold {} {} via REST".format(
                    threshold_type, buffer_type))
                return 0
        st.log("--> Success: Verifying Threshold {} {} config via REST".format(
            threshold_type, buffer_type))
        return 1 and result2

    elif call_type == "REST_SET":
        st.banner("Configuring Threshold {} {} via REST".format(
            threshold_type, buffer_type))
        if any("/" in interface for interface in make_list(port_alias)):
            port_alias = st.get_other_names(vars.D1, make_list(port_alias))[0]
        set_rest_data = tfapi.set_threshold_rest_data(
            threshold_type=threshold_type,
            port_alias=port_alias,
            index=index,
            buffer_type=buffer_type,
            value=th_value)
        if not rtapi.send_rest_request(dut, tf_rest_data.feature,
                                       tf_rest_data.configure_bst_thresholds,
                                       set_rest_data):
            st.error("Failed to SET Threshold {} {} via REST".format(
                threshold_type, buffer_type))
            return 0
        st.log("--> Success: Configuring Threshold {} {} via REST".format(
            threshold_type, buffer_type))
        return 1

    elif call_type == 'CLI_GET':
        st.banner("Verifying Threshold {} {} config via CLI".format(
            threshold_type, buffer_type))
        api_data = {
            'threshold_type': threshold_type,
            'buffer_type': buffer_type,
            'port_alias': port_alias,
            index_name: th_value
        }
        if not tfapi.verify_threshold(dut, **api_data):
            st.error("Failed to Verify Threshold {} {} via CLI".format(
                threshold_type, buffer_type))
            return 0
        st.log("--> Success: Verifying Threshold {} {} config via CLI".format(
            threshold_type, buffer_type))
        return 1

    elif call_type == 'REST_CLEAR':
        st.banner("Performing Clear BST thresholds via REST")
        if not rtapi.send_rest_request(dut, tf_rest_data.feature,
                                       tf_rest_data.clear_bst_thresholds, {}):
            st.error('REST: Clear BST thresholds call failed')
            return 0
        st.log("--> Success: Performing Clear thresholds via REST")
        return 1
    else:
        st.error("Unknown tf call_type : {}".format(call_type))
        return 0