Example #1
0
def dut_bgpv6(local_asn, remote_asn, data=[]):
    st.log("Creating the ipv6 routing interfaces in {}".format(vars.D1))
    ipfeature.config_ip_addr_interface(data.D1,
                                       data.dut_p2_interface,
                                       data.dut_p2_ipaddr,
                                       data.dut_p2_ipaddr_subnet,
                                       family="ipv6")
    if not ipfeature.verify_interface_ip_address(
            data.D1,
            data.dut_p2_interface,
            data.dut_p2_ipaddr + '/' + str(data.dut_p2_ipaddr_subnet),
            family="ipv6"):
        st.report_fail('ip6_routing_int_create_fail', data.dut_p2_ipaddr)

    bgp_obj.create_bgp_router(data.D1, data.local_asn, data.router_id_1)
    bgp_obj.create_bgp_neighbor(dut=data.D1,
                                local_asn=data.local_asn,
                                neighbor_ip=data.dut_p2_ipaddr_peer,
                                remote_asn=data.remote_asn,
                                family="ipv6")
    st.log("Waiting for the ecrm_bgp_config_v6 neighbors to get Established")
    st.wait(10)
Example #2
0
def config_dut2_verify():
    st.log("Enabling docker routing config mode in D2 ")
    bgp_obj.enable_docker_routing_config_mode(vars.D2)

    st.log("saving the BGP config in vtysh shell")
    st.log("config save in D2")
    reboot_obj.config_save(vars.D2, shell='vtysh')

    st.log("Performing reboot")
    st.reboot(vars.D2)
    st.wait(data.neighborship_wait, "wait for bgp neighborship")

    st.log("Verifying BGP is established after save and reload")
    if not st.poll_wait(bgp_obj.verify_bgp_neighborship,
                        60,
                        vars.D2,
                        family=data.af_ipv4,
                        shell=data.shell_vtysh,
                        neighbor=data.local_ip_addr,
                        state='Established',
                        asn=data.local_asn4):
        st.report_fail('bgp_ip_peer_establish_fail', data.local_ip_addr)
    else:
        st.log("eBGP V4 peer neigborship is successful")

    if data.ipv6_support:
        st.log("Verifying BGPV6 is  established after save and reload")
        if not st.poll_wait(bgp_obj.verify_bgp_neighborship,
                            60,
                            vars.D2,
                            family=data.af_ipv6,
                            shell=data.shell_vtysh,
                            neighbor=data.local_ip6_addr,
                            state='Established',
                            asn=data.local_asn4):
            st.report_fail('bgp_ip6_peer_establish_fail', data.local_ip6_addr)
        else:
            st.log("eBGP V6 peer neigborship is successful")
Example #3
0
def test_ft_nat_config_reload():
    # ################ Author Details ################
    # Name: Kiran Vedula
    # Eamil: [email protected]
    # ################################################
    # Objective - Verify dynamic NAPT translations after config save and reload
    # #################################################
    nat_obj.clear_nat(vars.D1, translations=True)
    nat_obj.clear_nat(vars.D1, statistics=True)
    st.log("Config reload the DUT")
    reboot_obj.config_save_reload(vars.D1)
    st.log("Get some debug info after config reload is complete")
    ip_obj.show_ip_route(vars.D1)
    arp_obj.show_arp(vars.D1)
    nat_obj.show_nat_translations(vars.D1)
    st.wait(2)
    st.log("Traffic for snat case")
    tg1.tg_traffic_control(action='run', handle=tg_str_data[1]["tg1_dyn_nat_udp_data_str_id_1"])
    tg1.tg_traffic_control(action='stop', handle=tg_str_data[1]["tg1_dyn_nat_udp_data_str_id_1"])
    st.wait(data.wait_nat_stats)
    trn_val_1 = nat_obj.get_nat_translations(vars.D1, protocol=data.proto_all, src_ip=data.in1_ip_addr_h[0])
    if not trn_val_1:
        nat_reboot_debug_fun()
        st.report_fail("nat_translation_table_entry_deleted_incorrectly")
    count = data.pkt_count
    trn_val = nat_obj.get_nat_translations(vars.D1, protocol=data.proto_udp, src_ip=data.in1_ip_addr_h[-1],
                                           src_ip_port=data.local_src_port[0])
    if not trn_val:
        nat_reboot_debug_fun()
        st.error("Received empty list,nat translation table not updated")
        st.report_fail("dynamic_snat_translation_entry_create_fail", data.in1_ip_addr_h[-1], data.out_ip_pool[0])
    trn_src_ip = trn_val[0]["trn_src_ip"]
    trn_src_port = trn_val[0]["trn_src_ip_port"]
    st.log("Traffic for dnat case")
    tg2_str_obj = tg2_str_selector(trn_src_ip, trn_src_port)
    tg2.tg_traffic_control(action='run', handle=tg2_str_obj)
    tg2.tg_traffic_control(action='stop', handle=tg2_str_obj)
    st.wait(data.wait_nat_stats)
    nat_stats_s = nat_obj.poll_for_nat_statistics(vars.D1, protocol=data.proto_udp,
                                                  src_ip=data.in1_ip_addr_h[-1], src_ip_port=data.local_src_port[0])
    if not nat_stats_s:
        nat_reboot_debug_fun()
        st.error("Received empty list,nat statistics are not updated")
        st.report_fail("dynamic_snat_translation_entry_create_fail", data.in1_ip_addr_h[-1], data.out_ip_pool[0])
    if not int(nat_stats_s[0]['packets']) >= (0.80 * (int(count))):
        nat_reboot_debug_fun()
        st.report_fail("dynamic_snat_translation_entry_create_fail", data.in1_ip_addr_h[-1], data.out_ip_pool[0])

    nat_stats_d = nat_obj.poll_for_nat_statistics(vars.D1, protocol=data.proto_udp, dst_ip=trn_src_ip,
                                                  dst_ip_port=trn_src_port)
    if not nat_stats_d:
        nat_reboot_debug_fun()
        st.error("Received empty list, nat statistics are not updated")
        st.report_fail("dynamic_dnat_translation_entry_create_fail", data.out_ip_pool[0], data.out_ip_pool[0])
    if not int(nat_stats_d[0]['packets']) >= (0.80 * (int(count))):
        nat_reboot_debug_fun()
        st.report_fail("dynamic_dnat_translation_entry_create_fail", data.out_ip_pool[0], data.out_ip_pool[0])
    st.report_pass("nat_translation_successful_after_config_reload")
def test_ft_ipv6_link_local_ping():
    report_flag = 0
    if not ip_obj.ping(vars.D1, d2_prt_link_local[0], family='ipv6', interface = vars.D1D2P1):
        st.log("Ipv6 Ping over Link Local address via the Port based routing interface is failed.")
        report_flag = 1
    if not ip_obj.ping(vars.D1, d2_prt_link_local[0], family='ipv6', interface = data.vlan_in_1):
        st.log("Ipv6 Ping over Link Local address via the Vlan  based routing interface is failed.")
        report_flag =1
    if not ip_obj.ping(vars.D1, d2_prt_link_local[0], family='ipv6', interface = data.prt_chnl):
        st.log("Ipv6 Ping over Link Local address via the Port Channel based routing interface is failed.")
        report_flag =1
    # Get show ndp output
    utils.exec_all(True, [[arp_obj.show_ndp, vars.D1, None], [arp_obj.show_ndp, vars.D2, None]])
    d1_int_li = [vars.D2D1P1, vars.D2D1P2, data.prt_chnl]
    intf_obj.interface_operation(vars.D2, [vars.D2D1P1, vars.D2D1P2, data.prt_chnl], operation="shutdown", skip_verify=True)
    st.log("Waiting for 10 sec after shutdown the interfaces")
    st.wait(10)
    intf_obj.interface_status_show(vars.D1, [vars.D2D1P1, vars.D2D1P2, data.prt_chnl])
    intf_obj.interface_operation(vars.D2, [vars.D2D1P1, vars.D2D1P2, data.prt_chnl], operation="startup",
                                 skip_verify=True)
    st.log("Polling for interface status after no shutdown")
    for intf in d1_int_li:
        if not intf_obj.poll_for_interface_status(vars.D2, intf, "oper", "up", iteration=5, delay=1):
            st.error("Failed to startup interface {} on the DUT {}".format(intf, vars.D2))
            report_flag = 0

    if not ip_obj.ping(vars.D1, d2_prt_link_local[0], family='ipv6', interface = vars.D1D2P1):
        st.log("After shut no shut, Ipv6 Ping over Link Local address via the Port based routing interface is failed.")
        report_flag = 1
    if not ip_obj.ping(vars.D1, d2_prt_link_local[0], family='ipv6', interface=data.vlan_in_1):
        st.log("After shut no shut, Ipv6 Ping over Link Local address via the Vlan  based routing interface is failed.")
        report_flag = 1
    if not ip_obj.ping(vars.D1, d2_prt_link_local[0], family='ipv6', interface=data.prt_chnl):
        st.log("After shut no shut, Ipv6 Ping over Link Local address via the Port Channel based routing interface is failed.")
        report_flag = 1
    if report_flag:
        st.report_fail("ip6_ping_fail_over_link_local_addr")
    st.report_pass("test_case_passed")
