Ejemplo n.º 1
0
    def run_once(self, dir=None, args=None):
        """
        Runs IOzone with appropriate parameters, record raw results in a per
        iteration raw output file as well as in the results attribute

        :param dir: IOzone file generation dir.
        :param args: Arguments to the iozone program.
        """
        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.lpttmpdir, "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 lutils.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 lutils.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" % lutils.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("----------运行测试脚本")
        cmd = os.path.join(self.srcdir, 'src', 'current', 'iozone')
        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.resultsdir, "iozone_%s_%d_%d.out" % (self.testmode, parallel, (iter+1)) )

                    #清除缓冲
                method.clean_buffer()
                lutils.run_shell2(cmd, 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))

        self.create_result()
        #save to result.xml
        self.save_results_to_xml()
        #create txt report
        self.txt_report()
Ejemplo n.º 2
0
    def run_once(self):
        tool_node = self.check_tool_result_node()
        lptlog.info("----------开始获取测试参数")

        cmd = os.path.join(self.srcdir, "bonnie++")
        args = ['-u', os.getuid(), '-m', 'lpt', '-q']

        #获取测试目录
        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)
        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 lutils.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 lutils.check_size_format(filesize, match="\d+[kKmMgGtT]?"):
            lptlog.warning("%s 格式 error,将采用默认大小10g" % filesize)
            filesize = "10g"

        if float(lutils.custom_format(memory)) * 2 > float(
                lutils.custom_format(filesize)):
            lptlog.warning("测试需求:测试内存*2 小于 文件大小,但实际相反,  将降低测试内存大小为测试文件的1/2")
            memory = float(lutils.custom_format(filesize)) / 2
            memory = lutils.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 lutils.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"] = lutils.list_to_str(["bonnie++"] +
                                                               args,
                                                               ops=" ")
        #清除缓冲
        method.clean_buffer()
        lptlog.info("----------运行测试脚本")
        lutils.run_shell2(cmd,
                          args_list=args,
                          file=os.path.join(self.resultsdir, "bonnie.out"))
        lptlog.info("%s 测试数据保存在 %s 中" %
                    (self.tool, os.path.join(self.resultsdir, "bonnie.out")))

        #create result list
        self.create_result()
        #save to result.xml
        self.save_results_to_xml()
        #create txt report
        self.txt_report()
Ejemplo n.º 3
0
    def run_once(self):
        tool_node = self.check_tool_result_node()

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

        cmd = os.path.join(self.srcdir, 'dbench')
        args = ['-B', 'fileio',  '-c', os.path.join(self.srcdir, '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" % lutils.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.resultsdir, "%s_%s_%s.out" % (self.tool, parallel, iter+1))

                    #清除buffer
                method.clean_buffer()
                lutils.run_shell2(cmd, args_list=args+parallel_args, file=tmp_file)
                lptlog.info("%d 并行  %d 次测试,测试数据保存在: %s " % (parallel, iter+1, tmp_file))
        #create result list
        self.create_result()
        #save to result.xml
        self.save_results_to_xml()
        #create txt report
        self.txt_report()
Ejemplo n.º 4
0
    def run_once(self):
        tool_node = self.check_tool_result_node()
        lptlog.info("----------开始获取测试参数")

        cmd = os.path.join(self.srcdir, "bonnie++")
        args = ['-u', os.getuid(),  '-m', 'lpt', '-q']

            #获取测试目录
        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)
        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 lutils.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 lutils.check_size_format(filesize, match="\d+[kKmMgGtT]?"):
            lptlog.warning("%s 格式 error,将采用默认大小10g" % filesize)
            filesize = "10g"

        if float(lutils.custom_format(memory)) * 2 > float(lutils.custom_format(filesize)):
            lptlog.warning("测试需求:测试内存*2 小于 文件大小,但实际相反,  将降低测试内存大小为测试文件的1/2" )
            memory = float(lutils.custom_format(filesize))/2
            memory = lutils.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 lutils.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"] = lutils.list_to_str(["bonnie++"]+args, ops=" ")
            #清除缓冲
        method.clean_buffer()
        lptlog.info("----------运行测试脚本")
        lutils.run_shell2(cmd, args_list=args, file=os.path.join(self.resultsdir, "bonnie.out"))
        lptlog.info("%s 测试数据保存在 %s 中"  %  (self.tool, os.path.join(self.resultsdir, "bonnie.out")))
	
	#create result list
        self.create_result()
        #save to result.xml
        self.save_results_to_xml()
        #create txt report
        self.txt_report()
Ejemplo n.º 5
0
    def run_once(self, dir=None, args=None):
        """
        Runs IOzone with appropriate parameters, record raw results in a per
        iteration raw output file as well as in the results attribute

        :param dir: IOzone file generation dir.
        :param args: Arguments to the iozone program.
        """
        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.lpttmpdir, "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 lutils.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 lutils.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" % lutils.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("----------运行测试脚本")
        cmd = os.path.join(self.srcdir, 'src', 'current', 'iozone')
        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.resultsdir,
                    "iozone_%s_%d_%d.out" % (self.testmode, parallel,
                                             (iter + 1)))

                #清除缓冲
                method.clean_buffer()
                lutils.run_shell2(cmd,
                                  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))

        self.create_result()
        #save to result.xml
        self.save_results_to_xml()
        #create txt report
        self.txt_report()