add getScriptResultData

This commit is contained in:
fanfuxiaoran 2013-12-08 23:14:23 +08:00
parent 0f76fd7584
commit dc16e09088
5 changed files with 79 additions and 33 deletions

2
.gitignore vendored
View File

@ -10,4 +10,4 @@
.externalToolBuilders .externalToolBuilders
/src/main/webapp/.htaccess /src/main/webapp/.htaccess
/logs/ /logs/log.log

View File

@ -32,7 +32,7 @@ public abstract class BaseControllerService {
public static final Properties prop = new Properties(); public static final Properties prop = new Properties();
public BaseControllerService() { public BaseControllerService() {
/*String masterIpFilePath; String masterIpFilePath;
try { try {
masterIpFilePath = BaseControllerService.class.getClassLoader() masterIpFilePath = BaseControllerService.class.getClassLoader()
.getResource("").toURI().getPath() .getResource("").toURI().getPath()
@ -47,9 +47,9 @@ public abstract class BaseControllerService {
e1.printStackTrace(); e1.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}*/ }
this.masterIP="127.0.0.1:7979/"; /*this.masterIP="127.0.0.1:7979/";*/
} }
public HttpRequester getHttpRequester() { public HttpRequester getHttpRequester() {

View File

@ -74,8 +74,11 @@ body {
<script src='js/jquery.dataTables.min.js'></script> <script src='js/jquery.dataTables.min.js'></script>
<script src="js/theme.js"></script> <script src="js/theme.js"></script>
<script src="js/jquery.i18n.properties-1.0.9.js"></script> <script src="js/jquery.i18n.properties-1.0.9.js"></script>
<script src="js/highcharts.js"></script>
<script src="script/base.js"></script> <script src="script/base.js"></script>
<script src="script/uiCreate.js"></script> <script src="script/uiCreate.js"></script>
<script src="script/graph.oper.js"></script>
<script src="script/highChartTheme.js"></script>
<script src="script/result-new.js"></script> <script src="script/result-new.js"></script>
</fmt:bundle> </fmt:bundle>
</body> </body>

View File

@ -13,7 +13,7 @@ Highcharts.theme = {
plotShadow: true, plotShadow: true,
plotBorderWidth: 1 plotBorderWidth: 1
}, },
title: { /* title: {
style: { style: {
color: '#000', color: '#000',
font: 'bold 16px "Trebuchet MS", Verdana, sans-serif' font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
@ -24,7 +24,7 @@ Highcharts.theme = {
color: '#666666', color: '#666666',
font: 'bold 12px "Trebuchet MS", Verdana, sans-serif' font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
} }
}, },*/
xAxis: { xAxis: {
gridLineWidth: 1, gridLineWidth: 1,
lineColor: '#000', lineColor: '#000',

View File

@ -1,6 +1,7 @@
var container = $('#container'); var container = $('#container');
var containerHeader = $('#containerHeader'); var containerHeader = $('#containerHeader');
var testPlanId; var testPlanId;
var initShowList=null;
var urlModel = new UrlModel(); var urlModel = new UrlModel();
var testBriefModelField = new Array("name", "uuid", "scripts", "SUT", "status"); var testBriefModelField = new Array("name", "uuid", "scripts", "SUT", "status");
var scriptInfo = new Array("name", "id", "load", "warm up", "execute", var scriptInfo = new Array("name", "id", "load", "warm up", "execute",
@ -10,9 +11,7 @@ var scriptResult = new Array("averageResponseTime",
"failThroughputThisTime"); "failThroughputThisTime");
var containerModel = new ContainerModel(); var containerModel = new ContainerModel();
var runningInfo=null;
function ContainerModel() { function ContainerModel() {
this.testBox = "testBox"; this.testBox = "testBox";
@ -30,10 +29,6 @@ $(document).ready(
function() { function() {
/* testPlanId = getvars()['testPlanId']; */ /* testPlanId = getvars()['testPlanId']; */
testPlanId = 1; testPlanId = 1;
var scripts = new Array("www", "wxr");
var allList = createScriptList(scripts, scriptResult);
initChartBox(container, containerModel.scriptChartBox, "char",
allList, null, null);
getRunningInfo(urlModel.runInfo, testPlanId); getRunningInfo(urlModel.runInfo, testPlanId);
/* getScriptResult(urlModel.scriptResult,testPlanId,initScriptResultContainer); */ /* getScriptResult(urlModel.scriptResult,testPlanId,initScriptResultContainer); */
@ -45,17 +40,53 @@ function getRunningInfo(url, testPlanId) {
testPlanId : testPlanId testPlanId : testPlanId
}, function(data) { }, function(data) {
processTestBriefInfo(data); processTestBriefInfo(data);
runningInfo=data;
}, "json"); }, "json");
} }
function getScriptResult(url, testPlanId, scriptId, callback) {
$.post(url, { function updateChart(){}
testPlanId : testPlanId, /*function getScriptResult( chart,testPlanId, scriptIndexModel,showList) {
scriptId : scriptId
}, callback(data), "json");
var intervalId = null;
intervalId = setInterval(function() {
for(var i=0;i<showList.child.length;i++){
var scriptName=showList.child[i].key;
var result=new Array();
var series=new Array();
for(var j=0;j<showList.child[i].child.length;j++){
result.push(showList.child[i].child[j].key);
series.push(chart.get(scriptName+"_"+showList.child[i].key));
}
var scriptId=getScriptIdByName(scriptName,scriptIndexModels);
$.post("getScriptBriefStatus", {
testPlanId : testPlanId,
scriptId : scriptId
}, function(data){
for(var i=0;i<result.length;i++){
for(var key in data){
if(key==result[i])
series[i].addPoint([(new Date()).getTime(),data.key]);
//add finish
}
}
},"json");
}
});
}*/
function getScriptIdByName(scriptName,scriptIndexModels){
for(var i=0;i<scriptIndexModels.length;i++){
if(scriptName==scriptIndexModels[i].scriptName){
return scriptIndexModels[i],scriptId;
}
}
} }
//need to refactor to createTree //need to refactor to createTree
function createScriptList(scripts, scriptResult) { function createSelectTree(scriptIndexModels, scriptResult) {
var scripts=new Array();
for(var i=0;i<scriptIndexModels.length;i++){
scripts.push(scriptIndexModels[i].scriptName);
}
if (scripts.length == null || scripts.length <= 0) if (scripts.length == null || scripts.length <= 0)
return; return;
var list = new treeNode("Script", "", new Array()); var list = new treeNode("Script", "", new Array());
@ -78,14 +109,20 @@ function processTestBriefInfo(data) {
if (data != null) { if (data != null) {
/* initTestInfoContainer(containerHeader, data); */ /* initTestInfoContainer(containerHeader, data); */
if (data.scriptIndexModels != null && data.scriptIndexModels.length > 0) { if (data.scriptIndexModels != null && data.scriptIndexModels.length > 0) {
initTestScriptContainer(container, data.scriptIndexModels); initTestScriptTable(container, data.scriptIndexModels);
var allTree=createSelectTree(data.scriptIndexModels,scriptResult);
/* initScriptResultContainer(container, data.scriptIndexModels); */ var initShowList = new treeNode("", "", null);
initChartBox(container, containerModel.scriptChartBox, "script chart", allTree, initShowLists);
getScriptResult(chart,testPlanId,data.scriptIndexModel);
updateChart();
} }
if (data.monitorModels != null && data.monitorModels.length > 0) if (data.monitorModels != null && data.monitorModels.length > 0)
initSUTContainer(parent, data.monitorModels); initSUTContainer(parent, data.monitorModels);
} else } else
alert("get testplan runing info is error! "); alert("get testplan runing info is error! ");
}
function updateChart(id,data){
} }
function initTestInfoContainer(parent, data) { function initTestInfoContainer(parent, data) {
var box = createBox(4, "Test"); var box = createBox(4, "Test");
@ -104,7 +141,7 @@ function initTestInfoContainer(parent, data) {
ul.append(createLi("status", data.status, "green", "icon-arrow-up")); ul.append(createLi("status", data.status, "green", "icon-arrow-up"));
} }
function initTestScriptContainer(parent, data) { function initTestScriptTable(parent, data) {
var box = createBox(12, "Scripts"); var box = createBox(12, "Scripts");
/* addId(box, containerModel.scriptBox); */ /* addId(box, containerModel.scriptBox); */
addCloseAndMinIcons(box); addCloseAndMinIcons(box);
@ -125,24 +162,30 @@ function initSUTContainer(data) {
} }
function initChartBox(parent, id, title, allList, initShowList, data) { function initChartBox(parent, id, title, allList, initShowList) {
var box = createChartBox(id, 12, title); var box = createChartBox(id, 12, title);
var div=$("<div></div>");
addId(div,id+"Chart");
box.append(div);
parent.append(box); parent.append(box);
if (allList == null) if (allList == null)
alert("list is null"); alert("list is null");
var excessList = generateExcessList(allList, initShowList); var excessList = generateExcessList(allList, initShowList);
if (initShowList == null) if (initShowList == null)
initShowList = new treeNode("", "", null); initShowList = new treeNode("", "", null);
var chart=createChart(id+"Chart", initAxis); var initAxis=null;
var chart=createChart(div, initAxis);
addChartEvent(id, excessList, initShowList); addChartEvent(id, excessList, initShowList);
} }
function createChart(id, initAxis) { function createChart(container, initAxis) {
var container = $("#" + id); container.highcharts({});
var chart = container.highcharts(); var chart = container.highcharts();
chart.xAxis[0].update({ chart.xAxis[0].update({
type : 'datetime', type : 'datetime',
}); });
if(initAxis==null)
return chart;
for(var i=0;i<initAxis.length;i++){ for(var i=0;i<initAxis.length;i++){
addAxis(chart,initAxis[i],initAxis[i]); addAxis(chart,initAxis[i],initAxis[i]);
} }