Example #5
0
def test_ft_ip_static_ip_on_mgmt_intrf():
    """
    Author:Karthik Kumar Goud Battula([email protected])
    Scenario: Verify the configuration of static ip address on eth0 interface and check the reachability
    """
    result = True
    vars = st.ensure_min_topology("D1", "CONSOLE_ONLY")
    data.interface = 'eth0'
    intf_obj.enable_dhcp_on_interface(vars.D1, data.interface)
    st.wait(5)
    ip_address_list = basic_obj.get_ifconfig_inet(vars.D1, data.interface)
    if not ip_address_list:
        st.report_fail("DUT_does_not_have_IP_address".format(
            vars.D1, data.interface))
    data.ip_address = ip_address_list[0]
    data.netmask = basic_obj.get_ifconfig(vars.D1,
                                          data.interface)[0]['netmask'][0]
    data.gateway = basic_obj.get_ifconfig_gateway(vars.D1, data.interface)
    intf_obj.config_static_ip_to_interface(vars.D1, data.interface,
                                           data.ip_address, data.netmask,
                                           data.gateway)
    st.log("Verify connectivity from DUT")
    if not ping_obj.ping(vars.D1, data.gateway):
        st.error("Ping is not successful for address {}".format(data.gateway))
        result = False
    intf_obj.delete_ip_on_interface_linux(
        vars.D1, data.interface, "{}/{}".format(data.ip_address, data.netmask))
    ip_address_list = basic_obj.get_ifconfig_inet(vars.D1, data.interface)
    if ip_address_list:
        st.error("DUT_have_IP_address".format(vars.D1, data.interface))
        result = False
    intf_obj.enable_dhcp_on_interface(vars.D1, data.interface)
    if not ping_obj.ping(vars.D1, data.gateway):
        st.error("Ping is not successful for address".format(data.gateway))
        result = False
    if not result:
        st.report_fail("test_case_failed")
    st.report_pass("test_case_passed")
Example #6
0
def poll_for_nat_translations(dut, itr=2, delay=2, **kwargs):
    """
    :param :dut:
    :param :protocol
    :param :src_ip
    :param :src_ip_port
    :param :dst_ip
    :param :dst_ip_port
    :param :trn_src_ip
    :param :trn_src_ip_port
    :param :trn_dst_ip
    :param :trn_dst_ip_port
    :return:
    """
    i = 1
    while True:
        result = verify_nat_translations(dut, **kwargs)
        if result:
            return get_nat_translations(dut, **kwargs)
        if i >= itr:
            return None
        st.wait(delay)
        i += 1
Example #7
0
def retry_rest_api(func, *args, **kwargs):
    """
    Author: Sunil Rajendra ([email protected])
    Util function to retry REST APIs.
    :param data:
    :return: output_data or False
    """
    retry_count = kwargs.pop("retry_count", 10)
    delay = kwargs.pop("delay", 3)
    ret_val = False
    for i in range(retry_count):
        st.log("Attempt {} of {}".format((i + 1), retry_count))
        try:
            ret_val = func(*args, **kwargs)
            if ret_val:
                return ret_val
        except Exception:
            pass
        if retry_count != (i + 1):
            st.log(
                "waiting for {} seconds before retyring again".format(delay))
            st.wait(delay)
    return False
def test_ft_verify_max_static_portchannel():
    '''
    Author: Venkatesh Terli <*****@*****.**>
    Scenario - 3.4.1 Verify the max number of Static Port Channels configurable per system.
    '''
    portchannel_list = []
    for i in range(2, static_data.max_portchannels + 1, 1):
        portchannelobj.create_portchannel(vars.D1,
                                          "PortChannel" + str(i),
                                          static=True)
    for i in range(2, static_data.max_portchannels + 1, 1):
        temp = "PortChannel" + str(i)
        portchannel_list.append(temp)
    portchannelobj.delete_portchannels(vars.D1, portchannel_list)
    st.wait(10)
    portchannel_list1 = portchannelobj.get_portchannel_names(vars.D1)
    portchannel_list1 = list(dict.fromkeys(portchannel_list1))
    if len(portchannel_list1) != 1:
        st.report_fail('portchannel_config_clear_failed')
    elif static_data.portchannel_name not in portchannel_list1:
        st.report_fail('portchannel_not_found', static_data.portchannel_name)
    else:
        st.report_pass('max_portchannels_per_system')
Example #9
0
def verify_port_table_port_config(dut, itter_count=30, delay=1):
    """
    To verify the Port Table Port config status
    Author: Prudvi Mangadu ([email protected])
    :param dut:
    :param itter_count:
    :param delay:
    :return:
    """
    command = redis.build(dut, redis.APPL_DB, "HGETALL PORT_TABLE:PortConfigDone")
    i = 1
    while True:
        output = st.show(dut, command)
        output_list = utils.filter_and_select(output, ["name"], None)
        output_list = utils.dicts_list_values(output_list, "name")
        if 'count' in output_list:
            st.log("{}".format(output))
            return True
        if i > itter_count:
            st.log("Max {} tries Exceeded.Exiting..".format(i))
            return False
        i += 1
        st.wait(delay)
Example #10
0
def poll_ztp_status(dut, status=["IN-PROGRESS", "Not Started"], iteration=40, retry=3, cli_type=""):
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    """
    API to poll the ztp status
    Author: Chaitanya Vella ([email protected])
    :param dut:
    :param status:
    :param iteration:
    :param retry:
    :return:
    """
    i = 1
    status = list([str(e) for e in status]) if isinstance(status, list) else [status]
    while True:
        response = show_ztp_status(dut, cli_type=cli_type)
        if response["status"] in status:
            st.log("Observed {} during polling ...".format(status))
            return True
        if i > iteration:
            st.log("Max polling interval {} exceeded ...".format(i))
            return False
        i += 1
        st.wait(retry)
def test_chef_evpn_vxlan_nvo():
    for dut in [data.d2, data.d3]:
        dut_type = get_hwsku(dut)
        if "7326" in dut_type or "AS7726" in dut_type or "S5232f" in dut_type or "S5248f" in dut_type or "S5296f" in dut_type or "AS5835" in dut_type or "IX8A" in dut_type or "IX8" in dut_type:
            st.log(
                "platform {} can be used as leaf node for EVPN testing".format(
                    dut_type))
        else:
            st.error(
                "expecting leaf node for EVPN testing to be \"7326\" or \"AS7726\" or \"S5232f\" or \"S5248f\" or \"S5296f\" or \"AS5835\" or \"IX8A\" or \"IX8\""
            )
            st.report_env_fail("platform_check_fail", dut)
    chef_server.role_dir = os.path.join(chef_server.path, 'roles')
    for file_name, role, node_name in zip(data.role_tc_list_evpn,
                                          data.role_list_mc,
                                          data.node_list_mc):

        new_file_name = modify_role_jsonfile(file_name)
        loc_lib.copy_role_file_to_chef_server(new_file_name)
        st.log('{}, {}, {}'.format(file_name, role, node_name))
        chef_evpn_obj.upload_role_chef_server(chef_server.ssh_obj,
                                              chef_server.role_dir,
                                              file_name=new_file_name)
        run_list = 'role[{}],recipe[sonic::vlan],recipe[sonic::vxlan],recipe[sonic::interface],recipe[sonic::evpn_nvo],recipe[sonic::loopback],recipe[sonic::router],recipe[sonic::bgprouter]'.format(
            role)
        chef_evpn_obj.update_node_run_list(chef_server.ssh_obj, node_name,
                                           run_list)
    run_chef_all_nodes()
    st.wait(data.wait)
    if not verify_vxlan_tunnel_status(data.d2, '3.3.3.2', ['4.4.4.2'],
                                      ['oper_up']):
        st.report_fail('test_case_failed')
    if not verify_vxlan_tunnel_status(data.d3, '4.4.4.2', ['3.3.3.2'],
                                      ['oper_up']):
        st.report_fail('test_case_failed')
    st.report_pass('test_case_passed')
