Exemple #1
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)
Exemple #2
0
def load_module(module_name):
    # Checks if a module has already been loaded
    if module_is_loaded(module_name):
        return False

    utils.system('/sbin/modprobe ' + module_name)
    return True
Exemple #3
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)
Exemple #4
0
 def __init__(self, jobs_xml, job_node, tool, tarball='dbench-4.0.0.tar.bz2'):
     super(TestControl, self).__init__(jobs_xml, job_node, tool, tarball)
     self.processBin = os.path.join(self.bin_dir, 'dbench')
     self.times = None
     self.parallel_type = None
     self.parallels = None
     utils.system("ulimit -n 100000", ignore_status=True)
Exemple #5
0
    def __init__(self, jobs_xml, job_node, tool, tarball='dbench-4.0.0.tar.bz2'):
        super(TestControl, self).__init__(jobs_xml, job_node, tool, tarball)
        self.processBin = os.path.join(self.bin_dir, 'dbench')
        self.times = None
        self.parallel_type = None
        self.parallels = None
	utils.system("ulimit -n 100000", ignore_status=True)
Exemple #6
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)
Exemple #7
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)
Exemple #8
0
def process_is_alive(name_pattern):
    """
    'pgrep name' misses all python processes and also long process names.
    'pgrep -f name' gets all shell commands with name in args.
    So look only for command whose initial pathname ends with name.
    Name itself is an egrep pattern, so it can use | etc for variations.
    """
    return utils.system("pgrep -f '^([^ /]*/)*(%s)([ ]|$)'" % name_pattern,
                        ignore_status=True) == 0
Exemple #9
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
Exemple #10
0
def unload_module(module_name):
    """
    Removes a module. Handles dependencies. If even then it's not possible
    to remove one of the modules, it will trhow an error.CmdError exception.

    :param module_name: Name of the module we want to remove.
    """
    l_raw = utils.system_output("/sbin/lsmod").splitlines()
    lsmod = [x for x in l_raw if x.split()[0] == module_name]
    if len(lsmod) > 0:
        line_parts = lsmod[0].split()
        if len(line_parts) == 4:
            submodules = line_parts[3].split(",")
            for submodule in submodules:
                unload_module(submodule)
        utils.system("/sbin/modprobe -r %s" % module_name)
        logging.info("Module %s unloaded" % module_name)
    else:
        logging.info("Module %s is already unloaded" % module_name)
Exemple #11
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
Exemple #12
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))
Exemple #13
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)
Exemple #14
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)
Exemple #15
0
def ping_default_gateway():
    """Ping the default gateway."""

    network = open('/etc/sysconfig/network')
    m = re.search('GATEWAY=(\S+)', network.read())

    if m:
        gw = m.group(1)
        cmd = 'ping %s -c 5 > /dev/null' % gw
        return utils.system(cmd, ignore_status=True)

    raise error.TestError('Unable to find default gateway')
Exemple #16
0
 def run(self):
     
     tool_node = self.check_tool_result_node()
         
     lptlog.info("-----------开始获取测试参数")
     self.parallels =self.get_config_value(tool_node, "parallel", 1, valueType=int)
     if self.parallels >999:
         lptlog.info("限制并行数小于999, 将采用1")
         self.parallels = 1
     lptlog.info("测试并行数: %d" % self.parallels)
     
     self.times = self.get_config_value(tool_node, "times", 5, valueType=int)
     lptlog.info("测试次数: %d" % self.times)
     
     jobs_sched = self.get_config_value(tool_node, "lmbench_sched", "DEFAULT", valueType=str)
     if jobs_sched not in ("DEFAULT", "BALANCED", "BALANCED_SPREAD", "UNIQUE", "NIQUE_SPREAD"):
         jobs_sched="DEFAULT"
     lptlog.info("调度模式为:%s" % jobs_sched)
     
     testMem = self.get_config_value(tool_node, "testmemory", 1000, valueType=int)
     lptlog.info("指定测试内存为: %sM, 但如果测试内存大于系统可用内存,lmbench将自动计算可用内存" % testMem)
     
     output = self.get_config_value(tool_node, "output", "/dev/tty", valueType=str)
     lptlog.info("lmbench 将打印信息到: %s" % output)
     
     self.mainParameters["parameters"] = "Mem:%dM jobSched:%s" %(testMem, jobs_sched)
     
     lptlog.info("----------运行测试脚本")      
         #执行测试程序
     os.chdir(self.tar_src_dir)
     #Now, 配置测试参数
     utils.system("./config.sh -p %d -j %s -m %d -o %s" %(self.parallels, jobs_sched, testMem, output))
     
     #clean 之前的测试数据
     for rootdir, subdirs, files in os.walk("./results"):
         for dir in subdirs:
             subabsdir = os.path.join(rootdir, dir)
             if os.path.exists(subabsdir):
                 shutil.rmtree(os.path.join(rootdir, dir))
     #run
     for iter in range(self.times):
         utils.system("./run.sh")
         time.sleep(60)
     
     #gen results
     utils.system("./genResults.sh %s" % os.path.join(self.tmp_dir, "lmbench.out"))
