Ejemplo n.º 1
0
Archivo: jobs.py Proyecto: zhyh329/lpts
def add_job(tools_list,
            jobs_xml=JOBS_XML,
            parameter=default_parameter,
            job_attrib={},
            resultXmlName="results"):
    '''
    创建新任务
    @param tools_list:工具列表
    @type tools_list: list 
    '''
    try:
        lptlog.info('''
                        ~~~~~~~~~~~~~~~~~~~~
                          开始创建测试任务
                        ~~~~~~~~~~~~~~~~~~~~''')
        lptlog.debug("指定测试工具集: %s" % utils.list_to_str(tools_list))
        lptxml.add_job(jobs_xml,
                       tools_list,
                       parameter,
                       job_attrib=job_attrib,
                       resultXmlName=resultXmlName)
        lptlog.info('''
                        ++++++++++++++++++
                         创建测试任务:PASS
                        ++++++++++++++++++''')
    except CreateJobException, e:
        lptlog.debug(e)
        lptlog.error('''
                        ++++++++++++++++++
                         创建测试任务:FAIL
                        ++++++++++++++++++''')
Ejemplo n.º 2
0
def has_file(name, *args):
    for file in args:
        if not os.path.isfile(file):
            raise DespendException, "缺少 %s 包"  % name 
        else:
            continue
    lptlog.info("%s 检查: PASS" % name )
Ejemplo n.º 3
0
def has_file(name, *args):
    for file in args:
        if not os.path.isfile(file):
            raise DespendException, "缺少 %s 包" % name
        else:
            continue
    lptlog.info("%s 检查: PASS" % name)
Ejemplo n.º 4
0
    def create_job(self,
                   tools_list,
                   parameter,
                   job_attrib={},
                   resultXmlName="results"):
        '''创建jobs.xml结构
        '''
        DateString = datetime.datetime.now().strftime('%y%m%d%H%M%S')
        #results = 'result_%s.xml' % DateString
        results = '%s_%s.xml' % (resultXmlName, DateString)

        job = self.create_node(
            'job', dict({
                'id': DateString,
                'status': "N/A"
            }, **job_attrib))
        lptlog.info('任务ID: %s' % DateString)

        self.create_element(job, 'resultsDB', results)
        lptlog.info('xml results文件:  %s' % results)

        lptlog.debug("创建参数")
        conftoxml = ConfigToXml(parameter, self.xml_file)
        conftoxml.add_test_group(tools_list)
        try:
            conftoxml.add_configparser_node(job, 'tool', {'status': 'no'})
        except Exception, e:
            #lptlog.exception('parameter.conf转换xml失败')
            #lptlog.error('parameter.conf转换xml失败')
            raise CreatNodeError, 'parameter.conf转换xml失败: %s' % e
Ejemplo n.º 5
0
 def extract_bar(self):
     """
     解压tar包到指定路径
     @return: 返回tar源码包详细路径, 如果发生错误返回异常
     """
     lptlog.info("开始解压测试程序")
     if not os.path.isdir(self.tar_src_dir):
         self.tar_src_dir = utils.extract_tarball_to_dir(self.tarpath, self.src_dir)
     return self.tar_src_dir
Ejemplo n.º 6
0
Archivo: test.py Proyecto: Scemoon/lpts
 def extract_bar(self):
     '''
     解压tar包到指定路径
     @return: 返回tar源码包详细路径, 如果发生错误返回异常
     '''
     lptlog.info("开始解压测试程序")
     if not os.path.isdir(self.tar_src_dir):
         self.tar_src_dir = utils.extract_tarball_to_dir(self.tarpath, self.src_dir)
     return self.tar_src_dir
Ejemplo n.º 7
0
 def _print_complier_log(*args, **kwargs):
     try:
         ret = func(*args, **kwargs)
     except Exception:
         lptlog.error('编译:FAIL')
         #    os.chdir(root_dir)
         raise CompileException()
     else:
         lptlog.info('编译:OK')
     return ret
Ejemplo n.º 8
0
Archivo: jobs.py Proyecto: zhyh329/lpts
def main():
    tools_list = getopts()

    if not tools_list:
        lptlog.error('没有输入有效的测试工具')
        sys.exit()
    else:
        lptlog.info('测试工具集:%s' % ', '.join(tools_list))

    add_job(tools_list)
Ejemplo n.º 9
0
 def _print_complier_log(*args, **kwargs):
     try:
         ret = func(*args, **kwargs)
     except Exception:
         lptlog.error('编译:FAIL')
     #    os.chdir(root_dir)
         raise CompileException()
     else:
         lptlog.info('编译:OK')
     return ret
Ejemplo n.º 10
0
Archivo: jobs.py Proyecto: Scemoon/lpts
def main():
    tools_list = getopts()
    
    if not tools_list :
        lptlog.error('没有输入有效的测试工具')
        sys.exit()
    else:
        	lptlog.info('测试工具集:%s' % ', '.join(tools_list))
    
    add_job(tools_list)
Ejemplo n.º 11
0
 def __compile_x11perf(self, x11perf_tar="x11perf-1.5.3.tar.gz"):
     x11perf_tar_path = os.path.join(self.tools_dir, x11perf_tar)
     lptlog.info("解压x11perf压缩包")
     x11perf_srcdir = utils.extract_tarball_to_dir(x11perf_tar_path, self.src_dir)
     lptlog.info("x11per源目录: %s " % x11perf_srcdir)
     
     os.chdir(x11perf_srcdir)
     if os.path.isdir(x11perf_srcdir):
         lptlog.debug("编译x11perf测试程序")
         self.compile(configure_status=True, make_status=True, make_install_status=True) 
     #返回根lpt根目录
     os.chdir(self.lpt_root)
Ejemplo n.º 12
0
Archivo: test.py Proyecto: Scemoon/lpts
 def save_results_to_xml(self):
     '''定义保存测试数据到result.xml中
     @param extra_attrbib: 定义result节点中包含的其他属性
     @attention: self.result_list定义了测试数据存储结构
                 [   [ {},{}] , [{},{}]  ]
     '''
     try:
         self.save_result_node(self.tool, self.mainParameters, self.result_list)
         lptlog.info("%s 保存到 %s :PASS" % (self.tool, self.result_xml))
     except Exception:
         #lptlog.exception("%s 保存到 %s :FAIL" % (self.tool, self.result_xml))
         raise SaveXMLError, "%s 保存到 %s :FAIL" % (self.tool, self.result_xml)
Ejemplo n.º 13
0
 def txt_report(self, width=15, writeType="horizontal", tag_width=25, format="txt"):
     """保存测试数据到xml成功后,生成简单的txt测试报告
     @param width: 定义数据段宽度
     @param writeType: 定义数据写入方向,
         horizontal,很如写入方法,宽度受width影响
         vertical, 纵向写入方法,指标字段宽度受tag_width影响,数据字段宽度受width影响
     """
     JOBID = lptxml.get_job_attrib_value("id", self.jobs_xml)
     result_txt_file = lptreport.set_result_file(self.lptresultsdir, self.tool, JOBID, format)
     lptlog.info("%s txt测试报告保存于: %s" % (self.tool, result_txt_file))
     # lptreport.save_result(self.tool, result_txt_file, self.result_xml, width=15, writeType=writeType, tag_width=tag_width)
     lptreport.txt_report(self.result_xml, [self.tool], result_txt_file, width=15)