Example #12
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)
Example #13
0
def test_ft_system_uptime():
    """
    Author: Sreenivasula Reddy V <*****@*****.**>
    Validate 'show uptime' command
    """
    vars = st.get_testbed_vars()
    st.log("About to get system uptime in seconds")
    intial_uptime=int(boxserv_obj.get_system_uptime_in_seconds(vars.D1))
    st.log("initial_uptime: {}".format(intial_uptime))
    st.log("About to wait for 1 min")
    st.wait(60)
    uptime_after_1min=intial_uptime+int(60)
    st.log("uptime_after_1min: {}".format(uptime_after_1min))
    st.log("About to check system uptime after 60 sec")
    sys_uptime=int(boxserv_obj.get_system_uptime_in_seconds(vars.D1))
    st.log("sys_uptime: {}".format(sys_uptime))
    st.log("About to validate system uptime which should be greater than or equal to system uptime after 1 min")
    st.log("uptime_after_1min+60: {}".format(uptime_after_1min+60))
    st.log("Verifying {}<={}<={}".format(uptime_after_1min, sys_uptime, uptime_after_1min + 60))
    if uptime_after_1min<=sys_uptime<=uptime_after_1min+60:
        st.log("System Uptime is getting updated with correct value")
    else:
        st.report_fail("sytem_uptime_fail",vars.D1)
    st.report_pass("test_case_passed")
Example #14
0
def test_ft_stp_loopguard_enable_both_interface():
    st.log("Verify the stp convergence")
    if not stp_wrap.poll_stp_convergence(
            vars, sc_data.vlan, iteration=20, delay=1):
        st.report_fail("stp_convergence_fail")
    st.log("Enable loop guard on interface")
    stp.config_stp_interface_params(vars.D1, vars.D1D2P2, loop_guard='enable')
    stp.config_stp_interface_params(vars.D1, vars.D1D2P1, loop_guard='enable')
    st.log("disable stp on an interface")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P2, mode="disable")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P1, mode="disable")
    st.wait(5)
    st.log("verify port moved to inconsistent state")
    if not stp.check_rg_current_state(vars.D1, sc_data.vlan, vars.D1D2P2):
        st.report_fail("port_inconsistent_state_fail")
    if not stp.check_rg_current_state(vars.D1, sc_data.vlan, vars.D1D2P1):
        st.report_fail("port_inconsistent_state_fail")
    st.log("enable stp on an interface")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P2, mode="enable")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P1, mode="enable")
    st.log("Unconfiguring the loop guard interface mode")
    stp.config_stp_interface_params(vars.D1, vars.D1D2P2, loop_guard='disable')
    stp.config_stp_interface_params(vars.D1, vars.D1D2P1, loop_guard='disable')
    st.report_pass("test_case_passed")
Example #15
0
def test_ft_stp_loopguard_pvst_mode():
    st.log("Disable rpvst and enable pvst")
    stp.config_stp_in_parallel(sc_data.dut_list,
                               feature="rpvst",
                               mode="disable",
                               vlan=None)
    stp.config_stp_in_parallel(sc_data.dut_list,
                               feature="pvst",
                               mode="enable",
                               vlan=None)
    st.wait(10)
    if not stp_wrap.poll_stp_convergence(
            vars, sc_data.vlan, iteration=40, delay=1):
        st.report_fail("stp_convergence_fail")
    st.log("Enable loop guard on device1")
    if stp.config_loopguard_global(vars.D1, mode='enable'):
        st.report_fail("loopguard_pvst_should_fail")
    st.log("Enable loop guard on interface")
    if stp.config_stp_interface_params(vars.D1,
                                       vars.D1D2P2,
                                       loop_guard='enable'):
        st.report_fail("loopguard_pvst_should_fail")
    st.log("revert back to previous config")
    stp.config_stp_in_parallel(sc_data.dut_list,
                               feature="pvst",
                               mode="disable",
                               vlan=None)
    stp.config_stp_in_parallel(sc_data.dut_list,
                               feature="rpvst",
                               mode="enable",
                               vlan=None)
    st.wait(10)
    if not stp_wrap.poll_stp_convergence(
            vars, sc_data.vlan, iteration=20, delay=1):
        st.report_fail("stp_convergence_fail")
    st.report_pass("test_case_passed")
Example #16
0
def test_ft_ssh_config_reload_docker():
    """
    Author : Prudvi Mangadu ([email protected])
    """
    result = True
    get_docker_ps(vars.D1)
    count = get_and_match_docker_count(vars.D1)
    ssh_d1 = connect_to_device(st.get_mgmt_ip(vars.D1), ssh_data.usr_default,
                               ssh_data.pwd_final)
    if ssh_d1:
        st.log(
            "Executing command - 'sudo config reload -y &' in to the SSH session."
        )
        st.log(execute_command(ssh_d1, 'sudo config reload -y &'))
        st.wait(5, 'After executing "config reload" cmd on SSH session.')
        st.log("Forcefully disconnecting the SSH session..")
        ssh_disconnect(ssh_d1)
    else:
        st.error('Cannot SSH into Device with default credentials')
        st.report_fail("ssh_failed")

    if not poll_wait(verify_docker_status, 180, vars.D1, 'Exited'):
        st.error(
            "Post 'config reload' from SSH, dockers are not auto recovered.")
        result = False

    if result:
        if not poll_wait(get_and_match_docker_count, 180, vars.D1, count):
            st.error("Post 'config reload' from SSH, ALL dockers are not UP.")
            result = False

    if not result:
        st.log("Test Failed: So recovering the device by reboot.")
        st.reboot(vars.D1)
        st.report_fail("test_case_failed")
    st.report_pass("test_case_passed")
Example #17
0
def verify_ntp_service_status(dut, status, iteration=1, delay=1):
    """
    Verify NTP service status with polling
    Author: Prudvi Mangadu ([email protected])

    :param dut:
    :param status:
    :param iteration: 1 sec (default)
    :param delay: 1 sec (default)
    :return:
    """
    command = "service ntp status | grep Active"
    i = 1
    while True:
        output = st.config(dut, command)
        if status in output:
            st.log("NTP service status is '{}' iteration".format(i))
            return True
        if i > iteration:
            st.log("NTP service status is not '{}'")
            st.log("Max iterations {} reached".format(i))
            return False
        i += 1
        st.wait(delay)
Example #18
0
def test_dhcp_relay_fast_reboot():
    #################################################
    #
    # Objective - Configure DHCP relay and verify if the configuration is retained after fast reboot.
    #
    #################################################
    st.log("Performing Config save")
    rb_obj.config_save(vars.D2)
    st.log("Performing fast Reboot")
    st.reboot(vars.D2, "fast")
    st.wait(5)
    st.log("Verifying DHCP Helper configuration post reboot")
    check_dhcp_relay_config()
    dhcp_relay_obj.dhcp_client_start(vars.D3, vars.D3D2P1)
    if not poll_wait(verify_dhcp_client, 60, vars.D3, vars.D3D2P1):
        dhcp_relay_debug(vars.D2, interface="Vlan{}".format(data.vlan))
        st.report_fail("dhcp_relay_functionality_tc_status", "IPv4", "failed",
                       "vlan")
    st.log("Verifying DHCP Relay statistics in dhcp client post fast reboot")
    check_dhcp_relay_statistics()
    st.log(
        "Successfully verified DHCP Helper configuration is retained post reboot"
    )
    st.report_pass("test_case_passed")
Example #19
0
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:
        ifapi.clear_interface_counters(vars.D1,interface_type="all")
        ifapi.show_interface_counters_all(vars.D1)
        st.log("Starting of traffic from TGen")
        tg.tg_traffic_control(action='run', stream_handle=tg_stream, duration=10)
        st.wait(sc_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(sc_data.wait_for_stats)
        ifapi.show_interface_counters_all(vars.D1)
        tg_1_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_1"], direction='tx')
        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(sc_data.higher_pkt_count ))
        st.log("Lower packet count value is : {}".format(sc_data.lower_pkt_count))
        if  counters_avg > sc_data.higher_pkt_count or counters_avg < sc_data.lower_pkt_count:
            st.report_fail("storm_control_traffic_verification_failed")
    return True
Example #20
0
def verify_cpu_queue_pkt_rate(dut, **kwargs):
    """
    Author: Gangadhara Sahu ([email protected])
    API to verify CPU queue packet rate for a particular CPU queue in pkts/sec
    :param dut:
    :param queue_id: <0-31>
    :param exp_rate:
    :param tolerance:
    :return:
    Example : verify_cpu_queue_pkt_rate(dut1,queue_id="0",exp_rate="1800",tolerance="100")
    """
    nooftimes = 3
    for itercountvar in range(nooftimes):
        if itercountvar != 0:
            st.wait(1)

        if "from_pkts_count" in kwargs and kwargs['from_pkts_count'] == "yes":
            out1 = get_cpu_queue_counters(dut,
                                          queue_id=kwargs['queue_id'],
                                          param="pkts_count")
            st.wait(10)
            out2 = get_cpu_queue_counters(dut,
                                          queue_id=kwargs['queue_id'],
                                          param="pkts_count")
            ob_value = (int(out2['pkts_count']) - int(out1['pkts_count'])) / 10
        elif "from_pkts_count" not in kwargs:
            st.wait(13)
            out1 = get_cpu_queue_counters(dut,
                                          queue_id=kwargs['queue_id'],
                                          param="pps")
            ob_value = int(out1['pps'])

        start_value = int(kwargs['exp_rate']) - int(kwargs['tolerance'])
        end_value = int(kwargs['exp_rate']) + int(kwargs['tolerance'])
        if ob_value >= start_value and ob_value <= end_value:
            st.log('obtained rate {} for queue: {} is in the range b/w '
                   '{} and {}'.format(ob_value, kwargs['queue_id'],
                                      start_value, end_value))
            return True
        else:
            st.error('obtained rate {} for queue: {} is NOT in the range b/w '
                     '{} and {}'.format(ob_value, kwargs['queue_id'],
                                        start_value, end_value))
            if itercountvar < (nooftimes - 1):
                st.log("Re-verifying again..")
                continue
            return False
