refactor the test history and getdata and js
This commit is contained in:
parent
687e770416
commit
f63a329dd1
|
@ -22,4 +22,4 @@
|
|||
<outputDirectory>/</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
</assembly>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bench4q.web.TestPlan;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -12,10 +11,11 @@ import org.bench4q.share.models.master.TestPlanDBModel;
|
|||
import org.bench4q.share.models.master.TestPlanResultModel;
|
||||
import org.bench4q.web.exception.CustomGenericException;
|
||||
import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
|
||||
import org.bench4q.web.model.RunningScriptInfoModel;
|
||||
import org.bench4q.web.service.BaseService;
|
||||
import org.bench4q.web.service.CommunicateWithMaster;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class TestPlanInfo {
|
||||
private CommunicateWithMaster communicateWithMaster;
|
||||
private String baseUrl=BaseService.getMasterIP()+"testPlan";
|
||||
|
|
|
@ -7,33 +7,25 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
|
||||
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.TestPlanBusinessModel;
|
||||
import org.bench4q.share.models.master.TestPlanDBModel;
|
||||
import org.bench4q.share.models.master.TestPlanResultModel;
|
||||
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.share.models.master.statistics.ScriptPagesBriefModel;
|
||||
import org.bench4q.web.TestPlan.RunTestPlan;
|
||||
import org.bench4q.web.TestPlan.TestPlanInfo;
|
||||
import org.bench4q.web.exception.CustomGenericException;
|
||||
import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
|
||||
import org.bench4q.web.model.*;
|
||||
import org.bench4q.web.service.CommunicateWithMaster;
|
||||
import org.bench4q.web.service.MonitorDescriptionInfoService;
|
||||
import org.bench4q.web.service.TestPlanService;
|
||||
import org.eclipse.jetty.util.HttpCookieStore.Empty;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
|
@ -265,8 +257,8 @@ public class TestPlanActionController extends BaseControllerService {
|
|||
throws CustomGenericException, NoSuchFieldException {
|
||||
String caller = "TestPlanActionController:getScriptBriefStatus";
|
||||
if (!validateInput(testPlanId) || !validateInput(scriptId)) {
|
||||
throw new CustomGenericException("0",
|
||||
"invalidate scriptid or testplanid", caller);
|
||||
return new BaseResponseModel(false, caller
|
||||
+ "invalidate scriptid or testplanid");
|
||||
}
|
||||
String url = this.getBaseUrl() + "/scriptBrief" + "/" + testPlanId
|
||||
+ "/" + scriptId + "/" + startTime;
|
||||
|
@ -288,8 +280,8 @@ public class TestPlanActionController extends BaseControllerService {
|
|||
String url = this.getBaseUrl() + "/getBehaviorsBrief" + "/"
|
||||
+ testPlanId + "/" + scriptId;
|
||||
if (!validateInput(testPlanId) || !validateInput(scriptId)) {
|
||||
throw new CustomGenericException("0",
|
||||
"invalidate scriptid or testplanid", caller);
|
||||
return new BaseResponseModel(false, caller
|
||||
+ ":invalidate scriptid or testplanid:");
|
||||
}
|
||||
ScriptBehaviorsBriefModel scriptBehaviorsBriefModel = (ScriptBehaviorsBriefModel) this
|
||||
.getCommunicateWithMaster().getResponseModel(accessToken, url,
|
||||
|
@ -314,14 +306,16 @@ public class TestPlanActionController extends BaseControllerService {
|
|||
return new BaseResponseModel(true, scriptPagesBriefModel);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping("/{testPlanId}/urlContentTypeDistribution")
|
||||
@ResponseBody
|
||||
public List<UrlContentTypeDistributionModel> getUrlContentTypeDistribution(
|
||||
public BaseResponseModel getUrlContentTypeDistribution(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) throws CustomGenericException {
|
||||
@PathVariable String testPlanId) throws CustomGenericException,
|
||||
JAXBException {
|
||||
List<UrlContentTypeDistributionModel> urlContentTypeDistributionModels = new ArrayList<UrlContentTypeDistributionModel>();
|
||||
Map<String, Long> urlContentTypeCountMap = getUrlContentTypeCount(
|
||||
accessToken, testPlanId);
|
||||
Map<String, Long> urlContentTypeCountMap = (Map<String, Long>)getUrlContentTypeCount(
|
||||
accessToken, testPlanId).getData();
|
||||
long totalCount = this.getTestPlanService().getTotalCount(
|
||||
urlContentTypeCountMap);
|
||||
Map<String, Double> urlContentTypePercentMap = this
|
||||
|
@ -336,77 +330,80 @@ public class TestPlanActionController extends BaseControllerService {
|
|||
urlContentTypeCountMap.get(key),
|
||||
urlContentTypePercentMap.get(key)));
|
||||
}
|
||||
return urlContentTypeDistributionModels;
|
||||
return new BaseResponseModel(true, urlContentTypeDistributionModels);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping("/{testPlanId}/urlContentTypePercent")
|
||||
@ResponseBody
|
||||
public Map<String, Double> getUrlContentTypePercent(
|
||||
public BaseResponseModel getUrlContentTypePercent(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) throws CustomGenericException {
|
||||
Map<String, Long> urlContentTypeCountMap = getUrlContentTypeCount(
|
||||
accessToken, testPlanId);
|
||||
@PathVariable String testPlanId) throws CustomGenericException,
|
||||
JAXBException {
|
||||
Map<String, Long> urlContentTypeCountMap =(Map<String, Long>) getUrlContentTypeCount(
|
||||
accessToken, testPlanId).getData();
|
||||
long totalCount = this.getTestPlanService().getTotalCount(
|
||||
urlContentTypeCountMap);
|
||||
return this.getTestPlanService().getUrlContentTypePercent(
|
||||
urlContentTypeCountMap, totalCount);
|
||||
|
||||
return new BaseResponseModel(true, this.getTestPlanService()
|
||||
.getUrlContentTypePercent(urlContentTypeCountMap, totalCount));
|
||||
}
|
||||
|
||||
@RequestMapping("/{testPlanId}/urlContentTypeCount")
|
||||
@ResponseBody
|
||||
public Map<String, Long> getUrlContentTypeCount(
|
||||
public BaseResponseModel getUrlContentTypeCount(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId) throws CustomGenericException {
|
||||
@PathVariable String testPlanId) throws CustomGenericException,
|
||||
JAXBException {
|
||||
Map<String, Long> urlContentCountMap = new HashMap<String, Long>();
|
||||
try {
|
||||
for (BehaviorStatusCodeResultModel behaviorStatusCodeResultModel : getBehaviorStatusCodeResultModels(
|
||||
accessToken, testPlanId)) {
|
||||
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());
|
||||
}
|
||||
|
||||
for (BehaviorStatusCodeResultModel behaviorStatusCodeResultModel : getBehaviorStatusCodeResultModels(
|
||||
accessToken, testPlanId)) {
|
||||
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());
|
||||
}
|
||||
return urlContentCountMap;
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
||||
}
|
||||
return new BaseResponseModel(true, urlContentCountMap);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/{testPlanId}/testBriefStatus/{startTime}")
|
||||
@ResponseBody
|
||||
public TestBriefStatusModel getTotalRequest(
|
||||
public BaseResponseModel getTotalRequest(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@PathVariable String testPlanId, @PathVariable String startTime)
|
||||
throws CustomGenericException {
|
||||
throws CustomGenericException, JAXBException {
|
||||
String caller = this.BASECALLER + "getTotalRequest";
|
||||
if (!validateInput(testPlanId)) {
|
||||
System.out.println("invalidate input testPlanId or scriptId");
|
||||
return null;
|
||||
return new BaseResponseModel(false, caller
|
||||
+ " :testplanId is invalidate:" + testPlanId);
|
||||
}
|
||||
TestBriefStatusModel testBriefStatusModel = new TestBriefStatusModel();
|
||||
long vus = 0;
|
||||
long requests = 0;
|
||||
Date time = new Date(0);
|
||||
try {
|
||||
for (RunningScriptInfoModel runningScriptInfoModel : this
|
||||
.getTestPlanScriptInfo(accessToken, testPlanId).getData()) {
|
||||
if (this.getTestPlanInfo()
|
||||
.getTestPlanInfoFromDB(accessToken, testPlanId, caller)
|
||||
.getRunningScriptModels() == null)
|
||||
throw new CustomGenericException("5", caller
|
||||
+ " :scripts in testPlan is empty", caller);
|
||||
for (RunningScriptModel runningScriptModel : this.getTestPlanInfo()
|
||||
.getTestPlanInfoFromDB(accessToken, testPlanId, caller)
|
||||
.getRunningScriptModels()) {
|
||||
ScriptBriefResultModel lastScriptBriefResultModel = getLastScriptBriefModel(
|
||||
accessToken, testPlanId, startTime,
|
||||
runningScriptInfoModel);
|
||||
|
||||
accessToken, testPlanId, startTime, runningScriptModel);
|
||||
requests += lastScriptBriefResultModel
|
||||
.getTotalFailCountFromBegin()
|
||||
+ lastScriptBriefResultModel
|
||||
|
@ -418,42 +415,35 @@ public class TestPlanActionController extends BaseControllerService {
|
|||
testBriefStatusModel.setRequests(requests);
|
||||
testBriefStatusModel.setVus(vus);
|
||||
testBriefStatusModel.setTime(time);
|
||||
return testBriefStatusModel;
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return new BaseResponseModel(true, testBriefStatusModel);
|
||||
|
||||
}
|
||||
|
||||
private ScriptBriefResultModel getLastScriptBriefModel(String accessToken,
|
||||
String testPlanId, String startTime,
|
||||
RunningScriptInfoModel runningScriptInfoModel)
|
||||
RunningScriptModel runningScriptModel)
|
||||
throws CustomGenericException {
|
||||
String caller = "TestPlanActionController:getLastScriptBriefModel";
|
||||
try {
|
||||
String[] paths = new String[] {
|
||||
"scriptBrief",
|
||||
testPlanId,
|
||||
new Integer(runningScriptInfoModel.getScriptId())
|
||||
.toString(), startTime };
|
||||
String[] paths = new String[] { "scriptBrief", testPlanId,
|
||||
new Integer(runningScriptModel.getScriptId()).toString(),
|
||||
startTime };
|
||||
String url = generateUrl(this.getBaseUrl(), paths);
|
||||
TestPlanScriptBriefResultModel testPlanScriptBriefResultModel = (TestPlanScriptBriefResultModel) this
|
||||
.getTestPlanService()
|
||||
.getCommunicateWithMaster()
|
||||
.getResponseModel(accessToken, url,
|
||||
TestPlanScriptBriefResultModel.class, null, caller);
|
||||
if(testPlanScriptBriefResultModel.getScriptBriefResultModels()==null)
|
||||
throw new CustomGenericException("5", "script result empty", caller);
|
||||
int lastScriptBriefResultIndex = testPlanScriptBriefResultModel
|
||||
.getScriptBriefResultModels().size();
|
||||
if (lastScriptBriefResultIndex == 0)
|
||||
return null;
|
||||
throw new CustomGenericException("5", "script result empty", caller);
|
||||
ScriptBriefResultModel lastScriptBriefResultModel = testPlanScriptBriefResultModel
|
||||
.getScriptBriefResultModels().get(
|
||||
lastScriptBriefResultIndex - 1);
|
||||
return lastScriptBriefResultModel;
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return lastScriptBriefResultModel;
|
||||
|
||||
}
|
||||
|
||||
private String generateUrl(String baseUrl, String[] paths) {
|
||||
|
@ -466,30 +456,29 @@ public class TestPlanActionController extends BaseControllerService {
|
|||
|
||||
private List<BehaviorStatusCodeResultModel> getBehaviorStatusCodeResultModels(
|
||||
String accessToken, String testPlanId)
|
||||
throws CustomGenericException {
|
||||
String caller="getBehaviorStatusCodeResultModels";
|
||||
throws CustomGenericException, JAXBException {
|
||||
String caller = "getBehaviorStatusCodeResultModels";
|
||||
List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = new ArrayList<BehaviorStatusCodeResultModel>();
|
||||
try {
|
||||
for (RunningScriptModel runningScriptModel : this
|
||||
.getTestPlanInfo().getTestPlanInfoFromDB(accessToken,
|
||||
testPlanId, caller).getRunningScriptModels()) {
|
||||
ScriptBehaviorsBriefModel scriptBehaviorBriefModel = getScriptBehaviorBriefModel(
|
||||
accessToken, testPlanId,
|
||||
runningScriptModel.getScriptId()
|
||||
);
|
||||
if (this.getTestPlanService()
|
||||
.getBehaviorStatusCodeResultModels(
|
||||
scriptBehaviorBriefModel) != null)
|
||||
behaviorStatusCodeResultModels.addAll(this
|
||||
.getTestPlanService()
|
||||
List<RunningScriptModel> runningScriptModels = this.getTestPlanInfo()
|
||||
.getTestPlanInfoFromDB(accessToken, testPlanId, caller)
|
||||
.getRunningScriptModels();
|
||||
if (runningScriptModels == null)
|
||||
throw new CustomGenericException("5",
|
||||
"scripts in testPlan is empty", caller);
|
||||
for (RunningScriptModel runningScriptModel : this.getTestPlanInfo()
|
||||
.getTestPlanInfoFromDB(accessToken, testPlanId, caller)
|
||||
.getRunningScriptModels()) {
|
||||
ScriptBehaviorsBriefModel scriptBehaviorBriefModel = (ScriptBehaviorsBriefModel) getScriptBehaviorBriefModel(
|
||||
accessToken, testPlanId,
|
||||
new Integer(runningScriptModel.getScriptId()).toString())
|
||||
.getData();
|
||||
behaviorStatusCodeResultModels
|
||||
.addAll(this.getTestPlanService()
|
||||
.getBehaviorStatusCodeResultModels(
|
||||
scriptBehaviorBriefModel));
|
||||
|
||||
}
|
||||
return behaviorStatusCodeResultModels;
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return behaviorStatusCodeResultModels;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,14 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
||||
import org.bench4q.share.models.ErrorResponseModel;
|
||||
import org.bench4q.share.models.master.TestPlanDBModel;
|
||||
import org.bench4q.share.models.master.TestPlanResponseModel;
|
||||
import org.bench4q.web.exception.CustomGenericException;
|
||||
import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
|
||||
import org.bench4q.web.model.BaseResponseModel;
|
||||
import org.bench4q.web.model.TestPlanListModel;
|
||||
import org.bench4q.web.service.CommunicateWithMaster;
|
||||
import org.bench4q.web.service.TestPlanService;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -29,6 +33,14 @@ import org.springframework.web.bind.annotation.SessionAttributes;
|
|||
public class TestPlanHistoryResult extends BaseControllerService {
|
||||
private String baseUrl = this.masterIP + "testPlan";
|
||||
private TestPlanService testPlanService;
|
||||
private CommunicateWithMaster communicateWithMaster;
|
||||
private CommunicateWithMaster getCommunicateWithMaster() {
|
||||
return communicateWithMaster;
|
||||
}
|
||||
@Autowired
|
||||
private void setCommunicateWithMaster(CommunicateWithMaster communicateWithMaster) {
|
||||
this.communicateWithMaster = communicateWithMaster;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
|
@ -50,7 +62,8 @@ public class TestPlanHistoryResult extends BaseControllerService {
|
|||
@RequestMapping(value = "loadTestPlans", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public TestPlanListModel loadTestPlans(
|
||||
public BaseResponseModel
|
||||
loadTestPlans(
|
||||
@ModelAttribute("accessToken") String accessToken)
|
||||
throws CustomGenericException {
|
||||
System.out.println("enter loadTestPlans");
|
||||
|
@ -62,12 +75,10 @@ public class TestPlanHistoryResult extends BaseControllerService {
|
|||
.getResponseModel(accessToken, url,
|
||||
TestPlanResponseModel.class, null, caller);
|
||||
if (testPlanResponseModel.isSuccess()) {
|
||||
System.out.println(SUCCESS);
|
||||
return buildTestPlanListModel(testPlanResponseModel
|
||||
.getTestPlanDBModels());
|
||||
return new BaseResponseModel(true,buildTestPlanListModel(testPlanResponseModel
|
||||
.getTestPlanDBModels()));
|
||||
} else {
|
||||
System.err.println(FAIL);
|
||||
return null;
|
||||
return new BaseResponseModel(false,testPlanResponseModel.getFailCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,22 +90,27 @@ public class TestPlanHistoryResult extends BaseControllerService {
|
|||
|
||||
@RequestMapping(value = "downloadReport", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
public void downloadReport(HttpServletResponse response,
|
||||
public BaseResponseModel downloadReport(HttpServletResponse response,
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam String testPlanId) {
|
||||
@RequestParam String testPlanId) throws CustomGenericException {
|
||||
String caller="TestPlanHistory:downloadReport";
|
||||
try {
|
||||
System.out.println("enter download report");
|
||||
HttpResponse httpResponse = this.getHttpRequester().sendGet(
|
||||
this.getBaseUrl() + "/getTestPlanReport",
|
||||
makeParamsMap("testPlanRunID", testPlanId),
|
||||
this.makeAccessTockenMap(accessToken));
|
||||
if (httpResponse == null || httpResponse.getContent().isEmpty()) {
|
||||
|
||||
return;
|
||||
|
||||
throw new CustomGenericException("1", "invalidate http response", caller);
|
||||
}
|
||||
if (httpResponse.getCode() == HttpStatus.BAD_REQUEST_400) {
|
||||
this.getProcessHttpReponse().processBadRequest(httpResponse);
|
||||
return;
|
||||
ErrorResponseModel errorResponseModel = (ErrorResponseModel) ObjectXmlExchange
|
||||
.fromXml(ErrorResponseModel.class,
|
||||
httpResponse.getContent());
|
||||
this.getCommunicateWithMaster().logException(errorResponseModel);
|
||||
throw new CustomGenericException("2", FAIL_WITH_EXCEPTION + "_"
|
||||
+ errorResponseModel.getMessage(), caller + "_"
|
||||
+ errorResponseModel.getResource());
|
||||
}
|
||||
byte[] pdfBuffer = httpResponse.getContent().getBytes();
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
|
@ -108,21 +124,19 @@ public class TestPlanHistoryResult extends BaseControllerService {
|
|||
outputStream.write(pdfBuffer);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
System.out.println("finish download report");
|
||||
return new BaseResponseModel(true);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
throw new CustomGenericException("1", "exception:io exception", caller);
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return;
|
||||
throw new CustomGenericException("1", "exception:io exception", caller);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "deleteTest", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public Boolean deleteTest(HttpServletResponse response,
|
||||
public BaseResponseModel deleteTest(HttpServletResponse response,
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam String testPlanId) throws CustomGenericException {
|
||||
String url = this.getBaseUrl() + "/removeTestPlanFromPool";
|
||||
|
@ -134,14 +148,13 @@ public class TestPlanHistoryResult extends BaseControllerService {
|
|||
.getCommunicateWithMaster()
|
||||
.getResponseModel(accessToken, url,
|
||||
TestPlanResponseModel.class, params, caller);
|
||||
if (testPlanResponseModel == null)
|
||||
return false;
|
||||
|
||||
if (testPlanResponseModel.isSuccess()) {
|
||||
System.out.println(SUCCESS);
|
||||
return true;
|
||||
|
||||
return new BaseResponseModel(true);
|
||||
} else {
|
||||
System.err.println(FAIL);
|
||||
return false;
|
||||
|
||||
return new BaseResponseModel(false,testPlanResponseModel.getFailCause());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.util.Properties;
|
|||
import org.bench4q.web.api.BaseControllerService;
|
||||
import org.bench4q.web.model.ResultInfoModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.support.StaticApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
|
|
@ -159,7 +159,7 @@ public class CommunicateWithMaster {
|
|||
return properties;
|
||||
}
|
||||
|
||||
private void logException(ErrorResponseModel errorResponseModel) {
|
||||
public void logException(ErrorResponseModel errorResponseModel) {
|
||||
logger.info(FAIL_WITH_EXCEPTION);
|
||||
logger.info("Exception code:" + errorResponseModel.getCode());
|
||||
logger.info("Exception message:" + errorResponseModel.getMessage());
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.bench4q.share.models.agent.scriptrecord.BatchModel;
|
|||
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
|
||||
import org.bench4q.share.models.agent.scriptrecord.PageModel;
|
||||
import org.bench4q.share.models.master.RunningScriptModel;
|
||||
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;
|
||||
|
@ -30,19 +29,16 @@ import org.springframework.web.bind.annotation.SessionAttributes;
|
|||
@Component
|
||||
@SessionAttributes({ "accessToken", "testPlanTaskList" })
|
||||
public class TestPlanService extends BaseService {
|
||||
private final String baseUrl = BaseService.getMasterIP() + "testPlan";
|
||||
/*private final String BASECALLER = "TestPlanService:";
|
||||
|
||||
private String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* private final String BASECALLER = "TestPlanService:";
|
||||
*
|
||||
* private String getBaseUrl() { return baseUrl; }
|
||||
*/
|
||||
public TestPlanService() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ResultInfoModel getScriptBriefStatusResultInfo() {
|
||||
String result = "briefStatus";
|
||||
|
||||
|
@ -354,22 +350,15 @@ public class TestPlanService extends BaseService {
|
|||
|
||||
public List<BehaviorStatusCodeResultModel> getBehaviorStatusCodeResultModels(
|
||||
ScriptBehaviorsBriefModel scriptBehaviorsBriefModel) {
|
||||
|
||||
List<BehaviorStatusCodeResultModel> behaviorStatusCodeResultModels = new ArrayList<BehaviorStatusCodeResultModel>();
|
||||
if (scriptBehaviorsBriefModel == null)
|
||||
return null;
|
||||
try {
|
||||
for (BehaviorBriefModel behaviorBriefModel : scriptBehaviorsBriefModel
|
||||
.getTestBehaviorsBriefModel().getBehaviorBriefModels()) {
|
||||
for (BehaviorBriefModel behaviorBriefModel : scriptBehaviorsBriefModel
|
||||
.getTestBehaviorsBriefModel().getBehaviorBriefModels()) {
|
||||
|
||||
if (behaviorBriefModel.getDetailStatusCodeResultModels() != null)
|
||||
behaviorStatusCodeResultModels.addAll(behaviorBriefModel
|
||||
.getDetailStatusCodeResultModels());
|
||||
}
|
||||
return behaviorStatusCodeResultModels;
|
||||
} catch (NullPointerException e) {
|
||||
return null;
|
||||
if (behaviorBriefModel.getDetailStatusCodeResultModels() != null)
|
||||
behaviorStatusCodeResultModels.addAll(behaviorBriefModel
|
||||
.getDetailStatusCodeResultModels());
|
||||
}
|
||||
return behaviorStatusCodeResultModels;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
masterAddress=133.133.12.1:7979/
|
||||
masterAddress=127.0.0.1:7979/
|
|
@ -25,7 +25,7 @@ function getColumn(obj, columnIndex) {
|
|||
}
|
||||
function extractRowData(data, tableModel, actionButton) {
|
||||
var dataArray = new Array();
|
||||
dataArray=getRowData(data, tableModel,dataArray)
|
||||
dataArray=getRowData(data, tableModel,dataArray);
|
||||
if (actionButton != null)
|
||||
dataArray.push(actionButton);
|
||||
return dataArray;
|
||||
|
|
|
@ -19,7 +19,7 @@ ChartSelector.prototype.getExcessTree=function(allTree,pathValues){
|
|||
|
||||
excessTree.deleteFromTree(pathValues);
|
||||
return excessTree;
|
||||
}
|
||||
};
|
||||
ChartSelector.prototype.addEventListener = function(chartSelector) {
|
||||
this.addButton.click(function(e) {
|
||||
e.preventDefault();
|
||||
|
@ -46,7 +46,7 @@ ChartSelector.prototype.updateSelector = function(selectorId, updatedData, tree)
|
|||
};
|
||||
ChartSelector.prototype.deleteChildSelector=function(parentDomNode,updatedData){
|
||||
var selectArray=$("#"+parentDomNode.attr("id")+" select");
|
||||
var divArray=$("#"+parentDomNode.attr("id")+" div")
|
||||
var divArray=$("#"+parentDomNode.attr("id")+" div");
|
||||
parentDomNode.html("");
|
||||
for(var i=0;i<selectArray.length;i++){
|
||||
parentDomNode.append(divArray[i]);
|
||||
|
@ -57,14 +57,14 @@ ChartSelector.prototype.deleteChildSelector=function(parentDomNode,updatedData){
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
};;
|
||||
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)
|
||||
selectedNode=this.getSelectNodeByValue(currentNode,pathValues);
|
||||
if(selectedNode==null)
|
||||
selectedNode = currentNode.children[0];
|
||||
var selectOptions = new Array();
|
||||
|
@ -88,7 +88,7 @@ ChartSelector.prototype.addSelectlistEvent=function(){
|
|||
chartSelector.updateSelector( chartSelector.addSelectorId, updatedData, chartSelector.excessTree);
|
||||
event.stopImmediatePropagation();
|
||||
});
|
||||
}
|
||||
};
|
||||
ChartSelector.prototype.createSelector = function(parentDomNode, treeNode) {
|
||||
var currentNode = treeNode;
|
||||
if (currentNode == null)
|
||||
|
@ -115,15 +115,15 @@ ChartSelector.prototype.getSelectNodeByValue=function(parentNode,values){
|
|||
}
|
||||
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.addClass("control-label");
|
||||
lable.text(lableText);
|
||||
div.append(lable);
|
||||
div.append("</br>")
|
||||
div.append("</br>");
|
||||
var select = $("<select ></select>");
|
||||
select.addClass("form-control");
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
|
@ -176,7 +176,7 @@ ChartSelector.prototype.initChart=function(pathValues){
|
|||
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);
|
||||
|
@ -224,7 +224,7 @@ Model.prototype.setIntervalId = function(intervalId) {
|
|||
function getSubDataArray(indexData, dataArray) {
|
||||
var subDataArray = new Array();
|
||||
for (var i = 0; i < dataArray.length; i++) {
|
||||
subDataArray.push(dataArray[i])
|
||||
subDataArray.push(dataArray[i]);
|
||||
if (dataArray[i] == indexData) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ Chart.prototype.addPoints=function(seriesId,data ) {
|
|||
chart.addPoint(seriesId,data[i]);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -87,7 +87,7 @@ Chart.prototype.addGraph = function(model) {
|
|||
$.post(model.url+"/"+model.time, {
|
||||
}, function(data) {
|
||||
if(!data.success){
|
||||
alert(data.failedMessage)
|
||||
alert(data.failedMessage);
|
||||
clearInterval(intervalId);
|
||||
return;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ Chart.prototype.addDataToGraph=function(chart,model,intervalId,data){
|
|||
chart.addPoint(model.series, point);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
Chart.prototype.deleteGraph = function(model) {
|
||||
for (var i = 0; i < this.modelArray.length; i++) {
|
||||
if (model.series==this.modelArray[i].series) {
|
||||
|
|
|
@ -15,7 +15,8 @@ function loadTests(table, model,loadLength,actionButton) {
|
|||
table.dataTable().fnClearTable();
|
||||
|
||||
$.post("loadTestPlans", {}, function(data) {
|
||||
if (data != null) {
|
||||
if (data.success) {
|
||||
data=data.data;
|
||||
if (data.list != null){
|
||||
if(loadLength<0)
|
||||
loadLength=data.list.length;
|
||||
|
@ -38,9 +39,10 @@ function loadTests(table, model,loadLength,actionButton) {
|
|||
testPlanIdColumn.html(href);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
alert("fail to load tests");
|
||||
alert(data.failedMessage);
|
||||
|
||||
|
||||
|
||||
$('.download').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
@ -78,12 +80,12 @@ function deleteTest(obj) {
|
|||
testPlanId : testPlanId
|
||||
}, function(data) {
|
||||
|
||||
if (data) {
|
||||
if (data.success) {
|
||||
var table = getTable(obj);
|
||||
var row = getRow(obj);
|
||||
$(table).dataTable().fnDeleteRow(row.rowIndex - 1);
|
||||
} else {
|
||||
alert("fail");
|
||||
alert(data.failedMessage);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -41,15 +41,15 @@ function login() {
|
|||
userName : userName,
|
||||
password : password
|
||||
}, function(data) {
|
||||
if (data) {
|
||||
|
||||
if (data.success) {
|
||||
$('#loginMsg').hide();
|
||||
window.location.replace("homepage.jsp");
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
$('#loginMsg').html($.i18n.prop('msgLogin'));
|
||||
$('#loginMsg').show();
|
||||
alert(data.failedMessage);
|
||||
}
|
||||
},"json");
|
||||
}
|
||||
|
@ -61,15 +61,14 @@ function adminLogin() {
|
|||
userName : userName,
|
||||
password : password
|
||||
}, function(data) {
|
||||
if (data) {
|
||||
if (data.success) {
|
||||
$('#loginMsg').hide();
|
||||
window.location.replace("agentManage.jsp");
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
$('#loginMsg').html($.i18n.prop('msgLogin'));
|
||||
$('#loginMsg').show();
|
||||
alert(data.failedMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -88,13 +87,14 @@ function register() {
|
|||
password : password,
|
||||
rePassword:rePassword
|
||||
}, function(data) {
|
||||
if (data) {
|
||||
if (data.success) {
|
||||
$('#registerMsg').hide();
|
||||
window.location.replace("index.jsp");
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
alert(data.failedMessage);
|
||||
// $('#registerMsg').html($.i18n.prop('msgRegister'));
|
||||
$('#registerMsg').show();
|
||||
}
|
||||
|
|
|
@ -47,12 +47,18 @@ var UrlContentTypeDistribution = function(containerId, testPlanId) {
|
|||
|
||||
$.post(url, "", function(data) {
|
||||
var dataArray = new Array();
|
||||
if (data != null) {
|
||||
if(!data.success){
|
||||
alert(data.failedMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
|
||||
for(var key in data)
|
||||
dataArray.push([key,data[key]]);
|
||||
chart.series[0].setData(dataArray);
|
||||
|
||||
}
|
||||
|
||||
loadItems.urlDistribution=true;
|
||||
},"json");
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ var loadItems=function(){
|
|||
this.behavior=false;
|
||||
this.urlDistribution=false;
|
||||
this.testBrief=false;
|
||||
}
|
||||
};
|
||||
function SetProgress(progress) {
|
||||
if (progress) {
|
||||
$("#" + progress_id + " > div").css("width", String(progress) + "%"); // 控制#loading
|
||||
|
|
|
@ -17,12 +17,15 @@ function getScriptList(testPlanId) {
|
|||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (data == null)
|
||||
return null;
|
||||
if(!data.success){
|
||||
alert(data.failedMessage);
|
||||
return;
|
||||
}
|
||||
else data=data.data;
|
||||
if (data.runningScriptModels.length <= 0)
|
||||
return null;
|
||||
for ( var i = 0; i < data.runningScriptModels.length; i++) {
|
||||
scriptList.push(data.runningScriptModels[i])
|
||||
scriptList.push(data.runningScriptModels[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +43,7 @@ var PageResult = function() {
|
|||
"averageResponseTimeThisTime", "latestResponseTime");
|
||||
this.table = $("#page").dataTable();
|
||||
|
||||
}
|
||||
};
|
||||
PageResult.prototype.addResultToTable = function() {
|
||||
this.table.fnClearTable();
|
||||
var result = this.result;
|
||||
|
@ -50,7 +53,7 @@ PageResult.prototype.addResultToTable = function() {
|
|||
}
|
||||
loadItems.pageResult=true;
|
||||
|
||||
}
|
||||
};
|
||||
var PageResultModel = function(page, scriptPageBriefModel, scriptName) {
|
||||
this.page = page;
|
||||
this.countFromBegin = scriptPageBriefModel.countFromBegin;
|
||||
|
@ -59,7 +62,7 @@ var PageResultModel = function(page, scriptPageBriefModel, scriptName) {
|
|||
this.averageResponseTimeThisTime = scriptPageBriefModel.averageResponseTimeThisTime;
|
||||
this.latestResponseTime = scriptPageBriefModel.latestResponseTime;
|
||||
this.scriptName = scriptName;
|
||||
}
|
||||
};
|
||||
|
||||
PageResult.prototype.getResult = function(testPlanId, scriptList) {
|
||||
var pageResult = this;
|
||||
|
@ -89,16 +92,18 @@ PageResult.prototype.getResult = function(testPlanId, scriptList) {
|
|||
}
|
||||
}, this.intevalTime);
|
||||
|
||||
}
|
||||
};
|
||||
PageResult.prototype.getSinglePageResult = function(pageResult, intervalId,
|
||||
finishedCount, script) {
|
||||
var urlPath = [ testPlanId, "script", script.scriptId, "page" ];
|
||||
var url = generateUrl(urlPath);
|
||||
$.post(url, {}, function(data) {
|
||||
if (data == null || data.scriptPageBriefModels == null) {
|
||||
if(!data.success){
|
||||
clearInterval(intervalId);
|
||||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
data = data.scriptPageBriefModels;
|
||||
var scriptPagesFinished = true;
|
||||
for ( var i = 0; i < data.length; i++) {
|
||||
|
@ -113,7 +118,7 @@ PageResult.prototype.getSinglePageResult = function(pageResult, intervalId,
|
|||
finishedCount++;
|
||||
|
||||
}, "json");
|
||||
}
|
||||
};
|
||||
|
||||
// Behavior-------------------------------------------------------
|
||||
var BehaviorResult = function() {
|
||||
|
@ -155,7 +160,7 @@ BehaviorResult.prototype.getResult = function(testPlanId, scriptList) {
|
|||
|
||||
}, this.intevalTime);
|
||||
|
||||
}
|
||||
};
|
||||
function generateUrl(urlPath) {
|
||||
var url = urlPath[0];
|
||||
for ( var i = 1; i < urlPath.length; i++)
|
||||
|
@ -168,10 +173,11 @@ BehaviorResult.prototype.getSingleBehaviorResult = function(behaviorResult,
|
|||
var urlPath = [ testPlanId, "script", script.scriptId, "behaviors" ];
|
||||
var url = generateUrl(urlPath);
|
||||
$.post(url, {}, function(data) {
|
||||
if (data == null) {
|
||||
if (!data.success) {
|
||||
clearInterval(intervalId);
|
||||
return;
|
||||
}
|
||||
data=data.data;
|
||||
if (data.finished || data.testBehaviorsBriefModel == null) {
|
||||
finishedCount++;
|
||||
}
|
||||
|
@ -182,11 +188,11 @@ BehaviorResult.prototype.getSingleBehaviorResult = function(behaviorResult,
|
|||
script.scriptName));
|
||||
|
||||
}, "json");
|
||||
}
|
||||
};
|
||||
var Behavior = function(behaviorBriefModel, scriptName) {
|
||||
this.behaviorBriefModel = behaviorBriefModel;
|
||||
this.scriptName = scriptName;
|
||||
}
|
||||
};
|
||||
BehaviorResult.prototype.getBehaviorsList = function(behaviorBriefModels,
|
||||
scriptName) {
|
||||
var behaviors = new Array();
|
||||
|
@ -194,7 +200,7 @@ BehaviorResult.prototype.getBehaviorsList = function(behaviorBriefModels,
|
|||
behaviors.push(new Behavior(behaviorBriefModels[i], scriptName));
|
||||
}
|
||||
return behaviors;
|
||||
}
|
||||
};
|
||||
|
||||
BehaviorResult.prototype.addBehaviorsToTable = function() {
|
||||
this.table.fnClearTable();
|
||||
|
@ -206,7 +212,7 @@ BehaviorResult.prototype.addBehaviorsToTable = function() {
|
|||
this.table.fnAddData(row);
|
||||
}
|
||||
loadItems.behaviorResult=true;
|
||||
}
|
||||
};
|
||||
BehaviorResult.prototype.DetailAddListener = function() {
|
||||
var behaviorResult = this;
|
||||
$(".show-detail-picture")
|
||||
|
@ -237,7 +243,7 @@ BehaviorResult.prototype.DetailAddListener = function() {
|
|||
}
|
||||
|
||||
});
|
||||
}
|
||||
};;
|
||||
BehaviorResult.prototype.showUrlDetailResult = function(brotherDom, url) {
|
||||
var theader = [ "url", "statusCode", "count", "contentLength",
|
||||
"minResponseTime", "maxResponseTime", "totalResponseTimeThisTime" ];
|
||||
|
@ -257,7 +263,7 @@ BehaviorResult.prototype.showUrlDetailResult = function(brotherDom, url) {
|
|||
this.addDataToDetailTable($(table.children("tbody")[0]), dataRows[i]);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
BehaviorResult.prototype.addDataToDetailTable = function(tbody, dataRow) {
|
||||
var tr = $("<tr></tr>");
|
||||
for ( var i = 0; i < dataRow.length; i++) {
|
||||
|
@ -266,9 +272,9 @@ BehaviorResult.prototype.addDataToDetailTable = function(tbody, dataRow) {
|
|||
tr.append(td);
|
||||
}
|
||||
tbody.append(tr);
|
||||
}
|
||||
};
|
||||
BehaviorResult.prototype.drawUrlDetailResult = function(theader) {
|
||||
var table = this.getDetaileTable(theader)
|
||||
var table = this.getDetaileTable(theader);
|
||||
var div = $("<div></div>");
|
||||
div.append(table);
|
||||
var td = $("<td colspan='5'></td>");
|
||||
|
@ -277,7 +283,7 @@ BehaviorResult.prototype.drawUrlDetailResult = function(theader) {
|
|||
tr.append(td);
|
||||
return tr;
|
||||
|
||||
}
|
||||
};
|
||||
BehaviorResult.prototype.getDetaileTable = function(theader) {
|
||||
var table = $("<table></table>");
|
||||
table.addClass("innerTable");
|
||||
|
@ -293,7 +299,7 @@ BehaviorResult.prototype.getDetaileTable = function(theader) {
|
|||
|
||||
return table;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
BehaviorResult.prototype.searchBehaviorByUrl = function(url) {
|
||||
var behaviors = this.behaviors;
|
||||
|
@ -303,7 +309,7 @@ BehaviorResult.prototype.searchBehaviorByUrl = function(url) {
|
|||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
var BehaviorModel = function(behavior, scriptName) {
|
||||
this.Url = behavior.behaviorUrl;
|
||||
|
@ -311,14 +317,14 @@ var BehaviorModel = function(behavior, scriptName) {
|
|||
this.Successful = this.getStatusCount(
|
||||
behavior.detailStatusCodeResultModels, 200);
|
||||
this.Total = this.getTotalCount(behavior.detailStatusCodeResultModels);
|
||||
}
|
||||
};
|
||||
var BehaviorDetailModel = function(url, behaviorDetaile) {
|
||||
this.url = url;
|
||||
for ( var key in behaviorDetaile) {
|
||||
if (key.indexOf("contentType") < 0)
|
||||
this[key] = behaviorDetaile[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
BehaviorModel.prototype.getStatusCount = function(behaviorStatusResultList,
|
||||
statusCode) {
|
||||
if (behaviorStatusResultList == null)
|
||||
|
@ -329,7 +335,7 @@ BehaviorModel.prototype.getStatusCount = function(behaviorStatusResultList,
|
|||
count += behaviorStatusResultList[i].count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
BehaviorModel.prototype.getTotalCount = function(behaviorStatusResultList) {
|
||||
if (behaviorStatusResultList == null)
|
||||
return 0;
|
||||
|
@ -338,7 +344,7 @@ BehaviorModel.prototype.getTotalCount = function(behaviorStatusResultList) {
|
|||
count += behaviorStatusResultList[i].count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
// need to abstract the tow
|
||||
// part----------------------------------------------------
|
||||
|
|
|
@ -12,8 +12,12 @@ function showTestPlanStatusAsync(testPlanId){
|
|||
/* var urlAddress= "/" + testPlanId + "/queryTestPlan";*/
|
||||
var urlAddress= testPlanId + "/queryTestPlan";
|
||||
$.post(urlAddress,{},function(data){
|
||||
if(data==null)
|
||||
if(!data.success){
|
||||
alert(data.failedMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
testStatus=data.currentStatus;
|
||||
$('#status').html('Test Status<br/><br><h4>'+testStatus+'</h4>');
|
||||
},"json");
|
||||
|
@ -21,8 +25,12 @@ function showTestPlanStatusAsync(testPlanId){
|
|||
function showTestBriefStatus(startTime){
|
||||
var urlAddress= testPlanId + "/testBriefStatus"+"/"+startTime;
|
||||
$.post(urlAddress,{},function(data){
|
||||
if(data==null)
|
||||
if(!data.success){
|
||||
alert(data.failedMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
startTime=data.time;
|
||||
$("#vu").html('VUs active<br/><br><h4>'+data.vus+'</h4>');
|
||||
$("#request").html('Requests<br/><br><h4>'+data.requests+'</h4>');
|
||||
|
@ -37,10 +45,12 @@ function getTestPlanStatus(testPlanId) {
|
|||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (data == null) {
|
||||
flag = false;
|
||||
if(!data.success){
|
||||
flag=false;
|
||||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
testStatus = data.currentStatus;
|
||||
if (data.currentStatus == "Complete"
|
||||
|| data.currentStatus == "InRunning") {
|
||||
|
|
|
@ -22,7 +22,7 @@ TreeNode.prototype.insertNodes = function(childNodes) {
|
|||
this.children.push(childNodes[i]);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
var Tree = function() {
|
||||
this.root = null;
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ Tree.prototype.getClondSubTreeByValue = function(value) {
|
|||
clonedTree.root.childClassName = parentNode.childClassName;
|
||||
this.getClonedSubTree(parentNode, clonedTree.root);// 这个就把引用传递过去了,应该没什么影响,我再看看吧
|
||||
return clonedTree;
|
||||
}
|
||||
};
|
||||
|
||||
Tree.prototype.searchTreeNodeByValue = function(parentNode, value) {
|
||||
|
||||
|
@ -53,7 +53,7 @@ Tree.prototype.searchTreeNodeByValue = function(parentNode, value) {
|
|||
if (value == parentNode.children[i].value) {
|
||||
return parentNode.children[i];
|
||||
}
|
||||
var node = this.searchTreeNodeByValue(parentNode.children[i], value)
|
||||
var node = this.searchTreeNodeByValue(parentNode.children[i], value);
|
||||
if (node != null)
|
||||
return node;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ Tree.prototype.getClonedTree = function(tree) {
|
|||
clonedTree.root = this.getClonedNode(tree.root);
|
||||
return clonedTree;
|
||||
|
||||
}
|
||||
};
|
||||
Tree.prototype.getClonedNode = function(node) {
|
||||
if (node == null)
|
||||
return null;
|
||||
|
@ -208,7 +208,7 @@ Tree.prototype.getClonedNode = function(node) {
|
|||
}
|
||||
}
|
||||
return clonedNode;
|
||||
}
|
||||
};
|
||||
/*
|
||||
* Tree.prototype.getExcessTreeNodes = function(allTreeNode, showTreeNode) { var
|
||||
* tree=this; if (allTreeNode == null) return null;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
var LoadItems=function(){
|
||||
this.scriptBriefStatusAve=false;
|
||||
this.pageResult=false;
|
||||
this.behaviorResult=false;
|
||||
this.urlDistribution=false;
|
||||
this.testBrief=false;
|
||||
var LoadItems = function() {
|
||||
this.scriptBriefStatusAve = false;
|
||||
this.pageResult = false;
|
||||
this.behaviorResult = false;
|
||||
this.urlDistribution = false;
|
||||
this.testBrief = false;
|
||||
};
|
||||
var loadItems=new LoadItems();
|
||||
var loadItems = new LoadItems();
|
||||
var testStatus;
|
||||
$(document).ready(
|
||||
function() {
|
||||
|
@ -18,8 +18,9 @@ $(document).ready(
|
|||
var replaceArray = createUrlReplaceArray(testPlanId);
|
||||
var chart = new Chart();
|
||||
chart.createChart($("#chart"));
|
||||
var chartSelector = createChartSelector(tree, chart, replaceArray,getShowTreePathValues(tree));
|
||||
chartSelector.initChart(getShowTreePathValues(tree),this);
|
||||
var chartSelector = createChartSelector(tree, chart, replaceArray,
|
||||
getShowTreePathValues(tree));
|
||||
chartSelector.initChart(getShowTreePathValues(tree), this);
|
||||
graphButtonListener(chartSelector);
|
||||
var behaviorResult = new BehaviorResult();
|
||||
behaviorResult.getResult(testPlanId, getScriptList(testPlanId));
|
||||
|
@ -29,10 +30,9 @@ $(document).ready(
|
|||
"url-distribution", testPlanId);
|
||||
});
|
||||
|
||||
|
||||
function replace(keyArray, replaceArray) {
|
||||
for ( var i = 0; i < keyArray.length; i++) {
|
||||
for ( var j = 0; j < replaceArray.length; j++) {
|
||||
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
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ function graphButtonListener(chartSelector) {
|
|||
if (chartSelector.excessTree.root != null)
|
||||
chartSelector.createSelector($("#"
|
||||
+ chartSelector.addSelectorId),
|
||||
chartSelector.excessTree.root)
|
||||
chartSelector.excessTree.root);
|
||||
}
|
||||
chartSelector.addSelectlistEvent();
|
||||
|
||||
|
@ -69,51 +69,57 @@ function graphButtonListener(chartSelector) {
|
|||
});
|
||||
}
|
||||
|
||||
function createChartSelector(tree, chart, replaceArray,showTreePathValues) {
|
||||
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 showTree = initShowTree(tree);
|
||||
var chartSelector = new ChartSelector(tree, showTree, chart, addSelectorId,
|
||||
deleteSelectorId, addButton, deleteButton, replaceArray,showTreePathValues);
|
||||
|
||||
deleteSelectorId, addButton, deleteButton, replaceArray,
|
||||
showTreePathValues);
|
||||
|
||||
return chartSelector;
|
||||
}
|
||||
function getShowTreePathValues(tree){
|
||||
function getShowTreePathValues(tree) {
|
||||
var currentNode = tree.root.children[0];
|
||||
var pathValues = new Array();
|
||||
while (currentNode != null) {
|
||||
pathValues.push(currentNode.value)
|
||||
if(currentNode.children!==null)
|
||||
pathValues.push(currentNode.value);
|
||||
if (currentNode.children !== null)
|
||||
currentNode = currentNode.children[0];
|
||||
else currentNode=null;
|
||||
else
|
||||
currentNode = null;
|
||||
|
||||
}
|
||||
return pathValues;
|
||||
}
|
||||
function initShowTree(tree) {
|
||||
|
||||
var pathValues=getShowTreePathValues(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",
|
||||
/* url : "/" + testPlanId + "/mapInfo", */
|
||||
url : testPlanId + "/mapInfo",
|
||||
dataType : "json",
|
||||
async : false,
|
||||
success : function(data) {
|
||||
if (data == null)
|
||||
return null;
|
||||
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);
|
||||
|
@ -129,7 +135,7 @@ 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++) {
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
|
|
Loading…
Reference in New Issue