CN105045707A - 一种基于Python服务器稳定性测试的方法 - Google Patents

一种基于Python服务器稳定性测试的方法 Download PDF

Info

Publication number
CN105045707A
CN105045707A CN201510438472.XA CN201510438472A CN105045707A CN 105045707 A CN105045707 A CN 105045707A CN 201510438472 A CN201510438472 A CN 201510438472A CN 105045707 A CN105045707 A CN 105045707A
Authority
CN
China
Prior art keywords
std
conf
self
check
perf
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510438472.XA
Other languages
English (en)
Inventor
张文珂
贾岛
罗强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Electronic Information Industry Co Ltd
Original Assignee
Inspur Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Electronic Information Industry Co Ltd filed Critical Inspur Electronic Information Industry Co Ltd
Priority to CN201510438472.XA priority Critical patent/CN105045707A/zh
Publication of CN105045707A publication Critical patent/CN105045707A/zh
Pending legal-status Critical Current

Links

Abstract

本发明提供一种基于Python服务器稳定性测试的方法。本测试方法主要分为配置检测,性能测试和整理日志三部分;输入运行主程序的命令后,主程序会首先调用检测配置的模块,该模块会加载相应的检测程序和配置文件,然后进行性能测试,每一步执行产生相对应的日志。本服务器稳定性测试方法适用于所有单电源或双电源服务器,在服务器上的测试过程稳定,能够很好的完成测试任务。操作简单,结果明了,大大节省了测试时间,提高了测试效率。

Description

