refactor testPlan result
This commit is contained in:
parent
a490260d05
commit
def1229fad
|
@ -0,0 +1,63 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="gbk">
|
||||
<title>???--???????????</title>
|
||||
<style type="text/css">
|
||||
body{margin:0;padding:0;font-size:14px;font-family:"????",Arial, Helvetica, sans-serif;}
|
||||
img,ul,li,form,h2,ol{border:0;padding:0;margin:0;list-style:none;}
|
||||
.cl{clear:both;height:0px;line-height:0px;font-size:0px;overflow:hidden;}
|
||||
input{vertical-align:middle;}
|
||||
a:link{color:#0033cc}
|
||||
a:visited{color:#800080;}
|
||||
a:hover{color:#800080;}
|
||||
a:actived{color:#800080;}
|
||||
#content{width:95%;align:center;margin:0 auto 0;}
|
||||
.logo{float:left;width:141px;margin:10px 0 0 0;}
|
||||
.title{float:right;width:;line-height:24px;background:#e5ecf9;margin:20px 0 0 0;padding-left:8px;}
|
||||
.title a{margin-left:320px;}
|
||||
.tip{font-size:18px;margin:25px 0 25px 5px;*margin:25px 0 25px 5px;}
|
||||
.reason{margin:25px 0 33px 5px;*margin:25px 0 30px 5px;}
|
||||
.reason li{line-height:24px;height:24px;}
|
||||
.searchbox{margin:0 0 40px 8px;*margin:0 0 40px 8px;}
|
||||
.help{margin:0 0 100px 5px;}
|
||||
.footer{margin:50px 0 20px 0;*margin:50px 0 20px 0;text-align:center;color:#666666;}
|
||||
.footer a{color:#666666;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table border="0" width="95%" align="center">
|
||||
<tr height="60">
|
||||
<td height="65" valign="top" width="141"><a href="http://www.baidu.com/"><img border="0" src="http://www.baidu.com/search/img/logo.gif" alt="????????" /></a></td>
|
||||
<td valign="bottom">
|
||||
<table border="0" cellspacing="0" cellpadding="0" width="100%">
|
||||
<tr bgcolor="#e5ecf9">
|
||||
<td height="24"> <b class="p1">???????????</b></td>
|
||||
<td class="p2" height="24"><div align="right"><a href="http://www.baidu.com/">??????</a> | <a href="http://www.baidu.com/search/jiqiao.html">????????</a> </div></td>
|
||||
</tr>
|
||||
<tr><td class="p2" height="20" colspan="2"></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="content">
|
||||
<h2 class="tip" style="padding-left:144px"><p>????????????????ÖÎ????!<br><br></p><hr color="#dddddd" size="1"></h2>
|
||||
</div>
|
||||
<div id="content">
|
||||
<ol class="reason" style="padding-left:144px">
|
||||
<li> 1. ?????????????????????</li><br>
|
||||
<li> 2. ????????????????????????<a href="http://www.baidu.com/more/index.html">?????</a>????????????</li><br>
|
||||
<li> 3. ??????????????????</li>
|
||||
<li class="searchbox"><br>
|
||||
<form action="http://www.baidu.com/s" name="f">
|
||||
<input type="text" name="wd" size="35" maxlength="100"><input type="hidden" name="cl" value="3"><input type="hidden" name="tn" value="baiduerr"><input type="submit" value="??????">
|
||||
</form></li>
|
||||
<li class="help">
|
||||
4.?????¦Ê??????ï…???<a href="http://qingting.baidu.com/">??????????</a>??
|
||||
<br><br><br>
|
||||
<b>?????????</b><a href="http://news.baidu.com/">????</a>??<a href="http://tieba.baidu.com/">???</a>??<a href="http://zhidao.baidu.com/">???</a>??<a href="http://music.baidu.com/">????</a>??<a href="http://image.baidu.com/">??</a>??<a href="http://video.baidu.com/">???</a>??<a href="http://map.baidu.com/">???</a>??<a href="http://baike.baidu.com/">???</a>??<a href="http://wenku.baidu.com/">???</a>??<a href="http://www.hao123.com/">hao123</a>
|
||||
</li>??</ol>
|
||||
|
||||
<div class="footer">© 2014 Baidu <a href="http://www.baidu.com/duty/index.html">????????</a></div>
|
||||
</div>
|
||||
</body>
|
||||
</html
|
|
@ -19,6 +19,7 @@ import org.bench4q.master.domain.service.report.ReportService;
|
|||
import org.bench4q.master.exception.Bench4QException;
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
import org.bench4q.share.models.master.MonitorModel;
|
||||
import org.bench4q.share.models.master.ScriptHandleModel;
|
||||
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
|
||||
import org.bench4q.share.models.master.TestPlanModel;
|
||||
import org.bench4q.share.models.master.TestPlanDBModel;
|
||||
|
@ -121,11 +122,11 @@ public class TestPlanController extends BaseController {
|
|||
|
||||
private TestPlanResultModel buildResponseModel(
|
||||
TestPlanStatus currentStatus, UUID testPlanId,
|
||||
List<Integer> scriptIds, List<MonitorModel> monitorModels) {
|
||||
List<ScriptHandleModel> scripts, List<MonitorModel> monitorModels) {
|
||||
TestPlanResultModel result = new TestPlanResultModel();
|
||||
result.setCurrentStatus(currentStatus);
|
||||
result.setTestPlanId(testPlanId);
|
||||
result.setScriptIds(scriptIds);
|
||||
result.setScripts(scripts);
|
||||
result.setMonitorModels(monitorModels);
|
||||
return result;
|
||||
}
|
||||
|
@ -165,6 +166,7 @@ public class TestPlanController extends BaseController {
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/getBehaviorsBrief/{testPlanRunID}/{scriptId}")
|
||||
@ResponseBody
|
||||
public ScriptBehaviorsBriefModel getBehaviorsBrief(
|
||||
|
@ -180,7 +182,6 @@ public class TestPlanController extends BaseController {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/pagesBrief/{testPlanRunId}/{scriptId}")
|
||||
@ResponseBody
|
||||
public ScriptPagesBriefModel getPagesBrief(
|
||||
|
@ -283,5 +284,19 @@ public class TestPlanController extends BaseController {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@RequestMapping(value = "/scriptBrief/{testPlanId}/{scriptId}/latestResult")
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@ResponseBody
|
||||
public ScriptBriefResultModel getLatestScriptResult(
|
||||
@PathVariable UUID testPlanId, @PathVariable int scriptId)
|
||||
throws Bench4QException {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
throw new Bench4QException(HAVE_NO_POWER,
|
||||
"You have not power to get test plan script brief",
|
||||
"/getLatestScriptResult");
|
||||
}
|
||||
return this.getTestPlanScriptResultService()
|
||||
.getLatestScriptBriefResultModel(testPlanId, scriptId);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ public class TestPlanScriptResultService {
|
|||
return new ScriptBehaviorsBriefModel();
|
||||
}
|
||||
|
||||
|
||||
private TestPlanScriptResult doGetLastSampleResult(UUID testPlanId,
|
||||
int scriptId, Class<?> resultType, Session session) {
|
||||
TestPlanScript testPlanScript = this.getTestPlanRepository()
|
||||
|
@ -147,4 +148,16 @@ public class TestPlanScriptResultService {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
public ScriptBriefResultModel getLatestScriptBriefResultModel(
|
||||
UUID testPlanId, int scriptId) {
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
TestPlanScriptResult testPlanScriptResult = this.doGetLastSampleResult(
|
||||
testPlanId, scriptId, ScriptBriefResultModel.class, session);
|
||||
if (testPlanScriptResult == null) {
|
||||
return null;
|
||||
}
|
||||
return (ScriptBriefResultModel) MarshalHelper.tryUnmarshal(
|
||||
ScriptBriefResultModel.class,
|
||||
testPlanScriptResult.getResultContent());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.bench4q.master.domain.factory.BusinessModelMapFactory;
|
|||
import org.bench4q.master.domain.repository.TestPlanRepository;
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
import org.bench4q.share.models.master.MonitorModel;
|
||||
import org.bench4q.share.models.master.ScriptHandleModel;
|
||||
import org.bench4q.share.models.master.TestPlanDBModel;
|
||||
import org.bench4q.share.models.master.TestPlanResultModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -66,11 +67,14 @@ public class TestPlanService {
|
|||
resultModel.setCurrentStatus(TestPlanStatus.valueOf(testPlan
|
||||
.getCurrentStatus()));
|
||||
resultModel.setTestPlanId(runId);
|
||||
List<Integer> scriptIds = new LinkedList<Integer>();
|
||||
List<ScriptHandleModel> scripts = new LinkedList<ScriptHandleModel>();
|
||||
for (TestPlanScript testPlanScript : testPlan.getTestPlanScripts()) {
|
||||
scriptIds.add(testPlanScript.getScript().getId());
|
||||
ScriptHandleModel scriptHandleModel = new ScriptHandleModel(
|
||||
testPlanScript.getScript().getId(), testPlanScript
|
||||
.getScript().getName());
|
||||
scripts.add(scriptHandleModel);
|
||||
}
|
||||
resultModel.setScriptIds(scriptIds);
|
||||
resultModel.setScripts(scripts);
|
||||
List<MonitorModel> monitorModels = new LinkedList<MonitorModel>();
|
||||
for (Monitor monitor : testPlan.getMonitors()) {
|
||||
monitorModels.add(BusinessModelMapFactory.toModel(monitor));
|
||||
|
|
|
@ -91,7 +91,7 @@ public class Test_TestPlanService extends TestBase_MakeUpTestPlan {
|
|||
public void testBuildResponseModel() {
|
||||
TestPlanResultModel responseModel = this.getTestPlanService()
|
||||
.buildResultModel(getTestPlanRunIdUuid());
|
||||
assertEquals(1, responseModel.getScriptIds().size());
|
||||
assertEquals(1, responseModel.getScripts().size());
|
||||
assertEquals(1, responseModel.getMonitorModels().size());
|
||||
assertEquals(getTestPlanRunIdUuid(), responseModel.getTestPlanId());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.bench4q.share.models.master;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class ScriptHandleModel {
|
||||
private Integer scriptId;
|
||||
private String scriptName;
|
||||
|
||||
public ScriptHandleModel() {
|
||||
|
||||
}
|
||||
|
||||
public ScriptHandleModel(Integer scriptId, String scriptName) {
|
||||
this.scriptId = scriptId;
|
||||
this.scriptName = scriptName;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Integer getScriptId() {
|
||||
return scriptId;
|
||||
}
|
||||
|
||||
public void setScriptId(Integer scriptId) {
|
||||
this.scriptId = scriptId;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getScriptName() {
|
||||
return scriptName;
|
||||
}
|
||||
|
||||
public void setScriptName(String scriptName) {
|
||||
this.scriptName = scriptName;
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,7 @@ import org.bench4q.share.enums.master.TestPlanStatus;
|
|||
public class TestPlanResultModel {
|
||||
private UUID testPlanId;
|
||||
private TestPlanStatus currentStatus;
|
||||
private List<Integer> scriptIds;
|
||||
private List<ScriptHandleModel> scripts;
|
||||
private List<MonitorModel> monitorModels;
|
||||
|
||||
@XmlElement(name = "testPlanId")
|
||||
|
@ -34,16 +34,6 @@ public class TestPlanResultModel {
|
|||
this.currentStatus = currentStatus;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "scriptIdList")
|
||||
@XmlElement(name = "scriptId")
|
||||
public List<Integer> getScriptIds() {
|
||||
return scriptIds;
|
||||
}
|
||||
|
||||
public void setScriptIds(List<Integer> scriptIds) {
|
||||
this.scriptIds = scriptIds;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "MonitorModelList")
|
||||
@XmlElement(name = "MonitorModel")
|
||||
public List<MonitorModel> getMonitorModels() {
|
||||
|
@ -54,4 +44,14 @@ public class TestPlanResultModel {
|
|||
this.monitorModels = monitorModels;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "scripts")
|
||||
@XmlElement(name = "script")
|
||||
public List<ScriptHandleModel> getScripts() {
|
||||
return scripts;
|
||||
}
|
||||
|
||||
public void setScripts(List<ScriptHandleModel> scripts) {
|
||||
this.scripts = scripts;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<testResult>
|
||||
<results>
|
||||
<result>
|
||||
<childResults>
|
||||
<name>processorTimePercent</name>
|
||||
<value>使用率</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>privilegedTimePercent</name>
|
||||
<value>系统使用率</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>userTimePercent</name>
|
||||
<value>用户使用率</value>
|
||||
</childResults>
|
||||
<name>cpu</name>
|
||||
<value>cpu</value>
|
||||
</result>
|
||||
<result>
|
||||
<childResults>
|
||||
<name>pagesPerSecond</name>
|
||||
<value>页速率</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>pagesInputPerSecond</name>
|
||||
<value>读页速率</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>pagesOutputPerSecond</name>
|
||||
<value>写页速率</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>availableKiloBytes</name>
|
||||
<value>可用内存(kb)</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>totalKiloBytes</name>
|
||||
<value>总容量(kb)</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>memoryUsedPercent</name>
|
||||
<value>使用率</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>swapKiloBytes</name>
|
||||
<value>交换内存(kb)</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>swapFreeKiloBytes</name>
|
||||
<value></value>
|
||||
</childResults>
|
||||
<name>内存</name>
|
||||
<value>mem</value>
|
||||
</result>
|
||||
<result>
|
||||
<childResults>
|
||||
<name>累计成功数目</name>
|
||||
<value>totalSuccessCountFromBegin</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>累计失败数目</name>
|
||||
<value>totalFailCountFromBegin</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>平均响应时间</name>
|
||||
<value>averageResponseTime</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>最大响应时间</name>
|
||||
<value>maxResponseTime</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>最小响应时间</name>
|
||||
<value>minResponseTime</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>最大吞吐率</name>
|
||||
<value>successThroughputThisTime</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>失败吞吐率</name>
|
||||
<value>failThroughputThisTime</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>响应时间</name>
|
||||
<value>responseTimeDeviationThisTime</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>平均延迟时间</name>
|
||||
<value>averageElapsedTime</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>计划运行时间</name>
|
||||
<value>planedRunningTime</value>
|
||||
</childResults>
|
||||
<childResults>
|
||||
<name>虚拟用户</name>
|
||||
<value>vUserCount</value>
|
||||
</childResults>
|
||||
<name>脚本运行结果</name>
|
||||
<value>scriptBriefResult</value>
|
||||
</result>
|
||||
</results>
|
||||
</testResult>
|
|
@ -0,0 +1,110 @@
|
|||
package org.bench4q.web.api;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
|
||||
import org.bench4q.web.model.ResultInfoModel;
|
||||
import org.bench4q.web.model.TestResult;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws JAXBException {
|
||||
Main main=new Main();
|
||||
try {
|
||||
TestResult testResult = new TestResult();
|
||||
List<ResultInfoModel> results = new LinkedList<ResultInfoModel>();
|
||||
results.add(main.createCpuResult());
|
||||
results.add(main.createMemoryResult());
|
||||
testResult.setResultInfoModels(results);
|
||||
OutputStream os = new FileOutputStream("sut.xml");
|
||||
Marshaller marshaller = JAXBContext.newInstance(TestResult.class)
|
||||
.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||
marshaller.marshal(testResult, os);
|
||||
|
||||
|
||||
results.clear();
|
||||
results.add(main.createScriptResult());
|
||||
testResult.setResultInfoModels(results);
|
||||
OutputStream os1 = new FileOutputStream("script.xml");
|
||||
|
||||
marshaller.marshal(testResult, os1);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private ResultInfoModel createScriptResult() {
|
||||
try {
|
||||
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
||||
resultInfoModel.setName("脚本运行结果");
|
||||
resultInfoModel.setValue("scriptBriefResult");
|
||||
|
||||
List<ResultInfoModel> resultIntems = new LinkedList<ResultInfoModel>();
|
||||
resultIntems.add(new ResultInfoModel("累计成功数目",
|
||||
"totalSuccessCountFromBegin"));
|
||||
resultIntems.add(new ResultInfoModel("累计失败数目",
|
||||
"totalFailCountFromBegin"));
|
||||
resultIntems.add(new ResultInfoModel("平均响应时间",
|
||||
"averageResponseTime"));
|
||||
resultIntems.add(new ResultInfoModel("最大响应时间", "maxResponseTime"));
|
||||
resultIntems.add(new ResultInfoModel("最小响应时间", "minResponseTime"));
|
||||
resultIntems.add(new ResultInfoModel("最大吞吐率",
|
||||
"successThroughputThisTime"));
|
||||
resultIntems.add(new ResultInfoModel("失败吞吐率",
|
||||
"failThroughputThisTime"));
|
||||
resultIntems.add(new ResultInfoModel("响应时间",
|
||||
"responseTimeDeviationThisTime"));
|
||||
resultIntems
|
||||
.add(new ResultInfoModel("平均延迟时间", "averageElapsedTime"));
|
||||
resultIntems
|
||||
.add(new ResultInfoModel("计划运行时间", "planedRunningTime"));
|
||||
resultIntems.add(new ResultInfoModel("虚拟用户", "vUserCount"));
|
||||
resultInfoModel.setChildren(resultIntems);
|
||||
return resultInfoModel;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ResultInfoModel createCpuResult() {
|
||||
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
||||
resultInfoModel.setName("cpu");
|
||||
resultInfoModel.setValue("cpu");
|
||||
List<ResultInfoModel> cpuItems = new LinkedList<ResultInfoModel>();
|
||||
cpuItems.add(new ResultInfoModel("processorTimePercent", "使用率"));
|
||||
cpuItems.add(new ResultInfoModel("privilegedTimePercent", "系统使用率"));
|
||||
cpuItems.add(new ResultInfoModel("userTimePercent", "用户使用率"));
|
||||
resultInfoModel.setChildren(cpuItems);
|
||||
return resultInfoModel;
|
||||
|
||||
}
|
||||
|
||||
private ResultInfoModel createMemoryResult() {
|
||||
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
||||
resultInfoModel.setName("内存");
|
||||
resultInfoModel.setValue("mem");
|
||||
List<ResultInfoModel> memItems = new LinkedList<ResultInfoModel>();
|
||||
memItems.add(new ResultInfoModel("pagesPerSecond", "页速率"));
|
||||
memItems.add(new ResultInfoModel("pagesInputPerSecond", "读页速率"));
|
||||
memItems.add(new ResultInfoModel("pagesOutputPerSecond", "写页速率"));
|
||||
memItems.add(new ResultInfoModel("availableKiloBytes", "可用内存(kb)"));
|
||||
memItems.add(new ResultInfoModel("totalKiloBytes", "总容量(kb)"));
|
||||
memItems.add(new ResultInfoModel("memoryUsedPercent", "使用率"));
|
||||
memItems.add(new ResultInfoModel("swapKiloBytes", "交换内存(kb)"));
|
||||
memItems.add(new ResultInfoModel("swapFreeKiloBytes", ""));
|
||||
resultInfoModel.setChildren(memItems);
|
||||
return resultInfoModel;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,395 @@
|
|||
package org.bench4q.web.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.share.helper.ExceptionLog;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
|
||||
import org.bench4q.share.models.master.MonitorModel;
|
||||
import org.bench4q.share.models.master.ScriptHandleModel;
|
||||
import org.bench4q.share.models.master.TestPlanDBModel;
|
||||
import org.bench4q.share.models.master.TestPlanModel;
|
||||
import org.bench4q.share.models.master.TestPlanResultModel;
|
||||
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
|
||||
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
|
||||
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
|
||||
import org.bench4q.share.models.master.statistics.ScriptPageBriefModel;
|
||||
import org.bench4q.web.init.TestResultHandle;
|
||||
import org.bench4q.web.masterMessager.TestPlanMessager;
|
||||
import org.bench4q.web.model.ResultInfoModel;
|
||||
import org.bench4q.web.model.TestBriefStatusModel;
|
||||
import org.bench4q.web.model.TestPlanRequestModel;
|
||||
import org.bench4q.web.model.UrlContentTypeDistributionModel;
|
||||
import org.bench4q.web.service.TestPlanService;
|
||||
import org.bench4q.web.validation.TestPlanValidate;
|
||||
import org.bench4q.web.validation.ValidateResponseModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
@Controller
|
||||
@SessionAttributes({ "accessToken" })
|
||||
public class TestPlanController extends BaseController {
|
||||
private TestPlanMessager testPlanMessager;
|
||||
|
||||
private TestPlanValidate testPlanValidate;
|
||||
|
||||
private TestPlanService testPlanService;
|
||||
|
||||
private final int monitorPort = 5556;
|
||||
|
||||
private TestPlanMessager getTestPlanMessager() {
|
||||
return testPlanMessager;
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private void setTestPlanMessager(TestPlanMessager testPlanMessager) {
|
||||
this.testPlanMessager = testPlanMessager;
|
||||
}
|
||||
|
||||
private TestPlanValidate getTestPlanValidate() {
|
||||
return testPlanValidate;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setTestPlanValidate(TestPlanValidate testPlanValidate) {
|
||||
this.testPlanValidate = testPlanValidate;
|
||||
}
|
||||
|
||||
private TestPlanService getTestPlanService() {
|
||||
return testPlanService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setTestPlanService(TestPlanService testPlanService) {
|
||||
this.testPlanService = testPlanService;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "runTestPlan", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Map<String, Object> runTestPlan(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestBody TestPlanRequestModel testPlanRequestModel) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
ValidateResponseModel validateResponseModel = this
|
||||
.getTestPlanValidate().validateTestPlanSubmited(
|
||||
testPlanRequestModel);
|
||||
if (!validateResponseModel.isSuccess()) {
|
||||
return fail(map, validateResponseModel.getMessage());
|
||||
} else {
|
||||
TestPlanModel testPlanModel = this.getTestPlanService()
|
||||
.createTestPlan(testPlanRequestModel, monitorPort);
|
||||
String testPlanContent;
|
||||
try {
|
||||
testPlanContent = MarshalHelper.marshal(TestPlanModel.class,
|
||||
testPlanModel);
|
||||
|
||||
} catch (JAXBException e) {
|
||||
Logger.getLogger(TestPlanController.class).info(
|
||||
ExceptionLog.getStackTrace(e));
|
||||
return fail(map, "error testPlan");
|
||||
}
|
||||
TestPlanResultModel testPlanResultModel = this
|
||||
.getTestPlanMessager().runTestPlan(accessToken,
|
||||
testPlanContent);
|
||||
if (testPlanResultModel != null
|
||||
&& testPlanResultModel.getTestPlanId() != null) {
|
||||
map = success(map);
|
||||
map.put("testPlanResult", testPlanResultModel);
|
||||
return map;
|
||||
} else {
|
||||
return fail(map, "empty test plan id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/{testPlanId}/runningInfo")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getRunningInfo(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
TestPlanResultModel testPlanResultModel = this.getTestPlanMessager()
|
||||
.getRunningTestInfo(accessToken, testPlanId);
|
||||
if (testPlanResultModel == null) {
|
||||
return fail(map, "");
|
||||
} else {
|
||||
success(map);
|
||||
map.put("testPlan", testPlanResultModel);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{testPlanId}/queryTestPlan")
|
||||
@ResponseBody
|
||||
public Map<String, Object> queryTestPlan(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
TestPlanDBModel testPlanResultModel = this.getTestPlanMessager()
|
||||
.queryTestPlanById(accessToken, testPlanId);
|
||||
if (testPlanResultModel != null) {
|
||||
success(map);
|
||||
map.put("testPlan", testPlanResultModel);
|
||||
return map;
|
||||
} else {
|
||||
return fail(map, "");
|
||||
}
|
||||
}
|
||||
@RequestMapping("/{testPlanId}/testResultHanadle")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getTestResultHandle(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
TestPlanResultModel testPlanResultModel = this.getTestPlanMessager()
|
||||
.getRunningTestInfo(accessToken, testPlanId);
|
||||
if (testPlanResultModel == null) {
|
||||
return fail(map, "");
|
||||
}
|
||||
try {
|
||||
List<ResultInfoModel> results = new LinkedList<ResultInfoModel>();
|
||||
List<ResultInfoModel> scriptResultInfoModels = TestResultHandle.scriptResultInfoModel;
|
||||
List<ResultInfoModel> sutResultInfoModels = TestResultHandle.sutInfoModel;
|
||||
|
||||
for (ScriptHandleModel scriptHandleModel : testPlanResultModel
|
||||
.getScripts()) {
|
||||
if (scriptHandleModel == null) {
|
||||
continue;
|
||||
}
|
||||
results.add(getScriptResultInfoModels(scriptHandleModel,
|
||||
scriptResultInfoModels));
|
||||
}
|
||||
if (testPlanResultModel.getMonitorModels() != null) {
|
||||
for (MonitorModel monitorModel : testPlanResultModel
|
||||
.getMonitorModels()) {
|
||||
results.add(getSUTResultInfoModel(monitorModel,
|
||||
sutResultInfoModels));
|
||||
}
|
||||
}
|
||||
|
||||
map.put("resultHandle", results);
|
||||
success(map);
|
||||
return map;
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(this.getClass()).info(
|
||||
ExceptionLog.getStackTrace(e));
|
||||
return fail(map, "");
|
||||
}
|
||||
}
|
||||
|
||||
private ResultInfoModel getScriptResultInfoModels(
|
||||
ScriptHandleModel scriptHandleModel,
|
||||
List<ResultInfoModel> scriptResultModels) {
|
||||
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
||||
resultInfoModel.setName(scriptHandleModel.getScriptName());
|
||||
resultInfoModel.setValue(scriptHandleModel.getScriptId().toString());
|
||||
resultInfoModel.setChildren(scriptResultModels);
|
||||
return resultInfoModel;
|
||||
}
|
||||
|
||||
private ResultInfoModel getSUTResultInfoModel(
|
||||
MonitorModel monitorModel, List<ResultInfoModel> resultInfoModels) {
|
||||
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
||||
resultInfoModel.setName(monitorModel.getHostName());
|
||||
resultInfoModel.setValue(monitorModel.getHostName());
|
||||
resultInfoModel.setChildren(resultInfoModels);
|
||||
return resultInfoModel;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/{testPlanId}/{scriptId}/scriptBriefResult/{fieldName}/{startTime}")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getScriptBriefStatus(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId, @PathVariable String scriptId,
|
||||
@PathVariable String fieldName, @PathVariable String startTime) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
TestPlanScriptBriefResultModel testPlanScriptBriefResultModel = this
|
||||
.getTestPlanMessager().getScriptBriefResult(accessToken,
|
||||
testPlanId, scriptId, startTime);
|
||||
if (testPlanScriptBriefResultModel != null) {
|
||||
success(map);
|
||||
map.put("result",
|
||||
this.getTestPlanService().extractResultModelList(
|
||||
testPlanScriptBriefResultModel, fieldName));
|
||||
return map;
|
||||
|
||||
} else {
|
||||
return fail(map, "");
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/{testPlanId}/testBriefStatus")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getTestBriefStatus(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
TestBriefStatusModel testBriefStatusModel = new TestBriefStatusModel();
|
||||
long vus = 0;
|
||||
long requests = 0;
|
||||
TestPlanResultModel testPlanResultModel = this.getTestPlanMessager()
|
||||
.getRunningTestInfo(accessToken, testPlanId);
|
||||
|
||||
if (testPlanResultModel == null) {
|
||||
return fail(map, "");
|
||||
}
|
||||
for (ScriptHandleModel scriptHandleModel : testPlanResultModel
|
||||
.getScripts()) {
|
||||
ScriptBriefResultModel lastScriptBriefResultModel = this
|
||||
.getTestPlanMessager().getLatestScriptBriefResult(
|
||||
accessToken, testPlanId,
|
||||
scriptHandleModel.getScriptId().toString());
|
||||
if (lastScriptBriefResultModel == null) {
|
||||
continue;
|
||||
}
|
||||
requests += lastScriptBriefResultModel.getTotalFailCountFromBegin()
|
||||
+ lastScriptBriefResultModel
|
||||
.getTotalSuccessCountFromBegin();
|
||||
vus += lastScriptBriefResultModel.getvUserCount();
|
||||
}
|
||||
testBriefStatusModel.setRequests(requests);
|
||||
testBriefStatusModel.setVus(vus);
|
||||
map.put("briefInfo", testBriefStatusModel);
|
||||
return success(map);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/{testPlanId}/script/{scriptId}/behaviors")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getScriptBehaviorBriefModel(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId, @PathVariable String scriptId) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
ScriptBehaviorsBriefModel scriptBehaviorsBriefModel = this
|
||||
.getTestPlanMessager().getScriptBehaviorsBriefResult(
|
||||
accessToken, testPlanId, scriptId);
|
||||
if (scriptBehaviorsBriefModel == null) {
|
||||
return fail(map, "");
|
||||
}
|
||||
map = success(map);
|
||||
map.put("result", scriptBehaviorsBriefModel);
|
||||
return map;
|
||||
}
|
||||
|
||||
@RequestMapping("/{testPlanId}/script/{scriptId}/page")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getScriptPageBriefModel(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId, @PathVariable String scriptId) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
ScriptPageBriefModel scriptPageBriefModel = this.getTestPlanMessager()
|
||||
.getScriptPageBriefModel(accessToken, testPlanId, scriptId);
|
||||
|
||||
if (scriptPageBriefModel == null) {
|
||||
return fail(map, "");
|
||||
}
|
||||
map = success(map);
|
||||
map.put("result", scriptPageBriefModel);
|
||||
return map;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping("/{testPlanId}/urlContentTypeDistribution")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getUrlContentTypeDistribution(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) {
|
||||
List<UrlContentTypeDistributionModel> urlContentTypeDistributionModels = new ArrayList<UrlContentTypeDistributionModel>();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Long> urlContentTypeCountMap = (Map<String, Long>) getUrlContentTypeCount(
|
||||
accessToken, testPlanId).get("result");
|
||||
if (urlContentTypeCountMap == null) {
|
||||
return fail(map, "");
|
||||
}
|
||||
Map<String, Double> urlContentTypePercentMap = this
|
||||
.getTestPlanService().getUrlContentTypePercent(
|
||||
urlContentTypeCountMap);
|
||||
Set<String> keys = urlContentTypeCountMap.keySet();
|
||||
Iterator<String> iterator = keys.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
urlContentTypeDistributionModels
|
||||
.add(new UrlContentTypeDistributionModel(key,
|
||||
urlContentTypeCountMap.get(key),
|
||||
urlContentTypePercentMap.get(key)));
|
||||
}
|
||||
map = success(map);
|
||||
map.put("result", urlContentTypePercentMap);
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping("/{testPlanId}/urlContentTypePercent")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getUrlContentTypePercent(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Long> urlContentTypeCountMap = (Map<String, Long>) getUrlContentTypeCount(
|
||||
accessToken, testPlanId).get("result");
|
||||
if (urlContentTypeCountMap == null) {
|
||||
return fail(map, "");
|
||||
}
|
||||
map = success(map);
|
||||
map.put("result",
|
||||
this.getTestPlanService().getUrlContentTypePercent(
|
||||
urlContentTypeCountMap));
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/{testPlanId}/urlContentTypeCount")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getUrlContentTypeCount(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) {
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = this
|
||||
.getTestPlanService().getAllBehaviorStatusCodeResultModels(
|
||||
accessToken, testPlanId);
|
||||
if (behaviorStatusCodeResultModels == null) {
|
||||
map.put("result", null);
|
||||
return fail(map, "");
|
||||
}
|
||||
Map<String, Long> urlContentCountMap = new HashMap<String, Long>();
|
||||
for (BehaviorStatusCodeResultModel behaviorStatusCodeResultModel : behaviorStatusCodeResultModels) {
|
||||
if (urlContentCountMap.get(behaviorStatusCodeResultModel
|
||||
.getContentType()) == null)
|
||||
urlContentCountMap.put(
|
||||
behaviorStatusCodeResultModel.getContentType(),
|
||||
behaviorStatusCodeResultModel.getCount());
|
||||
else {
|
||||
long originalValue = urlContentCountMap
|
||||
.get(behaviorStatusCodeResultModel.getContentType());
|
||||
urlContentCountMap.put(
|
||||
behaviorStatusCodeResultModel.getContentType(),
|
||||
originalValue
|
||||
+ behaviorStatusCodeResultModel.getCount());
|
||||
}
|
||||
|
||||
}
|
||||
map = success(map);
|
||||
map.put("result", urlContentCountMap);
|
||||
return map;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package org.bench4q.web.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
||||
import org.bench4q.share.helper.ExceptionLog;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.TestPlanResponseModel;
|
||||
import org.bench4q.web.masterMessager.TestPlanMessager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
|
||||
@Controller
|
||||
@SessionAttributes({ "accessToken" })
|
||||
public class TestPlanHistoryController extends BaseController {
|
||||
|
||||
private TestPlanMessager testPlanMessager;
|
||||
|
||||
public TestPlanMessager getTestPlanMessager() {
|
||||
return testPlanMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTestPlanMessager(TestPlanMessager testPlanMessager) {
|
||||
this.testPlanMessager = testPlanMessager;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "loadTestPlans", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public Map<String, Object> loadTestPlans(
|
||||
@ModelAttribute("accessToken") String accessToken) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
TestPlanResponseModel testPlanResponseModel = this
|
||||
.getTestPlanMessager().loadTestPlans(accessToken);
|
||||
System.out.println(MarshalHelper.tryMarshal(testPlanResponseModel));
|
||||
if (testPlanResponseModel == null || !testPlanResponseModel.isSuccess()) {
|
||||
return fail(map, "");
|
||||
|
||||
} else {
|
||||
success(map);
|
||||
map.put("testPlans", testPlanResponseModel.getTestPlanDBModels());
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "downloadReport", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
public void downloadReport(HttpServletResponse response,
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam String testPlanId) {
|
||||
HttpResponse httpResponse = this.getTestPlanMessager().loadReport(
|
||||
accessToken, testPlanId);
|
||||
if (httpResponse == null || httpResponse.getContent() == "") {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
byte[] pdfBuffer = httpResponse.getContent().getBytes();
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
response.reset();
|
||||
response.setHeader("Content-disposition", "attachment; filename=\""
|
||||
+ testPlanId.toString() + ".pdf\"");
|
||||
response.addHeader("Content-Length", "" + pdfBuffer.length);
|
||||
response.setContentType("application/pdf");
|
||||
outputStream.write(pdfBuffer);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
Logger.getLogger(this.getClass()).info(
|
||||
ExceptionLog.getStackTrace(e));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "deleteTest", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public Map<String, Object> deleteTest(HttpServletResponse response,
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam String testPlanId) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
TestPlanResponseModel testPlanResponseModel = this
|
||||
.getTestPlanMessager().deleteTestPlan(accessToken, testPlanId);
|
||||
if (testPlanResponseModel == null || !testPlanResponseModel.isSuccess()) {
|
||||
return fail(map, "");
|
||||
} else {
|
||||
return success(map);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package org.bench4q.web.init;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import org.bench4q.web.model.ResultInfoModel;
|
||||
import org.bench4q.web.model.TestResult;
|
||||
|
||||
public class TestResultHandle {
|
||||
private static final String SCRIPT_RESULT_FILE_NAME = "script_result.xml";
|
||||
private static final String SUT_RESULT_FILE_NAME = "SUT_result.xml";
|
||||
public static List<ResultInfoModel> scriptResultInfoModel;
|
||||
public static List<ResultInfoModel> sutInfoModel;
|
||||
static {
|
||||
String filePath;
|
||||
try {
|
||||
filePath = TestResultHandle.class.getClassLoader().getResource("")
|
||||
.toURI().getPath();
|
||||
|
||||
scriptResultInfoModel = readTestResultFromFile(filePath
|
||||
+ SCRIPT_RESULT_FILE_NAME);
|
||||
sutInfoModel = readTestResultFromFile(filePath
|
||||
+ SUT_RESULT_FILE_NAME);
|
||||
} catch (URISyntaxException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static List<ResultInfoModel> readTestResultFromFile(String filePath)
|
||||
throws JAXBException, IOException {
|
||||
InputStreamReader is = new InputStreamReader(new FileInputStream(
|
||||
new File(filePath)), "UTF-8");
|
||||
BufferedReader reader = new BufferedReader(is);
|
||||
JAXBContext context = JAXBContext.newInstance(TestResult.class);
|
||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
TestResult testResult = (TestResult) unmarshaller.unmarshal(reader);
|
||||
return testResult.getResultInfoModels();
|
||||
}
|
||||
|
||||
}
|
|
@ -160,6 +160,10 @@ public class ScriptMessager extends MasterMessager {
|
|||
try {
|
||||
httpResponse = this.getHttpRequester().sendPost(url, params,
|
||||
makeAccessTockenMap(accessToken));
|
||||
if (!validateHttpResponse(httpResponse)) {
|
||||
handleInvalidatedResponse(url);
|
||||
return createFailOperateScriptServerResponseModel();
|
||||
}
|
||||
return extractOperateScriptServerResponseModel(httpResponse);
|
||||
} catch (JAXBException | IOException e) {
|
||||
this.handleException(httpResponse, e);
|
||||
|
|
|
@ -5,30 +5,38 @@ import java.util.List;
|
|||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
@XmlRootElement
|
||||
public class ResultInfoModel {
|
||||
|
||||
private String result;
|
||||
private List<ResultInfoModel> childResults;
|
||||
private String name;
|
||||
private String value;
|
||||
private List<ResultInfoModel> children;
|
||||
public ResultInfoModel(){
|
||||
|
||||
}
|
||||
public ResultInfoModel(String result) {
|
||||
this.result=result;
|
||||
public ResultInfoModel(String name,String value,List<ResultInfoModel> resultInfoModels){
|
||||
this.name=name;
|
||||
this.value=value;
|
||||
this.children=resultInfoModels;
|
||||
}
|
||||
public ResultInfoModel(String result,List<ResultInfoModel> resultInfoModels){
|
||||
this.result=result;
|
||||
this.childResults=resultInfoModels;
|
||||
public ResultInfoModel(String name,String value){
|
||||
this.name=name;
|
||||
this.value=value;
|
||||
}
|
||||
public String getResult() {
|
||||
return result;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public List<ResultInfoModel> getChildResults() {
|
||||
return childResults;
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setChildResults(List<ResultInfoModel> childResults) {
|
||||
this.childResults = childResults;
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public List<ResultInfoModel> getChildren() {
|
||||
return children;
|
||||
}
|
||||
public void setChildren(List<ResultInfoModel> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package org.bench4q.web.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class TestResult {
|
||||
List<ResultInfoModel> resultInfoModels;
|
||||
@XmlElementWrapper(name="results")
|
||||
@XmlElement(name="result")
|
||||
public List<ResultInfoModel> getResultInfoModels() {
|
||||
return resultInfoModels;
|
||||
}
|
||||
public void setResultInfoModels(List<ResultInfoModel> resultInfoModels) {
|
||||
this.resultInfoModels = resultInfoModels;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package org.bench4q.web.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
import org.bench4q.share.models.master.MonitorModel;
|
||||
import org.bench4q.share.models.master.TestPlanResultModel;
|
||||
|
||||
public class WebTestPlanResultModel {
|
||||
private UUID testPlanId;
|
||||
private TestPlanStatus currentStatus;
|
||||
private List<NameAndIdMap> scriptIdNameMap;
|
||||
private List<MonitorModel> monitorModels;
|
||||
private List<Integer> scriptIds;
|
||||
|
||||
public WebTestPlanResultModel(TestPlanResultModel testPlanResultModel) {
|
||||
this.testPlanId = testPlanResultModel.getTestPlanId();
|
||||
this.currentStatus = testPlanResultModel.getCurrentStatus();
|
||||
this.monitorModels = testPlanResultModel.getMonitorModels();
|
||||
this.scriptIds = testPlanResultModel.getScriptIds();
|
||||
}
|
||||
|
||||
public UUID getTestPlanId() {
|
||||
return testPlanId;
|
||||
}
|
||||
|
||||
public void setTestPlanId(UUID testPlanId) {
|
||||
this.testPlanId = testPlanId;
|
||||
}
|
||||
|
||||
public TestPlanStatus getCurrentStatus() {
|
||||
return currentStatus;
|
||||
}
|
||||
|
||||
public void setCurrentStatus(TestPlanStatus currentStatus) {
|
||||
this.currentStatus = currentStatus;
|
||||
}
|
||||
|
||||
public List<NameAndIdMap> getScriptIdNameMap() {
|
||||
return scriptIdNameMap;
|
||||
}
|
||||
|
||||
public void setScriptIdNameMap(List<NameAndIdMap> scriptIdNameMap) {
|
||||
this.scriptIdNameMap = scriptIdNameMap;
|
||||
}
|
||||
|
||||
public List<MonitorModel> getMonitorModels() {
|
||||
return monitorModels;
|
||||
}
|
||||
|
||||
public void setMonitorModels(List<MonitorModel> monitorModels) {
|
||||
this.monitorModels = monitorModels;
|
||||
}
|
||||
|
||||
public List<Integer> getScriptIds() {
|
||||
return scriptIds;
|
||||
}
|
||||
|
||||
public void setScriptIds(List<Integer> scriptIds) {
|
||||
this.scriptIds = scriptIds;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package org.bench4q.web.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.share.helper.ExceptionLog;
|
||||
import org.bench4q.share.models.master.MonitorProcessorResponseModel;
|
||||
import org.bench4q.share.models.monitor.MemoryModel;
|
||||
import org.bench4q.share.models.monitor.ProcessorModel;
|
||||
import org.bench4q.share.models.monitor.ProcessorModelChild;
|
||||
import org.bench4q.web.masterMessager.MonitorMessager;
|
||||
import org.bench4q.web.model.ResultModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Component
|
||||
public class MonitorService {
|
||||
private MonitorMessager monitorMessager;
|
||||
|
||||
private MonitorMessager getMonitorMessager() {
|
||||
return monitorMessager;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setMonitorMessager(MonitorMessager monitorMessager) {
|
||||
this.monitorMessager = monitorMessager;
|
||||
}
|
||||
|
||||
private Logger logger = Logger.getLogger(MonitorService.class);
|
||||
|
||||
public List<ResultModel> extractCpuResultModelList(
|
||||
List<ProcessorModel> processorModels, String instance,
|
||||
String fieldName) {
|
||||
if (processorModels == null) {
|
||||
return null;
|
||||
}
|
||||
List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||
for (ProcessorModel processorModel : processorModels) {
|
||||
if (processorModel != null) {
|
||||
ResultModel resultModel;
|
||||
try {
|
||||
resultModel = extractResultModel(processorModel, instance,
|
||||
fieldName);
|
||||
if (resultModel != null)
|
||||
resultModels.add(resultModel);
|
||||
} catch (NoSuchFieldException | IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return resultModels;
|
||||
}
|
||||
|
||||
public List<ResultModel> extractResultModelList(
|
||||
List<MemoryModel> memoryModels, String fieldName) {
|
||||
if (memoryModels == null)
|
||||
return null;
|
||||
List<ResultModel> resultModels = new ArrayList<ResultModel>();
|
||||
List<String> fieldNames = new ArrayList<String>();
|
||||
fieldNames.add(fieldName);
|
||||
for (MemoryModel memoryModel : memoryModels) {
|
||||
if (memoryModel != null) {
|
||||
ResultModel resultModel;
|
||||
try {
|
||||
resultModel = ChangeToResultModel.getResultModel(
|
||||
memoryModel, fieldNames);
|
||||
resultModel.setTime(memoryModel.getSamplingTime());
|
||||
resultModels.add(resultModel);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return resultModels;
|
||||
}
|
||||
|
||||
private ResultModel extractResultModel(ProcessorModel processorModel,
|
||||
String instance, String fieldName) throws NoSuchFieldException,
|
||||
IllegalArgumentException {
|
||||
List<String> fieldNames = new ArrayList<String>();
|
||||
fieldNames.add(fieldName);
|
||||
if (processorModel.getProcessorModelList() == null) {
|
||||
return null;
|
||||
}
|
||||
for (ProcessorModelChild processorModelChild : processorModel
|
||||
.getProcessorModelList()) {
|
||||
if (processorModelChild.getInstance().equalsIgnoreCase(instance)) {
|
||||
ResultModel resultModel = ChangeToResultModel.getResultModel(
|
||||
processorModelChild, fieldNames);
|
||||
resultModel.setFinished(false);
|
||||
resultModel.setTime(processorModel.getSamplingTime());
|
||||
return resultModel;
|
||||
}
|
||||
}
|
||||
logger.info("no such cpu instance");
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getCpuList(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam("testPlanId") String testPlanId,
|
||||
@RequestParam String ip, String port) {
|
||||
try {
|
||||
MonitorProcessorResponseModel monitorProcessorResponseModel = getCpus(
|
||||
accessToken, testPlanId, ip, port, "0");
|
||||
|
||||
ProcessorModel processorModel = null;
|
||||
List<ProcessorModel> processorModels = monitorProcessorResponseModel
|
||||
.getProcessorModels();
|
||||
if (processorModels.size() > 0){
|
||||
processorModel = processorModels.get(0);
|
||||
}
|
||||
|
||||
else{
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
List<String> cpuList = new ArrayList<String>();
|
||||
for (ProcessorModelChild processorModelChild : processorModel
|
||||
.getProcessorModelList()) {
|
||||
cpuList.add(processorModelChild.getInstance());
|
||||
}
|
||||
return cpuList;
|
||||
} catch (NullPointerException e) {
|
||||
logger.info(ExceptionLog.getStackTrace(e));
|
||||
return new LinkedList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public MonitorProcessorResponseModel getCpus(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
String testPlanId, String ip, String port, String startTime)
|
||||
{
|
||||
MonitorProcessorResponseModel model = this.getMonitorMessager()
|
||||
.porcessor(accessToken, testPlanId, ip, port, startTime);
|
||||
return model;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package org.bench4q.web.service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bench4q.share.models.master.plugin.PluginInfoModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginResponseModel;
|
||||
import org.bench4q.share.models.master.plugin.PluginUIModel;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class PluginService {
|
||||
|
||||
public List<PluginInfoModel> extractPluginInfoModels(
|
||||
PluginResponseModel pluginResponseModel) {
|
||||
|
||||
List<PluginInfoModel> pluginInfoModels = new LinkedList<PluginInfoModel>();
|
||||
if (pluginResponseModel == null
|
||||
|| pluginResponseModel.getPluginUIModels() == null) {
|
||||
return pluginInfoModels;
|
||||
} else {
|
||||
for (PluginUIModel pluginUIModel : pluginResponseModel
|
||||
.getPluginUIModels()) {
|
||||
pluginInfoModels.add(pluginUIModel.getPluginInfoModel());
|
||||
}
|
||||
return pluginInfoModels;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package org.bench4q.web.service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -13,14 +12,13 @@ import org.bench4q.share.models.agent.BehaviorBriefModel;
|
|||
import org.bench4q.share.models.agent.BehaviorStatusCodeResultModel;
|
||||
import org.bench4q.share.models.master.MonitorModel;
|
||||
import org.bench4q.share.models.master.RunningScriptModel;
|
||||
import org.bench4q.share.models.master.ScriptModel;
|
||||
import org.bench4q.share.models.master.ScriptHandleModel;
|
||||
import org.bench4q.share.models.master.TestPlanModel;
|
||||
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
|
||||
import org.bench4q.share.models.master.TestScriptConfig;
|
||||
import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
|
||||
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
|
||||
import org.bench4q.web.masterMessager.TestPlanMessager;
|
||||
import org.bench4q.web.model.ResultInfoModel;
|
||||
import org.bench4q.web.model.ResultModel;
|
||||
import org.bench4q.web.model.TestPlanRequestModel;
|
||||
import org.bench4q.web.model.WebScriptModel;
|
||||
|
@ -88,43 +86,6 @@ public class TestPlanService {
|
|||
return ipList;
|
||||
}
|
||||
|
||||
public ResultInfoModel getScriptBriefStatusResultInfo() {
|
||||
String result = "briefStatus";
|
||||
LinkedList<String> results = new LinkedList<String>();
|
||||
for (Field field : ScriptBriefResultModel.class.getDeclaredFields()) {
|
||||
System.out.println(field.getGenericType());
|
||||
if (field.getGenericType().toString().equals("long")) {
|
||||
results.add(field.getName());
|
||||
}
|
||||
}
|
||||
return getResultInfoModel(result, results);
|
||||
}
|
||||
|
||||
public ResultInfoModel getResultInfoModel(String result, List<String> fields) {
|
||||
ResultInfoModel resultInfoModel = new ResultInfoModel();
|
||||
resultInfoModel.setResult(result);
|
||||
if (fields.size() <= 0)
|
||||
return resultInfoModel;
|
||||
|
||||
resultInfoModel.setChildResults(new ArrayList<ResultInfoModel>());
|
||||
for (String field : fields) {
|
||||
ResultInfoModel scriptResultInfoModelChild = new ResultInfoModel();
|
||||
|
||||
scriptResultInfoModelChild.setResult(field);
|
||||
resultInfoModel.getChildResults().add(scriptResultInfoModelChild);
|
||||
}
|
||||
return resultInfoModel;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getScriptNameIdMap(
|
||||
List<ScriptModel> scriptModels) {
|
||||
Map<String, Integer> map = new HashMap<String, Integer>();
|
||||
for (ScriptModel scriptModel : scriptModels) {
|
||||
map.put(scriptModel.getName(), scriptModel.getId());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public List<ResultModel> extractResultModelList(
|
||||
TestPlanScriptBriefResultModel testPlanScriptBriefResultModel,
|
||||
String fieldName) {
|
||||
|
@ -156,16 +117,17 @@ public class TestPlanService {
|
|||
|
||||
public List<BehaviorStatusCodeResultModel> getAllBehaviorStatusCodeResultModels(
|
||||
String accessToken, String testPlanId) {
|
||||
List<Integer> scriptIdList = this.getTestPlanMessager()
|
||||
.getRunningTestInfo(accessToken, testPlanId).getScriptIds();
|
||||
if (scriptIdList == null) {
|
||||
List<ScriptHandleModel> scriptList = this.getTestPlanMessager()
|
||||
.getRunningTestInfo(accessToken, testPlanId).getScripts();
|
||||
if (scriptList == null) {
|
||||
return null;
|
||||
}
|
||||
List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = new LinkedList<BehaviorStatusCodeResultModel>();
|
||||
for (Integer scriptId : scriptIdList) {
|
||||
for (ScriptHandleModel scriptHandleModel : scriptList) {
|
||||
ScriptBehaviorsBriefModel scriptBehaviorBriefModel = this
|
||||
.getTestPlanMessager().getScriptBehaviorsBriefResult(
|
||||
accessToken, testPlanId, scriptId.toString());
|
||||
accessToken, testPlanId,
|
||||
scriptHandleModel.getScriptId().toString());
|
||||
behaviorStatusCodeResultModels
|
||||
.addAll(extractBehaviorStatusCodeResultModels(scriptBehaviorBriefModel));
|
||||
}
|
||||
|
@ -189,6 +151,7 @@ public class TestPlanService {
|
|||
}
|
||||
return behaviorStatusCodeResultModels;
|
||||
}
|
||||
|
||||
public long getTotalCount(Map<String, Long> urlContentTypeCountMap) {
|
||||
|
||||
Set<String> keys = urlContentTypeCountMap.keySet();
|
||||
|
@ -199,6 +162,7 @@ public class TestPlanService {
|
|||
}
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public Map<String, Double> getUrlContentTypePercent(
|
||||
Map<String, Long> urlContentTypeCountMap) {
|
||||
long totalCount = this.getTotalCount(urlContentTypeCountMap);
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<testResult>
|
||||
<results>
|
||||
<result>
|
||||
<children>
|
||||
<name>processorTimePercent</name>
|
||||
<value>使用率</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>privilegedTimePercent</name>
|
||||
<value>系统使用率</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>userTimePercent</name>
|
||||
<value>用户使用率</value>
|
||||
</children>
|
||||
<name>cpu</name>
|
||||
<value>cpu</value>
|
||||
</result>
|
||||
<result>
|
||||
<children>
|
||||
<name>pagesPerSecond</name>
|
||||
<value>页速率</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>pagesInputPerSecond</name>
|
||||
<value>读页速率</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>pagesOutputPerSecond</name>
|
||||
<value>写页速率</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>availableKiloBytes</name>
|
||||
<value>可用内存(kb)</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>totalKiloBytes</name>
|
||||
<value>总容量(kb)</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>memoryUsedPercent</name>
|
||||
<value>使用率</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>swapKiloBytes</name>
|
||||
<value>交换内存(kb)</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>swapFreeKiloBytes</name>
|
||||
<value></value>
|
||||
</children>
|
||||
<name>内存</name>
|
||||
<value>mem</value>
|
||||
</result>
|
||||
</results>
|
||||
</testResult>
|
|
@ -1 +1 @@
|
|||
masterAddress=127.0.0.1:7979/
|
||||
masterAddress=127.0.0.1:7979
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<testResult>
|
||||
<results>
|
||||
<result>
|
||||
<children>
|
||||
<name>累计成功数目</name>
|
||||
<value>totalSuccessCountFromBegin</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>累计失败数目</name>
|
||||
<value>totalFailCountFromBegin</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>平均响应时间</name>
|
||||
<value>averageResponseTime</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>最大响应时间</name>
|
||||
<value>maxResponseTime</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>最小响应时间</name>
|
||||
<value>minResponseTime</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>最大吞吐率</name>
|
||||
<value>successThroughputThisTime</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>失败吞吐率</name>
|
||||
<value>failThroughputThisTime</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>响应时间</name>
|
||||
<value>responseTimeDeviationThisTime</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>平均延迟时间</name>
|
||||
<value>averageElapsedTime</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>计划运行时间</name>
|
||||
<value>planedRunningTime</value>
|
||||
</children>
|
||||
<children>
|
||||
<name>虚拟用户</name>
|
||||
<value>vUserCount</value>
|
||||
</children>
|
||||
<name>脚本运行结果</name>
|
||||
<value>scriptBriefResult</value>
|
||||
</result>
|
||||
</results>
|
||||
</testResult>
|
|
@ -0,0 +1,134 @@
|
|||
<!DOCTYPE html>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<html>
|
||||
<head>
|
||||
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<meta charset="utf-8">
|
||||
<title>Electricity</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description"
|
||||
content="Bench4Q, a new method for QOS benchmarking.">
|
||||
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
|
||||
rel="stylesheet">
|
||||
<link href="lib/chrisma/css/opa-icons.css" rel="stylesheet">
|
||||
<link
|
||||
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
|
||||
rel="stylesheet">
|
||||
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
|
||||
<link rel="shortcut icon" href="images/bench4q.png">
|
||||
<link href="css/bench4q.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
body {
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
padding: 9px 0;
|
||||
}
|
||||
.btn{
|
||||
margin-right:5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<fmt:bundle basename="i18n">
|
||||
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
|
||||
<!-- topbar ends -->
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div id="content" class="span10 center ">
|
||||
<!-- content starts -->
|
||||
<div class="sortable row-fluid ui-sortable">
|
||||
<a data-rel="tooltip" class="well span3 top-block" href="test.jsp"
|
||||
data-original-title=<fmt:message key="creattestplan" />> <span
|
||||
class="icon32 icon-red icon-plus"></span><br> <fmt:message
|
||||
key="creattestplan" />
|
||||
|
||||
</a> <a data-rel="tooltip" class="well span3 top-block"
|
||||
href="device.jsp"
|
||||
data-original-title=<fmt:message key="home-devManage" />>
|
||||
<span class="icon32 icon-color icon-edit"></span><br> <fmt:message
|
||||
key="home-devManage" />
|
||||
|
||||
</a> <a data-rel="tooltip" class="well span3 top-block"
|
||||
href="topologyManage.jsp"
|
||||
data-original-title=<fmt:message key="home-devTop" />> <span
|
||||
class="icon32 icon-green icon-envelope-closed"></span> <br>
|
||||
<fmt:message key="home-devTop" />
|
||||
</a> <a data-rel="tooltip" class="well span3 top-block"
|
||||
href="testplans.jsp"
|
||||
data-original-title=<fmt:message key="testhistory" />> <span
|
||||
class="icon32 icon-blue icon-star-on"></span><br> <fmt:message
|
||||
key="testhistory" />
|
||||
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row-fluid sortable">
|
||||
<div class="box span12"></div>
|
||||
<!-- content ends -->
|
||||
</div>
|
||||
<div class="row-fluid sortable">
|
||||
<div class="box span12">
|
||||
<div class="box-header well" data-original-title>
|
||||
<h2>
|
||||
<fmt:message key="latestTest" />
|
||||
</h2>
|
||||
<div class="box-icon">
|
||||
<a href="#" class="btn btn-setting btn-round"><i
|
||||
class="icon-cog"></i></a> <a href="#"
|
||||
class="btn btn-minimize btn-round"><i
|
||||
class="icon-chevron-up"></i></a> <a href="#"
|
||||
class="btn btn-close btn-round"><i class="icon-remove"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-content">
|
||||
<table class="table table-condensed " id="testPlanTab">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th><fmt:message key="name" /></th>
|
||||
<th><fmt:message key="status" /></th>
|
||||
<th><fmt:message key="createdatetime" /></th>
|
||||
<th><fmt:message key="testPlan-view" /></th>
|
||||
<th><fmt:message key="actions" /></th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- content ends -->
|
||||
</div>
|
||||
<!--/#content.span10-->
|
||||
</div>
|
||||
<!--/fluid-row-->
|
||||
</div>
|
||||
<hr>
|
||||
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
|
||||
</div>
|
||||
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.js"></script>
|
||||
<script
|
||||
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script>
|
||||
<script
|
||||
src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.js'></script>
|
||||
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
|
||||
<script
|
||||
src="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.1/bootstrap.min.js"></script>
|
||||
<script src="lib/chrisma/js/jquery.cookie.js"></script>
|
||||
<script src="lib/chrisma/js/theme.js"></script>
|
||||
<script src="script/base.js"></script>
|
||||
<script src="script/share/TestStatusMap.js"></script>
|
||||
<script src="script/scriptTable.js"></script>
|
||||
<script src="script/bench4q.table.js"></script>
|
||||
<script src="script/home.js"></script>
|
||||
<script src="script/testPlans.js"></script>
|
||||
|
||||
</fmt:bundle>
|
||||
</body>
|
||||
</html>
|
|
@ -20,7 +20,7 @@
|
|||
<div id="content" class="span10">
|
||||
<div>
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="#"><fmt:message key="home" /></a> <span class="divider">/</span></li>
|
||||
<li><a href="homepage.jsp"><fmt:message key="home" /></a> <span class="divider">/</span></li>
|
||||
<li><a href="#"><fmt:message key="portmanagement"></fmt:message></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<<<<<<< HEAD
|
||||
<!DOCTYPE html>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
|
@ -174,206 +173,17 @@ body {
|
|||
<script src="script/base.js"></script>
|
||||
<script src="http://code.highcharts.com/highcharts.js"></script>
|
||||
<script src="script/testResult/charts.js"></script>
|
||||
<script src="script/share/TestStatusMap.js"></script>
|
||||
<script src="script/testResult/testBriefResult.js"></script>
|
||||
<script src="script/bench4q.table.js"></script>
|
||||
<script src="script/testResult/behaviorAndPage.js"></script>
|
||||
<script src="script/testResult/highChartTheme.js"></script>
|
||||
<script src="script/testResult/tree.js"></script>
|
||||
<script src="script/testResult/Model.js"></script>
|
||||
<script src="script/testResult/graphSelectorTree.js"></script>
|
||||
<script src="script/testResult/pieChart.js"></script>
|
||||
<script src="script/testResult/graphSelector.js"></script>
|
||||
<script src="script/testResult/result-load.js"></script>
|
||||
<script src="script/testResult/result.js"></script>
|
||||
</fmt:bundle>
|
||||
</body>
|
||||
=======
|
||||
<!DOCTYPE html>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
padding-bottom: 40px;
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
padding: 9px 0;
|
||||
}
|
||||
</style>
|
||||
<title>Bench4q 2013</title>
|
||||
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
|
||||
rel="stylesheet">
|
||||
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
|
||||
<link
|
||||
href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/redmond/jquery-ui.css"
|
||||
rel="stylesheet">
|
||||
<link href='css/result.css' rel='stylesheet'>
|
||||
<link rel="shortcut icon" href="images/bench4q.png">
|
||||
</head>
|
||||
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
|
||||
<body>
|
||||
<fmt:bundle basename="i18n">
|
||||
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
|
||||
|
||||
<div id="content" class="span10 ">
|
||||
<!-- content starts -->
|
||||
<div>
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="homepage.jsp"><fmt:message key="home" /></a> <span
|
||||
class="divider">/</span></li>
|
||||
<li><a href="test.jsp"><fmt:message key="creatatest" /></a><span
|
||||
class="divider">/</span></li>
|
||||
<li><a href="#"><fmt:message key="result" /></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="row-fluid" id="test">
|
||||
<div class="span4 span-brief" id="status">
|
||||
Test Status<br /> <br>
|
||||
</div>
|
||||
<div class="span4 span-brief" id="vu">
|
||||
VUs active<br /> <br>
|
||||
</div>
|
||||
<div class="span4 span-brief-last" id="request">
|
||||
Requests<br /> <br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<h4 class="pull-left">Charts</h4>
|
||||
<div class="field-inline">
|
||||
<button type="button" class="btn btn-primary " id="del-graph">Delete
|
||||
Graph</button>
|
||||
|
||||
</div>
|
||||
<div class="field-inline">
|
||||
|
||||
<button type="button" class="btn btn-primary " id="add-graph">Add
|
||||
Graph</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="app-container " id="chart"></div>
|
||||
<div class="row-fluid">
|
||||
<h4 class="pull-left">Pages</h4>
|
||||
</div>
|
||||
<div class="app-container">
|
||||
<table id="page"
|
||||
class="table table-striped table-bordered bootstrap-datatable datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Page</th>
|
||||
<th>Script</th>
|
||||
<th>Count</th>
|
||||
<th>Test Min</th>
|
||||
<th>Test Max</th>
|
||||
<th>Average</th>
|
||||
<th>Last</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<h4 class="pull-left">Urls</h4>
|
||||
</div>
|
||||
<div class="app-container dataTables_wrapper">
|
||||
<table id="url"
|
||||
class="table table-striped table-bordered bootstrap-datatable datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>URL</th>
|
||||
<th>Script</th>
|
||||
<th>Successful</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="app-container" id="url-distribution"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal hide fade" id="add-graph-modal">
|
||||
<div class="modal-header">
|
||||
<button type="button" id="myModal-close" class="close"
|
||||
data-dismiss="modal">x</button>
|
||||
<h3>Add Graph</h3>
|
||||
</div>
|
||||
<div class="modal-body" id="add-graph-list"></div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="add-graph-add"
|
||||
data-dismiss="modal">add</button>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal hide fade" id="del-graph-modal">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">x</button>
|
||||
<h3>Delete Graph</h3>
|
||||
</div>
|
||||
<div class="modal-body" id="del-graph-list"></div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="del-graph-del"
|
||||
data-dismiss="modal">delete</button>
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal hide fade" id="load">
|
||||
<div class="modal-header">
|
||||
|
||||
<h3>Please wait,loading result data...</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="loading">
|
||||
<div></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="cancelLoading" class="btn btn-primary ">cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
|
||||
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.js"></script>
|
||||
<script
|
||||
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script>
|
||||
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
|
||||
<script src="lib/bootstrap/js/bootstrap-modal.js"></script>
|
||||
<script
|
||||
src="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.1/bootstrap.min.js"></script>
|
||||
<script src="lib/chrisma/js/jquery.cookie.js"></script>
|
||||
<script
|
||||
src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.js'></script>
|
||||
|
||||
<script src="lib/chrisma/js/theme.js"></script>
|
||||
<script src="lib/chrisma/js/jquery.cookie.js"></script>
|
||||
<script src="script/base.js"></script>
|
||||
<script src="http://code.highcharts.com/highcharts.js"></script>
|
||||
<script src="script/testResult/charts.js"></script>
|
||||
<script src="script/testResult/testBriefResult.js"></script>
|
||||
<script src="script/bench4q.table.js"></script>
|
||||
<script src="script/testResult/behaviorAndPage.js"></script>
|
||||
<script src="script/testResult/highChartTheme.js"></script>
|
||||
<script src="script/testResult/result-tree.js"></script>
|
||||
<script src="script/testResult/resultInfo.js"></script>
|
||||
<script src="script/testResult/chartSelector.js"></script>
|
||||
<script src="script/testResult/pieChart.js"></script>
|
||||
<script src="script/testResult/result-load.js"></script>
|
||||
<script src="script/testResult/result.js"></script>
|
||||
<script src="script/testResult/resultNew.js"></script>
|
||||
</fmt:bundle>
|
||||
</body>
|
||||
>>>>>>> parent of b008839... upadte result jsp
|
||||
</html>
|
|
@ -24,13 +24,12 @@ function startServer() {
|
|||
+ " and the port: "
|
||||
+ server.port
|
||||
+ " to record the script.");
|
||||
$('#startServer').attr('disabled', true);
|
||||
$('#stopServer').attr('disabled', false);
|
||||
}
|
||||
else{
|
||||
$('#scriptInfo').html("Fail to start record server:"+data.failedMessage);
|
||||
}
|
||||
$('#startServer').attr('disabled', true);
|
||||
$('#stopServer').attr('disabled', false);
|
||||
$('#uploadScript').attr('disabled',false);
|
||||
|
||||
}, "json");
|
||||
|
||||
|
@ -63,10 +62,15 @@ function stopServer() {
|
|||
if(server!=null){
|
||||
$.post("stopRecordServer", {
|
||||
port : server.port,
|
||||
fileNameUUID : server.fileName
|
||||
scriptRecordUUID : server.fileName
|
||||
}, function(data) {
|
||||
if (!data.success)
|
||||
if (!data.success){
|
||||
$('#scriptInfo').text("stop record server error:"+data.failedMessage);
|
||||
$('#stopServer').attr('disabled', true);
|
||||
$('#startServer').attr('disabled', false);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
$('#fileName').show();
|
||||
$('#scriptInfo').text(
|
||||
|
@ -78,8 +82,7 @@ function stopServer() {
|
|||
else{
|
||||
$('#scriptInfo').text("record script server has not started");
|
||||
}
|
||||
$('#stopServer').attr('disabled', true);
|
||||
$('#startServer').attr('disabled', false);
|
||||
|
||||
}
|
||||
|
||||
function saveScript() {
|
||||
|
|
|
@ -13,7 +13,7 @@ function getScriptList(testPlanId) {
|
|||
var scriptList = new Array();
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : testPlanId + "/queryTestPlan",
|
||||
url : testPlanId + "/runningInfo",
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
|
@ -21,12 +21,12 @@ function getScriptList(testPlanId) {
|
|||
alert(data.failedMessage);
|
||||
return;
|
||||
}
|
||||
else data=data.data;
|
||||
else data=data.testPlan;
|
||||
if (data.scriptIds.length <= 0)
|
||||
return null;
|
||||
for ( var i = 0; i < data.scriptIdNameMap.length; i++) {
|
||||
scriptList.push(data.scriptIdNameMap[i]);
|
||||
}
|
||||
// for ( var i = 0; i < data.scriptIdNameMap.length; i++) {
|
||||
// scriptList.push(data.scriptIdNameMap[i]);
|
||||
// }
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -102,9 +102,7 @@ PageResult.prototype.getSinglePageResult = function(pageResult, intervalId,
|
|||
clearInterval(intervalId);
|
||||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
data = data.scriptPageBriefModels;
|
||||
data = data.result;
|
||||
var scriptPagesFinished = true;
|
||||
for ( var i = 0; i < data.length; i++) {
|
||||
pageResult.result = $.merge(pageResult.result,
|
||||
|
@ -177,7 +175,7 @@ BehaviorResult.prototype.getSingleBehaviorResult = function(behaviorResult,
|
|||
clearInterval(intervalId);
|
||||
return;
|
||||
}
|
||||
data=data.data;
|
||||
data=data.result;
|
||||
if (data.finished || data.testBehaviorsBriefModel == null) {
|
||||
finishedCount++;
|
||||
}
|
||||
|
@ -346,5 +344,3 @@ BehaviorModel.prototype.getTotalCount = function(behaviorStatusResultList) {
|
|||
return count;
|
||||
};
|
||||
|
||||
// need to abstract the tow
|
||||
// part----------------------------------------------------
|
||||
|
|
|
@ -76,29 +76,25 @@ var Point = function(x, y) {
|
|||
this.y = y;
|
||||
};
|
||||
Chart.prototype.addGraph = function(model) {
|
||||
|
||||
var chart = this;
|
||||
chart.addAxis(model.axis, model.series, []);
|
||||
|
||||
var intervalId = setInterval(function() {
|
||||
|
||||
$.post(model.url + "/" + model.time, {}, function(data) {
|
||||
loadItems.scriptBriefStatusAve = true;
|
||||
if (!data.success) {
|
||||
alert(data.failedMessage);
|
||||
loadItems.scriptBriefStatusAve = true;// this need to change
|
||||
if (data==null||!data.success) {
|
||||
clearInterval(intervalId);
|
||||
return;
|
||||
}
|
||||
data = data.data;
|
||||
data = data.result;
|
||||
if (data instanceof Array) {
|
||||
|
||||
var points = new Array();
|
||||
for ( var i = 0; i < data.length; i++) {
|
||||
chart.addDataToGraph(chart, model, intervalId, data[i]);
|
||||
}
|
||||
} else
|
||||
} else{
|
||||
chart.addDataToGraph(chart, model, intervalId, data);
|
||||
loadItems.scriptBriefStatusAve = true;
|
||||
}
|
||||
|
||||
}, "json");
|
||||
|
||||
|
@ -114,11 +110,11 @@ Chart.prototype.addDataToGraph = function(chart, model, intervalId, data) {
|
|||
return;
|
||||
}
|
||||
var point = new Point(data.time, data.data);
|
||||
if (data.time > model.time)
|
||||
if (data.time > model.time){
|
||||
model.time = data.time;
|
||||
}
|
||||
model.time++;
|
||||
chart.addPoint(model.series, point);
|
||||
|
||||
};
|
||||
Chart.prototype.deleteGraph = function(model) {
|
||||
for ( var i = 0; i < this.modelArray.length; i++) {
|
||||
|
|
|
@ -0,0 +1,253 @@
|
|||
var ChartSelector = function(allTree, showTree, chart, addSelectorId,
|
||||
deleteSelectorId, addButton, deleteButton, showTreePathValues) {
|
||||
|
||||
this.allTree = allTree;
|
||||
this.showTree = showTree;
|
||||
this.addSelectorId = addSelectorId;
|
||||
this.deleteSelectorId = deleteSelectorId;
|
||||
this.excessTree = this.getExcessTree(allTree, showTreePathValues);
|
||||
this.addButton = addButton;
|
||||
this.deleteButton = deleteButton;
|
||||
this.createSelector($("#" + addSelectorId), this.excessTree.root);
|
||||
this.chart = chart;
|
||||
this.addEventListener(this);
|
||||
};
|
||||
ChartSelector.prototype.getExcessTree = function(allTree, pathValues) {
|
||||
var excessTree = allTree.getClonedTree(allTree);
|
||||
|
||||
excessTree.deleteFromTree(pathValues);
|
||||
return excessTree;
|
||||
};
|
||||
ChartSelector.prototype.addEventListener = function(chartSelector) {
|
||||
this.addButton.click(function(e) {
|
||||
e.preventDefault();
|
||||
chartSelector.addGraph();
|
||||
});
|
||||
this.deleteButton.click(function(e) {
|
||||
e.preventDefault();
|
||||
chartSelector.deleteGraph();
|
||||
});
|
||||
|
||||
};
|
||||
ChartSelector.prototype.updateSelector = function(selectorId, updatedData, tree) {
|
||||
var parentDomNode = $("#" + selectorId);
|
||||
this.deleteChildSelector(parentDomNode, updatedData);
|
||||
var newShowTree = tree.getClondSubTreeByValue(updatedData);
|
||||
if (newShowTree == null)
|
||||
return;
|
||||
this.createSelector(parentDomNode, newShowTree.root);
|
||||
this.addSelectlistEvent();
|
||||
};
|
||||
ChartSelector.prototype.deleteChildSelector = function(parentDomNode,
|
||||
updatedData) {
|
||||
var selectArray = $("#" + parentDomNode.attr("id") + " select");
|
||||
var divArray = $("#" + parentDomNode.attr("id") + " div");
|
||||
parentDomNode.html("");
|
||||
for ( var i = 0; i < selectArray.length; i++) {
|
||||
parentDomNode.append(divArray[i]);
|
||||
if ($(selectArray[i]).find("option:selected").val() == updatedData) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
;
|
||||
ChartSelector.prototype.createSelectorByValues = function(parentDomNode,
|
||||
treeNode, pathValues) {
|
||||
var currentNode = treeNode;
|
||||
if (currentNode == null)
|
||||
return;
|
||||
var selectedNode;
|
||||
if (currentNode.children != null && currentNode.children.length > 0) {
|
||||
selectedNode = this.getSelectNodeByValue(currentNode, pathValues);
|
||||
if (selectedNode == null)
|
||||
selectedNode = currentNode.children[0];
|
||||
var selectOptions = new Array();
|
||||
for ( var i = 0; i < currentNode.children.length; i++) {
|
||||
selectOptions.push(currentNode.children[i]);
|
||||
}
|
||||
var childName = "result";
|
||||
parentDomNode
|
||||
.append(this.createSingleListDom(childName, selectOptions));
|
||||
this.createSelectorByValues(parentDomNode, selectedNode, pathValues);
|
||||
}
|
||||
|
||||
};
|
||||
ChartSelector.prototype.addSelectlistEvent = function() {
|
||||
var chartSelector = this;
|
||||
$("#" + this.deleteSelectorId + " select").change(
|
||||
function(event) {
|
||||
var updatedData = $(this).find("option:selected").val();
|
||||
chartSelector.updateSelector(chartSelector.deleteSelectorId,
|
||||
updatedData, chartSelector.showTree);
|
||||
event.stopImmediatePropagation();
|
||||
});
|
||||
$("#" + this.addSelectorId + " select").change(
|
||||
function(event) {
|
||||
var updatedData = $(this).find("option:selected").val();
|
||||
chartSelector.updateSelector(chartSelector.addSelectorId,
|
||||
updatedData, chartSelector.excessTree);
|
||||
event.stopImmediatePropagation();
|
||||
});
|
||||
};
|
||||
ChartSelector.prototype.createSelector = function(parentDomNode, treeNode) {
|
||||
var currentNode = treeNode;
|
||||
if (currentNode == null)
|
||||
return;
|
||||
|
||||
var selectedNode;
|
||||
if (currentNode.children != null && currentNode.children.length > 0) {
|
||||
selectedNode = currentNode.children[0];
|
||||
var selectOptions = new Array();
|
||||
for ( var i = 0; i < currentNode.children.length; i++) {
|
||||
selectOptions.push(currentNode.children[i]);
|
||||
}
|
||||
parentDomNode.append(this.createSingleListDom("result", selectOptions));
|
||||
this.createSelector(parentDomNode, selectedNode);
|
||||
}
|
||||
|
||||
};
|
||||
ChartSelector.prototype.getSelectNodeByValue = function(parentNode, values) {
|
||||
for ( var i = 0; i < values.length; i++) {
|
||||
for ( var j = 0; j < parentNode.children.length; j++) {
|
||||
if (parentNode.children[j].value == values[i])
|
||||
return parentNode.children[j];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
};
|
||||
ChartSelector.prototype.createSingleListDom = function(lableText, options) {
|
||||
var div = $("<div></div>");
|
||||
div.addClass("control-group");
|
||||
var lable = $("<lable></lable>");
|
||||
lable.addClass("control-label");
|
||||
lable.text(lableText);
|
||||
div.append(lable);
|
||||
div.append("</br>");
|
||||
var select = $("<select ></select>");
|
||||
select.addClass("form-control");
|
||||
for ( var i = 0; i < options.length; i++) {
|
||||
|
||||
var option = $("<option></option>");
|
||||
option.text(options[i].name);
|
||||
option.val(options[i].value);
|
||||
if (i == 0) {
|
||||
option.attr("selected", true);
|
||||
}
|
||||
|
||||
select.append(option);
|
||||
}
|
||||
|
||||
div.append(select);
|
||||
return div;
|
||||
};
|
||||
|
||||
ChartSelector.prototype.getSlectedVluesArray = function(selectorId) {
|
||||
var dataArray = new Array();
|
||||
var selectArray = $("#" + selectorId + " select");
|
||||
for ( var i = 0; i < selectArray.length; i++) {
|
||||
dataArray.push($(selectArray[i]).find("option:selected").val());
|
||||
}
|
||||
return dataArray;
|
||||
};
|
||||
ChartSelector.prototype.getSelectedNames = function(selectorId) {
|
||||
var dataArray = new Array();
|
||||
var selectArray = $("#" + selectorId + " select");
|
||||
for ( var i = 0; i < selectArray.length; i++) {
|
||||
dataArray.push($(selectArray[i]).find("option:selected").text());
|
||||
}
|
||||
return dataArray;
|
||||
};
|
||||
|
||||
ChartSelector.prototype.addGraphToTree = function(tree, selectorId) {
|
||||
var pathValues = this.getSlectedVluesArray(selectorId);
|
||||
var singlePathTree = this.allTree.getCloneTreeFromVlaue(pathValues);
|
||||
if (tree == null)
|
||||
tree = singlePathTree;
|
||||
else
|
||||
tree.insertToTree(tree.root, singlePathTree.root);
|
||||
return tree;
|
||||
};
|
||||
ChartSelector.prototype.deleteGraphFromTree = function(tree, selectorId) {
|
||||
if (tree == null)
|
||||
return null;
|
||||
var pathValues = this.getSlectedVluesArray(selectorId);
|
||||
tree.deleteFromTree(pathValues);
|
||||
return tree;
|
||||
};
|
||||
|
||||
ChartSelector.prototype.addGraph = function() {
|
||||
this.showTree = this.addGraphToTree(this.showTree, this.addSelectorId);
|
||||
this.excessTree = this.deleteGraphFromTree(this.excessTree,
|
||||
this.addSelectorId);
|
||||
var model = new Model();
|
||||
model.setSeries(this.getSelectedNames(this.addSelectorId));
|
||||
model.setUrl(this.getSlectedVluesArray(this.addSelectorId), this);
|
||||
model.axis = (model.series + "_Axis");
|
||||
this.chart.addGraph(model);
|
||||
};
|
||||
ChartSelector.prototype.initChart = function() {
|
||||
var model = new Model();
|
||||
model.setSeries(this.getSelectedNames(this.addSelectorId));
|
||||
model.setUrl(this.getSlectedVluesArray(this.addSelectorId), this);
|
||||
model.axis = (model.series + "_Axis");
|
||||
this.chart.addGraph(model);
|
||||
};
|
||||
ChartSelector.prototype.deleteGraph = function() {
|
||||
this.showTree = this.deleteGraphFromTree(this.showTree,
|
||||
this.deleteSelectorId);
|
||||
this.excessTree = this.addGraphToTree(this.excessTree,
|
||||
this.deleteSelectorId);
|
||||
var model = new Model();
|
||||
model.setSeries(this.getSlectedVluesArray(this.deleteSelectorId));
|
||||
model.axis = (model.series + "_Axis");
|
||||
this.chart.deleteGraph(model);
|
||||
};
|
||||
var Model = function() {
|
||||
this.url = "";
|
||||
this.series = "";
|
||||
this.data = null;
|
||||
this.intervalId = null;
|
||||
this.axis = "";
|
||||
this.time = 0;
|
||||
};
|
||||
Model.prototype.setUrl = function(pathValue, chartSelector) {
|
||||
/* this.url = "/"+chartSelector.allTree.root.value; */
|
||||
this.url = chartSelector.allTree.root.value;
|
||||
if (pathValue == null)
|
||||
return null;
|
||||
if (pathValue.length <= 0)
|
||||
return null;
|
||||
|
||||
for ( var i = 0; i < pathValue.length; i++) {
|
||||
this.url += "/" + pathValue[i];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Model.prototype.setSeries = function(pathValue) {
|
||||
this.series = "";
|
||||
if (pathValue == null)
|
||||
return null;
|
||||
if (pathValue.length <= 0)
|
||||
return null;
|
||||
this.series += pathValue[0];
|
||||
for ( var i = 1; i < pathValue.length; i++) {
|
||||
this.series += "_" + pathValue[i];
|
||||
}
|
||||
};
|
||||
Model.prototype.setIntervalId = function(intervalId) {
|
||||
this.intervalId = intervalId;
|
||||
};
|
||||
function getSubDataArray(indexData, dataArray) {
|
||||
var subDataArray = new Array();
|
||||
for ( var i = 0; i < dataArray.length; i++) {
|
||||
subDataArray.push(dataArray[i]);
|
||||
if (dataArray[i] == indexData) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return subDataArray;
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
function getResultInfoTree(testPlanId) {
|
||||
|
||||
var tree = new Tree();
|
||||
tree.createRoot("Test Result","testPlan" ,testPlanId);
|
||||
createScriptResultInfoTree(testPlanId, tree);
|
||||
var sutResultInfo = new SutResult(testPlanId);
|
||||
if (sutResultInfo.root != null)
|
||||
tree.root.insertSingleNode(sutResultInfo.root);
|
||||
return tree;
|
||||
}
|
||||
|
||||
function getResultTree(testPlanId) {
|
||||
var tree = new Tree();
|
||||
tree.createRoot("Test Result", "testPlan",testPlanId);
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : testPlanId + "/testResultHanadle",
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (!data.success) {
|
||||
return;
|
||||
} else {
|
||||
data = data.resultHandle;
|
||||
for ( var i = 0; i < data.length; i++) {
|
||||
tree.root.insertSingleNode(data[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
return tree;
|
||||
}
|
||||
|
||||
function createScriptResultInfoTree(testPlanId, tree) {
|
||||
var scriptResultTree = new Tree();
|
||||
scriptResultTree.createRoot("Script", "script");
|
||||
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : testPlanId + "/runningScriptInfo",
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (!data.success) {
|
||||
return;
|
||||
} else
|
||||
data = data.scriptInfo;
|
||||
createScriptTree(data, scriptResultTree);
|
||||
tree.root.insertSingleNode(scriptResultTree.root);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createScriptTree(scriptResultInfoList, tree) {
|
||||
|
||||
if (scriptResultInfoList == null)
|
||||
return;
|
||||
for ( var i = 0; i < scriptResultInfoList.length; i++) {
|
||||
|
||||
var node = new TreeNode("Script Result",
|
||||
scriptResultInfoList[i].scriptName, null);
|
||||
tree.root.insertSingleNode(node);
|
||||
var nodeArray = insertResultList(scriptResultInfoList[i].childResults);
|
||||
for ( var j = 0; j < nodeArray.length; j++) {
|
||||
node.insertSingleNode(nodeArray[j]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var SutResult = function(testPlanId) {
|
||||
var sutResultInfo = this;
|
||||
var scriptResultTree = new Tree();
|
||||
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : testPlanId + "/sutInfo",
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (!data.success) {
|
||||
sutResultInfo.root = null;
|
||||
return;
|
||||
} else
|
||||
data = data.sutInfo;
|
||||
scriptResultTree.createRoot("SUT", "SUT");
|
||||
sutResultInfo.root = scriptResultTree.root;
|
||||
sutResultInfo.data = data;
|
||||
sutResultInfo.createTree(data);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
SutResult.prototype.createTree = function(sutResultInfoList) {
|
||||
for ( var i = 0; i < sutResultInfoList.length; i++) {
|
||||
var ipNode = new TreeNode("port", sutResultInfoList[i].ip, null);
|
||||
this.root.insertSingleNode(ipNode);
|
||||
var portNode = new TreeNode("sut result", sutResultInfoList[i].port,
|
||||
null);
|
||||
ipNode.insertSingleNode(portNode);
|
||||
var nodeArray = insertResultList(sutResultInfoList[i].childResults);
|
||||
for ( var j = 0; j < nodeArray.length; j++) {
|
||||
portNode.insertSingleNode(nodeArray[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function insertResultList(childResults) {
|
||||
|
||||
if (childResults == null)
|
||||
return null;
|
||||
else {
|
||||
var nodeArray = new Array();
|
||||
for ( var i = 0; i < childResults.length; i++) {
|
||||
var node = new TreeNode(childResults[i].result,
|
||||
childResults[i].result, null);
|
||||
var childNode = insertResultList(childResults[i].childResults);
|
||||
if (childNode !== null) {
|
||||
for ( var j = 0; j < childNode.length; j++) {
|
||||
node.insertSingleNode(childNode[j]);
|
||||
}
|
||||
|
||||
}
|
||||
nodeArray.push(node);
|
||||
}
|
||||
}
|
||||
return nodeArray;
|
||||
};
|
|
@ -99,32 +99,32 @@ var ReplaceNode = function(oldWord, newWord) {
|
|||
this.oldWord = oldWord;
|
||||
this.newWord = newWord;
|
||||
};
|
||||
function createUrlReplaceArray(testPlanId) {
|
||||
var replaceArray = new Array();
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
/* url : "/" + testPlanId + "/mapInfo", */
|
||||
url : testPlanId + "/mapInfo",
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (!data.success) {
|
||||
alert(data.failedMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
data = data.data;
|
||||
for ( var key in data) {
|
||||
var replaceNode = new ReplaceNode(key, data[key]);
|
||||
replaceArray.push(replaceNode);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
return replaceArray;
|
||||
|
||||
}
|
||||
//function createUrlReplaceArray(testPlanId) {
|
||||
// var replaceArray = new Array();
|
||||
// $.ajax({
|
||||
// type : "POST",
|
||||
// /* url : "/" + testPlanId + "/mapInfo", */
|
||||
// url : testPlanId + "/mapInfo",
|
||||
// dataType : "json",
|
||||
// async : false,
|
||||
// success : function(data) {
|
||||
// if (!data.success) {
|
||||
// alert(data.failedMessage);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// else
|
||||
// data = data.data;
|
||||
// for ( var key in data) {
|
||||
// var replaceNode = new ReplaceNode(key, data[key]);
|
||||
// replaceArray.push(replaceNode);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// return replaceArray;
|
||||
//
|
||||
//}
|
||||
|
||||
function getvars() {
|
||||
var vars = [], hash;
|
||||
|
|
|
@ -0,0 +1,178 @@
|
|||
var loadItems = new loadItems();
|
||||
var testStatus;
|
||||
|
||||
$(function() {
|
||||
var testPlanId=getvars()['testPlanId'];
|
||||
var testPlan=getTestInfo(testPlanId);
|
||||
// getTestBrief();
|
||||
var tree=getResultTree(testPlanId);
|
||||
var chart = new Chart();
|
||||
chart.createChart($("#chart"));
|
||||
var chartSelector = createChartSelector(tree, chart,
|
||||
getShowTreePathValues(tree));
|
||||
chartSelector.initChart();
|
||||
graphButtonListener(chartSelector);
|
||||
var behaviorResult = new BehaviorResult();
|
||||
behaviorResult.getResult(testPlanId, getScriptList(testPlanId));
|
||||
var pageResult = new PageResult();
|
||||
pageResult.getResult(testPlanId, getScriptList(testPlanId));
|
||||
var urlContentTypeDistribution = new UrlContentTypeDistribution(
|
||||
"url-distribution", testPlanId);
|
||||
});
|
||||
function getTestInfo( testPlanId){
|
||||
var testPlan;
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : testPlanId + "/runningInfo",
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (!data.success) {
|
||||
alert("no such testPlan!")
|
||||
return;
|
||||
} else{
|
||||
testPlan = data.testPlan;
|
||||
}
|
||||
}
|
||||
});
|
||||
return testPlan;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//$(document).ready(
|
||||
// function() {
|
||||
// testPlanId = getvars()['testPlanId'];
|
||||
// if (!getTestPlanStatus(testPlanId))
|
||||
// return;
|
||||
// getTestBrief(testPlanId);
|
||||
// var tree = getResultInfoTree(testPlanId);
|
||||
// var replaceArray = createUrlReplaceArray(testPlanId);
|
||||
// doProgress();
|
||||
// var chart = new Chart();
|
||||
// chart.createChart($("#chart"));
|
||||
// var chartSelector = createChartSelector(tree, chart,
|
||||
// getShowTreePathValues(tree));
|
||||
// chartSelector.initChart(getShowTreePathValues(tree), this);
|
||||
// graphButtonListener(chartSelector);
|
||||
// var behaviorResult = new BehaviorResult();
|
||||
// behaviorResult.getResult(testPlanId, getScriptList(testPlanId));
|
||||
// var pageResult = new PageResult();
|
||||
// pageResult.getResult(testPlanId, getScriptList(testPlanId));
|
||||
// var urlContentTypeDistribution = new UrlContentTypeDistribution(
|
||||
// "url-distribution", testPlanId);
|
||||
// });
|
||||
|
||||
function replace(keyArray, replaceArray) {
|
||||
for ( var i = 0; i < keyArray.length; i++) {
|
||||
for ( var j = 0; j < replaceArray.length; j++) {
|
||||
if (keyArray[i] == replaceArray[j].oldWord)
|
||||
keyArray[i] = replaceArray[j].newWord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function graphButtonListener(chartSelector) {
|
||||
$("#del-graph").click(
|
||||
function(event) {
|
||||
|
||||
$("#" + chartSelector.deleteSelectorId).html("");
|
||||
if (chartSelector.showTree != null) {
|
||||
if (chartSelector.showTree.root != null)
|
||||
chartSelector.createSelector($("#"
|
||||
+ chartSelector.deleteSelectorId),
|
||||
chartSelector.showTree.root);
|
||||
}
|
||||
|
||||
chartSelector.addSelectlistEvent();
|
||||
$("#del-graph-modal").modal('show');
|
||||
});
|
||||
$("#add-graph").click(
|
||||
function(event) {
|
||||
$("#" + chartSelector.addSelectorId).html("");
|
||||
if (chartSelector.excessTree != null) {
|
||||
if (chartSelector.excessTree.root != null)
|
||||
chartSelector.createSelector($("#"
|
||||
+ chartSelector.addSelectorId),
|
||||
chartSelector.excessTree.root);
|
||||
}
|
||||
chartSelector.addSelectlistEvent();
|
||||
|
||||
$("#add-graph-modal").modal('show');
|
||||
});
|
||||
}
|
||||
|
||||
function createChartSelector(tree, chart, replaceArray, showTreePathValues) {
|
||||
|
||||
var addSelectorId = "add-graph-list";
|
||||
var deleteSelectorId = "del-graph-list";
|
||||
var addButton = $("#add-graph-add");
|
||||
var deleteButton = $("#del-graph-del");
|
||||
var showTree = initShowTree(tree);
|
||||
var chartSelector = new ChartSelector(tree, showTree, chart, addSelectorId,
|
||||
deleteSelectorId, addButton, deleteButton, replaceArray,
|
||||
showTreePathValues);
|
||||
|
||||
return chartSelector;
|
||||
}
|
||||
function getShowTreePathValues(tree) {
|
||||
var currentNode = tree.root.children[0];
|
||||
var pathValues = new Array();
|
||||
while (currentNode != null) {
|
||||
pathValues.push(currentNode.value);
|
||||
if (currentNode.children !== null)
|
||||
currentNode = currentNode.children[0];
|
||||
else
|
||||
currentNode = null;
|
||||
|
||||
}
|
||||
return pathValues;
|
||||
}
|
||||
function initShowTree(tree) {
|
||||
|
||||
var pathValues = getShowTreePathValues(tree);
|
||||
|
||||
return tree.getCloneTreeFromVlaue(pathValues);
|
||||
}
|
||||
var ReplaceNode = function(oldWord, newWord) {
|
||||
this.oldWord = oldWord;
|
||||
this.newWord = newWord;
|
||||
};
|
||||
// function createUrlReplaceArray(testPlanId) {
|
||||
// var replaceArray = new Array();
|
||||
// $.ajax({
|
||||
// type : "POST",
|
||||
// /* url : "/" + testPlanId + "/mapInfo", */
|
||||
// url : testPlanId + "/mapInfo",
|
||||
// dataType : "json",
|
||||
// async : false,
|
||||
// success : function(data) {
|
||||
// if (!data.success) {
|
||||
// alert(data.failedMessage);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// else
|
||||
// data = data.data;
|
||||
// for ( var key in data) {
|
||||
// var replaceNode = new ReplaceNode(key, data[key]);
|
||||
// replaceArray.push(replaceNode);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// return replaceArray;
|
||||
//
|
||||
// }
|
||||
|
||||
function getvars() {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(
|
||||
window.location.href.indexOf('?') + 1).split('&');
|
||||
for ( var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
}
|
|
@ -1,39 +1,39 @@
|
|||
function getTestBrief(testPlanId) {
|
||||
var intervalId = setInterval(function() {
|
||||
showTestPlanStatusAsync(testPlanId);
|
||||
var startTime=0;
|
||||
showTestBriefStatus(startTime);
|
||||
showTestBriefStatus();
|
||||
loadItems.testBrief = true;
|
||||
if (testStatus == "Complete")
|
||||
clearInterval(intervalId);
|
||||
}, 5000);
|
||||
}
|
||||
function showTestPlanStatusAsync(testPlanId) {
|
||||
/* var urlAddress= "/" + testPlanId + "/queryTestPlan";*/
|
||||
var urlAddress= testPlanId + "/queryTestPlan";
|
||||
var urlAddress = testPlanId + "/runningInfo";
|
||||
$.post(urlAddress, {}, function(data) {
|
||||
if (!data.success) {
|
||||
alert(data.failedMessage);
|
||||
alert("runningInfo");
|
||||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
testStatus=data.currentStatus;
|
||||
$('#status').html('Test Status<br/><br><h4>'+testStatus+'</h4>');
|
||||
else
|
||||
data = data.testPlan;
|
||||
testStatus =testStatusMap(data.currentStatus);
|
||||
$('#status').html($('#status').html()+"<h4>"+testStatus+'</h4>');
|
||||
}, "json");
|
||||
}
|
||||
function showTestBriefStatus(startTime){
|
||||
var urlAddress= testPlanId + "/testBriefStatus"+"/"+startTime;
|
||||
function showTestBriefStatus() {
|
||||
var urlAddress = testPlanId + "/testBriefStatus" ;
|
||||
$.post(urlAddress, {}, function(data) {
|
||||
if (!data.success) {
|
||||
alert(data.failedMessage);
|
||||
alert("testBrief");
|
||||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
else
|
||||
data = data.briefInfo;
|
||||
startTime = data.time;
|
||||
$("#vu").html('VUs active<br/><br><h4>'+data.vus+'</h4>');
|
||||
$("#request").html('Requests<br/><br><h4>'+data.requests+'</h4>');
|
||||
$("#vu").html($("#vu").html()+"<h4>"+data.vus+"</h4>");
|
||||
$("#request").html( $("#request").html()+"<h4>"+data.requests+"</h4>")
|
||||
|
||||
}, "json");
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ function getTestPlanStatus(testPlanId) {
|
|||
var flag = null;
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : testPlanId + "/queryTestPlan",
|
||||
url : testPlanId + "/runningInfo",
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
|
@ -50,7 +50,8 @@ function getTestPlanStatus(testPlanId) {
|
|||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
else
|
||||
data = data.testPlan;
|
||||
testStatus = data.currentStatus;
|
||||
if (data.currentStatus == "Complete"
|
||||
|| data.currentStatus == "InRunning") {
|
||||
|
|
|
@ -0,0 +1,226 @@
|
|||
//Tree
|
||||
|
||||
var TreeNode = function(childClassName, name, value, childArray) {
|
||||
this.childClassName = childClassName;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.children = childArray;
|
||||
};
|
||||
TreeNode.prototype.insertSingleNode = function(childNode) {
|
||||
if (childNode == null)
|
||||
return;
|
||||
if (this.children == null)
|
||||
this.children = new Array();
|
||||
this.children.push(childNode);
|
||||
|
||||
};
|
||||
TreeNode.prototype.insertNodes = function(childNodes) {
|
||||
if (this.children == null)
|
||||
this.children = new Array();
|
||||
if (childNodes == null)
|
||||
return;
|
||||
for ( var i = 0; i < childNodes.length; i++) {
|
||||
this.children.push(childNodes[i]);
|
||||
}
|
||||
|
||||
};
|
||||
var Tree = function() {
|
||||
this.root = null;
|
||||
};
|
||||
|
||||
Tree.prototype.createRoot = function(rootChildrenClassName,name, value) {
|
||||
this.root = new TreeNode(rootChildrenClassName,name, value, null);
|
||||
};
|
||||
|
||||
Tree.prototype.getClondSubTreeByValue = function(value) {
|
||||
if (value == null)
|
||||
return null;
|
||||
if (this.root == null)
|
||||
return null;
|
||||
var clonedTree = new Tree();
|
||||
clonedTree.createRoot(this.root.childClassName, this.root.name,this.root.value);
|
||||
var parentNode = this.searchTreeNodeByValue(this.root, value);
|
||||
clonedTree.root.childClassName = parentNode.childClassName;
|
||||
this.getClonedSubTree(parentNode, clonedTree.root);// 这个就把引用传递过去了,应该没什么影响,我再看看吧
|
||||
return clonedTree;
|
||||
};
|
||||
|
||||
Tree.prototype.searchTreeNodeByValue = function(parentNode, value) {
|
||||
|
||||
if (parentNode.children == null)
|
||||
return null;
|
||||
|
||||
for ( var i = 0; i < parentNode.children.length; i++) {
|
||||
if (value == parentNode.children[i].value) {
|
||||
return parentNode.children[i];
|
||||
}
|
||||
var node = this.searchTreeNodeByValue(parentNode.children[i], value);
|
||||
if (node != null)
|
||||
return node;
|
||||
}
|
||||
|
||||
};
|
||||
Tree.prototype.getCloneTreeFromVlaue = function(pathValues) {
|
||||
|
||||
if (pathValues == null)
|
||||
return null;
|
||||
if (pathValues.length <= 0)
|
||||
return null;
|
||||
if (this.root == null)
|
||||
return null;
|
||||
var clonedTree = new Tree();
|
||||
clonedTree.createRoot(this.root.childClassName,this.root.name, this.root.value);
|
||||
var currentNode = this.root;
|
||||
var clonedTreeCurrentNode = clonedTree.root;
|
||||
for ( var i = 0; i < pathValues.length; i++) {
|
||||
var flag = false;
|
||||
for ( var j = 0; j < currentNode.children.length; j++) {
|
||||
if (currentNode.children[j].value == pathValues[i]) {
|
||||
var clonedNode = new TreeNode(
|
||||
currentNode.children[j].childClassName,currentNode.children[j].name,
|
||||
currentNode.children[j].value, null);
|
||||
clonedTreeCurrentNode.insertSingleNode(clonedNode);
|
||||
clonedTreeCurrentNode = clonedNode;
|
||||
currentNode = currentNode.children[j];
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag == false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
if (currentNode != null)
|
||||
this.getClonedSubTree(currentNode, clonedTreeCurrentNode);// 这个就把引用传递过去了,应该没什么影响,我再看看吧
|
||||
return clonedTree;
|
||||
};
|
||||
|
||||
// no problem to copy the tree
|
||||
Tree.prototype.getClonedSubTree = function(startNode, parentNode) {
|
||||
if (startNode == null)
|
||||
return null;
|
||||
if (startNode.children == null)
|
||||
return null;
|
||||
if (startNode.children.length <= 0)
|
||||
return null;
|
||||
for ( var i = 0; i < startNode.children.length; i++) {
|
||||
var node = new TreeNode(startNode.children[i].childClassName,startNode.children[i].name,
|
||||
startNode.children[i].value, null);
|
||||
parentNode.insertSingleNode(node);
|
||||
this.getClonedSubTree(startNode.children[i], node);
|
||||
}
|
||||
};
|
||||
|
||||
Tree.prototype.insertToTree = function(insertedTree, singlePathTree) {
|
||||
if (singlePathTree == null)
|
||||
return;
|
||||
|
||||
if (singlePathTree.children == null)
|
||||
return;
|
||||
if (singlePathTree.children.length < 1)
|
||||
return;
|
||||
if (insertedTree.children == null) {
|
||||
insertedTree.insertSingleNode(singlePathTree.children[0]);
|
||||
}
|
||||
var children = insertedTree.children;
|
||||
var flag = false;
|
||||
for ( var i = 0; i < children.length; i++) {
|
||||
if (children[i].value == singlePathTree.children[0].value) {
|
||||
|
||||
this.insertToTree(children[i], singlePathTree.children[0]);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
insertedTree.insertSingleNode(singlePathTree.children[0]);
|
||||
};
|
||||
|
||||
Tree.prototype.deleteFromTree = function(pathValues) {
|
||||
if (pathValues == null)
|
||||
return;
|
||||
if (this.root == null)
|
||||
return;
|
||||
var nodeArray = this.getTreePathNodes(pathValues);
|
||||
var currentNode = nodeArray.pop();
|
||||
var length = nodeArray.length;
|
||||
for ( var i = 0; i < length; i++) {
|
||||
var parent = nodeArray.pop();
|
||||
if (parent.treeNode.children.length == 1
|
||||
&& currentNode.treeNode.children == null)
|
||||
parent.treeNode.children = null;
|
||||
else if (parent.treeNode.children.length > 1
|
||||
&& currentNode.treeNode.children == null) {
|
||||
parent.treeNode.children.splice(currentNode.index, 1);
|
||||
} else
|
||||
return;
|
||||
currentNode = parent;
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
Tree.prototype.getTreePathNodes = function(pathValues) {
|
||||
|
||||
var DeleteNode = function(treeNode, index) {
|
||||
this.treeNode = treeNode;
|
||||
this.index = index;
|
||||
};
|
||||
if (pathValues == null)
|
||||
return;
|
||||
if (this.root == null) {
|
||||
alert("error");
|
||||
return;
|
||||
}
|
||||
var currentNode = this.root;
|
||||
|
||||
var nodeArray = new Array();
|
||||
nodeArray.push(new DeleteNode(this.root, 0));
|
||||
for ( var i = 0; i < pathValues.length; i++) {
|
||||
if (currentNode.children == null) {
|
||||
alert("error");
|
||||
return null;
|
||||
}
|
||||
for ( var j = 0; j < currentNode.children.length; j++)
|
||||
if (currentNode.children[j].value == pathValues[i]) {
|
||||
nodeArray.push(new DeleteNode(currentNode.children[j], j));
|
||||
currentNode = currentNode.children[j];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return nodeArray;
|
||||
};
|
||||
Tree.prototype.getClonedTree = function(tree) {
|
||||
var clonedTree = new Tree();
|
||||
clonedTree.root = this.getClonedNode(tree.root);
|
||||
return clonedTree;
|
||||
|
||||
};
|
||||
Tree.prototype.getClonedNode = function(node) {
|
||||
if (node == null)
|
||||
return null;
|
||||
var clonedNode = new TreeNode(node.childClassName, node.name,node.value, null);
|
||||
if (node.children != null && node.children.length > 0) {
|
||||
for ( var i = 0; i < node.children.length; i++) {
|
||||
var childClonedNode = this.getClonedNode(node.children[i]);
|
||||
if (childClonedNode != null)
|
||||
clonedNode.insertSingleNode(childClonedNode);
|
||||
}
|
||||
}
|
||||
return clonedNode;
|
||||
};
|
||||
function getClonedSubTree(startNode, parentNode) {
|
||||
if (startNode == null)
|
||||
return null;
|
||||
if (startNode.children == null)
|
||||
return null;
|
||||
if (startNode.children.length <= 0)
|
||||
return null;
|
||||
for ( var i = 0; i < startNode.children.length; i++) {
|
||||
var node = new TreeNode(startNode.children[i].childClassName,startNode.children[i].name,
|
||||
startNode.children[i].value, null);
|
||||
parentNode.insertSingleNode(node);
|
||||
this.getClonedSubTree(startNode.children[i], node);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue