def generate_report(xml_file, report_dir): xml_parser = FunkLoadXmlParser(1.5) xml_parser.parse(xml_file) options = _Options(xml_file=xml_file, report_dir=report_dir, html=True, with_percentiles=True, apdex_t=1.5) html_path = RenderHtml(xml_parser.config, xml_parser.stats, xml_parser.error, xml_parser.monitor, xml_parser.monitorconfig, options)() return html_path
def run(cls, root_path, test, base_url, workers=[], cycles=DEFAULT_CYCLES, duration=10): logging.debug("run bench") assert isinstance(test, TestConfig), "The test argument must be of type wight.worker.config.TestConfig" # fl-run-bench --distribute --distribute-workers=localhost -u http://www.something.com -c 10:20:30:40:50 -D 30 --simple-fetch geo.py GeoTests.test_geo arguments = [test.module, "%s.%s" % (test.class_name, test.test_name)] keyword_arguments = dict( # keyword arguments u=base_url, simple_fetch=True, c=":".join([str(cycle) for cycle in cycles[test.pressure]]), feedback_endpoint=join(root_path, "%s_%s" % (test.class_name, test.test_name)), # sh.py options _env={ "PYTHONPATH": "$PYTHONPATH:%s:%s" % (join(root_path.rstrip("/")), join(root_path.rstrip("/"), "bench")) }, _cwd=join(root_path, "bench"), _tty_in=True, _tty_out=True, ) logging.debug("creating arguments: %s" % str(keyword_arguments)) if workers: keyword_arguments["distribute"] = True if test.deps: keyword_arguments["distributed-packages"] = " ".join(['"%s"' % package for package in test.deps]) logging.debug("save config") cfg = BenchConfiguration( test_name=test.test_name, title=test.title, description=test.description, duration=duration, log_path=root_path, workers=workers, ) cfg.calculate_timeout(len(cycles[test.pressure])) cfg.save(join(root_path, "bench", "%s.conf" % test.class_name)) logging.debug("config saved") try: logging.debug("running bench") result = fl_run_bench(*arguments, **keyword_arguments) logging.debug("bench run") except ErrorReturnCode: err = sys.exc_info()[1] logging.error("run bench error: %s" % err) return FunkLoadTestRunResult(1, err.stderr + err.stdout, log=err.stderr, result=None, config=None) try: with open(join(root_path, "bench", "funkload.log")) as fl_log: logging.debug("readind log") log = fl_log.read() xml_path = join(root_path, "bench", "funkload.xml") if workers: logging.debug("merge resulting") MergeResultFiles( [join(root_path, "worker_%s-funkload.xml" % index) for index in range(len(workers))], xml_path ) parser = FunkLoadXmlParser(1.5) logging.debug("parse xml") parser.parse(xml_path) return FunkLoadTestRunResult( result.exit_code, result.stdout + result.stderr, log=log, result=parser.stats, config=parser.config ) except Exception: err = sys.exc_info()[1] logging.error("Parse error: %s" % err) return FunkLoadTestRunResult( 1, "Result STDOUT: %s\nResult STDERR: %s\nResult Parsing Error: %s" % (result.stdout, result.stderr, str(err)), log=None, result=None, config=None, )
def decode_result_performance(config_file_path): if os.path.isfile(config_file_path): config_parser=ConfigParser.ConfigParser() config_parser.read(config_file_path) xml_path=config_parser.get('bench','result_path') if os.path.isfile(xml_path): cycles=config_parser.get('bench','cycles').split(":") #print cycles xml_parser=FunkLoadXmlParser() xml_parser.parse(xml_path) #print xml_parser.stats response_list=[] test_list=[] for each in xml_parser.stats: phase=xml_parser.stats[each] #print "cycle for %s"%str(cycles[int(each)]) for each_key in phase: if each_key=='response': response=phase[each_key] #print 'Response:',response.max,response.min,response.total/float(response.count),response.total,response.count,response.success,response.error response_list.append((response.max,response.min,response.total/float(response.count),response.total,response.count,response.success,response.error)) if each_key=='test': test=phase[each_key] #print 'Test: ',test.max,test.min,test.total/float(test.count),test.total,test.count,test.success,test.error test_list.append((test.max,test.min,test.total/float(test.count),test.total,test.count,test.success,test.error)) """if each_key=='response_step': response_list=phase[each_key] count=0 total=0 success=0 error=0 all_time=[] for k in response_list: er = response_list[k] all_time.append(er.total) total+=er.total count+=1 success+=er.success error+=er.error print "Response: ",max(all_time),min(all_time),total/float(count),success,error """ #print "======================================" #print cycles temp=[] for each in cycles: temp.append(int(each)) cycles=sorted(temp,reverse=True) #print ":".join(str(x) for x in cycles) #print test_list #print response_list Dict={} column=['max_time','min_time','avg_time','total_time','count','success','error'] temp=[{'cycles':":".join(str(x) for x in cycles)}] for i in range(0,7): #print ":".join(str(each[i]) for each in test_list) temp.append({column[i]:":".join(str(each[i]) for each in test_list)}) temp.append({'result_type':'test'}) Dict.update({'test':temp}) temp=[{'cycles':":".join(str(x) for x in cycles)}] for i in range(0,7): #print ":".join(str(each[i]) for each in response_list) temp.append({column[i]:":".join(str(each[i]) for each in response_list)}) temp.append({'result_type':'response'}) Dict.update({'response':temp}) return Dict else: return False else: return False
def run(cls, root_path, test, base_url, workers=[], cycles=DEFAULT_CYCLES, duration=10): logging.debug("run bench") assert isinstance( test, TestConfig ), "The test argument must be of type wight.worker.config.TestConfig" #fl-run-bench --distribute --distribute-workers=localhost -u http://www.something.com -c 10:20:30:40:50 -D 30 --simple-fetch geo.py GeoTests.test_geo arguments = [test.module, "%s.%s" % (test.class_name, test.test_name)] keyword_arguments = dict( # keyword arguments u=base_url, simple_fetch=True, c=":".join([str(cycle) for cycle in cycles[test.pressure]]), feedback_endpoint=join(root_path, "%s_%s" % (test.class_name, test.test_name)), # sh.py options _env={ "PYTHONPATH": '$PYTHONPATH:%s:%s' % (join(root_path.rstrip('/')), join(root_path.rstrip('/'), "bench")) }, _cwd=join(root_path, 'bench'), _tty_in=True, _tty_out=True) logging.debug("creating arguments: %s" % str(keyword_arguments)) if workers: keyword_arguments["distribute"] = True if test.deps: keyword_arguments["distributed-packages"] = ' '.join( ['"%s"' % package for package in test.deps]) logging.debug("save config") cfg = BenchConfiguration(test_name=test.test_name, title=test.title, description=test.description, duration=duration, log_path=root_path, workers=workers) cfg.calculate_timeout(len(cycles[test.pressure])) cfg.save(join(root_path, 'bench', '%s.conf' % test.class_name)) logging.debug("config saved") try: logging.debug("running bench") result = fl_run_bench(*arguments, **keyword_arguments) logging.debug("bench run") except ErrorReturnCode: err = sys.exc_info()[1] logging.error("run bench error: %s" % err) return FunkLoadTestRunResult(1, err.stderr + err.stdout, log=err.stderr, result=None, config=None) try: with open(join(root_path, 'bench', 'funkload.log')) as fl_log: logging.debug("readind log") log = fl_log.read() xml_path = join(root_path, 'bench', 'funkload.xml') if workers: logging.debug("merge resulting") MergeResultFiles([ join(root_path, 'worker_%s-funkload.xml' % index) for index in range(len(workers)) ], xml_path) parser = FunkLoadXmlParser(1.5) logging.debug("parse xml") parser.parse(xml_path) return FunkLoadTestRunResult(result.exit_code, result.stdout + result.stderr, log=log, result=parser.stats, config=parser.config) except Exception: err = sys.exc_info()[1] logging.error("Parse error: %s" % err) return FunkLoadTestRunResult( 1, "Result STDOUT: %s\nResult STDERR: %s\nResult Parsing Error: %s" % (result.stdout, result.stderr, str(err)), log=None, result=None, config=None)