Exemplo n.º 1
0
def restart_and_verify_chef_client(dut):
    st.log("Stopping chef client")
    basic_obj.service_operations(dut, "chef-client", "stop")
    st.log("Verifying the chef client status")
    if basic_obj.verify_service_status(dut, "chef-client"):
        st.error("Chef client is running.")
        st.report_fail("client_running")
    basic_obj.service_operations(dut, "chef-client")
    st.log("Verifying the chef client status")
    if not basic_obj.verify_service_status(dut, "chef-client"):
        st.error("Chef client is not running.")
        st.report_fail("client_not_running")
Exemplo n.º 2
0
def test_ft_lldp_docker_restart():
    """
     Author : Karthikeya Kumar CH<*****@*****.**>
     Verify the LLDP functionality after docker restart.
     Reference Test Bed : D1 <--2--> D2
     """
    st.log("Checking the LLDP functionality with docker restart")
    service_name = "lldp"
    basic_obj.service_operations_by_systemctl(vars.D1, service_name, 'stop')
    basic_obj.service_operations_by_systemctl(vars.D1, service_name, 'restart')
    if not basic_obj.poll_for_system_status(vars.D1, service_name, 30, 1):
        st.report_fail("service_not_running", service_name)
    if not basic_obj.verify_service_status(vars.D1, service_name):
        st.report_fail("lldp_service_not_up")
    if not intf_obj.poll_for_interfaces(vars.D1, iteration_count=30, delay=1):
        st.report_fail("interfaces_not_up_after_poll")
    if not lldp_obj.poll_lldp_neighbors(
            vars.D1, iteration_count=30, delay=1, interface=vars.D1D2P1):
        st.report_fail("lldp_neighbors_info_not_found_after_poll")
    lldp_info = lldp_obj.get_lldp_neighbors(vars.D1, interface=vars.D1D2P1)
    if not lldp_info:
        st.error("No lldp entries are available")
        st.report_fail("operation_failed")
    lldp_value_dut1 = lldp_info[0]
    lldp_output_dut1 = lldp_value_dut1['chassis_name']
    hostname_cli_output = basic_obj.get_hostname(vars.D2)
    if lldp_output_dut1 != hostname_cli_output:
        st.report_fail("lldp_cli_not_matching")
    st.log("LLDP and CLI output values are : LLDP:{} , CLI:{} ".format(
        lldp_output_dut1, hostname_cli_output))
    st.report_pass("test_case_passed")
Exemplo n.º 3
0
def check_udld_status_after_restart(dut):
    ret = False
    max_wait_time = 300  # 5 mins, reason, cold reboot might take upto 5mins
    wait_start_time = time.time()
    total_wait_time = 0
    while not ret:
        st.wait(2)
        total_wait_time = int(time.time() - wait_start_time)
        st.log(
            "Verify UDLD service status after {} sec".format(total_wait_time))
        if total_wait_time > max_wait_time:
            st.error('UDLD is NOT READY even after {} seconds'.format(
                total_wait_time))
            return False
        ret = basic_obj.verify_service_status(dut, "udld")

    st.log('UDLD is READY after {} seconds'.format(total_wait_time))
    return True
def test_ft_pmon_docker_restart():
    """
    Author : Karthikeya Kumar CH<*****@*****.**>
    Verify that the platform monitoring(pmon) works fine after docker restart
    Reference Test Bed : D1 --- Mgmt Network
    """
    vars = st.get_testbed_vars()
    service_name = "pmon"
    basic_obj.service_operations_by_systemctl(vars.D1, service_name, 'stop')
    basic_obj.service_operations_by_systemctl(vars.D1, service_name, 'restart')
    if not basic_obj.poll_for_system_status(vars.D1, service_name, 30, 1):
        st.report_fail("service_not_running", service_name)
    if not basic_obj.verify_service_status(vars.D1, service_name):
        st.report_fail("pmon_service_not_up")
    pmon_check = basic_obj.show_version(vars.D1)
    if not pmon_check:
        st.report_fail("pmon_show_command_fail")
    st.report_pass("test_case_passed")
Exemplo n.º 5
0
def test_ft_snmp_docker_restart():
    """
    Author : Karthikeya Kumar CH<*****@*****.**>
    Verify that the sysName MIB object functions properly after docker restart
    Reference Test Bed : D1--- Mgmt Network
    """
    basic_obj.service_operations_by_systemctl(vars.D1, 'snmp', 'restart')
    if not basic_obj.poll_for_system_status(vars.D1, 'snmp', 30, 1):
        st.report_fail("service_not_running".format('snmp'))
    if not basic_obj.verify_service_status(vars.D1, 'snmp'):
        st.report_fail("snmp_service_not_up")
    hostname = basic_obj.get_hostname(vars.D1)
    get_snmp_output = snmp_obj.get_snmp_operation(
        ipaddress=ipaddress,
        oid=data.oid_sysName,
        community_name=data.ro_community)
    st.log("hostname Device('{}') and SNMP('{}')".format(
        hostname, get_snmp_output[0]))
    if not get_snmp_output[0] == hostname:
        st.report_fail("sysName_verification_fail_after_docker_restart")
    st.report_pass("test_case_passed")
Exemplo n.º 6
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")