一种基于Python服务器稳定性测试的方法
技术领域
本发明涉及一种服务器稳定性测试的方法,具体地说是一种基于Python服务器稳定性测试的方法。
背景技术
随着服务器行业的快速发展,越来越多的客户开始偏向于购买大批量的服务器作为自己的核心应用。所以对服务器的稳定性也提出了更高的要求,而服务器能否保持正常的运转,已经成为了客户应用能否稳定运行的前提。
服务器稳定性是最重要的,如果在稳定性方面不能够保证业务运行的需要,在高的性能也是无用的。正规的服务器厂商都会对产品惊醒不同温度和湿度下的运行稳定性测试。重点要考虑的是冗余功能,如:数据冗余、网卡荣誉、电源冗余、风扇冗余等。
一些测试方法主要分以下几种:
压力测试:已知系统高峰期使用人数,验证各事务在最大并发数(通过高峰期人数换算)下事务响应时间能够达到客户要求。系统各性能指标在这种压力下是否还在正常数值之内。系统是否会因这样的压力导致不良反应(如:宕机、应用异常中止等)。
稳定性测试:已知系统高峰期使用人数、各事务操作频率等。设计综合测试场景,测试时将每个场景按照一定人数比率一起运行,模拟用户使用数年的情况。并监控在测试中,系统各性能指标在这种压力下是否能保持正常数值。事务响应时间是否会出现波动或随测试时间增涨而增加。系统是否会在测试期间内发生如宕机、应用中止等异常情况。
发明内容
本发明的技术任务是针对现有技术的不足,提供一种基于Python服务器稳定性测试的方法。本测试方法通过测试配置的检测和压力测试,有效的对服务器稳定性进行了测试。
本发明解决其技术问题所采用的技术方案是:
一种基于Python服务器稳定性测试的方法,其特征在于,本测试方法主要分为配置检测,性能测试和整理日志三部分;输入运行主程序的命令后,主程序会首先调用检测配置的模块,该模块会加载相应的检测程序和配置文件,然后进行性能测试,每一步执行产生相对应的日志。
配置文件中记录了机型,bios和bmc的FW,bios的相关选项,内存、CPU、HDD、SSD和Raid卡的型号数量等信息。输入命令后,检测程序会先检测被测服务器的现有bios、bmc以及硬件配置的信息,并与配置文件做对比,如果不一致,则终止测试进程,显示测试失败。如果信息一致,则继续进行性能测试。
性能测试通过主程序调用性能测试模块来实现,该程序通过运行fio,Geekbench21和Stressapptest三个工具,分别对硬盘,CPU和内存进行加压测试,记录相关数据。程序中有实现设定好的硬盘、CPU、内存和SSD的相关数据的最低标准,然后把测试得到的数据与事先设定好的数据进行对比,如果能够达到设定的数据,则显示true,没有达到就显示false。
整理日志部分在每一步执行完成都会产生相对应的日志,最后一步就是整理这些日志,得到我们需要的结果。
本发明的一种基于Python服务器稳定性测试的方法与现有技术相比,所产生的有益效果是,事先设置好配置文件和性能数据,只要输入运行的命令,就对被测试的服务器进行检测和测试,并把得到的结果与事先设置的进行对比,满足要求的输出结果,表示通过测试,假如不满足要求,则终止测试,显示报错。
附图说明
附图1为本发明的文件体系结构图;
附图2为本发明的程序运行流程图。
具体实施方式
下面结合附图1、附图2对本发明的一种基于Python服务器稳定性测试的方法作以下详细地说明。
一种基于Python服务器稳定性测试的方法,其特征在于,本测试方法主要分为配置检测,性能测试和整理日志三部分;输入运行主程序的命令后,主程序会首先调用检测配置的模块,该模块会加载相应的检测程序和配置文件,然后进行性能测试,每一步执行产生相对应的日志。
主程序如下:
#!/usr/bin/python
"""
"""
#导入程序运行的环境
importos
importjson
importshutil
importoptparse
importcPickleaspickle
#调用confcheck.py程序
fromconfcheckimportConfCheck
#调用perfcheck.py程序
fromperfcheckimportPerfCheck
#从程序包中lib下的comm文件夹下导入需要的程序模块
fromlib.comm.gparasimportgparas
fromlib.comm.logtraceimportLogFile
fromlib.comm.logtraceimportLogInfo
fromlib.comm.commonapiimportSafeApi
#从程序包中lib文件夹下导入需要的程序模块
fromlib.getmachineinfoimportCardInfo
fromlib.getmachineinfoimportHbaCard
fromlib.checkiofwimportCheckIoFw
classMachCheck(object):#定义一个类函数
def__init__(self,purTime,machModel,purPackage):#对时间,机型和测试的套餐等变量进行定义
logfile="./mcheck.log"#定义相关的log文件
ifos.path.exists(logfile):
os.remove(logfile)#如果系统中已经存在这个log文件,则进行删除的动作
#将配置文件中的相关信息赋予到对应变量
self.purTime=purTime
self.machModel=machModel
self.purPackage=purPackage
logfile=LogFile(logfile)
self.log=LogInfo(logfile)
self.safeapi=SafeApi(self.log)
self.safe_run=self.safeapi.safe_run
self.safe_split=self.safeapi.s_split
self.std_output={}#将以上标准信息输出
self._start_hmonitor()
def_get_tool(self):
commands="unzip-o-Phrmbaidutool/tool.zip-dtool"#对工具包进行解压
self.safe_run(commands)
ifos.path.exists("tool/common-tool"):
self.log.msg("zipsucess")
else:
self.log.msg("zipfailed")#如果检测到系统中存在tool文件夹,则log中记录解压成功,反之则记录解压失败
defdel_tool(self):
try:
shutil.rmtree("tool/common-tool")
shutil.rmtree("tool/hdoctor")
shutil.rmtree("tool/hmonitor")
shutil.rmtree("tool/spec-tool")
except:
self.log.msg("rmtoolerror")
pass#递归删除指定目录以及目录里面所有的东西,如果没有出现删除错误,则pass
defcheck_conf(self):
#command="./confcheck.py-j%s"%(json_list)
#(ret,output)=self.safe_run(command,200)
#forlineinoutput:
#line=line.strip()
#ifnotline:continue
#self.log.msg(line)
#printline
(ret,cur_path)=self.safe_run("pwd")
conf_check=ConfCheck()
conf_check.get_std_conf(self.purTime,self.machModel,self.purPackage)
conf_check.get_conf()
conf_check.check_conf("all")
conf_check.print_conf()
tmp_output=conf_check.std_output("all")#将抓取到的信息和配置文件中的信息做对比,并把对比结果输出
os.chdir(cur_path[0])#改变工作目录到cur_path[0]
check_flag=0
foriintmp_output:
self.std_output[i]=tmp_output[i]
if'OK'notinself.std_output[i]:
check_flag=-1
returncheck_flag#设置flag的值为0,定义一个变量i,并与标准值进行对比,如果变量并未在标准值里面,则flag的值变为-1,并返回。
defcheck_perf(self):
#command="./perfcheck.py-j%s"%(json_list)
#(ret,output)=self.safe_run(command,3000)
#forlineinoutput:
#line=line.strip()
#ifnotline:continue
#self.log.msg(line)
#printline
(ret,cur_path)=self.safe_run("pwd")
perf_check=PerfCheck()
perf_check.get_std_perf(self.purTime,self.machModel,self.purPackage)
perf_check.run_perf()
perf_check.get_perf()
perf_check.check_perf()
perf_check.print_perf()
tmp_output=perf_check.std_output()#将抓取到的信息和配置文件中的信息做对比,并把对比结果输出
foriintmp_output:
self.std_output[i]=tmp_output[i]
os.chdir(cur_path[0])#改变工作目录到cur_path[0]
def_start_hmonitor(self):
(ret,cur_path)=self.safe_run("pwd")
conf_check=ConfCheck()
conf_check.get_std_conf(self.purTime,self.machModel,self.purPackage)
os.chdir(cur_path[0])
(ret,cur_path)=self.safe_run("pwd")
perf_check=PerfCheck()
perf_check.get_std_perf(self.purTime,self.machModel,self.purPackage)
os.chdir(cur_path[0])
in_dict=dict(conf_check.check_item["machInfo"].std_conf)
in_dict.update(perf_check.check_item["extraPerf"].std_perf)
self._start_monitor_plus(in_dict)
command="tool/hmonitor/hmonitor-bg/NOAH/controlstart"
self.safe_run(command)
def_start_monitor_plus(self,input_dict):
ifnot(input_dict.has_key('machModel')and\
input_dict.has_key('bmcInfoValid')and\
input_dict.has_key('fanSpeedMin')and\
input_dict.has_key('fanSpeedMax')and\
input_dict.has_key('cpuTempMax')and\
input_dict.has_key('cpuTempMin')and\
input_dict.has_key('machPowerMax')):
print'errorerror!!!!!!!!!!cannotstartmonitor_plus'
raise()
return
tmp_dict={}
importbase64
model=base64.encodestring(input_dict['machModel'])
tmp_dict["model"]="%s"%model
tmp_dict["bmc"]="%s"%input_dict['bmcInfoValid']
tmp_dict["fan"]=(input_dict['fanSpeedMin'],input_dict['fanSpeedMax'])
tmp_dict["cpu"]=(input_dict['cpuTempMin'],input_dict['cpuTempMax'])
tmp_dict["power_max"]="%s"%input_dict['machPowerMax']
str_dict=str(json.dumps(tmp_dict))
command="nohup%s-i'%s'>tmp_bmc.log2>&1&"%(gparas.monitor_plus,str_dict)
os.system(command)
def_stop_monitor_plus(self):
command="killall-9do_check.py"
(ret,output)=self.safe_run(command,100)#运行一周期后结束
def_check_hmonitor(self):
conf_list=["conf_raid","conf_noraid"]
conf_dir="tool/hmonitor/hmonitor-fg/"
com_file="tool/hmonitor/hmonitor-fg/main"
foriinconf_list:
conf_file=os.path.join(conf_dir,i)
command="%s%s"%(com_file,conf_file)
(ret,output)=self.safe_run(command)
forlineinoutput:
line=line.strip()
ifnotline:continue
self.log.msg(line)
if'Version'inline:continue
items=line.split(":")
iflen(items)==2:
self.std_output[items[0].strip()]=items[1].strip()
#printline#检测有无Raid等信息,做出判断后输出
def_stop_hmonitor(self):
command="tool/hmonitor/hmonitor-bg/NOAH/controlstop"
self.safe_run(command)
self._stop_monitor_plus()#检测完毕后,结束该程序
def_check_hdd_fault(self):
hdoctor_file="tool/hdoctor/hdoctor"
hdd_list=self._get_hdd_list()
foriinhdd_list:
command="%s-t%s"%(hdoctor_file,i)
(ret,output)=self.safe_run(command,100)
ifret!=0:
self.log.msg("hdoctor%sFAIL%sNULLNULLtimeoutNULLNULL"%(i,i))
else:
forlineinoutput:
line=line.strip()
ifnotline:continue
self.log.msg("hdoctor"+line)
def_get_hdd_list(self):
dev_list=[]
base_card=CardInfo(self.log)
base_card.getmanu()
ifbase_card.manunotin["pmc","lsi"]:
card=HbaCard(self.log)
card.getpdinfo()
pd_info=card.pdinfo
foriinpd_info:
dev_point=pd_info[i]["name"]
dev_list.append(dev_point)
returndev_list
def_gen_result(self,line):
f=open("./check_result","w")
f.write(line)
f.close()#检查硬盘和外插卡的相关信息,做出判断后将其写入check_result
defgen_log(self):
importglob
ifnotos.path.exists("./machcheck.log.swf"):
f=open("./machcheck.log.swf","w")
f.close()
f=open("./machcheck.log.swf","a+")
#all_file=glob.glob("*check*.log")
all_file=glob.glob("*.log")
forlineinall_file:
tmp_file=open(line,"r")
allinfo=tmp_file.readlines()
f.write("-------%s-------\n"%(line))
forinfoinallinfo:
f.write(info)
tmp_file.close()
os.remove(line)#整理log日志,并把多余的文件删掉
f.close()
defcheck_fault(self):
self._check_hmonitor()
self._stop_hmonitor()
self._check_hdd_fault()
hd_status=["CpuStatus","MemoryStatus","FlashStatus",
"RaidCardStatus","RaidCardVdStatus",
"RaidCardPdStatus"]
f=open("./mcheck.log")
allinfo=f.readlines()
f.close()
repair_err_list=[]
forlineinallinfo:
line=line.strip()
ifnotline:continue
foriteminhd_status:
ifline.find("hdoctor")>=0:
hd_status=self.safe_split(line,"",4)
ifhd_status=="FAIL":
try:
hd_err_desc=self.safe_split(line,"",8)
hd_err_slot=self.safe_split(line,"",5)
except:
hd_err_desc="err"
hd_err_slot="-1"
tmp_key="%s#%s#%s"%(hd_err_slot,hd_status,hd_err_desc)
iftmp_keynotinrepair_err_list:
repair_err_list.append(tmp_key)
self._gen_result(line)
elifline.find(item)>=0:
ifline.find("Error#")>=0:
self.std_output[item]='FAIL;%s'%(line.split(':')[-1])
self._gen_result(line)
else:
continue
ifrepair_err_list:
self.std_output["RepairStatus"]='FAIL;%s'%(';'.join(repair_err_list))
extra_err_list=[]
ifos.path.exists('/tmp/__check.log'):
tmp_list=[]
tmp_dict=pickle.load(file('/tmp/__check.log','rb'))
forkeyintmp_dict:
info=tmp_dict[key]
#extra_err_list.append('%s%s'%(key,info))
extra_err_list.append('%s'%info)
#fp.write('FAIL:%s'%(';'.join(tmp_list)))
os.system("rm-rf/tmp/__check.log")
check_ops=CheckIoFw()
check_ops.do_check()
ifcheck_ops.hdd_fw_list:
forhdd_fwincheck_ops.hdd_fw_list:
if'be27'inhdd_fw.lower()or'be27'<=hdd_fw.lower():
extra_err_list.append('hddFwErr%s'%hdd_fw)
ifextra_err_list:
self.std_output["MachExtraError"]='FAIL;%s'%(';'.join(extra_err_list))
returnTrue#将检测到的CPU,内存和硬盘等一系列该测试配置的基本信息,并与配置文件中的进行对比,如果不同,则输出error,如果一样就输出true
if__name__=="__main__":
VERSION='Version:#测试程序的版本号
opt_parse=optparse.OptionParser(version="1.0")
#opt_parse.add_option("--test","-t",default="all",help="Checksometing")
#opt_parse.add_option("--config_file","-c",default="./conf/main.conf",help="Configfile")
opt_parse.add_option("--json_list","-j",default="",help="jsonlistcontainsparas")
opt_parse.add_option("--time","-t",default=10,help="runningtime")//该函数用于添加命令行选项
(options,argument)=opt_parse.parse_args()
chk_opt=options.json_list
try:
run_time=int(options.time)
except:
run_time=0
ifrun_time<4:
print"runtimemustbemore"
raise()
avg_time=run_time/4
f=open(".time.tmp","w")
f.write(str(avg_time))
f.close()#规定程序运行的时间,并将其写入time.tmp
forlineinopen('VERSION'):
line=line.strip()
ifline:
VERSION+=line
break
printVERSION#程序开始运行,输出版本号
ifchk_opt!="":
json_obj=json.loads(chk_opt)
ifisinstance(json_obj,dict)and\
json_obj.has_key("purTime")and\
json_obj.has_key("machModel")and\
json_obj.has_key("purPackage"):
purTime=json_obj["purTime"]
machModel=json_obj["machModel"]
purPackage=json_obj["purPackage"]
mach_check=MachCheck(purTime,machModel,purPackage)
ret=mach_check.check_conf()
ifnotret:
mach_check.check_perf()
ret=mach_check.check_fault()
#printjson.dumps(mach_check.std_output)
forlineinmach_check.std_output:
printline,':',mach_check.std_output[line]
mach_check.gen_log()
#mach_check.del_tool()
else:
print"paraserror"
else:
print"noparas"#isinstance是Python中的一个内建函数,如果参数json_obj是dict的实例,或者json_obj是dict类的子类的一个实例,返回paraserror。如果json_obj不是一个给定类型的的对象,则返回结果是noparas。
配置文件中记录了机型,bios和bmc的FW,bios的相关选项,内存、CPU、HDD、SSD和Raid卡的型号数量等信息。输入命令后,检测程序会先检测被测服务器的现有bios、bmc以及硬件配置的信息,并与配置文件做对比,如果不一致,则终止测试进程,显示测试失败。如果信息一致,则继续进行性能测试。
配置检测模块:
#!/usr/bin/python
"""
"""
importos
importoptparse
#调用lib下的comm文件夹里的程序模块
fromlib.comm.logtraceimportLogFile
fromlib.comm.logtraceimportLogInfo
fromlib.comm.logtraceimportgparas
fromlib.machconfimportMachConf
fromlib.cpuconfimportCpuConf
fromlib.memconfimportMemConf
fromlib.fwconfimportFwConf
fromlib.biosconfimportBiosConf
fromlib.hddconfimportHddConf
fromlib.ssdconfimportSsdConf
fromlib.flashconfimportFlashConf
fromlib.raidconfimportRaidConf
fromlib.netconfimportNetConf
fromlib.bmcconfimportBmcConf
fromlib.armconfcheckimportArmConfCheck
classConfCheck(object):
def__init__(self):
logfile="./ccheck.log"
logfile=LogFile(logfile)
self.log=LogInfo(logfile)
self.check_item={"machInfo":MachConf(),
"cpuInfo":CpuConf(),
"memInfo":MemConf(),
"fwInfo":FwConf(),
"biosInfo":BiosConf(),
"hddInfo":HddConf(),
"ssdInfo":SsdConf(),
"flashInfo":FlashConf(),
"raidInfo":RaidConf(),
"netInfo":NetConf(),
"bmcInfo":BmcConf()}
self.dev_item={"machine":"machInfo",
"cpu":"cpuInfo",
"memory":"memInfo",
"firmware":"fwInfo",
"bios":"biosInfo",
"harddisk":"hddInfo",
"ssd":"ssdInfo",
"flash":"flashInfo",
"raid":"raidInfo",
"net":"netInfo",
"bmc":"bmcInfo"}
defget_conf(self):
foriinself.check_item:
self.log.msg(i)
self.check_item[i].get_conf()#检测测试配置的基本信息,并将其赋予某个变量
#根据输入的时间,机型等信息获取对应的配置文件,提取里面的内容
defget_std_conf(self,pur_time,mach_model,pur_package):
std_conf={}
std_conf["machManu"]="lsy"
std_conf["machModel"]="lsy"
std_conf["machInfo"]="lsy"
self.check_item["machInfo"].get_std_conf(std_conf)
std_conf={}
std_conf["cpuNum"]=12
std_conf["cpuModel"]="lsy"
std_conf["cpuFreq"]="lsy"
self.check_item["cpuInfo"].get_std_conf(std_conf)
std_conf={}
std_conf["memNum"]=34
std_conf["memModel"]="lsy"
std_conf["memCap"]="lsy"
self.check_item["memInfo"].get_std_conf(std_conf)
std_conf={}
std_conf["Number"]=1
std_conf["turbo"]="lsy"
std_conf["pstate"]="lsy"
std_conf["cstate"]="lsy"
std_conf["c1e"]="lsy"
std_conf["ht"]="lsy"
std_conf["vt"]="lsy"
std_conf["numa"]="lsy"
std_conf["hwprefetch"]="lsy"
std_conf["adjprefetch"]="lsy"
std_conf["powermode"]="lsy"
std_conf["qpispped"]="lsy"
std_conf["ddrspeed"]="lsy"
std_conf["poweonboot"]="lsy"
std_conf["ncsimode"]="lsy"
std_conf["terminaltype"]="lsy"
std_conf["bitspersecond"]="lsy"
std_conf["databits"]="lsy"
std_conf["parity"]="lsy"
std_conf["stopbits"]="lsy"
self.check_item["biosInfo"].get_std_conf(std_conf)
std_conf={}
std_conf["raidNum"]=18
std_conf["raidModel"]="lsy"
std_conf["raidVdNum"]="lsy"
std_conf["raidType"]="lsy"
std_conf["raidBbu"]="lsy"
self.check_item["raidInfo"].get_std_conf(std_conf)
std_conf={}
std_conf["hddNum"]=121
std_conf["hddModel"]="lsy"
std_conf["hddCap"]="lsy"
self.check_item["hddInfo"].get_std_conf(std_conf)
std_conf={}
std_conf["ssdNum"]=121
std_conf["ssdModel"]="lsy"
std_conf["ssdCap"]="lsy"
self.check_item["ssdInfo"].get_std_conf(std_conf)
std_conf={}
std_conf["flashNum"]=19
std_conf["flashModel"]="lsy"
std_conf["flashCap"]="lsy"
self.check_item["flashInfo"].get_std_conf(std_conf)
std_conf={}
std_conf["Number"]=1
std_conf["mboardVer"]="lsy"
std_conf["biosVer"]="lsy"
std_conf["sasVer"]="lsy"
std_conf["bmcVer"]="lsy"
std_conf["netVer"]="lsy"
self.check_item["fwInfo"].get_std_conf(std_conf)
conf_dir="./conf"
conf_file="%s_%s_%s.conf"%(pur_time,mach_model,pur_package)
conf_file=os.path.join(conf_dir,conf_file)
ifos.path.exists(conf_file):
f=open(conf_file)
allinfo=f.readlines()
f.close()
component="machInfo"
forlineinallinfo:
line=line.strip()
ifnotline:continue
ifline.startswith("#"):continue
ifline.startswith("[")andline.endswith("]"):
component=line.lstrip("[").rstrip("]")
else:
items=line.split(":")
iflen(items)!=2:continue
self.check_item[component].get_std_item(items[0].strip(),items[1].strip())
else:
print"conffilenotexist"
raise()
defcheck_conf(self,dev="all"):
ifdev=="all":
foriinself.check_item:
self.check_item[i].check_conf()
else:
self.check_item[self.dev_item[dev]].check_conf()
defprint_conf(self,dev="all"):
ifdev=="all":
foriinself.check_item:
self.check_item[i].print_conf()
else:
self.check_item[self.dev_item[dev]].print_conf()
defstd_output(self,dev="all"):
std_list={}
ifdev=="all":
foriinself.check_item:
(key,value)=self.check_item[i].std_output()
std_list[key]=value
else:
self.check_item[self.dev_item[dev]].std_output()
#printstd_list
returnstd_list
defis_arm():
f=open("/etc/issue")
allinfo=f.readlines()
f.close()
forlineinallinfo:
line=line.strip()
ifnotline:continue
ifline.find("Ubuntu")>=0:
returnTrue
returnFalse#将检测到的信息与配置文件中提取的内容进行比较,相同则返回True,不同则返回False
if__name__=="__main__":
ifis_arm():
arm_conf_check=ArmConfCheck()
arm_conf_check.get_conf()
arm_conf_check.check_env()
else:
opt_parse=optparse.OptionParser(version="1.0")
opt_parse.add_option("--json_list","-j",default="",help="jsonlistcontainsparas")
(options,argument)=opt_parse.parse_args()
chk_opt=options.json_list
ifchk_opt!="":
printchk_opt
json_obj=json.loads(chk_opt)
printjson_obj
ifisinstance(json_obj,dict)and\
json_obj.has_key("purTime")and\
json_obj.has_key("machModel")and\
json_obj.has_key("purPackage"):
purTime=json_obj["purTime"]
machModel=json_obj["machModel"]
purPackage=json_obj["purPackage"]
conf_check=ConfCheck()
conf_check.get_std_conf(purTime,machModel,purPackage)
conf_check.get_conf()
conf_check.check_conf("all")
#conf_check.print_conf()
conf_check.std_output("all")
else:
print"paraserror"
else:
print"noparas"#如果参数json_obj是dict的实例,或者json_obj是dict类的子类的一个实例,返回paraserror。如果json_obj不是一个给定类型的的对象,则返回结果是noparas。
性能测试通过主程序调用性能测试模块来实现,该程序通过运行fio,Geekbench21和Stressapptest三个工具,分别对硬盘,CPU和内存进行加压测试,记录相关数据。程序中有实现设定好的硬盘、CPU、内存和SSD的相关数据的最低标准,然后把测试得到的数据与事先设定好的数据进行对比,如果能够达到设定的数据,则显示true,没有达到就显示false。
性能测试模块:
#!/usr/bin/python
"""
"""
#导入程序运行环境
importos
importoptparse
#调用lib下的comm文件夹里的程序模块
fromlib.cpuperfimportCpuPerf
fromlib.memperfimportMemPerf
fromlib.raidperfimportRaidPerf
fromlib.hddperfimportHddPerf
fromlib.ssdperfimportSsdPerf
fromlib.flashperfimportFlashPerf
fromlib.extraperfimportExtraPerf
fromlib.comm.logtraceimportLogFile
fromlib.comm.logtraceimportLogInfo
#进行相关性能测试,记录需要比较的数据
classPerfCheck(object):
def__init__(self):
logfile="./pcheck.log"
logfile=LogFile(logfile)
self.log=LogInfo(logfile)
self.check_item={"extraPerf":ExtraPerf()}
self.check_items={"cpuPerf":CpuPerf(),
"memPerf":MemPerf(),
"raidPerf":RaidPerf(),
"hddPerf":HddPerf(),
"ssdPerf":SsdPerf(),
"flashPerf":FlashPerf()
}
self._init_env()
def_init_env(self):
command="tar-xvzftool/spec-tool/stressapptest/libaio.tar.gz-Ctool/spec-tool/stressapptest/>/dev/null2>&1"
os.system(command)
os.environ['LD_LIBRARY_PATH']="tool/spec-tool/stressapptest/"
defrun_perf(self):
foriinself.check_items:
#print"-"*10+"Run%sstart"%(i)+"-"*10
self.check_items[i].run_perf()
#print"-"*10+"Run%sdone"%(i)+"-"*10
defget_perf(self):
foriinself.check_items:
self.log.msg(i)
self.check_items[i].get_perf()
#读取文件中标准的性能数据
defget_std_perf(self,pur_time,mach_model,pur_package):
std_perf={}
std_perf["cpuIntCalc"]=1000000000
self.check_items["cpuPerf"].get_std_perf(std_perf)
std_perf={}
std_perf["memBandwidth"]=1000000000
self.check_items["memPerf"].get_std_perf(std_perf)
std_perf={}
std_perf["raidRrBs4"]=1000000000
std_perf["raidRwBs4"]=1000000000
std_perf["raidrBs256"]=1000000000
std_perf["raidwBs256"]=1000000000
self.check_items["raidPerf"].get_std_perf(std_perf)
std_perf={}
std_perf["hddRrBs4"]=1000000000
std_perf["hddRwBs4"]=1000000000
std_perf["hddrBs256"]=1000000000
std_perf["hddwBs256"]=1000000000
self.check_items["hddPerf"].get_std_perf(std_perf)
std_perf={}
std_perf["ssdRrBs4"]=1000000000
std_perf["ssdRwBs4"]=1000000000
std_perf["ssdrBs256"]=1000000000
std_perf["ssdwBs256"]=1000000000
self.check_items["ssdPerf"].get_std_perf(std_perf)
std_perf={}
std_perf["flashRrBs4"]=1000000000
std_perf["flashRwBs4"]=1000000000
std_perf["flashrBs256"]=1000000000
std_perf["flashwBs256"]=1000000000
self.check_items["flashPerf"].get_std_perf(std_perf)
std_perf={}
std_perf["bmcInfoValid"]=1000000000
std_perf["fanSpeedMin"]=1000000000
std_perf["fanSpeedMax"]=1000000000
std_perf["cpuTempMax"]=1000000000
std_perf["cpuTempMin"]=1000000000
std_perf["machPowerMax"]=1000000000
self.check_item["extraPerf"].get_std_perf(std_perf)
#将测试记录的数据与标准的性能数据做比较,符合要求的返回True,不符合要求的返回False
conf_dir="./conf"
conf_file="%s_%s_%s.spec"%(pur_time,mach_model,pur_package)
conf_file=os.path.join(conf_dir,conf_file)
ifos.path.exists(conf_file):
f=open(conf_file)
allinfo=f.readlines()
f.close()
component="cpuPerf"
forlineinallinfo:
line=line.strip()
ifnotline:continue
ifline.startswith("#"):continue
ifline.startswith("[")andline.endswith("]"):
component=line.lstrip("[").rstrip("]")
else:
items=line.split(":")
iflen(items)!=2:continue
ifcomponentinself.check_items:
self.check_items[component].get_std_item(items[0].strip(),items[1].strip())
elifcomponentinself.check_item:
self.check_item[component].get_std_item(items[0].strip(),items[1].strip())
else:
pass
else:
print"conffilenotexist"
raise()
defcheck_perf(self):
foriinself.check_items:
self.check_items[i].check_perf()
defprint_perf(self):
foriinself.check_items:
self.check_items[i].print_perf()
defstd_output(self):
std_list={}
foriinself.check_items:
(key,value)=self.check_items[i].std_output()
std_list[key]=value
#printstd_list
returnstd_list
defis_arm():
f=open("/etc/issue")
allinfo=f.readlines()
f.close()
forlineinallinfo:
line=line.strip()
ifnotline:continue
ifline.find("Ubuntu")>=0:
returnTrue
returnFalse
if__name__=="__main__":
ifnotis_arm():
opt_parse=optparse.OptionParser(version="1.0")
opt_parse.add_option("--json_list","-j",default="",help="jsonlistcontainsparas")
(options,argument)=opt_parse.parse_args()
chk_opt=options.json_list
ifchk_opt!="":
printchk_opt
json_obj=json.loads(chk_opt)
printjson_obj
ifisinstance(json_obj,dict)and\
json_obj.has_key("purTime")and\
json_obj.has_key("machModel")and\
json_obj.has_key("purPackage"):
purTime=json_obj["purTime"]
machModel=json_obj["machModel"]
purPackage=json_obj["purPackage"]
perf_check=PerfCheck()
perf_check.get_std_perf(purTime,machModel,purPackage)
perf_check.run_perf()
perf_check.get_perf()
perf_check.check_perf()
#perf_check.print_perf()
perf_check.std_output()
else:
print"paraserror"
else:
print"noparas"#如果参数json_obj是dict的实例,或者json_obj是dict类的子类的一个实例,返回paraserror。如果json_obj不是一个给定类型的的对象,则返回结果是noparas。
整理日志部分在每一步执行完成都会产生相对应的日志,最后一步就是整理这些日志,得到我们需要的结果。
本服务器稳定性测试方法适用于所有单电源或双电源服务器,在服务器上的测试过程稳定,能够很好的完成测试任务。操作简单,结果明了,大大节省了测试时间,提高了测试效率。