Example #21
0
def debug_copp_config(dut):
    """
    Author: Gangadhara Sahu ([email protected])
    API to display the system internal details for CoPP config which can bed upon TC failure
    :param dut:
    :return: True
    Example :
    """
    st.log("----------------------------Debug show output 1-----------------------------")
    st.wait(2,"Waiting for debugsh to be ready")
    st.show(dut,'sudo debugsh $@ -c COPPMGRD -e show system internal coppmgr group',skip_tmpl=True)
    st.log("----------------------------Debug show output 2-----------------------------")
    st.wait(2,"Waiting for debugsh to be ready")
    st.show(dut, 'sudo debugsh $@ -c COPPMGRD -e show system internal coppmgr trap',skip_tmpl=True)
    st.log("----------------------------Debug show output 3-----------------------------")
    st.wait(1,"Waiting for debugsh to be ready")
    st.show(dut, "sudo sonic-db-dump -n 'APPL_DB' -k \"COPP_TABLE:*\" -y | grep -v hash",skip_tmpl=True)
    st.log("----------------------------Debug show end here-----------------------------")

    return True
Example #22
0
def test_ft_stp_loopguard_config_reload():
    st.log("Verify the stp convergence")
    if not stp_wrap.poll_stp_convergence(
            vars, sc_data.vlan, iteration=20, delay=1):
        st.report_fail("stp_convergence_fail")
    st.log("Enable loop guard on device1")
    if not stp.config_loopguard_global(vars.D1, mode='enable'):
        st.report_fail("STP_loop_guard_config_fail")
    st.log("disable stp on an interface")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P2, mode="disable")
    st.wait(5)
    st.log("verify port moved to inconsistent state")
    if not stp.check_rg_current_state(vars.D1, sc_data.vlan, vars.D1D2P2):
        st.report_fail("port_inconsistent_state_fail")
    st.log("enable stp on an interface")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P2, mode="enable")
    reboot_obj.config_save(vars.D1)
    st.reboot(vars.D1)
    st.log("disable stp on an interface")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P2, mode="disable")
    st.wait(5)
    st.log("verify port moved to inconsistent state")
    if not stp.check_rg_current_state(vars.D1, sc_data.vlan, vars.D1D2P2):
        st.report_fail("port_inconsistent_state_fail")
    st.log("enable stp on an interface")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P2, mode="enable")
    st.wait(5)
    if not stp.verify_stp_intf_status(vars.D1,
                                      interface=vars.D1D2P2,
                                      status="DISCARDING",
                                      vlanid=sc_data.vlan):
        st.report_fail("port_discarding_fail")
    st.log("Unconfiguring the loop guard global mode")
    if not stp.config_loopguard_global(vars.D1, mode='disable'):
        st.report_fail("STP_loop_guard_config_fail")
    st.report_pass("test_case_passed")
def test_scale_ip_unnumbered():

    ##########################################################################################################################################

    result = 0
    st.banner('FtOpSoRoIPunScl001 - Verify maximum IPv4 unnumbered interfaces')
    st.log(
        'Configure IP unnumbered on Physical interfaces between DUT1 and DUT3')
    for d1port, d2port in zip(data.d1_d2_ports, data.d2_d1_ports):
        dict1 = {
            'family': 'ipv4',
            'action': 'add',
            'interface': d1port,
            'loop_back': dut1_loopback[0]
        }
        dict2 = {
            'family': 'ipv4',
            'action': 'add',
            'interface': d2port,
            'loop_back': dut2_loopback[0]
        }
        parallel.exec_parallel(True, [data.dut1, data.dut2],
                               ip_obj.config_unnumbered_interface,
                               [dict1, dict2])
    st.log(
        'Configure IP unnumbered on Physical interfaces between DUT2 and DUT3')
    for d2port, d3port in zip(data.d2_d3_ports, data.d3_d2_ports):
        dict2 = {
            'family': 'ipv4',
            'action': 'add',
            'interface': d2port,
            'loop_back': dut2_loopback[0]
        }
        dict3 = {
            'family': 'ipv4',
            'action': 'add',
            'interface': d3port,
            'loop_back': dut3_loopback[0]
        }
        parallel.exec_parallel(True, [data.dut2, data.dut3],
                               ip_obj.config_unnumbered_interface,
                               [dict2, dict3])
    if not ip_obj.verify_interface_ip_address(
            data.dut2, data.d2_d3_ports[0],
            dut2_loopback_ip[0] + '/' + ip_loopback_prefix, 'ipv4', '', 'U'):
        st.error(
            'IP Unnumbered configuration on DUT2-Physical Interface failed')
        result += 1
    if not loc_lib.retry_api(ip_obj.ping,
                             data.dut1,
                             addresses=dut3_loopback_ip[0],
                             retry_count=5,
                             delay=10):
        st.error('IPv4 Ping from DUT1 to DUT3 failed')
        result += 1
    if not arp_obj.verify_arp(dut=data.dut2, ipaddress=dut3_loopback_ip[0]):
        st.error(
            "Failed to resolve ARP for link local address over physical interface"
        )
        result += 1
    aggrResult = loc_lib.send_verify_traffic(type='ipv4')
    if not aggrResult:
        st.error('IPv4 traffic with IPv4 unnumbered failed')
        result += 1
    port_obj.shutdown(data.dut2, [
        data.d2_d1_ports[0], data.d2_d1_ports[1], data.d2_d1_ports[2],
        data.d2_d1_ports[3], data.d2_d3_ports[0], data.d2_d3_ports[1],
        data.d2_d3_ports[2], data.d2_d3_ports[3]
    ])
    st.log('Wait for OSFP to go down')
    st.wait(10)
    port_obj.noshutdown(data.dut2, [
        data.d2_d1_ports[0], data.d2_d1_ports[1], data.d2_d1_ports[2],
        data.d2_d1_ports[3], data.d2_d3_ports[0], data.d2_d3_ports[1],
        data.d2_d3_ports[2], data.d2_d3_ports[3]
    ])
    st.log('Wait for OSFP to come up')
    st.wait(10)
    if not loc_lib.retry_api(ip_obj.ping,
                             data.dut1,
                             addresses=dut3_loopback_ip[0],
                             retry_count=5,
                             delay=10):
        st.error('IPv4 Ping from DUT1 to DUT2 failed')
        result += 1
    aggrResult = loc_lib.send_verify_traffic(type='ipv4')
    if not aggrResult:
        st.error('IPv4 traffic with IPv4 unnumbered failed')
        result += 1
    if result == 0:
        st.report_tc_pass('FtOpSoRoIPunScl001', 'test_case_passed')
    else:
        st.report_tc_fail('FtOpSoRoIPunScl001', 'test_case_failed')
    if result == 0:
        st.report_pass('test_case_passed')
    else:
        st.report_fail('test_case_failed')
Example #24
0
def test_ft_ssh_add_user_verify():
    """
    Author : Prudvi Mangadu ([email protected])
    """
    user_ssh = 0
    acl_sshv4 = 0
    acl_sshv6 = 0
    acl_snmp = 0

    if not snmp_config(config='add'): acl_snmp = +1

    ipaddress = st.get_mgmt_ip(vars.D1)
    if not ipaddress:
        st.report_env_fail("ip_verification_fail")

    snmp_cmd = "snmpget -Oqv -v 2c -c {} {} {}".format(ssh_data.ro_community,
                                                       ipaddress,
                                                       ssh_data.oid_sysName)

    out = config_nondefault_user()
    if not out: user_ssh = +1

    st.log("connecting to device with username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    if not st.exec_ssh(vars.D1, ssh_data.usr_default, ssh_data.pwd_final,
                       ssh_data.commands_to_verify):
        st.error('Cannot SSH into Device with default credentials')
        user_ssh = +1

    st.log('connecting to device with username={},password={}'.format(
        ssh_data.usr_non_default, ssh_data.pwd_non_default))
    if not st.exec_ssh(vars.D1, ssh_data.usr_non_default,
                       ssh_data.pwd_non_default, ssh_data.commands_to_verify):
        st.error('Cannot SSH into Device with non-default credentials')
        user_ssh = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output:
        user_ssh = +1

    IPAddr = ensure_service_params(vars.D1, "snmptrap", "ip") + "/32"
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_1",
                     "SRC_IP", IPAddr)
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_2",
                     "SRC_IP", IPAddr)
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_3",
                     "SRC_IP", ssh_data.ipv4_network)
    change_acl_rules(acl_data.acl_json_config_control_plane,
                     "V6_SSH_ONLY|RULE_1", "SRC_IPV6",
                     ssh_data.ipv6_network_D1)
    acl_config = acl_data.acl_json_config_control_plane
    st.log("ACL_DATA: {}".format(acl_config))
    acl_obj.apply_acl_config(vars.D1, acl_config)
    acl_obj.show_acl_table(vars.D1)
    acl_obj.show_acl_rule(vars.D1)

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_1"):
        st.error("Failed to create ACL rule '{}' ".format("SNMP_SSH"))
        acl_snmp = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_2"):
        st.error("Failed to create ACL rule '{}' ".format("SNMP_SSH"))
        acl_sshv4 = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "V6_SSH_ONLY",
                     "RULE_1"):
        st.error("Failed to create ACL rule '{}' ".format("V6_SSH_ONLY"))
        acl_sshv6 = +1

    hostname = get_hostname(vars.D1)
    st.log("HOSTNAME: {}".format(hostname))
    snmp_out = execute_command(ssh_conn_obj, snmp_cmd)
    if hostname not in snmp_out:
        st.error("SNMP walk operation is failed")
        acl_snmp = +1

    st.log("connecting to device with default username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv6 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv6 = +1

    st.log(
        "connecting to device with non default username={},password={}".format(
            ssh_data.usr_non_default, ssh_data.pwd_non_default))
    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P1,
                                   ssh_data.usr_non_default,
                                   ssh_data.pwd_non_default)
    if not output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P1,
                                   ssh_data.usr_non_default,
                                   ssh_data.pwd_non_default)
    if not output: acl_sshv6 = +1

    config_save(vars.D1)
    st.log('rebooting the device.')
    st.reboot(vars.D1, 'fast')

    acl_obj.show_acl_table(vars.D1)
    acl_obj.show_acl_rule(vars.D1)

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_2"):
        st.log("Failed to create ACL rule '{}' ".format("SSH_SSH"))
        acl_sshv4 = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "V6_SSH_ONLY",
                     "RULE_1"):
        st.log("Failed to create ACL rule '{}' ".format("V6_SSH_ONLY"))
        acl_sshv4 = +1

    if not poll_wait(acl_obj.verify_acl_table_rule, 5, vars.D1, "SNMP_SSH",
                     "RULE_1"):
        st.error("Failed to create ACL rule '{}' ".format("SNMP_SSH"))
        acl_snmp = +1

    ipaddress = st.get_mgmt_ip(vars.D1)
    if not ipaddress or not ip_obj.ping(vars.D1, IPAddr.strip('/32')):
        st.error(
            "Ping to SNMP server or getting ip address to the dut is failed after reload"
        )
        acl_obj.acl_delete(vars.D1)
        config_nondefault_user(config='remove')
        st.report_fail("ip_verification_fail")

    snmp_cmd = "snmpget -Oqv -v 2c -c {} {} {}".format(ssh_data.ro_community,
                                                       ipaddress,
                                                       ssh_data.oid_sysName)

    hostname = get_hostname(vars.D1)
    snmp_out = execute_command(ssh_conn_obj, snmp_cmd)
    if hostname not in snmp_out:
        st.error("SNMP walk operation is failed after reload")
        acl_snmp = +1

    st.log('Verifying SNMP ACL with invalid source address')
    change_acl_rules(acl_data.acl_json_config_control_plane, "SNMP_SSH|RULE_1",
                     "SRC_IP", "2.2.2.0/24")
    acl_config = acl_data.acl_json_config_control_plane
    acl_obj.acl_delete(vars.D1)
    acl_obj.apply_acl_config(vars.D1, acl_config)
    st.wait(3, "Waiting to apply acl rules")
    snmp_out = execute_command(ssh_conn_obj, snmp_cmd)
    if "Timeout" not in snmp_out: acl_snmp = +1

    st.log("connecting to device with default username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P2,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if output: acl_sshv6 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv4_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv4 = +1

    output = verify_ssh_connection(vars.D2, ssh_data.ipv6_address_D1D2P1,
                                   ssh_data.usr_default, ssh_data.pwd_final)
    if not output: acl_sshv6 = +1

    if acl_sshv4:
        st.report_tc_fail("test_ft_controlplane_acl_service_sshv4",
                          "ssh_failed",
                          "with control plane ACL service SSHv4 after reboot")
    else:
        st.report_tc_pass("test_ft_controlplane_acl_service_sshv4",
                          "ssh_failed",
                          "with control plane ACL service SSHv4 after reboot")

    if acl_sshv6:
        st.report_tc_fail("test_ft_controlplane_acl_service_sshv6",
                          "ssh_failed",
                          "with control plane ACL service SSHv6 after reboot")
    else:
        st.report_tc_pass("test_ft_controlplane_acl_service_sshv6",
                          "ssh_failed",
                          "with control plane ACL service SSHv6 after reboot")

    if acl_snmp:
        st.report_tc_fail("test_ft_controlplane_acl_service_snmp",
                          "snmp_output_failed",
                          "with control plane ACL service SNMP after reboot")
    else:
        st.report_tc_pass("test_ft_controlplane_acl_service_snmp",
                          "snmp_output_failed",
                          "with control plane ACL service SNMP after reboot")

    acl_obj.acl_delete(vars.D1)

    if acl_sshv4 or acl_sshv6 or acl_snmp:
        st.generate_tech_support(vars.D1,
                                 "controlplane_acl_services_after_reboot")

    st.log('Verifying SSH connection after removing control plane ACLs')
    st.log("connecting to device with username={},password={}".format(
        ssh_data.usr_default, ssh_data.pwd_final))
    if not st.exec_ssh(vars.D1, ssh_data.usr_default, ssh_data.pwd_final,
                       ssh_data.commands_to_verify):
        st.error(
            'Cannot SSH into Device with default credentials after reboot')
        user_ssh = +1

    st.log('connecting to device with username={},password={}'.format(
        ssh_data.usr_non_default, ssh_data.pwd_non_default))
    if not st.exec_ssh(vars.D1, ssh_data.usr_non_default,
                       ssh_data.pwd_non_default, ssh_data.commands_to_verify):
        st.error(
            'Cannot SSH into Device with non-default credentials after reboot')
        user_ssh = +1

    config_nondefault_user(config='remove')

    if (user_ssh or acl_snmp or acl_sshv4 or acl_sshv6):
        st.report_fail("test_case_failed")
    st.report_pass("test_case_passed")
Example #25
0
def test_system_up_performance():
    timer_dict = {}
    test_port = vars.D1D2P1
    max_port_up_time = 20
    if not intapi.verify_interface_status(vars.D1, test_port, 'oper', 'up'):
        st.error('{} interface is down on dut'.format(test_port))
        st.report_fail('test_case_failed')

    st.banner("START - REBOOT TEST ")
    tstart = datetime.now()
    st.reboot(vars.D1)
    bcapi.get_system_status(vars.D1)
    tdiff = datetime.now() - tstart
    timer_dict['REBOOT_TEST'] = "{} {}".format(tdiff, 'H:M:S:msec')
    st.banner("END - REBOOT TEST -- {}".format(timer_dict['REBOOT_TEST']))

    st.banner("START - CONFIG REBOOT TEST ")
    tstart = datetime.now()
    config_reload(vars.D1)
    bcapi.get_system_status(vars.D1)
    tdiff = datetime.now() - tstart
    timer_dict['CONFIG_REBOOT_TEST'] = "{} {}".format(tdiff, 'H:M:S:msec')
    st.banner("END - CONFIG REBOOT TEST -- {}".format(
        timer_dict['CONFIG_REBOOT_TEST']))

    st.banner("START - PORT UP TEST ")
    logapi.clear_logging(vars.D1)
    intapi.interface_shutdown(vars.D1, test_port)
    intapi.verify_interface_status(vars.D1, test_port, 'oper', 'down')
    st.wait(5)
    intapi.interface_noshutdown(vars.D1, test_port)
    if not intapi.poll_for_interface_status(
            vars.D1, test_port, 'oper', 'up', iteration=max_port_up_time,
            delay=1):
        st.error('{} interface is down on dut for MAX time = {}'.format(
            test_port, max_port_up_time))
    log_down = logapi.show_logging(
        vars.D1,
        filter_list=['sudo config interface startup {}'.format(test_port)])
    log_up = logapi.show_logging(
        vars.D1,
        filter_list=[
            'Set operation status UP to host interface {}'.format(test_port)
        ])
    logapi.show_logging(vars.D1)
    log_down_time = utils.log_parser(log_down[0])[0]
    log_up_time = utils.log_parser(log_up[0])[0]
    f_down_time = utils.convert_time_to_milli_seconds(
        days=0,
        hours=log_down_time['hours'],
        minutes=log_down_time['minutes'],
        seconds=log_down_time['seconds'],
        milli_second=log_down_time['micro_second'])

    f_up_time = utils.convert_time_to_milli_seconds(
        days=0,
        hours=log_up_time['hours'],
        minutes=log_up_time['minutes'],
        seconds=log_up_time['seconds'],
        milli_second=log_up_time['micro_second'])

    st.log("f_down_time : {} , f_up_time : {}".format(f_down_time, f_up_time))
    timer_dict['PORT_UP_TEST'] = "{} {}".format(
        (f_up_time - f_down_time) / 1000, 'mili sec')
    st.banner("END - PORT UP TEST -- {}".format(timer_dict['PORT_UP_TEST']))

    st.log("\n" + pprint.pformat(timer_dict, width=2) + '\n')
    st.log('\n' +
           cutils.sprint_vtable(['Test Name', 'Time'], timer_dict.items()) +
           '\n')
    csv_str = '\nTest, Result\n'
    for i, j in timer_dict.items():
        csv_str += "{}, {}\n".format(i, j)
    st.log(csv_str)
    st.report_pass('test_case_passed')
Example #26
0
def test_l3_host_scaling_tc5_4():
    pre_test_l3_fwding()
    vars = st.get_testbed_vars()
    data.my_dut_list = st.get_dut_names()

    dut1 = vars.D1
    ipfeature.get_interface_ip_address(dut1, family="ipv4")
    ipfeature.get_interface_ip_address(dut1, family="ipv6")
    ipfeature.show_ip_route(dut1)
    ifapi.interface_status_show(dut1)

    # L3 traffic streams
    (tg1, tg2, tg_ph_1, tg_ph_2) = get_handles()

    tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1)
    tr1 = create_l3_host(tg1, tg_ph_1, data.max_host_1, 20)
    st.wait(15)

    # Verified ARP and counters at the DUT.
    total = arpfeature.get_arp_count(dut1)
    st.log("Total ARP entries: {}".format(total))
    tg1.tg_traffic_control(action='stop', handle=tr1['stream_id'])
    tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1)

    tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1)
    tg2.tg_traffic_control(action='reset', port_handle=tg_ph_2)

    res = tg1.tg_interface_config(port_handle=tg_ph_1,
                                  mode='config',
                                  intf_ip_addr=data.t1d1_ip_addr,
                                  gateway=data.d1t1_ip_addr,
                                  src_mac_addr='00:0a:01:00:11:01',
                                  arp_send_req='1')
    st.log("INTFCONF: " + str(res))
    handle1 = res['handle']
    #tg1.tg_test_control(action='sync')

    res = tg2.tg_interface_config(port_handle=tg_ph_2,
                                  mode='config',
                                  intf_ip_addr=data.t1d2_ip_addr,
                                  gateway=data.d1t2_ip_addr,
                                  src_mac_addr='00:0a:01:00:12:01',
                                  arp_send_req='1')
    st.log("INTFCONF: " + str(res))
    handle2 = res['handle']
    #tg2.tg_test_control(action='sync')

    tr1 = tg1.tg_traffic_config(port_handle=tg_ph_1,
                                mode='create',
                                transmit_mode='continuous',
                                length_mode='fixed',
                                l3_length=data.tgen_l3_len,
                                rate_pps=data.tgen_rate_pps,
                                emulation_src_handle=handle1,
                                emulation_dst_handle=handle2)
    tr2 = tg2.tg_traffic_config(port_handle=tg_ph_2,
                                mode='create',
                                transmit_mode='continuous',
                                length_mode='fixed',
                                l3_length=data.tgen_l3_len,
                                rate_pps=data.tgen_rate_pps,
                                emulation_src_handle=handle2,
                                emulation_dst_handle=handle1)

    tg1.tg_packet_control(port_handle=tg_ph_1, action='start')
    tg2.tg_packet_control(port_handle=tg_ph_2, action='start')

    tg1.tg_traffic_control(action='clear_stats', handle=tr1['stream_id'])
    tg2.tg_traffic_control(action='clear_stats', handle=tr2['stream_id'])
    papi.clear_interface_counters(dut1)
    tg1.tg_traffic_control(action='run', handle=tr1['stream_id'], duration=2)
    tg2.tg_traffic_control(action='run', handle=tr2['stream_id'], duration=2)
    st.wait(data.traffic_run_time)
    tg1.tg_traffic_control(action='stop', handle=tr1['stream_id'])
    tg2.tg_traffic_control(action='stop', handle=tr2['stream_id'])

    st.wait(5)
    tg1.tg_packet_control(port_handle=tg_ph_1, action='stop')
    tg2.tg_packet_control(port_handle=tg_ph_2, action='stop')

    stats_tg1 = tg1.tg_traffic_stats(port_handle=tg_ph_1, mode='aggregate')
    total_tg1_tx = stats_tg1[tg_ph_1]['aggregate']['tx']['total_pkts']
    total_tg1_rx = stats_tg1[tg_ph_1]['aggregate']['rx']['total_pkts']

    stats_tg2 = tg2.tg_traffic_stats(port_handle=tg_ph_2, mode='aggregate')
    total_tg2_tx = stats_tg2[tg_ph_2]['aggregate']['tx']['total_pkts']
    total_tg2_rx = stats_tg2[tg_ph_2]['aggregate']['rx']['total_pkts']

    st.log(
        "Tgen Sent Packets on D1T1P1: {} and Received Packets on D2T1P1: {}".
        format(total_tg1_tx, total_tg2_rx))
    st.log(
        "Tgen Sent Packets on D2T1P1: {} and Received Packets on D1T1P1: {}".
        format(total_tg2_tx, total_tg1_rx))

    flap_interface(vars.D1T1P1)
    flap_interface(vars.D1T1P2)

    #Getting interfaces counter values on DUT
    DUT_rx_value = ifapi.get_interface_counters(dut1, vars.D1T1P1, "rx_ok")
    DUT_tx_value = ifapi.get_interface_counters(dut1, vars.D1T1P2, "tx_ok")

    for i in DUT_rx_value:
        p1_rcvd = i['rx_ok']
        p1_rcvd = p1_rcvd.replace(",", "")

    for i in DUT_tx_value:
        p2_txmt = i['tx_ok']
        p2_txmt = p2_txmt.replace(",", "")

    st.log(
        "rx_ok counter value on DUT Ingress port: {} and tx_ok xounter value on DUT Egress port : {}"
        .format(p1_rcvd, p2_txmt))

    post_test_l3_fwding()
    if (total >= data.max_host_1):
        st.report_pass("test_case_passed")
    else:
        st.report_fail("test_case_failed")
Example #27
0
def test_l3_host_scaling_tc5_3():
    pre_test_l3_fwding()

    vars = st.get_testbed_vars()
    # Config 2 IPV4 interfaces on DUT.
    (tg1, tg2, tg_ph_1, tg_ph_2) = get_handles()
    dut1 = vars.D1
    ipfeature.get_interface_ip_address(dut1, family="ipv4")
    ipfeature.get_interface_ip_address(dut1, family="ipv6")
    ipfeature.show_ip_route(dut1)
    ifapi.interface_status_show(dut1)

    tr1 = create_l3_host(tg1, tg_ph_1, data.max_host_1, 20)
    st.wait(15)

    # Verified ARP and counters at the DUT.
    total = arpfeature.get_arp_count(dut1)
    st.log("Total ARP entries: {}".format(total))
    tg1.tg_traffic_control(action='stop', handle=tr1['stream_id'])
    tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1)

    tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1)
    tg2.tg_traffic_control(action='reset', port_handle=tg_ph_2)

    res = tg1.tg_interface_config(port_handle=tg_ph_1,
                                  mode='config',
                                  intf_ip_addr=data.t1d1_ip_addr,
                                  gateway=data.d1t1_ip_addr,
                                  src_mac_addr='00:0a:01:00:11:01',
                                  arp_send_req='1')
    st.log("INTFCONF: " + str(res))
    handle1 = res['handle']
    #tg1.tg_test_control(action='sync')

    res = tg2.tg_interface_config(port_handle=tg_ph_2,
                                  mode='config',
                                  intf_ip_addr=data.t1d2_ip_addr,
                                  gateway=data.d1t2_ip_addr,
                                  src_mac_addr='00:0a:01:00:12:01',
                                  arp_send_req='1')
    st.log("INTFCONF: " + str(res))
    handle2 = res['handle']
    #tg2.tg_test_control(action='sync')

    tr1 = tg1.tg_traffic_config(port_handle=tg_ph_1,
                                mode='create',
                                transmit_mode='continuous',
                                length_mode='fixed',
                                l3_length=data.tgen_l3_len,
                                rate_pps=data.tgen_rate_pps,
                                emulation_src_handle=handle1,
                                emulation_dst_handle=handle2)
    tr2 = tg2.tg_traffic_config(port_handle=tg_ph_2,
                                mode='create',
                                transmit_mode='continuous',
                                length_mode='fixed',
                                l3_length=data.tgen_l3_len,
                                rate_pps=data.tgen_rate_pps,
                                emulation_src_handle=handle2,
                                emulation_dst_handle=handle1)

    tg1.tg_packet_control(port_handle=tg_ph_1, action='start')
    tg2.tg_packet_control(port_handle=tg_ph_2, action='start')

    tg1.tg_traffic_control(action='clear_stats', handle=tr1['stream_id'])
    tg2.tg_traffic_control(action='clear_stats', handle=tr2['stream_id'])
    papi.clear_interface_counters(dut1)
    tg1.tg_traffic_control(action='run', handle=tr1['stream_id'], duration=2)
    tg2.tg_traffic_control(action='run', handle=tr2['stream_id'], duration=2)
    st.wait(data.traffic_run_time)
    tg1.tg_traffic_control(action='stop', handle=tr1['stream_id'])
    tg2.tg_traffic_control(action='stop', handle=tr2['stream_id'])

    tg1.tg_packet_control(port_handle=tg_ph_1, action='stop')
    tg2.tg_packet_control(port_handle=tg_ph_2, action='stop')

    papi.clear_interface_counters(dut1)
    tg2.tg_traffic_control(action='run', handle=tr1['stream_id'])
    st.wait(20)
    retval = check_intf_traffic_counters(dut1)

    post_test_l3_fwding()
    if (total >= data.max_host_1 and retval):
        st.report_pass("test_case_passed")
    else:
        st.report_fail("test_case_failed")
