def verify_host_after_bios_default(self, config, cimc_util_obj): ''' Test Case verify_host_after_bios_default ''' #Bios Config bios_obj = classparam['bios_obj'] host_detail_config = config.host_info[0].nw_intf_list[0] host_info_config = config.host_info[0].host_detail if bios_obj.load_bios_defaults() is False: self.failed("Failed to load bios defaults") else: res_host_up = cimc_util_obj.verify_host_up( hostname=host_detail_config.ip_address, wait_for_ping_fail=False) if res_host_up: logger.info('Host rebooted successfully after bios defaults') else: logger.warning('Issue with host reboot after bios default') logger.info("IP : "+host_detail_config.ip_address+ "\n user : "******"\n pass : "******"Unable to connect to host") else: self.passed( "Successfully booted to os after token change without any error" ) host.disconnect()
def validate_cdn_techsupport(self, config): con = ConfigParser() tftp_config = con.load_common_config().tftp_share remote_ip = tftp_config.tftp_server_ip remote_user = tftp_config.tftp_user remote_passwd = tftp_config.tftp_password tftp_root_dir = tftp_config.tftp_root_path tftp_handle = LinuxUtils(remote_ip, remote_user, remote_passwd) tftp_handle.connect() ts_path = tftp_root_dir + '/TechSupport/' tftp_handle.execute_cmd('mkdir -p ' + ts_path) tftp_handle.execute_cmd('chmod 777 ' + ts_path) tftp_handle.execute_cmd('tar -xzvf /TFTP_DIR/' + self.ts_file_path + ' ' + "-C" + ' ' + ts_path) platform_type = config.mgmtdetail.platform_series if platform_type == 'M5': cdn_ts = tftp_handle.execute_cmd('cat' + ' ' + ts_path + 'mnt/jffs2/BIOS/bt/BiosTech.log \ | grep "Patched eNIC Name"') else: cdn_ts = tftp_handle.execute_cmd('cat' + ' ' + ts_path + 'var/nuova/BIOS/BiosTech.txt \ | grep "Patched eNIC Name"') time.sleep(20) tftp_handle.disconnect() cdn_from_tsr = re.findall(r'=\s+([^\r\n\'\s]+)', cdn_ts) logger.info('CDN info from Tech-support data') logger.info(cdn_from_tsr) '''Getting CDN name from CIMC''' logger.info('Fetching CDN name from CIMC CLI') vic_list = config.inventory_detail vic_obj = VicLib(self, config) for vic in vic_list: slot_no = vic.slot_number out = vic_obj.cimc_cdn_mac_dict(slot_no) cnd_from_cimc = [] for cdn_name in out.values(): cnd_from_cimc.append(cdn_name) logger.info('CDN name from CIMC') logger.info(cnd_from_cimc) for val in cdn_from_tsr: if val not in cnd_from_cimc: logger.info( "From CIMC CDN name are not same as TSR CDN name") return False return True
def get_release_note_content(self, config): try: mgmt_detail_obj = config.mgmtdetail plat = mgmt_detail_obj.platform platform = self.get_platform_name(plat) build = os.environ["BUILD"] huu_image = os.environ["HUU_IMAGE"] if not build: logger.error("Build is not set in environment variable") return False if not huu_image: logger.error("HUU IMAGE is not set in environment variable") return False huu_iso_file = "/var/www/html/HUU_Sanity/systemupgrade/isos/" + \ platform + "/" + build + "/" + huu_image logger.info("HUU FILe: " + huu_iso_file) host = LinuxUtils('10.127.45.20', 'root', 'HuuWelcome123') host.connect() if "No such file or directory" in host.execute_cmd("ls " + huu_iso_file): logger.error("HUU file not found in filer") return False # Mouting ISO logger.info("Mouting ISO" + huu_iso_file) mount_folder = "/mnt/" + \ re.search(r'(.*?)\.iso', huu_image).group(1) logger.info("Mount Foleder" + mount_folder) host.execute_cmd("mkdir " + mount_folder) # Check mount folder if "No such file or directory" in host.execute_cmd("ls " + mount_folder): logger.error("mount folder is not found in filer") return False host.execute_cmd("mount -o loop " + huu_iso_file + " " + mount_folder) if "No such file or directory" in host.execute_cmd("ls " + mount_folder + "/TOC*.xml"): logger.error("TOC file not found") return False toc_out = host.execute_cmd("cat " + mount_folder + "/TOC*.xml") host.disconnect() return toc_out except: dump_error_in_lib()
def verify_cpu_host(self, config): ''' Test Case verify_cpu_host ''' procc_obj = classparam['procc_obj'] cpu_list = classparam['cpu_info'] result = 'Pass' host_detail_config = config.host_info[0].nw_intf_list[0] host_info_config = config.host_info[0].host_detail logger.info("IP : "+host_detail_config.ip_address+ "\n user : "******"\n pass : "******"CPU OBJECT LIST") logger.info(cpu_list) host.disconnect() if len(cpu_list) > 0: thread_count_config = int( procc_obj.processor_config.thread_count) * len(cpu_list) else: self.failed("Error is getting CPU object list") if cpu_host_info['cores'] == procc_obj.processor_config.core_count: logger.info("Core count verification from host is successful") else: logger.error("Core count not matching : \n In host - " + str(cpu_host_info['cores'])) logger.error("In Config : " + str(procc_obj.processor_config.core_count)) result = 'Fail' if cpu_host_info['thread'] == thread_count_config: logger.info("Thread count verification from host is successful") else: logger.error("Thread count not matching : \n In host - " + str(cpu_host_info['thread'])) logger.error("In Config : " + str(thread_count_config)) result = 'Fail' if result == 'Pass': self.passed("Successfully verified core and thread in host") else: self.failed("Core and Thread verification failed")
def remove_techsupport_file(self): ''' Procedure to remove the tech-support file Returns: True: on success False: on failure ''' try: logger.info('Deleting tech-support file: ' + self.ts_file_path) con = ConfigParser() tftp_config = con.load_common_config().tftp_share remote_ip = tftp_config.tftp_server_ip remote_user = tftp_config.tftp_user remote_passwd = tftp_config.tftp_password handle = LinuxUtils(remote_ip, remote_user, remote_passwd) handle.connect() handle.execute_cmd('rm -f ' + '/TFTP_DIR/' + self.ts_file_path) handle.disconnect() except: dump_error_in_lib()
def specjvm_test(self, cimc_util_obj): ''' Runs specjvm at 30,90 and 180 ops and checks for error in host , cimc log , sel log ''' host_ping_status = cimc_util_obj.verify_host_up( hostname=self.host_ip, wait_for_ping_fail=False, wait_time=30) if host_ping_status is True: logger.info("Host OS is pinging ...") else: output = self.boot_order_obj.set_boot_order_HDD() if output == True: host_ping_status = cimc_util_obj.verify_host_up( hostname=self.host_ip, wait_for_ping_fail=False, wait_time=600) if host_ping_status is True: logger.info("Host OS is pinging ...") else: self.failed( "Testcase failed .... since Unabke to boot to OS") ops_list = [30, 90, 180] spec_jvm_pid = '' spec_jvm_kill = "kill -9 " + spec_jvm_pid time_out = 2 host = self.host host.connect() host_utils = self.host_utils host_log_flag = False sel_log_flag = False cimc_log_flag = False handle_2 = LinuxUtils(host.ip, host.username, host.password) handle_2.connect() for ops in ops_list: logger.info("Running specJVM at " + str(ops) + " Ops") logs_before_stress = host_utils.get_host_logs(host) cimc_log_before = cimc_util_obj.get_cimc_sel_log_latest_event() sel_log_before = cimc_util_obj.get_cimc_sel_log_latest_event( log_scope='sel') spec_jvm_cmd = "java -jar /root/tools/SPECjvm2008.jar -ikv -ops " + \ str(ops) + " crypto.aes > /root/tools/specjvm.txt 2>&1 &" spec_jvm_pid = self.get_pid(handle_2.execute_cmd(spec_jvm_cmd)) start_time = strftime("%H", gmtime()) end_time = strftime("%H", gmtime()) time.sleep((3600 * time_out) / 4) while (abs(int(start_time) - int(end_time)) <= time_out): end_time = strftime("%H", gmtime()) out = host.execute_cmd("ps -ef | grep SPECjvm") ps_out = '\t'.join([line.strip() for line in out.splitlines()]) logger.info("process out is" + ps_out) if spec_jvm_pid in ps_out: time.sleep(60) else: break if (abs(int(start_time) - int(end_time))) > time_out: host.execute_cmd('kill -9 ' + spec_jvm_pid) logs_after_stress = host_utils.get_host_logs(host) cimc_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event( cimc_log_before) cimc_log_flag = True sel_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event( sel_log_before, log_scope='sel') sel_log_flag = True host_log_flag = host_utils.check_host_logs_diff( logs_before_stress, logs_after_stress) if host_log_flag and cimc_log_flag and sel_log_flag: continue else: self.failed("Difference in host log") host.disconnect() handle_2.disconnect() if host_log_flag: self.passed("Spec JVM ran successfully") else: self.failed("Difference in host log")
class ExpImpUtils(): def __init__(self, cimc_utils_obj, config, common_config): self.cimc_utils_obj = cimc_utils_obj self.handle = cimc_utils_obj.handle self.config = config self.common_config = common_config self.tftp_ip = self.common_config.tftp_share.tftp_server_ip self.tftp_user = self.common_config.tftp_share.tftp_user self.tftp_password = self.common_config.tftp_share.tftp_password self.tftp_handle = LinuxUtils(self.tftp_ip, self.tftp_user, self.tftp_password) self.tftp_root_dir = self.common_config.tftp_share.tftp_root_path self.export_path = None def export_vic_config(self, slot_no, protocol='tftp', server=None, path=None, user=None, password=None): ''' Procedure to export VIC configuration Parameter: slot_no: slot number on adapter card is present protocol: Protocol to use { tftp | ftp | sftp | scp | http } server: Remote server IP address path: Image file path on the remote server user: remote server user name password: remote server user password Return: True : Success False : Failure ''' try: if server == None: remote_dir = '/vic_export/' remote_path = self.tftp_root_dir + remote_dir self.tftp_handle.connect() logger.info('Successfully connected to remote tftp server') self.tftp_handle.execute_cmd_list('mkdir -p ' + remote_path) self.tftp_handle.execute_cmd_list('chmod 777 ' + remote_path) self.tftp_handle.disconnect() self.handle.execute_cmd_list('top', 'scope chassis', 'scope adapter ' + slot_no) vic_xml_file = "vic_config" + "_" + "slot_no_" + slot_no if protocol is 'tftp' or protocol is 'http': out = self.handle.execute_cmd('export-vnic' + ' ' + protocol + ' ' + self.tftp_ip + ' ' + remote_dir + vic_xml_file, wait_time=6) if 'Export succeeded' in out: logger.info( 'VIC export operation completed successfully: ' + remote_path + vic_xml_file) self.export_path = remote_path + vic_xml_file else: logger.exception('Failed to export VIC config data') return False elif protocol is 'sftp' or protocol is 'scp': out = self.handle.execute_cmd('export-vnic' + ' ' + protocol + ' ' + self.tftp_ip + ' ' + remote_path + vic_xml_file, wait_time=6) if 'Do you wish to continue' in out: self.handle.execute_cmd('y') time.sleep(1) self.handle.execute_cmd(user) time.sleep(1) out = self.handle.execute_cmd(password, wait_time=6) if 'Export succeeded' in out: logger.info( 'VIC export operation completed successfully') self.export_path = remote_path + vic_xml_file else: logger.exception('Failed to export VIC config data') return False elif protocol is 'ftp': self.handle.execute_cmd('export-vnic' + ' ' + protocol + ' ' + self.tftp_ip + ' ' + remote_dir + vic_xml_file, wait_time=6) self.handle.execute_cmd(user) time.sleep(1) out = self.handle.execute_cmd(password, wait_time=6) if 'Export succeeded' in out: logger.info('VIC export operation completed successfully') self.export_path = remote_path + vic_xml_file else: logger.exception('Failed to export VIC config data') return False else: logger.error('Invalid protocol selected') return False return True except: dump_error_in_lib() return False def validate_vic_config(self, slot_no): logger.info("Verifying the VIC configuration exported for slot no " + slot_no) self.tftp_handle.connect() out = self.tftp_handle.execute_cmd('cat ' + self.export_path + ' | ' + 'grep -F "<CDN>"') self.tftp_handle.disconnect() cdn_name_from_export = re.findall(r'<CDN>(\w+)<\/CDN>', out) logger.info('exported CDN_names are') logger.info(cdn_name_from_export) logger.info('Fetching CDN name from CIMC CLI') vic_obj = VicLib(self.cimc_utils_obj, self.config) out = vic_obj.cimc_cdn_mac_dict(slot_no) cnd_name_from_cimc = [] for cdn_name in out.values(): cnd_name_from_cimc.append(cdn_name) logger.info('CDN Name from CIMC list:' + str(cnd_name_from_cimc)) ''' if len(cnd_name_from_cimc) != len(cdn_name_from_export): logger.error('Both lists have different size lengths') return False ''' for val in cdn_name_from_export: if val not in cnd_name_from_cimc: logger.info("From CIMC CDN name are not same as TSR CDN name") return False return True def remove_vic_config(self): ''' Procedure to remove the VIC exported file Returns: True: on success False: on failure ''' try: logger.info('Deleting vic export config file: ' + self.export_path) self.tftp_handle.connect() self.tftp_handle.execute_cmd('rm -f ' + self.export_path) self.tftp_handle.disconnect() except: dump_error_in_lib()
def cpu_frequency_eist_turbo_ed(self, config, parameter, cimc_util_obj): bios_obj = classparam['bios_obj'] procc_obj = classparam['procc_obj'] host_util = classparam['host_utils'] ######## Bios Default ############################# if bios_obj.load_bios_defaults() is False: self.failed("Failed to load bios defaults") else: logger.info("Waiting for host to reboot after load bios default") time.sleep(180) ################################################## if bios_obj.set_bios_token_value( parameter, 'Disabled', commit_wait=150) is False: self.failed("Failed to Disable " + parameter) else: turbo_value = bios_obj.get_bios_token_value(parameter) if 'Disabled' not in turbo_value: self.failed("Disabling " + parameter + " token failed") host_detail_config = config.host_info[0].nw_intf_list[0] host_info_config = config.host_info[0].host_detail logger.info("IP : " + host_detail_config.ip_address + "\n user : "******"\n pass : "******"Host OS is not pinging") if host.connect() is False: self.failed("Unable to connect to host") else: logger.info( "Successfully booted to os after token change without any error" ) logger.info("Keeping host for 5mins before PTU monitor") time.sleep(300) param_key = PARAM_TOKEN[parameter] config_frequency = float( getattr(procc_obj.processor_config, param_key)) logger.info("Config core val " + str(config_frequency)) if host_util.start_ptu_gen(host, wait=60) is False: self.failed("Failed to start PTU stress") host.disconnect() else: platform_type = config.mgmtdetail.platform_series avg_cpu_list = host_util.get_ptu_monitor_out(host) if len(avg_cpu_list) < 1: self.failed("Error is getting average frequency") for ind, core_freq in enumerate(avg_cpu_list): if platform_type == 'M5': core_freq = core_freq * 1000 if core_freq - 1000 <= config_frequency <= core_freq + 1000: logger.info("Successfully Verified core " + str(ind) + " frequency after stress when " + parameter + " Disabled :(" + str(core_freq) + ")") else: logger.error("Core " + str(ind) + " value not satisfied with config : " + str(core_freq)) result = 'Fail' host.disconnect() if result == 'Pass': self.passed( "Processor frequency verification for all cores successful" ) else: self.failed( "Frequency value in idle state not matched with PTU value")
def verify_cpu_frequency_eist_turbo(self, config, parameter): bios_obj = classparam['bios_obj'] procc_obj = classparam['procc_obj'] host_util = classparam['host_utils'] ######## Bios Default ############################# if bios_obj.load_bios_defaults() is False: self.failed("Failed to load bios defaults") else: logger.info("Waiting for host to reboot after load bios default") time.sleep(180) ################################################### host_detail_config = config.host_info[0].nw_intf_list[0] host_info_config = config.host_info[0].host_detail logger.info("############# Host Info ##########") logger.info("IP : " + host_detail_config.ip_address + "\n user : "******"\n pass : "******"##################################") result = 'Pass' host = LinuxUtils(host_detail_config.ip_address, host_info_config.os_login, host_info_config.os_password) if host.connect() is False: self.failed("Unable to connect to host") else: logger.info( "Successfully booted to os after token change without any error" ) eist_value = bios_obj.get_bios_token_value( 'EnhancedIntelSpeedStep') logger.info("Currently EIST is " + eist_value) turbo_value = bios_obj.get_bios_token_value('IntelTurboBoostTech') logger.info("Currently Turbo is " + turbo_value) if 'Enabled' not in eist_value: self.failed("Eist is not set to enabled") if 'Enabled' not in turbo_value: self.failed("Turbo is not set to enabled") cores_enabled = bios_obj.get_bios_token_value( 'CoreMultiProcessing') if parameter in cores_enabled: logger.info("Enabled cores is " + cores_enabled) logger.info("#########Param" + parameter + "########") logger.info(PARAM_DICT_PTU) logger.info("####################################") param_key = PARAM_DICT_PTU[parameter] logger.info("Config Key " + param_key) max_core_config = float( getattr(procc_obj.processor_config, param_key)) logger.info("Config core val " + str(max_core_config)) if host_util.start_ptu_gen(host, wait=600) is False: self.failed("Failed to start PTU stress") host.disconnect() else: platform_type = config.mgmtdetail.platform_series avg_cpu_list = host_util.get_ptu_monitor_out(host) if len(avg_cpu_list) < 1: self.failed("Error is getting average frequency") for ind, core_freq in enumerate(avg_cpu_list): if platform_type == 'M5': core_freq = core_freq * 1000 if core_freq - 1000 <= max_core_config <= core_freq + 1000: logger.info("Successfully Verified core " + str(ind) + " frequency after stress when " + parameter + " enabled :(" + str(core_freq) + ")") else: logger.error( "Core " + str(ind) + " value not satisfied with config : " + str(core_freq)) result = 'Fail' else: self.failed("Expected cores not got enabled(" + cores_enabled + ")") host.disconnect() host.disconnect() if result == 'Pass': self.passed( "Processor frequency verification for all cores successful" ) else: self.failed( "Frequency value in idle state not matched with PTU value")
def verify_processor_frequency_idlestate(self, config): bios_obj = classparam['bios_obj'] procc_obj = classparam['procc_obj'] host_util = classparam['host_utils'] ######## Bios Default ############################# if bios_obj.load_bios_defaults() is False: self.failed("Failed to load bios defaults") else: logger.info("Waiting for host to reboot after load bios default") time.sleep(180) #################################################### host_detail_config = config.host_info[0].nw_intf_list[0] host_info_config = config.host_info[0].host_detail logger.info("##### Host Detail ####################") logger.info("IP : " + host_detail_config.ip_address + "\n user : "******"\n pass : "******"#####################################") host = LinuxUtils(host_detail_config.ip_address, host_info_config.os_login, host_info_config.os_password) if host.connect() is False: self.failed("Unable to connect to host") else: logger.info( "Successfully booted to os after token change without any error" ) logger.info("Keeping host for 5mins before PTU monitor") time.sleep(300) # Average frequency from ptu platform_type = config.mgmtdetail.platform_series avg_cpu_list = host_util.get_ptu_monitor_out(host, wait=600) if len(avg_cpu_list) < 1: self.failed("Error is getting average frequency") logger.info(avg_cpu_list) #idle_freq = round(float(procc_obj.processor_config.cpu_maxcore_turbo), 2) idle_freq = round( float(procc_obj.processor_config.cpu_lowest_freq), 2) logger.info('Idle frequency from config file is: ' + str(idle_freq)) result = 'Pass' for ind, core_freq in enumerate(avg_cpu_list): if platform_type == 'M5': core_freq = core_freq * 1000 if core_freq - 600 <= idle_freq <= core_freq + 600: logger.info("Successfully Verified core " + str(ind) + " frequency in idle state(" + str(core_freq) + ")") else: logger.error("Core " + str(ind) + " value not satisfied the idle frequency : " + str(core_freq)) result = 'Fail' host.disconnect() if result == 'Pass': self.passed( "Processor frequency verification for all cores successful" ) else: self.failed( "Frequency value in idle state not matched with PTU value")
def verfiy_hyper_thread(self, config, cimc_util_obj, parameter): bios_obj = classparam['bios_obj'] host_util = classparam['host_utils'] procc_obj = ProcessorUtils(classparam['bios_obj']) host_detail_config = config.host_info[0].nw_intf_list[0] host_info_config = config.host_info[0].host_detail ######## Bios Default ############################# if bios_obj.load_bios_defaults() is False: self.failed("Failed to load bios defaults") else: res_host_up = cimc_util_obj.verify_host_up( hostname=host_detail_config.ip_address, wait_for_ping_fail=False) if res_host_up: logger.info('Host rebooted successfully after bios defaults') else: logger.warning('Issue with host reboot after bios default') #################################################### htpthd_value = bios_obj.get_bios_token_value('IntelHyperThread') logger.info("##########################################") logger.info("Currently Hyper Thread Token is " + htpthd_value) logger.info("##########################################") if 'Enabled' not in htpthd_value: self.failed("Hyper Thread is not set to enabled") cores_enabled = bios_obj.get_bios_token_value('CoreMultiProcessing') if parameter != cores_enabled: if bios_obj.set_bios_token_value('CoreMultiProcessing', parameter, commit_wait=150) is False: self.failed("Failed to set core enabled to " + parameter) else: cores_enabled1 = bios_obj.get_bios_token_value( 'CoreMultiProcessing') if parameter != cores_enabled1: self.failed("Failed to set core enabled to " + parameter) logger.info("################################################") logger.info("Successfully set the core enabled to " + parameter) logger.info("################################################") logger.info("############## Host Info ####################") logger.info("IP : " + host_detail_config.ip_address + "\n user : "******"\n pass : "******"#############################################") result = 'Pass' status = host_util.check_host_up(cimc_util_obj, procc_obj.boot_order_obj, config) if status is False: self.failed('Host is not up') host = LinuxUtils(host_detail_config.ip_address, host_info_config.os_login, host_info_config.os_password) if host.connect() is False: self.failed("Unable to connect to host") else: logger.info( "################################################################" ) logger.info( "Successfully booted to os after token change without any error" ) logger.info( "#################################################################" ) cpu_host_info = procc_obj.get_cpu_info_host(host) logger.info("Enabled cores is " + cores_enabled) if parameter == 'All': physical_core = int(procc_obj.processor_config.core_count) else: physical_core = int(parameter) cpu_list = classparam['cpu_info'] logger.info("CPU list") logger.info(cpu_list) if len(cpu_list) > 0: calculated_logical_core = int(physical_core) * len( cpu_list) * 2 else: self.failed("Error in getting CPU object") logger.info("################################################") logger.info("Logical and Physical values") logger.info("Logical : " + str(cpu_host_info['thread'])) logger.info("Physical : " + str(physical_core)) logger.info("################################################") if cpu_host_info['thread'] == calculated_logical_core: logger.info( "Logical thread is equal to calculated logical core from physical core thread" ) else: logger.error("Logical Core not matching: \n Logical- " + str(cpu_host_info['thread']) + "Calculated Logical core" + str(calculated_logical_core)) result = 'Fail' host.disconnect() if result == 'Pass': self.passed("Physical and logical core comparison passed") else: self.failed("Physical and logical core comparison failed")