Ejemplo n.º 14
0
Archivo: test.py Proyecto: Scemoon/lpts
 def txt_report(self, width=15, writeType='horizontal', tag_width=25, format='txt'):
     '''保存测试数据到xml成功后,生成简单的txt测试报告
     @param width: 定义数据段宽度
     @param writeType: 定义数据写入方向,
         horizontal,很如写入方法,宽度受width影响
         vertical, 纵向写入方法,指标字段宽度受tag_width影响,数据字段宽度受width影响
     ''' 
     JOBID =  lptxml.get_job_attrib_value('id', self.jobs_xml)
     result_txt_file = lptreport.set_result_file(self.lptresultsdir, self.tool, JOBID, format)
     lptlog.info("%s txt测试报告保存于: %s" % (self.tool, result_txt_file))
     #lptreport.save_result(self.tool, result_txt_file, self.result_xml, width=15, writeType=writeType, tag_width=tag_width)
     lptreport.txt_report(self.result_xml, [self.tool], result_txt_file, width=15)
Ejemplo n.º 15
0
Archivo: test.py Proyecto: Scemoon/lpts
 def save_results_to_xml(self):
     '''定义保存测试数据到result.xml中
     @param extra_attrbib: 定义result节点中包含的其他属性
     @attention: self.result_list定义了测试数据存储结构
                 [   [ {},{}] , [{},{}]  ]
     '''
     try:
         self.save_result_node(self.tool, self.mainParameters, self.result_list)
         lptlog.info("%s 保存到 %s :PASS" % (self.tool, self.result_xml))
     except Exception:
         #lptlog.exception("%s 保存到 %s :FAIL" % (self.tool, self.result_xml))
         #lptlog.error("%s 保存到 %s :FAIL" % (self.tool, self.result_xml))
         raise SaveXMLError("%s 保存到 %s :FAIL" % (self.tool, self.result_xml))
Ejemplo n.º 16
0
 def run(self):
     tool_node = self.check_tool_result_node()
         
     lptlog.info("----------开始获取测试参数")
     
     self.parallels =  self.get_config_array(tool_node, "parallel", [1])
     lptlog.info("测试并行组: %s" % utils.list_to_str(self.parallels))
     self.times = self.get_config_value(tool_node, "times", 10, valueType=int)
     if self.times < 3:
         self.times = 10
         lptlog.warning("测试次数必须大于3, 将采用默认值10")
     lptlog.info("测试次数: %d" % self.times)
            
     cmd = "./Run"
     
         #运行unixbench程序,进入unixbench 根目录, 清理环境
     os.chdir(self.tar_src_dir)
     utils.system("rm -rf results/*")
     
     #执行测试程序
     #执行测试脚本
     lptlog.info("---------运行测试脚本")
     #添加测试次数
     args_list=["-i", "%d" %self.times]
   
  #添加并行数
     for parallel in self.parallels:
         args_list.append("-c")
         args_list.append("%d" % parallel)
     
     self.mainParameters["parameters"] = " ".join([cmd]+args_list)
     utils.run_shell2(cmd, args_list=args_list, file=os.devnull)
     #utils.system_output(cmd, args=args_list)
      #返回根目录
     os.chdir(self.lpt_root)
Ejemplo n.º 17
0
Archivo: run.py Proyecto: zhyh329/lpts
def main():
    #判断是否root用户
    #if os.getuid() <>0:
     #   lptlog.critical('请使用root用户')
      #  sys.exit()
        
    lptlog.info(__START_MSG)
    try:
        if not os.path.isfile(JOBS_XML):
            #lptlog.warning("jobs.xml文件不存在")
            raise NameError, "%s 不存在"  % JOBS_XML
        run()
    except Exception, e:
        lptlog.error('Debug Message: %s' % e)
Ejemplo n.º 18
0
Archivo: test.py Proyecto: Scemoon/lpts
 def get_config_testdir(self, tool_node):
     '''获取IO测试目录
     '''
     testdir = self.get_config_value(tool_node, "testdir", os.path.join(self.lpttmpdir, "testdir"), valueType=str)
     if os.path.exists(testdir):
         if not os.path.isdir(testdir):
             lptlog.warning("%s 不是有效目录,将采用 /home/%u/testdir 目录" % testdir)
             testdir = "/home/%s/testdir" % getpass.getuser()
             os.makedirs(testdir, stat.S_IRWXU)
     else:
         os.makedirs(testdir, stat.S_IRWXU)
         testdir = os.path.abspath(testdir)
     lptlog.info("测试目录: %s" % testdir)
     return testdir
Ejemplo n.º 19
0
 def run(self):
     tool_node = self.check_tool_result_node()
         
     lptlog.info("----------开始获取测试参数")
     
     self.parallels =  self.get_config_array(tool_node, "parallel", [1])
     lptlog.info("测试并行组: %s" % utils.list_to_str(self.parallels))
     self.times = self.get_config_value(tool_node, "times", 10, valueType=int)
     if self.times < 3:
         self.times = 10
         lptlog.warning("测试次数必须大于3, 将采用默认值10")
     lptlog.info("测试次数: %d" % self.times)
            
     cmd = "./Run"
     
         #运行unixbench程序,进入unixbench 根目录, 清理环境
     os.chdir(self.tar_src_dir)
     utils.system("rm -rf results/*")
     
     #执行测试程序
     #执行测试脚本
     lptlog.info("---------运行测试脚本")
     #添加测试次数
     args_list=["-i", "%d" %self.times]
   
  #添加并行数
     for parallel in self.parallels:
         args_list.append("-c")
         args_list.append("%d" % parallel)
     
     self.mainParameters["parameters"] = " ".join([cmd]+args_list)
     utils.run_shell2(cmd, args_list=args_list, file=os.devnull)
     #utils.system_output(cmd, args=args_list)
      #返回根目录
     os.chdir(self.lpt_root)
Ejemplo n.º 20
0
 def setup(self):
     '''编译源码,设置程序
     '''
     if not self.check_bin(self.processBin):
         self.tar_src_dir = self.extract_bar()
         os.chdir(self.tar_src_dir)
         utils.make(extra='clean', make='make')
          #修改Makefile文件
 
         lptlog.info("修改Makefile, 取消#GRAPHIC_TESTS = defined注释")
         cmd = '''sed -i "s/^#GRAPHIC_TESTS/GRAPHIC_TESTS/g" Makefile '''
         utils.system(cmd)
         self.compile(make_status=True)
         os.chdir(self.lpt_root)
Ejemplo n.º 21
0
 def get_config_testdir(self, tool_node):
     """获取IO测试目录
     """
     testdir = self.get_config_value(tool_node, "testdir", os.path.join(self.lpttmpdir, "testdir"), valueType=str)
     if os.path.exists(testdir):
         if not os.path.isdir(testdir):
             lptlog.warning("%s 不是有效目录,将采用 /home/%u/testdir 目录" % testdir)
             testdir = "/home/%s/testdir" % getpass.getuser()
             os.makedirs(testdir, stat.S_IRWXU)
     else:
         os.makedirs(testdir, stat.S_IRWXU)
         testdir = os.path.abspath(testdir)
     lptlog.info("测试目录: %s" % testdir)
     return testdir
Ejemplo n.º 22
0
 def setup(self):
     '''编译源码,设置程序
     '''
     if not self.check_bin(self.processBin):
         self.tar_src_dir = self.extract_bar()
         os.chdir(self.tar_src_dir)
         utils.make(extra='clean', make='make')
          #修改Makefile文件
 
         lptlog.info("修改Makefile, 取消#GRAPHIC_TESTS = defined注释")
         cmd = '''sed -i "s/^#GRAPHIC_TESTS/GRAPHIC_TESTS/g" Makefile '''
         utils.system(cmd)
         self.compile(make_status=True)
         os.chdir(self.lpt_root)
Ejemplo n.º 23
0
    def __compile_x11perf(self, x11perf_tar="x11perf-1.5.3.tar.gz"):
        x11perf_tar_path = os.path.join(self.tools_dir, x11perf_tar)
        lptlog.info("解压x11perf压缩包")
        x11perf_srcdir = utils.extract_tarball_to_dir(x11perf_tar_path,
                                                      self.src_dir)
        lptlog.info("x11per源目录: %s " % x11perf_srcdir)

        os.chdir(x11perf_srcdir)
        if os.path.isdir(x11perf_srcdir):
            lptlog.debug("编译x11perf测试程序")
            self.compile(configure_status=True,
                         make_status=True,
                         make_install_status=True)
        #返回根lpt根目录
        os.chdir(self.lpt_root)
Ejemplo n.º 24
0
 def add_configparser_node(self, father_node, node_tag, node_attrib):
     '''
     向father_node中添加包含ParserConfig信息的节点
     @param fathor_node:父节点
     @param node_tag: 节点标签
     @param node_attrib: 节点属性
         '''
         
     sections = self.custom_sections
     lptlog.info('测试工具集:%s' % ' ,'.join(sections))
     for section in sections:
         subnode = self.create_node(node_tag, dict({'id':section}, **node_attrib))
         self.add_node(father_node, subnode)
         options = self.get_options(section)
         for option in options:
             value = self.get_str_value(section, option)
             self.create_element(subnode, option, value)
Ejemplo n.º 25
0
    def add_configparser_node(self, father_node, node_tag, node_attrib):
        '''
        向father_node中添加包含ParserConfig信息的节点
        @param fathor_node:父节点
        @param node_tag: 节点标签
        @param node_attrib: 节点属性
            '''

        sections = self.custom_sections
        lptlog.info('测试工具集:%s' % ' ,'.join(sections))
        for section in sections:
            subnode = self.create_node(node_tag,
                                       dict({'id': section}, **node_attrib))
            self.add_node(father_node, subnode)
            options = self.get_options(section)
            for option in options:
                value = self.get_str_value(section, option)
                self.create_element(subnode, option, value)
Ejemplo n.º 26
0
Archivo: test.py Proyecto: Scemoon/lpts
 def get_config_devices(self, tool_node, testdir):
     '''获取测试设备, 并挂载到testdir
     '''
     devices = self.get_config_value(tool_node, "devices", "Nodevice", valueType=str)
     lptlog.info("测试分区: %s " % devices)
     if not os.path.exists(devices):
         lptlog.debug("%s 不存在" % devices)
         return False
     else:
         try:
             if not os.path.ismount(testdir):
                 utils.system("mount %s %s" % (devices, testdir))
             else:
                 lptlog.debug("%s 已经挂载到 %s 目录" % (devices, testdir))
                 
             return True
         except Exception:
             lptlog.warning("mount %s %s 失败,请确认分区是否已经格式化!!" % (devices, testdir))
             return False
Ejemplo n.º 27
0
    def get_config_devices(self, tool_node, testdir):
        """获取测试设备, 并挂载到testdir
        """
        devices = self.get_config_value(tool_node, "devices", "Nodevice", valueType=str)
        lptlog.info("测试分区: %s " % devices)
        if not os.path.exists(devices):
            lptlog.debug("%s 不存在" % devices)
            return False
        else:
            try:
                if not os.path.ismount(testdir):
                    utils.system("mount %s %s" % (devices, testdir))
                else:
                    lptlog.debug("%s 已经挂载到 %s 目录" % (devices, testdir))

                return True
            except Exception:
                lptlog.warning("mount %s %s 失败,请确认分区是否已经格式化!!" % (devices, testdir))
                return False
Ejemplo n.º 28
0
def main():
    global TEST
    global RESULT_DB
    global RESULT_FILE

    getopts()
    if TEST is None:
        lptlog.critical("请指定测试工具")
        usage()

    if RESULT_DB is None:
        lptlog.critical("请指定result Databases")
        usage()

    if RESULT_FILE is None:
        lptlog.critical("请指定report Name")
        usage()

    lptlog.info('\n指定工具:%s\n报告文件:%s' % (TEST, RESULT_FILE))
    lptreport.save_result(TEST, RESULT_FILE, RESULT_DB)
Ejemplo n.º 29
0
 def setup(self):
     '''编译源码,设置程序
     '''
            
     if not self.check_bin(self.processBin):
         self.tar_src_dir = self.extract_bar()
         os.chdir(self.tar_src_dir)
         self.compile(make_status=True)
         os.chdir(self.lpt_root)
             
     #检查x11perf安装程序
     if os.path.exists("/usr/bin/x11perf") or  os.path.exists("/usr/local/bin/x11perf"):
         lptlog.info("将使用系统x11perf程序")
     else:
         raise ValueError, "请安装x11perf程序, xort-x11-apps"
         lptlog.info("系统中并没有安装x11perf程序,由lpt安装x11perf-1.5.3程序,如果系统缺少依赖,请安装提示安装依赖")
         utils.has_file("libX11-devel", "/usr/include/X11/Xlib.h")
         utils.has_file("libXmu-devel", "/usr/include/X11/Xmu/Xmu.h")
         utils.has_file("libXrender-devel", "/usr/include/X11/extensions/Xrender.h")
         self.__compile_x11perf(x11perf_tar="x11perf-1.5.3.tar.bz2")
Ejemplo n.º 30
0
def main():
    global TEST 
    global RESULT_DB
    global RESULT_FILE 
        
    getopts()
    if TEST is None:
        lptlog.critical("请指定测试工具")
        usage()
        
        
    if RESULT_DB is None:
        lptlog.critical("请指定result Databases")
        usage()
        
    if RESULT_FILE is None:
        lptlog.critical("请指定report Name")
        usage()

    lptlog.info('\n指定工具:%s\n报告文件:%s' % (TEST, RESULT_FILE))
    lptreport.save_result(TEST, RESULT_FILE, RESULT_DB)
Ejemplo n.º 31
0
    def compile(
        self,
        configure_status=False,
        configure_para="",
        make_status=False,
        make_para="",
        make_install_status=False,
        make_install_para="",
    ):
        """
        安装源码包,执行configure、make、make install等操作
        @param configure_status:判断是否需要configrue
        @param configure_para:configrue的参数
        @param make_status:判断是否需要make
        @param make_para:make 操作需要的参数
        @param make_install_status: 判断是否需要make install
        """

        if configure_status:
            lptlog.info("源码包进行configure")
            utils.configure(extra=configure_para, configure="./configure")

        if make_status:
            lptlog.info("源码包进行make")
            utils.make(extra=make_para, make="make")

        if make_install_status:
            lptlog.info("源码包进行make install")
            utils.make(extra="install " + make_install_para, make="make")
Ejemplo n.º 32
0
    def compile(self,
                configure_status=False,
                configure_para='',
                make_status=False,
                make_para='',
                make_install_status=False,
                make_install_para=''):
        '''
        安装源码包,执行configure、make、make install等操作
        @param configure_status:判断是否需要configrue
        @param configure_para:configrue的参数
        @param make_status:判断是否需要make
        @param make_para:make 操作需要的参数
        @param make_install_status: 判断是否需要make install
        '''

        if configure_status:
            lptlog.info("源码包进行configure")
            utils.configure(extra=configure_para, configure='./configure')

        if make_status:
            lptlog.info("源码包进行make")
            utils.make(extra=make_para, make='make')

        if make_install_status:
            lptlog.info("源码包进行make install")
            utils.make(extra='install ' + make_install_para, make='make')
Ejemplo n.º 33
0
def run_shell2(cmd, args_list=[], file=None):
    """
        采用subprocess.call执行测试
    """
    args_list.insert(0, cmd)
    args_string_list = map(str, args_list)

    lptlog.info("执行命令: %s" % " ".join(args_string_list))

    if file:
        fd = open(file, "w")
    else:
        fd = None

    status = subprocess.call(args_string_list, stdout=fd, stderr=fd)

    if status > 0:
        lptlog.error("执行 %s 发生Error:" % " ".join(args_string_list))
        raise RunShellError()

    if file:
        fd.close()
Ejemplo n.º 34
0
 def create_job(self, tools_list, parameter, job_attrib={}, resultXmlName="results"):
     '''创建jobs.xml结构
     '''
     DateString = datetime.datetime.now().strftime('%y%m%d%H%M%S')
     #results = 'result_%s.xml' % DateString
     results = '%s_%s.xml' % (resultXmlName, DateString)
     
     job = self.create_node('job', dict({'id':DateString, 'status':"N/A"}, **job_attrib))
     lptlog.info('任务ID: %s' % DateString)
     
     self.create_element(job, 'resultsDB', results)
     lptlog.info('xml results文件:  %s' % results)
     
     lptlog.debug("创建参数")
     conftoxml = ConfigToXml(parameter, self.xml_file)
     conftoxml.add_test_group(tools_list)
     try:
         conftoxml.add_configparser_node(job, 'tool', {'status':'no'})
     except Exception, e:
         #lptlog.exception('parameter.conf转换xml失败')
         #lptlog.error('parameter.conf转换xml失败')
         raise CreatNodeError, 'parameter.conf转换xml失败: %s' % e
Ejemplo n.º 35
0
def run_shell2(cmd, args_list=[], file=None):
    '''
        采用subprocess.call执行测试
    '''
    args_list.insert(0, cmd)
    args_string_list = map(str, args_list)
    
    lptlog.info("执行命令: %s" % " ".join(args_string_list))
                 
    if file:
        fd = open(file, 'w')
    else:
        fd=None
        
    status = subprocess.call(args_string_list, stdout=fd, stderr=fd)
    
    if status > 0:
        lptlog.error("执行 %s 发生Error:" % " ".join(args_string_list))
        raise  RunShellError()
    
    if file:
        fd.close()
Ejemplo n.º 36
0
    def run_once(self):
        tool_node = self.check_tool_result_node()

        lptlog.info("----------开始获取测试参数")

        self.parallels = self.get_config_array(tool_node, "parallel", [1])
        lptlog.info("测试并行组: %s" % lutils.list_to_str(self.parallels))
        self.times = self.get_config_value(tool_node,
                                           "times",
                                           10,
                                           valueType=int)
        if self.times < 3:
            self.times = 10
            lptlog.warning("测试次数必须大于3, 将采用默认值10")
        lptlog.info("测试次数: %d" % self.times)

        cmd = "./Run"

        #执行测试脚本
        lptlog.info("---------运行测试脚本")

        #shutil.rmtree(self.resultsdir)
        os.chdir(self.srcdir)

        #添加测试次数
        args_list = ["-i", "%d" % self.times]

        #添加并行数
        for parallel in self.parallels:
            args_list.append("-c")
            args_list.append("%d" % parallel)
        self.mainParameters["parameters"] = " ".join([cmd] + args_list)
        #utils.run_shell2(cmd, args_list=args_list, file=os.devnull)
        #utils.system_output(cmd, args=args_list)
        #返回根目录

        vars = 'UB_TMPDIR="%s" UB_RESULTDIR="%s"' % (self.tmpdir,
                                                     self.resultsdir)
        self.report_data = utils.system_output(vars + ' %s ' % cmd +
                                               ' '.join(args_list))
        self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%s' % self.iteration)
        utils.open_write_close(self.results_path, self.report_data)

        #数据处理
        self.create_result()
        self.save_results_to_xml()
        #create txt report
        self.txt_report()
Ejemplo n.º 37
0
Archivo: jobs.py Proyecto: Scemoon/lpts
def add_job(tools_list, jobs_xml=JOBS_XML, parameter=default_parameter, job_attrib={}, resultXmlName="results"):
    '''
    创建新任务
    @param tools_list:工具列表
    @type tools_list: list 
    '''
    try:
        lptlog.info('''
                        ~~~~~~~~~~~~~~~~~~~~
                          开始创建测试任务
                        ~~~~~~~~~~~~~~~~~~~~''')
        lptlog.debug("指定测试工具集: %s" % utils.list_to_str(tools_list))
        lptxml.add_job(jobs_xml, tools_list, parameter, job_attrib=job_attrib, resultXmlName=resultXmlName)
        lptlog.info('''
                        ++++++++++++++++++
                         创建测试任务:PASS
                        ++++++++++++++++++''')
    except CreateJobException, e:
        lptlog.debug(e)
        lptlog.error('''
                        ++++++++++++++++++
                         创建测试任务:FAIL
                        ++++++++++++++++++''')
Ejemplo n.º 38
0
    def setup(self):
        '''编译源码,设置程序
        '''

        if not self.check_bin(self.processBin):
            self.tar_src_dir = self.extract_bar()
            os.chdir(self.tar_src_dir)
            self.compile(make_status=True)
            os.chdir(self.lpt_root)

        #检查x11perf安装程序
        if os.path.exists("/usr/bin/x11perf") or os.path.exists(
                "/usr/local/bin/x11perf"):
            lptlog.info("将使用系统x11perf程序")
        else:
            raise ValueError("请安装x11perf程序, xort-x11-apps")
            lptlog.info(
                "系统中并没有安装x11perf程序,由lpt安装x11perf-1.5.3程序,如果系统缺少依赖,请安装提示安装依赖")
            utils.has_file("libX11-devel", "/usr/include/X11/Xlib.h")
            utils.has_file("libXmu-devel", "/usr/include/X11/Xmu/Xmu.h")
            utils.has_file("libXrender-devel",
                           "/usr/include/X11/extensions/Xrender.h")
            self.__compile_x11perf(x11perf_tar="x11perf-1.5.3.tar.bz2")
Ejemplo n.º 39
0
    def run_once(self):
        tool_node = self.check_tool_result_node()

        lptlog.info("----------开始获取测试参数")

        self.parallels =  self.get_config_array(tool_node, "parallel", [1])
        lptlog.info("测试并行组: %s" % lutils.list_to_str(self.parallels))
        self.times = self.get_config_value(tool_node, "times", 10, valueType=int)
        if self.times < 3:
            self.times = 10
            lptlog.warning("测试次数必须大于3, 将采用默认值10")
        lptlog.info("测试次数: %d" % self.times)

        cmd = "./Run"

        #执行测试脚本
        lptlog.info("---------运行测试脚本")

	#shutil.rmtree(self.resultsdir)
        os.chdir(self.srcdir)

        #添加测试次数
        args_list=["-i", "%d" %self.times]

        #添加并行数
        for parallel in self.parallels:
            args_list.append("-c")
            args_list.append("%d" % parallel)
        self.mainParameters["parameters"] = " ".join([cmd]+args_list)
        #utils.run_shell2(cmd, args_list=args_list, file=os.devnull)
        #utils.system_output(cmd, args=args_list)
         #返回根目录

        vars = 'UB_TMPDIR="%s" UB_RESULTDIR="%s"' % (self.tmpdir,
                                                     self.resultsdir)
        self.report_data = utils.system_output(vars + ' %s ' % cmd  + ' '.join(args_list))
        self.results_path = os.path.join(self.resultsdir,
                                         'raw_output_%s' % self.iteration)
        utils.open_write_close(self.results_path, self.report_data)

        #数据处理
        self.create_result()
        self.save_results_to_xml()
        #create txt report
        self.txt_report()
Ejemplo n.º 40
0
 def clean(self):
     '''清理测试环境
     '''
     try:
         if self.tar_src_dir:
             lptlog.info(self.tar_src_dir)
             shutil.rmtree(self.tar_src_dir)
             lptlog.info("清理源目录 %s :PASS" % self.tar_src_dir)
         if self.processBin is not None and os.path.exists(self.processBin):
             os.remove(self.processBin)
             lptlog.info("清理Bin文件 %s :PASS" % self.processBin)
         if self.processBin2 is not None and os.path.exists(
                 self.processBin2):
             os.remove(self.processBin2)
             lptlog.info("清理Bin文件 %s :PASS" % self.processBin2)
     except Exception as e:
         lptlog.warning('清理临时目录或文件:FAIL')
         lptlog.debug(e)
         #raise CleanError, e
     finally:
         os.chdir(self.lpt_root)
Ejemplo n.º 41
0
Archivo: test.py Proyecto: Scemoon/lpts
 def clean(self):
     '''清理测试环境
     '''
     try:
         if self.tar_src_dir:
             shutil.rmtree(self.tar_src_dir)
             lptlog.info("清理源目录 %s :PASS" % self.tar_src_dir)
         if self.processBin is not None and os.path.exists(self.processBin):
             os.remove(self.processBin)
             lptlog.info("清理Bin文件 %s :PASS" % self.processBin)
         if self.processBin2 is not None and os.path.exists(self.processBin2):
             os.remove(self.processBin2)
             lptlog.info("清理Bin文件 %s :PASS" % self.processBin2)
     except Exception, e:
         lptlog.warning('清理临时目录或文件:FAIL')
         lptlog.debug(e)
Ejemplo n.º 42
0
 def clean(self):
     '''清理测试环境
     '''
     try:
         if self.tar_src_dir:
             shutil.rmtree(self.tar_src_dir)
             lptlog.info("清理源目录 %s :PASS" % self.tar_src_dir)
         if self.processBin is not None and os.path.exists(self.processBin):
             os.remove(self.processBin)
             lptlog.info("清理Bin文件 %s :PASS" % self.processBin)
         if self.processBin2 is not None and os.path.exists(
                 self.processBin2):
             os.remove(self.processBin2)
             lptlog.info("清理Bin文件 %s :PASS" % self.processBin2)
     except Exception, e:
         lptlog.warning('清理临时目录或文件:FAIL')
         lptlog.debug(e)
Ejemplo n.º 43
0
    def run(self):
        tool_node = self.check_tool_result_node()
        self.config_file = os.path.join(self.tar_src_dir, self.get_config_value(tool_node, "config_file", "./fio-mixed.job", valueType=str))
        lptlog.info("使用配置文件: %s" % self.config_file)
        self.result_tmp_file = os.path.join(self.tmp_dir, "fio_output")
        self.filesize = self.get_config_value(tool_node, "filesize", "100M", valueType=str)
        lptlog.info("测试读写文件大小: %s" % self.filesize)
        f = open(self.config_file,'r')
        lines = f.read()
        f.close()
        f = open(self.config_file,'w')
        lines = re.sub('size=(\d+)M', 'size=%s'%self.filesize, lines)
        f.write(lines)
        f.close()
        self.mainParameters["parameters"] = "./fio --output %s %s"%(self.result_tmp_file, self.config_file)

        lptlog.info("----------开始测试")

        os.chdir(self.tar_src_dir)
        utils.system("./fio --output %s %s"%(self.result_tmp_file, self.config_file))
Ejemplo n.º 44
0
Archivo: test.py Proyecto: Scemoon/lpts
 def check_bin(self, Binfile, *args):
     '''检查是否存在Binfile
     @return: Boolean
     '''
     lptlog.info("检查测试程序...")
     if args:
         args = list(args)
         args.insert(0, Binfile)
     else:
         args = [Binfile]   
         
     for file in args:
         if file is None:
             return False
         if not os.path.exists(file):
             lptlog.info("未安装  %s " % file)
             return False
         else:
             lptlog.info("已安装 %s " % file )
             continue
     return True
Ejemplo n.º 45
0
    def check_bin(self, Binfile, *args):
        """检查是否存在Binfile
        @return: Boolean
        """
        lptlog.info("检查测试程序...")
        if args:
            args = list(args)
            args.insert(0, Binfile)
        else:
            args = [Binfile]

        for file in args:
            if file is None:
                return False
            if not os.path.exists(file):
                lptlog.info("未安装  %s " % file)
                return False
            else:
                lptlog.info("已安装 %s " % file)
                continue
        return True
Ejemplo n.º 46
0
 def run(self):
     '''
     '''
     tool_node = self.check_tool_result_node()
     lptlog.info("----------开始获取测试参数")
     self.parallels = [1]
     self.times = self.get_config_value(tool_node, "times", 10, valueType=int)
     lptlog.info("测试次数: %d" % self.times)
     cmd = "./Run"
     args_list = ["graphics", "-i", "%d" % self.times]
     #运行unixbench程序,进入unixbench 根目录, 清理环境
     os.chdir(self.tar_src_dir)
     os.system("rm -rf results/*")
     
     #执行测试程序
     lptlog.info("---------运行测试脚本")
     self.mainParameters["parameters"] = " ".join([cmd]+args_list)
     utils.run_shell2(cmd, args_list=args_list, file=os.devnull)
  
     #返回根目录
     os.chdir(self.lpt_root)
Ejemplo n.º 47
0
 def run(self):
     
     tool_node = self.check_tool_result_node()
         
     lptlog.info("----------开始获取测试参数")
     
     self.times = self.get_config_value(tool_node, "times", 10, valueType=int)
     lptlog.info("测试次数: %d" % self.times)     
  
     self.parallels = [1]
         
     cmd = "./Run"
     args_list = ["ubgears", "-i", "%d" % self.times]
     self.mainParameters["parameters"] = " ".join([cmd]+args_list) 
     #运行unixbench程序,进入unixbench 根目录
     os.chdir(self.tar_src_dir)
     utils.system("rm -rf results/*")
     lptlog.info("---------运行测试脚本")
     utils.run_shell2(cmd, args_list=args_list, file=os.devnull)
 
     os.chdir(self.lpt_root)
Ejemplo n.º 48
0
Archivo: test.py Proyecto: Scemoon/lpts
 def compile(self, configure_status=False, configure_para='', 
             make_status=False, make_para='', 
             make_install_status=False, make_install_para=''):
     '''
     安装源码包,执行configure、make、make install等操作
     @param configure_status:判断是否需要configrue
     @param configure_para:configrue的参数
     @param make_status:判断是否需要make
     @param make_para:make 操作需要的参数
     @param make_install_status: 判断是否需要make install
     '''
             
     if configure_status:
         lptlog.info("源码包进行configure")
         utils.configure(extra=configure_para, configure='./configure')
             
     if make_status:
         lptlog.info("源码包进行make")
         utils.make(extra=make_para, make='make')
             
     if make_install_status:
         lptlog.info("源码包进行make install")
         utils.make(extra='install '+make_install_para, make='make')
Ejemplo n.º 49
0
 def run(self):
 
     tool_node = self.check_tool_result_node()
         
     lptlog.info("----------获取测试参数")
     
     cmd = self.processBin
     args = ['-B', 'fileio',  '-c', os.path.join(self.tmp_dir, 'loadfiles/client.txt'), '-R', '999999.99']
     
         #获取测试目录
     testdir = self.get_config_testdir(tool_node)
     args.append("-D")
     args.append(testdir)
         
         #获取设备,并尝试挂载到testdir
     devices_status = self.get_config_devices(tool_node, testdir)
         
     self.times = self.get_config_value(tool_node, "times", 5, valueType=int)
     lptlog.info("测试次数: %d " % self.times)
     
     
     self.parallel_type = self.get_config_value(tool_node, "parallel_type", "process", valueType=str)
     lptlog.info("测试并行方式: %s" % self.parallel_type)
     
     self.parallels = self.get_config_array(tool_node, "parallel", [4])
     lptlog.info("测试并行: %s" % utils.list_to_str(self.parallels))
     if self.parallel_type  not in ("threads", "process"):
         self.parallel_type = "process"
     runtime = self.get_config_value(tool_node, 'runtime', 300, valueType=int)
     lptlog.info("测试时长: %s s" % runtime)
     args.append("-t")
     args.append("%d" % runtime)
     
         
     warnuptime = self.get_config_value(tool_node, 'warnuptime', 120, valueType=int)
     if warnuptime > runtime:
         lptlog.warning("warnuptime 大于 runtime, warnuptime = runtime/5")
         warnuptime = runtime/5
     lptlog.info("预热时长: %s s" % warnuptime)
     args.append("--warmup=%d" % warnuptime)
     
     self.mainParameters["parameters"] = " ".join(["dbench"]+args)
     lptlog.info("----------运行测试脚本")
     for parallel in self.parallels:
         lptlog.info("运行 %s 并行" % parallel)
         parallel_args = []
             
         if self.parallel_type == "threads":
             parallel_args.append("--clients-per-process=%d" % parallel)
             parallel_args.append("1")
         else:
             parallel_args.append(str(parallel))
             
         for iter in range(self.times):
             lptlog.info("第 %s 次测试" % (iter+1))
             tmp_file = os.path.join(self.tmp_dir, "%s_%s_%s.out" % (self.tool, parallel, iter+1))
                
                 #清除buffer
             method.clean_buffer()
             utils.run_shell2(self.processBin, args_list=args+parallel_args, file=tmp_file)
             lptlog.info("%d 并行  第 %d 次测试,测试数据保存在: %s " % (parallel, iter+1, tmp_file))
Ejemplo n.º 50
0
    def run_once(self):
        tool_node = self.check_tool_result_node()
        self.mainParameters["parameters"] = "stream_mu"
        lptlog.info("-----------开始获取测试参数")
        testmode = self.get_config_value(tool_node, "testmode", "default", valueType=str)
        lptlog.info("测试模式: %s" % testmode)

        self.parallels = self.get_config_array(tool_node, "parallel", [1])
        lptlog.info("测试并行数组: %s" % ",".join(map(str, self.parallels)))

        self.times = self.get_config_value(tool_node, "times", 5, valueType=int)
        lptlog.info("测试次数: %d" % self.times )
        if testmode == 'custom':
            cmd = "./stream_mu"

        else:
            cmd = "./stream" 
            self.parallels = [1]

        lptlog.info("----------运行测试脚本")
        os.chdir(self.srcdir)
        #执行测试程序
        for parallel in self.parallels:
            if parallel == 1:
                pass
            else:
                os.environ['OMP_NUM_THREADS'] = str(parallel)
            for iter in range(self.times):
                #tmp_result_file = os.path.join(self.lpttmpdir, "stream_%d_%d.out" %(parallel, iter+1))
                #utils.run_shell2(cmd, args_list=[], file=tmp_result_file)
                #self.report_data = utils.system_output(cmd)
                self.results_path = os.path.join(self.resultsdir, "stream_%d_%d.out" %(parallel, iter+1))
                lutils.run_shell2(cmd, args_list=[], file=self.results_path)
                lptlog.info('并行数 %d, 第 %d 测试:PASS' % (parallel, iter+1))
                #utils.open_write_close(self.results_path, self.report_data)	

	#create result list
        self.create_result()
	#save to result.xml
        self.save_results_to_xml()
	#create txt report
        self.txt_report()
Ejemplo n.º 51
0
Archivo: jobs.py Proyecto: zhyh329/lpts
                       resultXmlName=resultXmlName)
        lptlog.info('''
                        ++++++++++++++++++
                         创建测试任务:PASS
                        ++++++++++++++++++''')
    except CreateJobException, e:
        lptlog.debug(e)
        lptlog.error('''
                        ++++++++++++++++++
                         创建测试任务:FAIL
                        ++++++++++++++++++''')
        #lptlog.exception('')

    finally:
        lptlog.info('''
                        ~~~~~~~~~~~~~~~~~~~~
                          创建测试任务结束
                        ~~~~~~~~~~~~~~~~~~~~''')


def usage():
    print '''
	Usage: jobs.py [options] args
	options: -h --help, 帮助信息
             	 -t --test, 指定测试测试工具
		 -g --group 指定测试工具组,用空格隔开,如"stream lmbench"
        '''
    sys.exit()


