From 855c8800cabcbfaee157e221ddf04cc0b18f385f Mon Sep 17 00:00:00 2001 From: shaoshian Date: Tue, 20 Dec 2016 14:16:48 +0800 Subject: [PATCH] ui add sysbench Signed-off-by: shaoshian Signed-off-by: root --- analyzer/analyzer.py | 43 +++- analyzer/analyzer_remote.py | 37 +++ benchmarking/mod/bblock/__init__.py | 2 +- benchmarking/mod/bblock/sysbench.py | 334 ++++++++++++++++++++++++++++ benchmarking/mod/benchmark.py | 1 + benchmarking/run_cases.py | 2 + conf/pre_test.py | 2 + conf/prepare_mysql.sh | 134 +++++++++++ conf/run_sysbench.sh | 74 ++++++ vm-scripts/prepare-vm.sh | 7 +- vm-scripts/secret.xml | 2 +- webui/static/js/Common.js | 12 +- webui/templates/index.html | 1 + 13 files changed, 643 insertions(+), 8 deletions(-) create mode 100644 benchmarking/mod/bblock/sysbench.py create mode 100644 conf/pre_test.py create mode 100644 conf/prepare_mysql.sh create mode 100755 conf/run_sysbench.sh diff --git a/analyzer/analyzer.py b/analyzer/analyzer.py index aa37257..ee01911 100644 --- a/analyzer/analyzer.py +++ b/analyzer/analyzer.py @@ -131,7 +131,10 @@ def process_data(self): os.mkdir(self.workpath) all_node = [] - for node in self.cluster["osds"] + self.cluster["client"]: + all_nodes = set(self.cluster["osds"] + self.cluster["client"]) + if case_type == "sysbench": + all_nodes = set(self.cluster["vclient"]) + for node in all_nodes: common.printout("LOG","note "+ node + " start analysis") common.scp(self.cluster["user"],node,remote_file,self.cluster["tmp_dir"]) common.scp(self.cluster["user"],node,remote_file1,self.cluster["tmp_dir"]) @@ -341,7 +344,7 @@ def get_execute_time(self): def summary_result(self, data): # generate summary - benchmark_tool = ["fio", "cosbench", "vdbench"] + benchmark_tool = ["fio", "cosbench", "vdbench","sysbench"] data["summary"]["run_id"] = {} res = re.search('^(\d+)-(\w+)-(\w+)-(\w+)-(\w+)-(\w+)-(\w+)-(\d+)-(\d+)-(\w+)$',data["session_name"]) if not res: @@ -471,6 +474,8 @@ def _process_data(self, node_name): result.update(res) if 'cosbench' in dir_name: workload_result.update(self.process_cosbench_data("%s/%s/%s" %(dest_dir, node_name, dir_name), dir_name)) + if 'sysbench' in dir_name: + workload_result.update(self.process_sysbench_data("%s/%s/%s" %(dest_dir, node_name, dir_name), node_name, dir_name)) if '_sar.txt' in dir_name: result.update(self.process_sar_data("%s/%s/%s" % (dest_dir, node_name, dir_name))) if 'totals.html' in dir_name: @@ -779,6 +784,40 @@ def process_iostat_data(self, node, path): result[output]["disk_num"] = disk_num return result + def process_sysbench_data(self, path,node_name, dirname): + result = {} + sysbench_data = {} + runtime_tmp = path.replace(self.all_conf_data.get("dest_dir"),'').split('/') + while '' in runtime_tmp: + runtime_tmp.remove('') + runtime = runtime_tmp[0].split('-')[-2] + with open(path,"r") as fd: + self.data = fd.readlines() + self.sysbench_data = {} + if len(self.data) != 0: + for i in self.data: + self.line = i.strip('\n').split(':') + while '' in self.line: + self.line.remove('') + if len(self.line) == 2: + self.sysbench_data[self.line[0].strip()] = self.line[1].strip() + output_sysbench_data = OrderedDict() + output_sysbench_data['read_lat'] = '%.3f'%float(self.sysbench_data["avg"].strip("ms")) + output_sysbench_data["read_iops"] = '%.3f'%(int(self.sysbench_data["read"])/int(runtime)) + output_sysbench_data["read_bw"] = '0.000' + output_sysbench_data['read_runtime'] = '%.3f'%float(runtime) + output_sysbench_data['write_lat'] = '%.3f'%float(self.sysbench_data["avg"].strip("ms")) + output_sysbench_data["write_iops"] = '%.3f'%(int(self.sysbench_data["write"])/int(runtime)) + output_sysbench_data["write_bw"] = '0.000' + output_sysbench_data["99.99%_lat"] = '%.3f'%float(self.sysbench_data["approx. 99 percentile"].strip("ms")) + output_sysbench_data['write_runtime'] = '%.3f'%float(runtime) + output_sysbench_data['lat_unit'] = 'msec' + output_sysbench_data['runtime_unit'] = 'sec' + output_sysbench_data['bw_unit'] = 'MB/s' + result[node_name] = {} + result[node_name]["sysbench"] = output_sysbench_data + return result + def process_vdbench_data(self, path, dirname): result = {} vdbench_data = {} diff --git a/analyzer/analyzer_remote.py b/analyzer/analyzer_remote.py index 25613c9..b750179 100644 --- a/analyzer/analyzer_remote.py +++ b/analyzer/analyzer_remote.py @@ -361,6 +361,9 @@ def _process_data(self): if 'cosbench' in dir_name: self.common.printout("LOG","Processing %s_%s" % (self.whoami, dir_name)) workload_result.update(self.process_cosbench_data("%s/%s" %(dest_dir, dir_name), dir_name)) + if 'sysbench' in dir_name: + self.common.printout("LOG","Processing %s_%s" % (self.whoami, dir_name)) + workload_result.update(self.process_sysbench_data("%s/%s/%s" %(dest_dir, node_name, dir_name), node_name, dir_name)) if '_sar.txt' in dir_name: self.common.printout("LOG","Processing %s_%s" % (self.whoami, dir_name)) result.update(self.process_sar_data("%s/%s" % (dest_dir, dir_name))) @@ -671,6 +674,40 @@ def process_iostat_data(self, node, path): result[output]["disk_num"] = disk_num return result + def process_sysbench_data(self, path,node_name, dirname): + result = {} + sysbench_data = {} + runtime_tmp = path.replace(self.all_conf_data.get("dest_dir"),'').split('/') + while '' in runtime_tmp: + runtime_tmp.remove('') + runtime = runtime_tmp[0].split('-')[-2] + with open(path,"r") as fd: + self.data = fd.readlines() + self.sysbench_data = {} + if len(self.data) != 0: + for i in self.data: + self.line = i.strip('\n').split(':') + while '' in self.line: + self.line.remove('') + if len(self.line) == 2: + self.sysbench_data[self.line[0].strip()] = self.line[1].strip() + output_sysbench_data = OrderedDict() + output_sysbench_data['read_lat'] = '%.3f'%float(self.sysbench_data["avg"].strip("ms")) + output_sysbench_data["read_iops"] = '%.3f'%(int(self.sysbench_data["read"])/int(runtime)) + output_sysbench_data["read_bw"] = '0.000' + output_sysbench_data['read_runtime'] = '%.3f'%float(runtime) + output_sysbench_data['write_lat'] = '%.3f'%float(self.sysbench_data["avg"].strip("ms")) + output_sysbench_data["write_iops"] = '%.3f'%(int(self.sysbench_data["write"])/int(runtime)) + output_sysbench_data["write_bw"] = '0.000' + output_sysbench_data["99.99%_lat"] = '%.3f'%float(self.sysbench_data["approx. 99 percentile"].strip("ms")) + output_sysbench_data['write_runtime'] = '%.3f'%float(runtime) + output_sysbench_data['lat_unit'] = 'msec' + output_sysbench_data['runtime_unit'] = 'sec' + output_sysbench_data['bw_unit'] = 'MB/s' + result[node_name] = {} + result[node_name]["sysbench"] = output_sysbench_data + return result + def process_vdbench_data(self, path, dirname): result = {} vdbench_data = {} diff --git a/benchmarking/mod/bblock/__init__.py b/benchmarking/mod/bblock/__init__.py index 07dd2f1..d564632 100644 --- a/benchmarking/mod/bblock/__init__.py +++ b/benchmarking/mod/bblock/__init__.py @@ -1,3 +1,3 @@ -__all__ = ['qemurbd', 'fiorbd', 'vdbench'] +__all__ = ['qemurbd', 'fiorbd', 'vdbench','sysbench'] diff --git a/benchmarking/mod/bblock/sysbench.py b/benchmarking/mod/bblock/sysbench.py new file mode 100644 index 0000000..136e88e --- /dev/null +++ b/benchmarking/mod/bblock/sysbench.py @@ -0,0 +1,334 @@ +from ..benchmark import * +from collections import OrderedDict +import itertools +from multiprocessing import Process +import time + +class SysBench(Benchmark): + def load_parameter(self): + super(self.__class__, self).load_parameter() + self.cluster["vclient"] = self.all_conf_data.get_list("list_vclient") + disk_num_per_client = self.cluster["disk_num_per_client"] + self.volume_size = self.all_conf_data.get("volume_size") + self.instance_list = self.cluster["vclient"] + self.testjob_distribution(disk_num_per_client, self.instance_list) + + def prepare_result_dir(self): + #1. prepare result dir + self.get_runid() + vdisk = self.benchmark["vdisk"].split('/')[-1] + self.benchmark["section_name"] = "sysbench-%s-%s-qd%s-%s-%s-%s-%s" % (self.benchmark["iopattern"], self.benchmark["block_size"], self.benchmark["qd"], self.benchmark["volume_size"],self.benchmark["rampup"], self.benchmark["runtime"], vdisk) + self.benchmark["dirname"] = "%s-%s-%s" % (str(self.runid), str(self.benchmark["instance_number"]), self.benchmark["section_name"]) + self.cluster["dest_dir"] = "/%s/%s" % (self.cluster["dest_dir"], self.benchmark["dirname"]) + + if common.remote_dir_exist( self.cluster["user"], self.cluster["head"], self.cluster["dest_dir"] ): + common.printout("ERROR","Output DIR %s exists" % (self.cluster["dest_dir"])) + sys.exit() + + common.pdsh(self.cluster["user"] ,["%s" % (self.cluster["head"])], "mkdir -p %s" % (self.cluster["dest_dir"])) + + def prepare_images(self): + pass + ''' + user = self.cluster["user"] + dest_dir = self.cluster["tmp_dir"] + controller = self.cluster["head"] + rbd_count = len(self.instance_list) + rbd_size = self.all_conf_data.get("volume_size") + if rbd_count and rbd_size: + super(self.__class__, self).create_image(rbd_count, rbd_size, 'rbd') + else: + common.printout("ERROR","need to set rbd_volume_count and volune_size in all.conf") + + #create image xml + common.printout("LOG","create rbd volume vm attach xml") + common.scp(user, controller, "%s/vm-scripts" % (self.pwd), "/opt/"); + common.scp(user, controller, "%s/conf" % (self.pwd), "/opt/"); + common.pdsh(user, [controller], "cd /opt/vm-scripts; echo 3 | bash create-volume.sh create_disk_xml", "check_return") + common.rscp(user, controller, "%s/vm-scripts/" % (self.pwd), "/opt/vm-scripts/vdbs/"); + common.printout("LOG","Distribute vdbs xml") + for client in self.cluster["testjob_distribution"]: + common.scp(user, client, "../vm-scripts/vdbs", dest_dir) + + #attach to vm + self.attach_images(self.cluster["testjob_distribution"]) + + #init + common.printout("LOG","rbd initialization finished") + ''' + + def prerun_check(self): + super(self.__class__, self).prerun_check() + pass + '''#1. check is vclient alive + user = self.cluster["user"] + vdisk = self.benchmark["vdisk"] + planed_space = str(len(self.instance_list) * int(self.volume_size)) + "MB" + common.printout("LOG","Prerun_check: check if rbd volume be intialized") + if not self.check_rbd_init_completed(planed_space): + common.printout("WARNING","rbd volume initialization has not be done") + self.prepare_images() + + nodes = [] + for client in self.benchmark["distribution"]: + nodes.extend( self.benchmark["distribution"][client] ) + + #common.printout("LOG","Prerun_check: check if fio installed in vclient") + #common.pdsh(user, nodes, "fio -v") + common.printout("LOG","Prerun_check: check if rbd volume attached") + need_to_attach = False + stdout, stderr = common.pdsh(user, nodes, "fdisk -l %s" % vdisk, option="check_return") + res = common.format_pdsh_return(stdout) + if len(nodes) != len(res.keys()): + need_to_attach = True + if need_to_attach: + common.printout("WARNING","vclients are not attached with rbd volume") + self.attach_images() + common.printout("WARNING","vclients attached rbd volume now") + common.printout("LOG","Prerun_check: check if sysstat installed on %s" % nodes) + common.pdsh(user, nodes, "mpstat") + ''' + + def attach_images(self, to_attach_dict = None): + pass + ''' + user = self.cluster["user"] + vdisk = self.benchmark["vdisk"] + dest_dir = self.cluster["tmp_dir"] + if not to_attach_dict: + to_attach_dict = self.benchmark["distribution"] + for client in to_attach_dict: + nodes = to_attach_dict[client] + for node in nodes: + common.printout("LOG","Attach rbd image to %s" % node) + stdout, stderr = common.pdsh(user, [node], "fdisk -l %s" % vdisk, option="check_return") + res = common.format_pdsh_return(stdout) + if node not in res: + common.pdsh(user, [client], "cd %s/vdbs; virsh attach-device %s %s.xml" % (dest_dir, node, node), except_returncode=1) + ''' + + def detach_images(self): + pass + ''' + user = self.cluster["user"] + vdisk = self.benchmark["vdisk"] + tmp_vdisk = re.search('/dev/(\w+)',vdisk) + vdisk_suffix = tmp_vdisk.group(1) + #for client in self.cluster["testjob_distribution"]: + for client in self.benchmark["distribution"]: + nodes = self.benchmark["distribution"][client] + for node in nodes: + common.printout("LOG","Detach rbd image from %s" % node) + stdout, stderr = common.pdsh(user, [node], "df %s" % vdisk, option="check_return") + if not stderr: + common.pdsh(user, [client], "virsh detach-disk %s %s" % (node, vdisk_suffix), except_returncode=1) + ''' + + def prepare_mysql_on_node(self,node): + user = self.cluster["user"] + #common.pdsh(user, [node], "cd /%s/;bash prepare_mysql.sh" %self.cluster["tmp_dir"]) + common.pdsh(user, [node], "cd /%s/;python pre_test.py" %self.cluster["tmp_dir"]) + + def run_sysbench_on_node(self,node,threads,readonly,dist_type): + user = self.cluster["user"] + common.pdsh(user, [node], "cd %s; ./run_sysbench.sh %s %s %s %s %s %s %s %s %s" %(self.cluster["tmp_dir"],'oltp','on',threads,readonly,dist_type,self.benchmark["runtime"],0,99,self.cluster["tmp_dir"])) + + + def prepare_run(self): + super(self.__class__, self).prepare_run() + user = self.cluster["user"] + dest_dir = self.cluster["tmp_dir"] + #common.printout("LOG","Prepare_run: distribute fio.conf to vclient") + #for client in self.benchmark["distribution"]: + # for vclient in self.benchmark["distribution"][client]: + # common.scp(user, vclient, "../conf/fio.conf", self.cluster["tmp_dir"]) + self.cleanup() + #1. copy shell code to all node + #copy mysql_deploy_file and sysbench_shell to vms's tmp_dir + common.printout("LOG","copy mysql_deploy_file and sysbench_shell to vms's tmp_dir") + for vclient in self.cluster["vclient"]: + sh_path = os.path.join(os.path.dirname(os.getcwd()),'conf') + print "%s/run_sysbench.sh" %sh_path, "%s/" %self.cluster["tmp_dir"],vclient + #common.scp(user, vclient, "%s/prepare_mysql.sh" %sh_path, "%s/" %self.cluster["tmp_dir"]) + common.scp(user, vclient, "%s/pre_test.py" %sh_path, "%s/" %self.cluster["tmp_dir"]) + common.scp(user, vclient,"%s/run_sysbench.sh" %sh_path,"%s/" %self.cluster["tmp_dir"]) + + #2. set all vclient mysql + common.printout("LOG","start set all vclient mysql!") + self.all_prepare_mysql_proc = [] + for vclient in self.cluster["vclient"]: + p_proc = Process(target=self.prepare_mysql_on_node,args=(vclient,)) + p_proc.daemon = True + p_proc.start() + self.all_prepare_mysql_proc.append((p_proc,vclient)) + while(len(self.all_prepare_mysql_proc)!=0): + time.sleep(5) + self.preparing_nodes = '' + for p_proc,vclient in self.all_prepare_mysql_proc: + if not p_proc.is_alive(): + self.all_prepare_mysql_proc.remove((p_proc,vclient)) + if self.preparing_nodes == '': + self.preparing_nodes += vclient + else: + self.preparing_nodes += ","+vclient + common.printout("WARNING","Nodes:%s are still in preparing ."%self.preparing_nodes) + common.printout("LOG","Set all vclient mysql completed!") + + def run(self): + super(self.__class__, self).run() + user = self.cluster["user"] + waittime = int(self.benchmark["runtime"]) + int(self.benchmark["rampup"]) + dest_dir = self.cluster["tmp_dir"] + monitor_interval = self.cluster["monitoring_interval"] + nodes = [] + for client in self.benchmark["distribution"]: + nodes.extend(self.benchmark["distribution"][client]) + + #run log collect process + common.printout("LOG", "Start Log Collect Process!") + for node in nodes: + common.pdsh(user, [node], "date > %s/`hostname`_process_log.txt" % (dest_dir)) + common.pdsh(user, [node], "top -c -b -d %s > %s/`hostname`_top.txt & echo `date +%s`' top start' >> %s/`hostname`_process_log.txt" % (monitor_interval, dest_dir, '%s', dest_dir)) + common.pdsh(user, [node], "mpstat -P ALL %s > %s/`hostname`_mpstat.txt & echo `date +%s`' mpstat start' >> %s/`hostname`_process_log.txt" % (monitor_interval, dest_dir, '%s', dest_dir)) + common.pdsh(user, [node], "iostat -p -dxm %s > %s/`hostname`_iostat.txt & echo `date +%s`' iostat start' >> %s/`hostname`_process_log.txt" % (monitor_interval, dest_dir, '%s', dest_dir)) + common.pdsh(user, [node], "sar -A %s > %s/`hostname`_sar.txt & echo `date +%s`' sar start' >> %s/`hostname`_process_log.txt" % (monitor_interval, dest_dir, '%s', dest_dir)) + #3. run sysbench on all vms + common.printout("LOG", "Start Running SysBench!") + params = {} + for i in self.benchmark["poolname"].split(","): + params[i.split('=')[0]] = i.split('=')[1] + #params:$test_type $init_rng $num_thread $oltp_read_only $oltp_dist_type $timeout $max_requests $percentile $resultsdir + if len(params) == 3: + self.all_runcase_proc = [] + for node in nodes: + run_proc = Process(target=self.run_sysbench_on_node,args=(node,str(params['num-threads']),params['oltp-read-only'],params['oltp-dist-type'],)) + run_proc.daemon = True + run_proc.start() + self.all_runcase_proc.append((run_proc,node)) + while(len(self.all_runcase_proc)!=0): + time.sleep(5) + self.running_nodes = '' + for run_proc,node in self.all_runcase_proc: + if not run_proc.is_alive(): + self.all_runcase_proc.remove((run_proc,node)) + if self.running_nodes == '': + self.running_nodes += node + else: + self.running_nodes += ","+node + common.printout("WARNING","Nodes:%s are still in running sysbench ."%self.running_nodes) + else: + common.printout("ERROR","params:num-threads,oltp-read-only or oltp-dist-type is NULL !!") + common.printout("LOG", "SysBench test is completed!") + + + def chkpoint_to_log(self, log_str): + super(self.__class__, self).chkpoint_to_log(log_str) + dest_dir = self.cluster["tmp_dir"] + user = self.cluster["user"] + nodes = [] + for client in self.benchmark["distribution"]: + nodes.extend(self.benchmark["distribution"][client]) + common.pdsh(user, nodes, "echo `date +%s`' %s' >> %s/`hostname`_process_log.txt" % ('%s', log_str, dest_dir)) + + def cleanup(self): + super(self.__class__, self).cleanup() + #1. clean the tmp res dir + user = self.cluster["user"] + nodes = [] + for client in self.benchmark["distribution"]: + nodes.extend(self.benchmark["distribution"][client]) + common.pdsh(user, nodes, "rm -f %s/*.txt" % self.cluster["tmp_dir"]) + common.pdsh(user, nodes, "rm -f %s/*.log" % self.cluster["tmp_dir"]) + common.pdsh(user, nodes, "rm -f %s/*.res" % self.cluster["tmp_dir"]) + + def wait_workload_to_stop(self): + pass + '''common.printout("LOG","Waiting Workload to complete its work") + nodes = [] + for client in self.benchmark["distribution"]: + nodes.extend(self.benchmark["distribution"][client]) + max_check_times = 30 + cur_check = 0 + while self.check_fio_pgrep(nodes): + if cur_check > max_check_times: + break + time.sleep(10) + cur_check += 1 + common.printout("LOG","Workload completed") + ''' + + def stop_data_collecters(self): + super(self.__class__, self).stop_data_collecters() + user = self.cluster["user"] + dest_dir = self.cluster["tmp_dir"] + for client in self.benchmark["distribution"]: + nodes = self.benchmark["distribution"][client] + common.pdsh(user, nodes, "killall -9 sar; echo `date +%s`' sar stop' >> %s/`hostname`_process_log.txt" % ('%s', dest_dir), option = "check_return") + common.pdsh(user, nodes, "killall -9 mpstat; echo `date +%s`' mpstat stop' >> %s/`hostname`_process_log.txt" % ('%s', dest_dir), option = "check_return") + common.pdsh(user, nodes, "killall -9 iostat; echo `date +%s`' iostat stop' >> %s/`hostname`_process_log.txt" % ('%s', dest_dir), option = "check_return") + common.pdsh(user, nodes, "killall -9 top; echo `date +%s`' top stop' >> %s/`hostname`_process_log.txt" % ('%s', dest_dir), option = "check_return") + + def stop_workload(self): + user = self.cluster["user"] + for client in self.benchmark["distribution"]: + nodes = self.benchmark["distribution"][client] + common.pdsh(user, nodes, "killall -9 fio", option = "check_return") + common.printout("LOG","Workload stopped, detaching rbd volume from vclient") + self.chkpoint_to_log("fio stop") + try: + self.detach_images() + except KeyboardInterrupt: + common.printout("WARNING","Caught KeyboardInterrupt, stop detaching") + + def archive(self): + super(self.__class__, self).archive() + user = self.cluster["user"] + head = self.cluster["head"] + dest_dir = self.cluster["dest_dir"] + for client in self.benchmark["distribution"]: + nodes = self.benchmark["distribution"][client] + for node in nodes: + common.bash("mkdir -p %s/raw/%s" % (dest_dir, node)) + common.rscp(user, node, "%s/raw/%s/" % (dest_dir, node), "%s/*.res" % self.cluster["tmp_dir"]) + common.rscp(user, node, "%s/raw/%s/" % (dest_dir, node), "%s/*.txt" % self.cluster["tmp_dir"]) + common.cp("/etc/ceph/ceph.conf", "%s/conf/" % dest_dir) + common.bash("mkdir -p %s/conf/fio_errorlog/;find %s/raw/ -name '*_fio_errorlog.txt' | while read file; do cp $file %s/conf/fio_errorlog/;done" % (dest_dir, dest_dir, dest_dir)) + + def generate_benchmark_cases(self, testcase): + return True + + def parse_benchmark_cases(self, testcase): + p = testcase + testcase_dict = { + "instance_number":p[0], "volume_size":p[1], "iopattern":p[2], + "block_size":p[3], "qd":p[4], "rampup":p[5], + "runtime":p[6], "vdisk":p[7], "poolname":p[8] + } + if len(p) >= 10: + testcase_dict["description"] = p[9] + else: + testcase_dict["description"] = "" + + return testcase_dict + + def check_sb_pgrep(self, nodes, sb_node_num = 1, check_type="jobnum"): + user = self.cluster["user"] + stdout, stderr = common.pdsh(user, nodes, "pgrep -x sysbench", option = "check_return") + res = common.format_pdsh_return(stdout) + if res != []: + sb_running_job_num = 0 + sb_running_node_num = 0 + for node in res: + sb_running_node_num += 1 + sb_running_job_num += len(str(res[node]).strip().split('\n')) + if (check_type == "jobnum" and sb_running_job_num >= sb_node_num) or (check_type == "nodenum" and sb_running_node_num >= sb_node_num): + common.printout("WARNING","%d sb job still runing" % sb_running_job_num) + return True + else: + if check_type == "nodenum": + common.printout("WARNING","Expecting %d nodes run sb, detect %d node runing" % (sb_node_num, sb_running_node_num)) + if check_type == "jobnum": + common.printout("WARNING","Expecting %d nodes run sb, detect %d node runing" % (sb_node_num, sb_running_job_num)) + return False + common.printout("WARNING","Detect no sysbench job runing" % (sb_node_num, sb_running_node_num)) + return False diff --git a/benchmarking/mod/benchmark.py b/benchmarking/mod/benchmark.py index 5241629..bfd9b91 100644 --- a/benchmarking/mod/benchmark.py +++ b/benchmarking/mod/benchmark.py @@ -60,6 +60,7 @@ def go(self, testcase, tuning): common.printout("LOG","Post Process Result Data") try: + common.printout("LOG","%s"%self.cluster["dest_dir"]) analyzer.main(['--path', self.cluster["dest_dir"], 'process_data']) except: common.printout("ERROR","analyzer failed, pls try cd analyzer; python analyzer.py --path %s process_data " % self.cluster["dest_dir"]) diff --git a/benchmarking/run_cases.py b/benchmarking/run_cases.py index e8a78c6..57deb73 100644 --- a/benchmarking/run_cases.py +++ b/benchmarking/run_cases.py @@ -83,6 +83,8 @@ def main(args): benchmark = hook.Hook() if testcase["engine"] == "vdbench": benchmark = vdbench.VdBench() + if testcase["engine"] == "sysbench": + benchmark = sysbench.SysBench() if not benchmark: common.printout("ERROR","Unknown benchmark engine") try: diff --git a/conf/pre_test.py b/conf/pre_test.py new file mode 100644 index 0000000..d3be16f --- /dev/null +++ b/conf/pre_test.py @@ -0,0 +1,2 @@ +import time +time.sleep(30) diff --git a/conf/prepare_mysql.sh b/conf/prepare_mysql.sh new file mode 100644 index 0000000..4003057 --- /dev/null +++ b/conf/prepare_mysql.sh @@ -0,0 +1,134 @@ +#!/bin/bash + + +#echo "127.0.0.1 `hostname`" >> /etc/hosts + +mount_dir=/root/test +install_dir=${mount_dir}/mysql/ +default_dir=/var/lib/mysql/ +filename=/etc/mysql/my.cnf + +size=2G +disk=/dev/vdb + +function remove_log_data { + local dir=$1 + rm -f ${dir}/ib_logfile* + rm -f ${dir}/ibdata* +} + +function start_mysql_timeout { + local wait_time=150 + timeout $wait_time service mysql start + if [ $? -ne 0 ]; then + return 1 + else + return 0 + fi +} + +function stop_mysql_with_retry { + local cnt=0 + while [ $cnt -lt 10 ]; do + service mysql stop + killall -KILL mysql mysqld_safe mysqld + service mysql status | grep "stop/waiting" + if [ $? -eq 0 ]; then + return; + fi + let cnt++ + sleep 1 + done + echo "Can't stop MySQL, exit!" + exit 1 +} + +loop_cnt=0 +max_retry=5 + +while [ $loop_cnt -lt $max_retry ]; do + fdisk -l | grep vdb + if [ $? -ne 0 ]; then + echo "vdb not found! exit!" + exit 1 + else + (echo o; echo w) | fdisk /dev/vdb + fi + + fdisk -l | grep vda2 + if [ $? -ne 0 ]; then + echo "vda2 not found! exit!" + exit 1 + fi + + mkfs.ext4 /dev/vda2 + mkdir -p $mount_dir + mount /dev/vda2 $mount_dir + mkdir -p $install_dir + chmod -R 777 $install_dir + + stop_mysql_with_retry + remove_log_data $default_dir + remove_log_data $install_dir + + cd /etc/apparmor.d/ + mv usr.sbin.mysqld disable/ + service apparmor reload + cd /root/ + + sed -i '/^innodb_data_file_path/d' $filename + sed -i '/^innodb_data_home_dir/d' $filename + sed -i '/^user.*/d' $filename + sed -i '/^datadir.*/d' $filename + sed -i "/\[mysqld\]/a user=root" $filename + mysql_install_db --user=root --datadir=$install_dir + + remove_log_data $default_dir + + sed -i "/\[mysqld\]/a datadir="$install_dir"" $filename + + start_mysql_timeout + if [ $? -ne 0 ]; then + echo "[$loop_cnt]: Restart at install mysql to $install_dir!" + let loop_cnt++ + continue + fi + + sleep 2 + + stop_mysql_with_retry + remove_log_data $install_dir + + sed -i "/\[mysqld\]/a innodb_data_file_path="$disk:$size"newraw" $filename + sed -i "/\[mysqld\]/a innodb_data_home_dir=" $filename + start_mysql_timeout + if [ $? -ne 0 ]; then + echo "[$loop_cnt]: Restart at newraw!" + let loop_cnt++ + continue + fi + sleep 2 + stop_mysql_with_retry + + sed -i '/^innodb_data_file_path/d' $filename + sed -i "/^innodb_data_home_dir/a innodb_data_file_path="$disk:$size"raw" $filename + start_mysql_timeout + if [ $? -ne 0 ]; then + echo "[$loop_cnt]: Restart at raw!" + let loop_cnt++ + continue + fi + + sleep 2 + + echo "create database sbtest; CREATE USER 'sbtest'@'localhost'; GRANT ALL PRIVILEGES ON * . * TO 'sbtest'@'localhost'; FLUSH PRIVILEGES;" | mysql -u root -p123456 + if [ $? -ne 0 ]; then + echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');" | mysql -uroot + echo "create database sbtest; CREATE USER 'sbtest'@'localhost'; GRANT ALL PRIVILEGES ON * . * TO 'sbtest'@'localhost'; FLUSH PRIVILEGES;" | mysql -u root -p123456 + fi + + echo -e "\033[32m[$loop_cnt]: Success!\033[0m" + exit 0; +done + +exit 1 diff --git a/conf/run_sysbench.sh b/conf/run_sysbench.sh new file mode 100755 index 0000000..2687451 --- /dev/null +++ b/conf/run_sysbench.sh @@ -0,0 +1,74 @@ +#!/bin/bash +host=localhost +port=3306 +socket=/var/lib/mysql/mysql.sock +user=root +password=123456 +connparams= +test_type=$1 +init_rng=$2 +#threads=$3 +num_thread=$3 +oltp_read_only=$4 +oltp_dist_type=$5 +timeout=$6 +max_requests=$7 +percentile=$8 +resultsdir=$9 + +function usage_exit { + echo -e "usage:\n\t $0 test-type init-rng num-threads oltp-read-only oltp-dist-type max-time max-requests percentile resultsdir" + exit +} + +function main { + # readonly_op=${readonly_op//,/ } + if [ ! "$socket" == "/var/lib/mysql/mysql.sock" ]; then + connparams="--mysql-socket=$socket --mysql-user=$user --mysql-password=$password" + else + connparams="--mysql-host=$host --mysql-port=$port --mysql-user=$user --mysql-password=$password" + fi + + sysbench $connparams --test=oltp prepare + + mkdir -p $resultsdir +# run_num=-1 + +# if [ -f "$resultsdir/.run_number" ]; then +# read run_num < $resultsdir/.run_number +# fi + +# if [ $run_num -eq -1 ]; then +# run_num=1 +# fi + +# if [ $run_num -lt 10 ]; then +# outdir=result-0$run_num +# else +# outdir=result-$run_num +# fi + + mkdir -p $resultsdir + +# run_num=`expr $run_num + 1` +# echo $run_num > $resultsdir/.run_number + + # Run iostat + iostat -dx 10 $(($timeout/10+1)) >> $resultsdir/iostat.$num_thread.res & + + #preapare + sysbench $connparams --test=oltpĀ prepare + # Run sysbench + sysbench $connparams --test=$test_type --init-rng=$init_rng --num-threads=$num_thread --oltp-read-only=$oltp_read_only --oltp-dist-type=$oltp_dist_type --max-time=$timeout --max-requests=$max_requests --percentile=$percentile run | tee -a $resultsdir/$outdir/sysbench.$num_thread.res + sleep 10 + #clean + sysbench $connparams --test=oltp cleanup +} + +echo "$0 $1 $2 $3 $4 $5 $6 $7 $8 $9" + +if [ "$#" != "9" ]; then + usage_exit +fi + +main $test_type $init_rng $num_thread $oltp_read_only $oltp_dist_type $timeout $max_requests $percentile $resultsdir diff --git a/vm-scripts/prepare-vm.sh b/vm-scripts/prepare-vm.sh index 9e0179f..6a16453 100644 --- a/vm-scripts/prepare-vm.sh +++ b/vm-scripts/prepare-vm.sh @@ -120,9 +120,10 @@ vm_num_per_client=$2 img_path_prefix=$3 ip_prefix=$4 cpuset_start=$cpuset -if [ -z "$5" ]; then - ip_fix=201 -fi +#if [ -z "$5" ]; then +# ip_fix=201 +#fi +ip_fix=$5 . ../conf/common.sh get_conf main $cpuset_start $vm_num_per_client $img_path_dir $ip_prefix $ip_fix diff --git a/vm-scripts/secret.xml b/vm-scripts/secret.xml index 5ce6ee0..843b9ce 100644 --- a/vm-scripts/secret.xml +++ b/vm-scripts/secret.xml @@ -1,5 +1,5 @@ - 007032f7-e5a1-4c2d-ae3a-38ecddcbf8cf + 68fa505e-d62a-11e6-9579-001e67519d29 client.admin secret diff --git a/webui/static/js/Common.js b/webui/static/js/Common.js index 9fdbc8f..0a483de 100644 --- a/webui/static/js/Common.js +++ b/webui/static/js/Common.js @@ -485,7 +485,8 @@ function Select_Value(){ ['0(use 0 to initialize container) and 160(as worker)','r(1,100)','write, read','128KB','r(1,100)','100','400','','librados_4MB_write','restart,redeploy,resetPerf'], ['140','10g','seqwrite,seqread,randwrite,randread,readwrite,randrw','4k','64','100','400','','librados_4MB_write','restart,redeploy,resetPerf'], [' ',' ',' ',' ',' ',' ','400','','librados_4MB_write','restart,redeploy,resetPerf'], - ['50','30g','seqwrite,seqread,randwrite,randread,readwrite,randrw','8k','32','30','120','width=10,depth=1,files=10000,threads=16,rdpct=65','librados_4MB_write','restart,redeploy,resetPerf']] + ['50','30g','seqwrite,seqread,randwrite,randread,readwrite,randrw','8k','32','30','120','width=10,depth=1,files=10000,threads=16,rdpct=65','librados_4MB_write','restart,redeploy,resetPerf'], + ['50','30g','seqwrite,seqread,randwrite,randread,readwrite,randrw','8k','32','30','120','num-threads=10,oltp-read-only=off,oltp-dist-type=uniform','librados_4MB_write','restart,redeploy,resetPerf']] var select_value = document.getElementById("recipient_benchmark_engine"); var item = 0 if(select_value.value == "qemurbd"){ @@ -506,6 +507,9 @@ function Select_Value(){ if(select_value.value == "vdbench"){ item = 5; } + if(select_value.value == "sysbench"){ + item = 6; + } var readonly = false; if(select_value.value == "hook"){ readonly = true; @@ -528,6 +532,10 @@ function Select_Value(){ document.getElementById("recipient_parameter").value = "width=10,depth=1,files=10000,threads=16,rdpct=65"; document.getElementById('recipient_parameter').readOnly=false; } + if(select_value.value == "sysbench"){ + document.getElementById("recipient_parameter").value = "num-threads=10,oltp-read-only=off,oltp-dist-type=uniform"; + document.getElementById('recipient_parameter').readOnly=false; + } if(select_value.value == "fiorbd" || select_value.value == "qemurbd"){ document.getElementById("recipient_parameter").value = "rbd"; document.getElementById('recipient_parameter').readOnly=false; @@ -661,6 +669,8 @@ function BenchMarkModel_OK(){ device = "generic" if(benchmark_driver == "vdbench") device = "/dev/vdb" + if(benchmark_driver == "sysbench") + device = "/dev/vdb" if(benchmark_driver == "hook") device = "hook" //if(CheckInput('parameter',parameter) == "true"){ diff --git a/webui/templates/index.html b/webui/templates/index.html index 1a95320..1bbc913 100644 --- a/webui/templates/index.html +++ b/webui/templates/index.html @@ -315,6 +315,7 @@