Claims (4)

1.一种基于Python服务器稳定性测试的方法,其特征在于,本测试方法主要分为配置检测,性能测试和整理日志三部分;输入运行主程序的命令后,主程序会首先调用检测配置的模块,该模块会加载相应的检测程序和配置文件,然后进行性能测试,每一步执行产生相对应的日志。
2.根据权利要求1所述的一种基于Python服务器稳定性测试的方法,其特征在于,所述配置文件中记录了机型,bios和bmc的FW,bios的相关选项,内存、CPU、HDD、SSD和Raid卡的型号数量等信息。
3.根据权利要求1所述的一种基于Python服务器稳定性测试的方法,其特征在于,所述性能测试通过主程序调用性能测试模块来实现,该程序通过运行fio,Geekbench21和Stressapptest三个工具,分别对硬盘,CPU和内存进行加压测试,记录相关数据。
4.根据权利要求1所述的一种基于Python服务器稳定性测试的方法,其特征在于,所述整理日志部分在每一步执行完成都会产生相对应的日志,最后将这些日志整理,得到结果。
CN201510438472.XA 2015-07-24 2015-07-24 一种基于Python服务器稳定性测试的方法 Pending CN105045707A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510438472.XA CN105045707A (zh) 2015-07-24 2015-07-24 一种基于Python服务器稳定性测试的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510438472.XA CN105045707A (zh) 2015-07-24 2015-07-24 一种基于Python服务器稳定性测试的方法