Example #28
0
def config_dhcpv6_options(ssh_conn_obj, ztp_params, config_params, options=dict(), cli_type=""):
    """
    Common function to configure dhcpv6 options and verify the result on both inband and out of band interfaces
    :param ssh_conn_obj:
    :param ztp_params:
    :param config_params:
    :param options:
    :return:
    """
    cli_type = st.get_ui_type(config_params.dut, cli_type=cli_type)
    retry_count = config_params.retry_count if "retry_count" in config_params and config_params.retry_count else 0
    iteration = config_params.iteration if "iteration" in config_params and config_params.iteration else 300
    delay = config_params.delay if "delay" in config_params and config_params.delay else 3
    expect_reboot = True if "expect_reboot" in options and options ["expect_reboot"] else False
    st.log(config_params)
    if "func_name" in config_params:
        syslog_file_names = ["syslog_1_{}".format(config_params.func_name), "syslog_{}".format(config_params.func_name)]
    if "json_content" in config_params:
        file_path = basic_obj.write_to_json_file(config_params.json_content)
        st.log(file_path)
        if file_path:
            destination_path = "{}{}/{}".format(config_params.home_path, ztp_params.config_path, config_params.ztp_file)
            st.log(destination_path)
            basic_obj.copy_file_from_client_to_server(ssh_conn_obj, src_path=file_path, dst_path=destination_path)
    config_params.option_59_url = "http://[{}]{}/{}".format(config_params.static_ip, ztp_params.config_path, config_params.ztp_file)
    config_params.search_pattern = r'\s*option\s+dhcp6.boot-file-url\s+"\S+";'
    write_option_59_to_dhcp_server(ssh_conn_obj, config_params)
    basic_obj.service_operations(ssh_conn_obj, config_params.dhcp6_service_name, "restart", "server")
    if not verify_dhcpd_service_status(ssh_conn_obj, config_params.dhcpd6_pid):
        st.log("{} service is running which is not expected".format(config_params.dhcp6_service_name))
        st.report_fail("service_running_not_expected", config_params.dhcp6_service_name)
    reboot_type = config_params.reboot_type if "reboot_type" in config_params and config_params.reboot_type else "normal"
    if "ztp_operation" in config_params:
        config_params.ztp_operation = "reboot" if cli_type == "klish" else config_params.ztp_operation
        if config_params.ztp_operation == "reboot":
            basic_obj.remove_file(config_params.dut, config_params.config_db_path)
            st.reboot(config_params.dut, reboot_type, skip_port_wait=True)
        elif config_params.ztp_operation == "run":
            ztp_operations(config_params.dut, config_params.ztp_operation)
    else:
        st.log("ZTP operation is not mentioned hence rebooting the device ...")
        basic_obj.remove_file(config_params.dut, config_params.config_db_path)
        st.reboot(config_params.dut, reboot_type, skip_port_wait=True)
    if "reboot_on_success" in options and options["reboot_on_success"]:
        result = verify_ztp_status(config_params.dut, retry_count, iteration, delay, expect_reboot=expect_reboot, reboot_on_success=options["reboot_on_success"], cli_type=cli_type)
    else:
        result = verify_ztp_status(config_params.dut, retry_count, iteration, delay, expect_reboot=expect_reboot, cli_type=cli_type)
    if not result:
        if "logs_path" in config_params and "func_name" in config_params:
            capture_syslogs(config_params.dut, config_params.logs_path, syslog_file_names)
        st.log("ZTP status verification failed")
        st.report_fail("ztp_status_verification_failed")
    if "reboot_on_success" in options and options["reboot_on_success"]:
        reboot_obj.config_reload(config_params.dut)
        st.wait(5)
        if not ip_obj.ping(config_params.dut, config_params.static_ip, family="ipv6"):
            st.log("Pinging to DHCP server failed from DUT, issue either with DUT or server")
            # intf_obj.enable_dhcp_on_interface(config_params.dut, config_params.network_port, "v6")
        if not verify_ztp_status(config_params.dut, retry_count, iteration, delay, cli_type=cli_type):
            if "logs_path" in config_params and "func_name" in config_params:
                capture_syslogs(config_params.dut, config_params.logs_path, syslog_file_names)
            st.log("ZTP status verification failed")
            st.report_fail("ztp_status_verification_failed")
    verify_ztp_filename_logs(config_params.dut, config_params)
    if "ztp_log_string" in config_params and config_params.ztp_log_string:
        if not basic_obj.poll_for_error_logs(config_params.dut, config_params.ztp_log_path, config_params.ztp_log_string):
            st.log("ZTP log {} verification failed for message {}".format(config_params.ztp_log_path, config_params.ztp_log_string))
            if not basic_obj.poll_for_error_logs(config_params.dut, config_params.ztp_log_path_1, config_params.ztp_log_string):
                st.log("ZTP log {} verification failed for message {}".format(config_params.ztp_log_path_1, config_params.ztp_log_string))
                st.report_fail("ztp_log_verification_failed", config_params.ztp_log_path_1, config_params.ztp_log_string)
    if "result" in config_params and config_params.result == "pass":
        st.report_pass("test_case_passed")