def getopts(argv=sys.argv):
    '''
Ejemplo n.º 52
0
 def run(self):
 
     tool_node = self.check_tool_result_node()
         
     lptlog.info("----------获取测试参数")
     
     cmd = self.processBin
     #args = ['-B', 'fileio',  '-c', os.path.join(self.tmp_dir, 'loadfiles/client.txt'), '-R', '999999.99']
     args = ['-c', os.path.join(self.tmp_dir, 'client.txt'), '-R', '999999.99']
     
         #获取测试目录
     testdir = self.get_config_testdir(tool_node)
     args.append("-D")
     args.append(testdir)
         
         #获取设备,并尝试挂载到testdir
     devices_status = self.get_config_devices(tool_node, testdir)
         
     self.times = self.get_config_value(tool_node, "times", 5, valueType=int)
     lptlog.info("测试次数: %d " % self.times)
     
     
     self.parallel_type = self.get_config_value(tool_node, "parallel_type", "process", valueType=str)
     lptlog.info("测试并行方式: %s" % self.parallel_type)
     
     self.parallels = self.get_config_array(tool_node, "parallel", [4])
     lptlog.info("测试并行: %s" % utils.list_to_str(self.parallels))
     if self.parallel_type  not in ("threads", "process"):
         self.parallel_type = "process"
     runtime = self.get_config_value(tool_node, 'runtime', 300, valueType=int)
     lptlog.info("测试时长: %s s" % runtime)
     args.append("-t")
     args.append("%d" % runtime)
     
         
     #warnuptime = self.get_config_value(tool_node, 'warnuptime', 120, valueType=int)
     #if warnuptime > runtime:
     #    lptlog.warning("warnuptime 大于 runtime, warnuptime = runtime/5")
     #    warnuptime = runtime/5
     #lptlog.info("预热时长: %s s" % warnuptime)
     #args.append("--warmup=%d" % warnuptime)
     
     self.mainParameters["parameters"] = " ".join(["dbench"]+args)
     lptlog.info("----------运行测试脚本")
     for parallel in self.parallels:
         lptlog.info("运行 %s 并行" % parallel)
         parallel_args = []
             
         if self.parallel_type == "threads":
             parallel_args.append("--clients-per-process=%d" % parallel)
             parallel_args.append("1")
         else:
             parallel_args.append(str(parallel))
             
         for iter in range(self.times):
             lptlog.info("第 %s 次测试" % (iter+1))
             tmp_file = os.path.join(self.tmp_dir, "%s_%s_%s.out" % (self.tool, parallel, iter+1))
                
                 #清除buffer
             method.clean_buffer()
             utils.run_shell2(self.processBin, args_list=args+parallel_args, file=tmp_file)
             lptlog.info("%d 并行  第 %d 次测试,测试数据保存在: %s " % (parallel, iter+1, tmp_file))
Ejemplo n.º 53
0
 def setup(self):
     '''编译源码,设置程序
     '''
     if not self.check_bin(self.processBin):
         self.tar_src_dir = self.extract_bar()
         os.chdir(self.tar_src_dir)
         os.system("./autogen.sh")
         self.compile(configure_status=True, make_status=True)
         utils.copy(os.path.join(self.tar_src_dir, 'dbench'), self.processBin)
         lptlog.info('loadfiles-0')
         lptlog.info(os.path.join(self.tmp_dir, "loadfiles"))
         if not os.path.exists(os.path.join(self.tmp_dir, "client.txt")):
             lptlog.info('loadfiles-1')
             lptlog.info(os.path.join(self.tar_src_dir, 'client.txt'))
             lptlog.info(os.path.join(self.tmp_dir, "loadfiles"))
             #utils.copy(os.path.join(self.tar_src_dir, 'loadfiles'), os.path.join(self.tmp_dir, "loadfiles"))
             utils.copy(os.path.join(self.tar_src_dir, 'client.txt'), os.path.join(self.tmp_dir, "client.txt"))
             lptlog.info('loadfiles-2')
         os.chdir(self.lpt_root) 
Ejemplo n.º 54
0
    def run(self):

        tool_node = self.check_tool_result_node()

        lptlog.info("----------开始获取测试参数")

        speed_mount_status = False
        args = ["-i", "0", "-i", "1", "-i", "2"]

        self.testmode = self.get_config_value(tool_node,
                                              "testmode",
                                              os.path.join(
                                                  self.tmp_dir, "speed"),
                                              valueType=str)
        if self.testmode not in ("speed", "throughput"):
            self.testmode = "speed"
        lptlog.info("测试模式: %s" % self.testmode)

        testdir = self.get_config_testdir(tool_node)
        #获取设备,并尝试挂载到testdir,返回True或者False
        devices_status = self.get_config_devices(tool_node, testdir)

        filesize = self.get_config_value(tool_node, "filesize", "10g")
        if not utils.check_size_format(filesize):
            lptlog.warning("%s 格式 error,将采用默认大小10g" % filesize)
            filesize = "10g"
        lptlog.info("测试文件大小: %s" % filesize)
        args.append("-s")
        args.append(filesize)

        blocksize = self.get_config_value(tool_node, "blocksize", "4k")
        if not utils.check_size_format(blocksize, match="[\d]+k?"):
            lptlog.warning("blocksize=%s 格式 error,将采用默认大小4k" % blocksize)

        lptlog.info("测试块大小: %s" % blocksize)
        args.append("-r")
        args.append(blocksize)

        self.times = self.get_config_value(tool_node,
                                           "times",
                                           5,
                                           valueType=int)
        direct_status = self.get_config_value(tool_node,
                                              "directio",
                                              "False",
                                              valueType=str)
        if direct_status == "True":
            args.append("-I")
            lptlog.info("DirectIO: True")

        self.parallel_type = self.get_config_value(tool_node,
                                                   "parallel_type",
                                                   "process",
                                                   valueType=str)
        if self.parallel_type not in ("threads", "process"):
            self.parallel_type = "process"
        lptlog.info("测试并行方式: %s" % self.parallel_type)

        self.parallels = self.get_config_array(tool_node, "parallel", [4])
        lptlog.info("测试并行: %s" % utils.list_to_str(self.parallels))

        if self.testmode == "speed":
            self.parallels = [1]
        #运行测试程序,要求保存结果到tmp目录,result_file命令为iozone_$parallel_type_$iter.out
        self.mainParameters["parameters"] = " ".join(["iozone"] + args)
        lptlog.info("----------运行测试脚本")
        for parallel in self.parallels:
            parallel_args = []
            lptlog.info("%s 并行测试" % parallel)
            if self.testmode == 'throughput':
                parallel_args.append("-t")
                parallel_args.append(str(parallel))
                parallel_args.append("-F")
                for num in range(parallel):
                    parallel_args.append(
                        os.path.join(testdir, "iozone_%s_%s_%s") %
                        (self.testmode, parallel, num + 1))

                if self.parallel_type == "threads":
                    parallel_args.append("-T")

            else:
                # if devices_status:
                #  parallel_args.append("-U")
                #   parallel_args.append(testdir)

                parallel_args.append("-f")
                parallel_args.append("%s/iozone_test_file" % testdir)

            for iter in range(self.times):
                lptlog.info("第 %d 次测试" % (iter + 1))
                iozone_iter_result_file = os.path.join(
                    self.tmp_dir,
                    "iozone_%s_%d_%d.out" % (self.testmode, parallel,
                                             (iter + 1)))

                #清除缓冲
                method.clean_buffer()
                utils.run_shell2(self.processBin,
                                 args_list=args + parallel_args,
                                 file=iozone_iter_result_file)
                lptlog.info("%s %s方式, %s并行, 第%d次测试数据保存在 %s 中" %
                            (self.tool, self.testmode, parallel,
                             (iter + 1), iozone_iter_result_file))
Ejemplo n.º 55
0
def report(result_xml, resultDir, tools_list=None, 
            reportname=None, format='xls', chart=False):
    '''report 方法'''
    lptlog.info('''
                        ~~~~~~~~~~~~~~~~~~~~
                          开始创建测试报告
                        ~~~~~~~~~~~~~~~~~~~~''')
    if  reportname is None:
        reportname = "LPTResult_%s.%s" %(datetime.datetime.now().strftime('%y-%m-%d_%H:%M:%S'), format)
    elif reportname.split(".")[-1] in ('txt', 'xls', 'doc', 'pdf'):
        reportname = reportname
    else:
        reportname = "%s.%s" %(reportname, format)
        
    report_file = os.path.join(resultDir, reportname)
    
    if not tools_list:
        tools_list = lptxml.get_result_tools(result_xml)
        if tools_list is None :
            lptlog.warning("%s 中无测试数据" % result_xml)
            raise ValueError, "result.xml: %s" % result_xml
        
    lptlog.info("测试报告工具集:  %s" % utils.list_to_str(tools_list))
    lptlog.info("测试报告格式: %s" % format)
    lptlog.info("测试报告名称:  %s" % reportname)
        
    #lptreport.report(result_xml, tools_list, report_file, format)
    if format == "xls":
        lptreport.xls_report(result_xml, tools_list, report_file, chart=chart)
    elif format == "txt":
        lptreport.txt_report(result_xml, tools_list, report_file)
    else:
        pass    
        
    if format=='txt':
        lptlog.info("Report File: %s*.txt" % report_file.split(".txt")[0])
    else:
         lptlog.info("Report File: %s" % report_file)
        
    lptlog.info('''
                        ~~~~~~~~~~~~~~~~~~~~
                          创建测试报告结束
                        ~~~~~~~~~~~~~~~~~~~~''')
Ejemplo n.º 56
0
    def run_once(self):

        tool_node = self.check_tool_result_node()
        lptlog.info("----------开始获取测试参数")

        self.games = self.get_config_array(tool_node, "games", [64, 128, 256])
        lptlog.info("测试games组: %s" % lutils.list_to_str(self.games))
        self.times = self.get_config_value(tool_node,
                                           "times",
                                           18,
                                           valueType=int)
        lptlog.info("测试次数: %s" % self.times)

        cmd = "./pingpong.sh"

        #执行测试程序
        os.chdir(self.srcdir)
        self.mainParameters["parameters"] = " ".join(
            ["pprun", '-c', "%d" % self.times, '-t', "games"])
        lptlog.info("----------运行测试脚本")
        for game in self.games:
            lptlog.info("执行 %s games" % game)
            args = [
                '-c',
                "%d" % self.times, '-t',
                "%d" % game, '-d', self.resultsdir
            ]
            result_tmp_file = os.path.join(self.resultsdir,
                                           "%d.pingpong" % game)
            command = cmd + " " + " ".join(args)
            utils.system(command)
            #self.results_path = os.path.join(self.resultsdir, 'stream_%d_%d.out' % (parallel, iter+1))
            #utils.open_write_close(result_tmp_file, self.report_data)

            #lutils.run_shell2(cmd, args_list=args, file=result_tmp_file)
            lptlog.info("%d games测试数据保存到: %s" % (game, result_tmp_file))

        self.create_result()
        #save to result.xml
        self.save_results_to_xml()
        #create txt report
        self.txt_report()
Ejemplo n.º 57
0
 def run(self):
 
     tool_node = self.check_tool_result_node()
         
     lptlog.info("----------开始获取测试参数")
     
     cmd = self.processBin
     args = ['-u', os.getuid(),  '-m', 'lpt', '-q']
     
         #获取测试目录
     testdir = self.get_config_value(tool_node, "testdir", os.path.join(self.tmp_dir, "testdir"), valueType=str)
     if os.path.exists(testdir):
         if not os.path.isdir(testdir):
             lptlog.warning("%s 不是有效目录,将采用 /home/%u/testdir 目录" % testdir)
             testdir = "/home/%s/testdir" % getpass.getuser()
             os.makedirs(testdir, stat.S_IRWXU)
     else:
         os.makedirs(testdir, stat.S_IRWXU)
         testdir = os.path.abspath(testdir)
     args.append("-d")
     args.append(testdir)
     lptlog.info("测试目录: %s" % testdir)
         
         #获取设备
         
     devices = self.get_config_value(tool_node, "devices", "Nodevice", valueType=str)
     lptlog.info("测试分区: %s " % devices)
     if not os.path.exists(devices):
         lptlog.debug("%s 不存在" % devices)
     else:
         try:
             if not os.path.ismount(testdir):
                 util.system("mount %s %s" % (devices, testdir))
             else:
                 lptlog.debug("%s 已经挂载到 %s 目录" % (devices, testdir))
         except Exception:
             lptlog.warning("mount %s %s 失败,请确认分区是否已经格式化!!" % (devices, testdir))
     
         #获取测试内存大小
     memory = self.get_config_value(tool_node, "memory", sysinfo.get_memory_size(), valueType=str)
     if not utils.check_size_format(memory, match="\d+[kKmMgGtT]?"):
         lptlog.warning("测试内存配置error, 将采用系统内存")
         memory = sysinfo.get_memory_size()
         lptlog.debug("系统内存大小:%s" % memory)
     
               
        #获取测试文件大小
     filesize = self.get_config_value(tool_node, "filesize", "10g", valueType=str)
     if not utils.check_size_format(filesize, match="\d+[kKmMgGtT]?"):
         lptlog.warning("%s 格式 error,将采用默认大小10g" % filesize)
         filesize = "10g"
         
     if float(utils.custom_format(memory)) * 2 > float(utils.custom_format(filesize)):
         lptlog.warning("测试需求:测试内存*2 小于 文件大小,但实际相反,  将降低测试内存大小为测试文件的1/2" )
         memory = float(utils.custom_format(filesize))/2
         memory = utils.custom_format(memory, auto=True)
     
     lptlog.info("测试内存大小:%s" % memory)
     lptlog.info("测试文件大小: %s" % filesize)           
     args.append("-r")
     args.append(memory)
     
     #获取block大小
     blocksize = self.get_config_value(tool_node, "blocksize", "4k", valueType=str)
     if not utils.check_size_format(blocksize, match="\d+k?"):
         lptlog.warning("blocksize=%s 格式 error,将采用默认大小8k" % blocksize)
         blocksize = "8k"
                  
     args.append("-s")
     args.append("%s:%s" %(filesize, blocksize))
     lptlog.info("测试块大小: %s" % blocksize)
     
     small_files_num = self.get_config_value(tool_node, "small_files_num", 0, valueType=int)                
     small_file_size = self.get_config_value(tool_node, "small_file_size", "1k", valueType=str) 
     if not small_file_size in ("1k", "2k", "4k", "8k", "16k", "32k", "64k", "128k", "256k"):
         lptlog.warning("small_file_size=%s 格式error,请输入整型数字, 将采用默认值1k" % small_file_size)
     else:
         small_file_size = "1k"
     
     small_files_dirs = self.get_config_value(tool_node, "small_files_dirs", 0, valueType=int)
                     
     if small_files_num == "0":
         args.append("-n")
         args.append("0")
     else:
         args.append("-n")
         args.append("%s:%s:%s:%d" %(small_files_num, small_file_size, small_file_size, small_files_dirs))
     
     lptlog.info("小文件数: %s k, 小文件大小: %s, 测试目录: %s" % (small_files_num, small_file_size,  small_files_dirs))
         
     self.times = self.get_config_value(tool_node, "times", 5, valueType=int)
     lptlog.info("测试次数: %d " % self.times)
     args.append("-x")
     args.append("%d" % self.times)            
         
     no_buffer = self.get_config_value(tool_node, "no_buffer", "False", valueType=str)
    
     if no_buffer == "True":
         lptlog.info("no_buffer=True")
         args.append("-b")
    
     direct_io = self.get_config_value(tool_node, "direct_io", "False")
     if direct_io == "True":
         args.append("-D")
         lptlog.info("direct_io=True")
     
            
     #运行测试程序,要求保存结果到tmp目录,result_file命令为iozone_$parallel_type_$iter.out
     self.mainParameters["parameters"] = utils.list_to_str(["bonnie++"]+args, ops=" ")
         #清除缓冲
     method.clean_buffer()
     lptlog.info("----------运行测试脚本")
     utils.run_shell2(self.processBin, args_list=args, file=os.path.join(self.tmp_dir, "bonnie.out"))
     lptlog.info("%s 测试数据保存在 %s 中"  %  (self.tool, os.path.join(self.tmp_dir, "bonnie.out")))
Ejemplo n.º 58
0
Archivo: run.py Proyecto: Scemoon/lpts
     
 if not tools_list:
     lptlog.debug("未指定测试工具,将默认执行job中未执行成功的测试工具")  
     test_tools = map(jobs.get_tool_name, no_exec_tools_nodes_list)
 else: #python 2.7 #tools = filter(lambda x:job_node.find("tool[@id='%s']" % x).get('status') == "no", tools_list) #python 2.6 #no_exec_tools = map(lambda y:y.get('id'), jobs.get_noexec_tools_nodes(job_node)) #tools = filter(lambda x:no_exec_tools.count(x)>0, tools_list)
     test_tools = [ tool for tool in no_exec_tools if tool in tools_list]
     
     if not test_tools:
         #lptlog.warning('指定运行的测试工具已经全部执行完毕, 请重新创建任务')
         raise TestOK, '指定运行的测试工具已经全部执行完毕, 请重新创建任务'
     else:
         tools_string = " ".join(test_tools)
         lptlog.debug("尚未执行完毕的测试工具集:%s" % tools_string)
    
 for tool in test_tools:
     lptlog.info(__BEGIN_MSG % tool)
     try:
         control.run(tool, jobs_xml, job_node, clean=clean)
     except Exception, e:
         lptlog.debug(e)
         lptlog.error('''
                 ----------------------------------
                 +       %s 测试:FAIL    +
                 ----------------------------------
                 ''' % tool) 
         lptlog.info(__END_MSG % tool)
         #lptlog.exception("")
         if test_tools[-1] == tool:
             raise TestOK, "Test Over, but Some Case FAIL"
         else:
             continue