Publications (1)

Publication Number Publication Date
CN105045707A true CN105045707A (zh) 2015-11-11

Family

ID=54452270

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510438472.XA Pending CN105045707A (zh) 2015-07-24 2015-07-24 一种基于Python服务器稳定性测试的方法

Country Status (1)

Country Link
CN (1) CN105045707A (zh)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105653451A (zh) * 2015-12-29 2016-06-08 北京金山安全软件有限公司 一种软件性能测试方法及装置
CN105930240A (zh) * 2016-05-19 2016-09-07 浪潮电子信息产业股份有限公司 一种对服务器进行自动化差异化老化测试的方法
CN107741848A (zh) * 2017-10-13 2018-02-27 郑州云海信息技术有限公司 一种基于python的pxe系统管理方法
CN108170454A (zh) * 2018-01-22 2018-06-15 郑州云海信息技术有限公司 一种应用于bios和基板管理控制器的数据交互方法
CN109032874A (zh) * 2018-08-15 2018-12-18 郑州云海信息技术有限公司 一种内存压力测试方法、装置、终端及存储介质
CN109471645A (zh) * 2018-10-30 2019-03-15 郑州云海信息技术有限公司 一种BMC与BIOS的Setup交互实现方法、装置、终端及存储介质
CN109471802A (zh) * 2018-11-01 2019-03-15 郑州云海信息技术有限公司 一种Python网页中的异常处理的方法及装置
CN112667487A (zh) * 2020-12-25 2021-04-16 深圳创新科技术有限公司 一种Linux下使用Python脚本执行FIO性能测试的方法及装置

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104407951A (zh) * 2014-11-05 2015-03-11 浪潮电子信息产业股份有限公司 一种自动化进行服务器整机测试的方法

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104407951A (zh) * 2014-11-05 2015-03-11 浪潮电子信息产业股份有限公司 一种自动化进行服务器整机测试的方法

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105653451A (zh) * 2015-12-29 2016-06-08 北京金山安全软件有限公司 一种软件性能测试方法及装置
CN105930240A (zh) * 2016-05-19 2016-09-07 浪潮电子信息产业股份有限公司 一种对服务器进行自动化差异化老化测试的方法
CN107741848A (zh) * 2017-10-13 2018-02-27 郑州云海信息技术有限公司 一种基于python的pxe系统管理方法
CN107741848B (zh) * 2017-10-13 2020-09-22 苏州浪潮智能科技有限公司 一种基于python的pxe系统管理方法
CN108170454A (zh) * 2018-01-22 2018-06-15 郑州云海信息技术有限公司 一种应用于bios和基板管理控制器的数据交互方法
CN109032874A (zh) * 2018-08-15 2018-12-18 郑州云海信息技术有限公司 一种内存压力测试方法、装置、终端及存储介质
CN109471645A (zh) * 2018-10-30 2019-03-15 郑州云海信息技术有限公司 一种BMC与BIOS的Setup交互实现方法、装置、终端及存储介质
CN109471802A (zh) * 2018-11-01 2019-03-15 郑州云海信息技术有限公司 一种Python网页中的异常处理的方法及装置
CN112667487A (zh) * 2020-12-25 2021-04-16 深圳创新科技术有限公司 一种Linux下使用Python脚本执行FIO性能测试的方法及装置