Exemple #17
0
    def run(self):
        tool_node = self.check_tool_result_node()
        self.result_tmp_file = os.path.join(self.tmp_dir, "netperf_output")
        self.time = self.get_config_value(tool_node, "time", "100", valueType=int)
        lptlog.info("单项测试时间: %s秒" % self.time)
        self.server_ip = self.get_config_value(tool_node, "server_ip", "127.0.0.1", valueType=str)
        lptlog.info("Server端地址为: %s" % self.server_ip)
        self.password = self.get_config_value(tool_node, "password", "root", valueType=str)
        lptlog.info("使用账户root密码%s登录Server端" % self.password)
        self.mainParameters["parameters"] = "./src/netperf -t TCP_STREAM -H %s -l %s &&"%(self.server_ip, self.time)
        self.mainParameters["parameters"] += "./src/netperf -t UDP_STREAM -H %s -l %s &&"%(self.server_ip, self.time)
        self.mainParameters["parameters"] += "./src/netperf -t TCP_RR -H %s -l %s &&"%(self.server_ip, self.time)
        self.mainParameters["parameters"] += "./src/netperf -t UDP_RR -H %s -l %s &&"%(self.server_ip, self.time)
        self.mainParameters["parameters"] += "./src/netperf -t TCP_CRR -H %s -l %s"%(self.server_ip, self.time)

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

        os.chdir(self.tar_src_dir)
        utils.system("rm %s -f"%self.result_tmp_file)
        utils.system('echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config')
        setup_server_cmd = "sshpass -p '%s' scp src/netserver root@%s:/root"%(self.password, self.server_ip)
        utils.system('rm /root/.ssh/known_hosts -f')
        utils.system('rm /root/netserver -f')
        utils.system(setup_server_cmd)
        lptlog.info("拷贝Netperf Server端到%s"%self.server_ip)
        utils.system("sshpass -p '%s' ssh -lroot %s '%s'"%(self.password, self.server_ip,'pkill -9 netserver || :'))
        utils.system("sshpass -p '%s' ssh -lroot %s '%s'"%(self.password, self.server_ip,'/root/netserver'))
        lptlog.info("启动Server端")
        for i in range(2):
            for test in ['TCP_STREAM','UDP_STREAM','TCP_RR','UDP_RR','TCP_CRR']:
                lptlog.info("开始%s测试%s"%(test,i))
                utils.system("./src/netperf -t %s -H %s -l %s >> %s"%(test, self.server_ip, self.time, self.result_tmp_file))
Exemple #18
0
def clean_buffer():
    try:
        utils.system('echo "3" > /proc/sys/vm/drop_caches')
    except Exception:
        lptlog.warning("非root用户, 清除缓冲失败...")
Exemple #19
0
def clean_buffer():
    try:
        utils.system('echo "3" > /proc/sys/vm/drop_caches')
    except Exception:
        lptlog.warning("非root用户, 清除缓冲失败...")