Example #29
0
def config_and_verify_dhcp_option(ssh_conn_obj, dut, ztp_params, data, expect_reboot=False, reboot_on_success=list(), cli_type=""):
    """
    Common function to configure DHCP option along with status / logs verification
    Author: Chaitanya Vella ([email protected])
    :param ssh_conn_obj:
    :param dut:
    :param ztp_params:
    :param data:
    :return:
    """
    cli_type = st.get_ui_type(dut,cli_type=cli_type)
    cli_type = "klish" if cli_type in ["rest-put", "rest-patch"] else cli_type
    retry_count = data.retry_count if "retry_count" in data and data.retry_count else 0
    iteration = data.iteration if "iteration" in data and data.iteration else 300
    delay = data.delay if "delay" in data and data.delay else 3
    if "func_name" in data:
        syslog_file_names = ["syslog_1_{}".format(data.func_name), "syslog_{}".format(data.func_name)]
    # basic_obj.copy_config_db_to_temp(dut, data.config_db_path, data.config_db_temp)
    if "config_file_type" in data and data.config_file_type == "text":
        file_path = "/tmp/file_temp.json"
        basic_obj.write_to_file(ssh_conn_obj, data.json_content, file_path, device="server")
    elif "config_file_type" in data and data.config_file_type == "EoL":
        file_path = ""
    else:
        file_path = basic_obj.write_to_json_file(data.json_content)
    if file_path:
        destination_path = "{}{}/{}".format(ztp_params.home_path, ztp_params.config_path, data.config_file)
        basic_obj.copy_file_from_client_to_server(ssh_conn_obj, src_path=file_path, dst_path=destination_path)
    if "config_db_location" in data and data.config_db_location == "json":
        st.download_file_from_dut(dut, data.config_db_temp, file_path)
        destination_path = "{}{}/{}".format(ztp_params.home_path, ztp_params.config_path, data.config_db_file_name)
        basic_obj.copy_file_from_client_to_server(ssh_conn_obj, src_path=file_path, dst_path=destination_path)
    if "scenario" in data and data.scenario == "invalid-json":
        st.log("Writing invalid content to make invalid json ...")
        basic_obj.write_to_file_to_line(ssh_conn_obj, ",", 5, destination_path, "server")
    if data.option_type == "67":
        st.log("Creating {} file on DHCP server ...".format(data.config_file))
        data.search_pattern = r'\s*option\s+bootfile-name\s*\S*\s*"\S+";'
        data.option_string = "option bootfile-name"
        if data.type == "http":
            data.option_url = "http://{}{}/{}".format(data.static_ip, data.config_path, data.config_file)
        elif data.type == "tftp":
            data.option_url = "tftp://{}/{}/{}".format(data.static_ip, data.config_path, data.config_file)
        elif data.type == "ftp":
            data.option_url = "ftp://{}/{}/{}".format(data.static_ip, data.config_path, data.config_file)
        write_option_to_dhcp_server(ssh_conn_obj, data)
        basic_obj.service_operations(ssh_conn_obj, data.dhcp_service_name, data.action, data.device)
        if not verify_dhcpd_service_status(ssh_conn_obj, data.dhcpd_pid):
            st.log("{} service not running".format(data.dhcp_service_name))
            st.report_fail("service_not_running", data.dhcp_service_name)
        # write_option_67_to_dhcp_server(ssh_conn_obj, data)
    data.device_action = "reboot" if cli_type == "klish" else data.device_action
    if data.device_action == "reboot":
        reboot_type = data.reboot_type if "reboot_type" in data and data.reboot_type else "normal"
        basic_obj.remove_file(dut, data.config_db_path)
        st.reboot(dut, reboot_type, skip_port_wait=True)
        st.wait_system_status(dut, 500)
    elif data.device_action == "run":
        ztp_operations(dut, data.device_action)
    if "band_type" in data and data.band_type=="inband":
        if not basic_obj.poll_for_system_status(dut):
            st.log("Sytem is not ready ..")
            st.report_env_fail("system_not_ready")
        if not basic_obj.check_interface_status(dut, ztp_params.oob_port,"up"):
            basic_obj.ifconfig_operation(dut, ztp_params.oob_port, "down")
        interface_status = basic_obj.check_interface_status(dut, ztp_params.inband_port, "up")
        if interface_status is not None:
            if not interface_status:
                intf_obj.interface_noshutdown(dut, ztp_params.inband_port, cli_type=cli_type)
    if "service" in data and data.service == "disable":
        basic_obj.service_operations_by_systemctl(dut, "ztp", "stop")
        if basic_obj.verify_service_status(dut, "ztp"):
            st.log("ZTP status is not stopped")
            st.report_fail("service_not_stopped", "ztp")
        basic_obj.service_operations_by_systemctl(dut, "ztp", "start")
    if not poll_ztp_status(dut, ["IN-PROGRESS", "Not Started", "SUCCESS"], cli_type=cli_type):
        st.report_fail("ztp_max_polling_interval")
    if "check" in data and data.check == "not":
        if verify_ztp_status(dut, retry_count, iteration, delay, cli_type=cli_type):
            if "logs_path" in data and "func_name" in data:
                capture_syslogs(dut, data.logs_path, syslog_file_names)
            st.log("ZTP status verification failed")
            st.report_fail("ztp_status_verification_failed")
    else:
        st.log("Iteration count {}".format(iteration))
        st.log("REBOOT ON SUCCESS - {}".format(reboot_on_success))
        if reboot_on_success:
            if "configdb-json" in reboot_on_success:
                st.wait_system_reboot(dut)
                st.wait_system_status(dut, 300)
            result = verify_ztp_status(dut, retry_count, iteration, delay, expect_reboot=expect_reboot, reboot_on_success=reboot_on_success, cli_type=cli_type)
        else:
            result = verify_ztp_status(dut, retry_count, iteration, delay, expect_reboot=expect_reboot, cli_type=cli_type)
        if not result:
            if "logs_path" in data and "func_name" in data:
                capture_syslogs(dut, data.logs_path, syslog_file_names)
            st.log("ZTP status verification failed")
            st.report_fail("ztp_status_verification_failed")
        if reboot_on_success:
            output = show_ztp_status(dut, cli_type=cli_type)
            if output["status"] != "SUCCESS":
                st.wait(300, "Waiting for device to reboot after success...")
                st.wait_system_status(dut, 300)
            # st.wait_system_reboot(dut)
            if not verify_ztp_status(dut, retry_count, iteration, delay, cli_type=cli_type):
                if "logs_path" in data and "func_name" in data:
                    capture_syslogs(dut, data.logs_path, syslog_file_names)
                st.log("ZTP status verification failed")
                st.report_fail("ztp_status_verification_failed")
            st.banner(boot_up_obj.sonic_installer_list(dut))
    verify_ztp_filename_logs(dut, data)
    if "ztp_log_string" in data and data.ztp_log_string:
        if not basic_obj.poll_for_error_logs(dut, data.ztp_log_path, data.ztp_log_string):
            st.log("ZTP log {} verification failed for message {}".format(data.ztp_log_path, data.ztp_log_string))
            if not basic_obj.poll_for_error_logs(dut, data.ztp_log_path_1, data.ztp_log_string):
                st.log("ZTP log {} verification failed for message {}".format(data.ztp_log_path_1, data.ztp_log_string))
                st.report_fail("ztp_log_verification_failed", data.ztp_log_path_1, data.ztp_log_string)
    if "result" in data and data.result == "pass":
        st.report_pass("test_case_passed")
Example #30
0
def verify_ztp_status(dut, retry_cnt=0, iteration=300, retry=3, expect_reboot=False, reboot_on_success=list(), cli_type=""):
    cli_type = st.get_ui_type(dut, cli_type=cli_type)
    """
    Author: Chaitanya Vella ([email protected])
    API to verify ZTP status
    :param dut:
    :param retry_cnt:
    :return:
    """
    retry_count_if_no_response = 0
    if retry_cnt:
        return _verify_ztp_status_with_retry(dut, retry_cnt, cli_type=cli_type)
    else:
        st.log("Verifying the ZTP status with iteration method ...")
        for _ in range(1, iteration + 1):
            response = show_ztp_status(dut, expect_reboot=expect_reboot, cli_type=cli_type)
            if not response:
                st.log("Observed no response in ZTP status ... retrying {} .. ".format(retry_count_if_no_response))
                if retry_count_if_no_response > 5:
                    st.error("show ztp status returned empty data...")
                    return False
                st.wait(retry)
                retry_count_if_no_response += 1
                continue
            if "service" not in response or "status" not in response or "adminmode" not in response:
                st.log("Values of service or status or adminmode is not populated yet, retrying ...")
                st.wait(10)
                continue
            if response["adminmode"] == "True":
                if "service" not in response or "status" not in response or "adminmode" not in response:
                    st.log("Values of service or status or adminmode is not populated yet, retrying ...")
                    st.wait(retry)
                else:
                    # return verify_ztp_status(dut)
                    st.log("Found that admin mode as {}".format(response["adminmode"]))
                    if response["service"] == "Inactive":
                        st.log("Found that service as {}".format(response["service"]))
                        if response["status"] == "FAILED":
                            st.log("Found that status as {}".format(response["status"]))
                            return False
                        elif response["status"] == "SUCCESS":
                            st.log("Found that status as {}".format(response["status"]))
                            return True
                        else:
                            st.log("ZTP status is not in expected values , retrying...")
                            st.wait(retry)
                            # return verify_ztp_status(dut)
                    elif response["service"] == "Processing" or response["service"] == "Active Discovery":
                        st.log("Found that service as {}".format(response["service"]))
                        if response["status"] == "IN-PROGRESS":
                            st.log("Found that status as {}".format(response["status"]))
                            st.log("Files - {}".format(response["filenames"]))
                            if reboot_on_success and "filenames" in response and response["filenames"]:
                                reboot_flag = list(reboot_on_success) if isinstance(reboot_on_success, list) else [reboot_on_success]
                                if len(response["filenames"]) > 0:
                                    filenames = response["filenames"][0]
                                    for filename in reboot_flag:
                                        if filename in filenames and filenames[filename] == "SUCCESS":
                                            return True
                            if cli_type == "klish":
                                if len(response["filenames"]) > 0:
                                    for key,value in response["filenames"][0].items():
                                        if ("configdb-json" in key or "graphservice" in key) and value == "IN-PROGRESS":
                                            st.wait(300)
                            st.wait(retry)
                            # return verify_ztp_status(dut)
                        elif response["status"] == "FAILED":
                            st.log("Found that status as {}".format(response["status"]))
                            return False
                        elif response["status"] == "Not Started":
                            st.log("Found that status as {}".format(response["status"]))
                            st.wait(retry)
                            # return verify_ztp_status(dut)
                        elif response["status"] == "SUCCESS":
                            st.log("Found that status as {}".format(response["status"]))
                            st.wait(retry)
                            # return verify_ztp_status(dut)
                        else:
                            st.log("ZTP status is not in expected values, retrying...")
                            st.wait(retry)
                    elif response["service"] == "SUCCESS":
                        st.log("Found that service as {}".format(response["service"]))
                        return True
            else:
                st.log("Found that ZTP is disabled hence enabling it ..")
                ztp_operations(dut, "enable")
                # ztp_operations(dut, "run")
                # return verify_ztp_status(dut)
        return False