Similar Documents

Publication Publication Date Title
CN105045707A (zh) 一种基于Python服务器稳定性测试的方法
CN110750396B (zh) 一种服务器操作系统兼容性测试方法、装置及存储介质
CN110992992B (zh) 一种硬盘测试方法、设备以及存储介质
CN104407951A (zh) 一种自动化进行服务器整机测试的方法
CN104536860A (zh) 一种实时监测jbod模式下硬盘排列顺序的方法
US20100070805A1 (en) Method and Apparatus for Validating System Properties Exhibited in Execution Traces
Dong et al. Practical and accurate pinpointing of configuration errors using static analysis
CN108009067A (zh) 一种在服务器下查看raid卡详细信息的方法及系统
CN108572895B (zh) 一种Linux下自动检查软硬件配置的稳定性测试方法
US9842044B2 (en) Commit sensitive tests
US10248544B2 (en) System and method for automatic root cause detection
CN108089961A (zh) 一种基于MOC板卡硬件reboot测试方法与系统
CN114880177A (zh) 固态硬盘的整机异常掉电测试方法、装置和计算机设备
TW201516665A (zh) 伺服器之系統錯誤資訊偵測系統及方法
US8997048B1 (en) Method and apparatus for profiling a virtual machine
US20220345360A1 (en) Fault Locating Method, Apparatus And System Based On I2C Communication
CN112235128A (zh) 一种交易路径分析方法、装置、服务器及存储介质
CN107168819B (zh) 一种操作系统重启方法及装置
CN115480970A (zh) 一种性能测试方法、装置、设备及存储介质
CN112463508B (zh) 一种服务器休眠状态测试方法、系统、终端及存储介质
CN103514086A (zh) 一种软件错误报告的提取方法及装置
US9448903B2 (en) Multiple test type analysis for a test case using test case metadata
CN112486717A (zh) 一种磁盘数据一致性校验方法、系统、终端及存储介质
CN105242880A (zh) 一种自动化创建Raid并执行压力测试的方法
Vieira et al. From performance to dependability benchmarking: A mandatory path

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20151111

RJ01 Rejection of invention patent application after publication