get test plan schedule model from chart

This commit is contained in:
hmm 2014-09-24 11:09:47 +08:00
parent cbc19f8207
commit a7553c3c98
13 changed files with 136 additions and 62 deletions

View File

@ -1 +0,0 @@
<html><head><meta http-equiv="Content-Type" content="text/html; charset=GBK"><script type='text/javascript'>document.domain='baidu.com';</script></head><body></body><script>try{parent.bdcallback({"CNYBA.fx":{na:"美元人民币",pc:"6.1400",op:"0.0000",la:"6.1403",hi:"6.1411",lo:"6.1360",bp1:"6.1418",ap1:"6.1403",zde:"0.0003",zdf:"0.00",type:"4",time:"2014-09-19 16:31:55"},"HKCNBA.fx":{na:"港元人民币",pc:"0.7922",op:"0.0000",la:"0.7921",hi:"0.7923",lo:"0.7916",bp1:"0.7924",ap1:"0.7921",zde:"-0.0001",zdf:"-0.01",type:"4",time:"2014-09-19 17:15:40"},"ERCNBA.fx":{na:"欧元人民币",pc:"7.9341",op:"0.0000",la:"7.9099",hi:"7.9356",lo:"7.8995",bp1:"7.9131",ap1:"7.9099",zde:"-0.0242",zdf:"-0.31",type:"4",time:"2014-09-19 17:17:09"},"UKCNBA.fx":{na:"英镑人民币",pc:"10.0696",op:"0.0000",la:"10.0590",hi:"10.1469",lo:"10.0406",bp1:"10.0640",ap1:"10.0590",zde:"-0.0106",zdf:"-0.11",type:"4",time:"2014-09-19 17:17:08"},"USDJPY.fx":{na:"美元日元",pc:"108.7800",op:"108.8000",la:"108.8200",hi:"109.4500",lo:"108.7600",bp1:"108.8200",ap1:"108.8400",zde:"0.0400",zdf:"0.04",type:"1",time:"2014-09-19 17:18:58"},"EURUSD.fx":{na:"欧元美元",pc:"1.2917",op:"1.2917",la:"1.2884",hi:"1.2928",lo:"1.2866",bp1:"1.2884",ap1:"1.2885",zde:"-0.0033",zdf:"-0.26",type:"1",time:"2014-09-19 17:18:57"},"GBPUSD.fx":{na:"英镑美元",pc:"1.6427",op:"1.6438",la:"1.6382",hi:"1.6523",lo:"1.6353",bp1:"1.6382",ap1:"1.6386",zde:"-0.0045",zdf:"-0.27",type:"1",time:"2014-09-19 17:18:57"},"tofnow":{time:"2014-09-19 17:24:08"}})}catch(e){}</script></html

View File

@ -121,7 +121,7 @@ public class ResponseParser {
charset = Charset.forName("utf-8"); charset = Charset.forName("utf-8");
} }
this.getResponseHeader().setContentCharset(charset); this.getResponseHeader().setContentCharset(charset);
logger.error(e, e); // logger.error(e, e);
} }
this.setResponseBody(new String(contentBodyAfterDecoded, charset)); this.setResponseBody(new String(contentBodyAfterDecoded, charset));
} }
@ -159,7 +159,7 @@ public class ResponseParser {
charset = this.getResponseHeader().getContentCharset(); charset = this.getResponseHeader().getContentCharset();
if (charset == null) if (charset == null)
charset = Charset.forName("utf-8"); charset = Charset.forName("utf-8");
logger.error(e, e); // logger.error(e, e);
} }
byte[] responseBytes = responseBody.getBytes(charset); byte[] responseBytes = responseBody.getBytes(charset);
responseBytes = contentEncoder.encoderContent(responseBytes); responseBytes = contentEncoder.encoderContent(responseBytes);

View File

@ -210,3 +210,6 @@ stop=Stop
testProxySettings=testProxySettings testProxySettings=testProxySettings
startRecording=startRecording startRecording=startRecording
stopRecording=Stop Recording stopRecording=Stop Recording
custom-mode=Custom Mode
target-mode=Target Mode
load-mode=Load Mode

View File

@ -211,3 +211,6 @@ stop=\u505C\u6B62
testProxySettings=\u6d4b\u8bd5Proxy\u8bbe\u7f6e testProxySettings=\u6d4b\u8bd5Proxy\u8bbe\u7f6e
startRecording=\u5f00\u59cb\u5f55\u5236 startRecording=\u5f00\u59cb\u5f55\u5236
stopRecording=\u505C\u6B62\u5f55\u5236 stopRecording=\u505C\u6B62\u5f55\u5236
custom-mode=\u5E38\u89C4\u6A21\u5F0F
target-mode=\u76EE\u6807\u6A21\u5F0F
load-mode=\u65BD\u538B\u6A21\u5F0F

View File

@ -115,3 +115,18 @@ select{
div#test-plan-continuous{ div#test-plan-continuous{
width:100%; width:100%;
} }
.modeSelectLabel{
margin-right:15px;
cursor:default;
}
.modeSelectDiv{
margin-bottom:10px;
margin-top:5px;
font-size:14px;
}
.modeSelectRadio{
margin-left:15px;
}
.modeSelectTitle{
margin-right:15px;
}

View File

@ -64,7 +64,7 @@ body {
<div class="image"></div> <div class="image"></div>
<div class="desc"> <div class="desc">
<h3> <h3>
<fmt:message key="scriptmanagerment" /> <fmt:message key="scriptmanagement" />
</h3> </h3>
</div> <span class="step-number two">3</span> </div> <span class="step-number two">3</span>
</a></li> </a></li>

View File

@ -50,3 +50,5 @@ startRecordingMessage=Please click start recording
stopRecordingMessage=Please click stop recording stopRecordingMessage=Please click stop recording
failed-connect-server=failed to connect server failed-connect-server=failed to connect server
close-proxy-setting=clear the proxy setting close-proxy-setting=clear the proxy setting
custom-mode=custom mode
target-mode=target mode

View File

@ -46,3 +46,5 @@ startRecordingMessage=\u8bf7\u70b9\u51fb\u5f00\u59cb\u5f55\u5236
stopRecordingMessage=\u8bf7\u70b9\u51fb\u505c\u6b62\u5f55\u5236 stopRecordingMessage=\u8bf7\u70b9\u51fb\u505c\u6b62\u5f55\u5236
failed-connect-server=\u8FDE\u63A5\u670D\u52A1\u5668\u5931\u8D25\uFF01 failed-connect-server=\u8FDE\u63A5\u670D\u52A1\u5668\u5931\u8D25\uFF01
close-proxy-setting=\u8BF7\u5173\u95ED\u4EE3\u7406 close-proxy-setting=\u8BF7\u5173\u95ED\u4EE3\u7406
custom-mode=\u5E38\u89C4\u6A21\u5F0F
target-mode=\u76EE\u6807\u6A21\u5F0F

View File

@ -6,10 +6,11 @@ function ScriptModel(ID, schedule, isFilterTimer, filterTypeMatches) {
}; };
function TestPlanRequestModel(scriptList, ipList, testPlanName) { function TestPlanRequestModel(scriptList, ipList, testPlanName, limitModel) {
this.scriptList = scriptList; this.scriptList = scriptList;
this.ipList = ipList; this.ipList = ipList;
this.testPlanName = testPlanName; this.testPlanName = testPlanName;
this.limitModel = limitModel;
}; };
function WebScheduleModel(points){ function WebScheduleModel(points){
@ -20,3 +21,12 @@ function WebPointModel(timeInSecond, load){
this.timeInSecond = timeInSecond; this.timeInSecond = timeInSecond;
this.load = load; this.load = load;
} }
function LimitModel(params){
this.params = params;
}
function ParameterModel(name, limit){
this.name = name;
this.limit = limit;
}

View File

@ -71,14 +71,11 @@ function getScriptId(scriptName) {
return scriptId; return scriptId;
} }
function getPointModelList(allocation,requireLoadArrayObj,executeRangeArrayObj){ function getPointModelList(allocation,chartPoint){
var pointModelList = new Array(); var pointModelList = new Array();
var preExeRange = 0; for(var i=0;i< chartPoint.length;i++){
var zeroPointModel = new WebPointModel(0,0); var realLoad = parseInt(parseInt(chartPoint[i][1])*allocation/100);
pointModelList.push(zeroPointModel); var pointModel = new WebPointModel(parseInt(chartPoint[i][0]),realLoad);
for(var i=1;i< requireLoadArrayObj.length;i++){
var realLoad = parseInt(parseInt(requireLoadArrayObj[i].value)*allocation/100);
var pointModel = new WebPointModel(preExeRange+=parseInt(executeRangeArrayObj[i].value),realLoad);
pointModelList.push(pointModel); pointModelList.push(pointModel);
} }
return pointModelList; return pointModelList;
@ -93,10 +90,6 @@ function start() {
var scriptList = new Array(); var scriptList = new Array();
var scriptIdList = new Array(); var scriptIdList = new Array();
//
var requireLoadArrayObj = $("#test-plan-continuous").find("input[name='RequireLoad']");
var executeRangeArrayObj = $("#test-plan-continuous").find("input[name='ExecuteRange']");
for ( var i = 0; i < input.length; i++) for ( var i = 0; i < input.length; i++)
allocationList.push(parseInt(input[i].value)); allocationList.push(parseInt(input[i].value));
@ -118,12 +111,14 @@ function start() {
//delete last | //delete last |
if(filterTypeMatches != "") if(filterTypeMatches != "")
filterTypeMatches = filterTypeMatches.substring(0,filterTypeMatches.length-1); filterTypeMatches = filterTypeMatches.substring(0,filterTypeMatches.length-1);
var chartPoint = currentChart.options.series[0].data;
//get schedule model by selected mode
for ( var k = 0; k < input.length; k++){ for ( var k = 0; k < input.length; k++){
var scheduleModel = new WebScheduleModel(getPointModelList(allocationList[k],requireLoadArrayObj,executeRangeArrayObj)); var scheduleModel = new WebScheduleModel(getPointModelList(allocationList[k],chartPoint));
scriptList.push(new ScriptModel(scriptIdList[k],scheduleModel ,isFilterTimer,filterTypeMatches)); scriptList.push(new ScriptModel(scriptIdList[k],scheduleModel ,isFilterTimer,filterTypeMatches));
} }
//collect limit
var name = $("#testConfigurationName").val(); var name = $("#testConfigurationName").val();
var testPlan = new TestPlanRequestModel(scriptList, ipList, name); var testPlan = new TestPlanRequestModel(scriptList, ipList, name);
@ -144,7 +139,18 @@ function start() {
}); });
} }
function loadLimitableFields(){
$.post("getLimitableFields", {}, function(data) {
if(!data.success){
information(data.failedMessage);
return;
}else{
data.limitableFields.fields;//this is list<String>, limitable fields' name
}
}).error(function(){
information($.i18n.prop('failed-connect-server'));
});
}
function createNewScript(){ function createNewScript(){
window.open("script.jsp"); window.open("script.jsp");
} }

View File

@ -81,6 +81,7 @@ function loadSchedulePlot() {
options.series[0].data.push([ExecuteRange,RequireLoad]); options.series[0].data.push([ExecuteRange,RequireLoad]);
} }
var chart = new Highcharts.Chart(options); var chart = new Highcharts.Chart(options);
currentChart = chart;
} }
@ -109,3 +110,8 @@ function toggleIpConfig() {
else else
$("#icon-ip").attr("class", "icon-plus"); $("#icon-ip").attr("class", "icon-plus");
} }
function changeMode(newModeId, oldModeId){
$("#"+oldModeId).addClass("hide");
$("#"+newModeId).removeClass("hide");
}

View File

@ -1,3 +1,4 @@
var currentChart;
$(document).ready(function() { $(document).ready(function() {
loadScripts(); loadScripts();
loadSchedulePlot(); loadSchedulePlot();

View File

@ -80,23 +80,39 @@ body {
<fmt:message key="testPlanConfig" /> <fmt:message key="testPlanConfig" />
</p> </p>
</div> </div>
<div id="loadTestExecutionPlan" class="content-frame row-fluid"> <div id="loadTestExecutionPlan">
<div id="modeSelectDiv" class="modeSelectDiv">
<span class="modeSelectTitle"><fmt:message key="load-mode" />:</span>
<input
type="radio" name="modeSelect" id="customSelected"
class="modeSelectRadio" value="custom mode" onclick="changeMode('customMode','targetMode')" checked>
<span
class="modeSelectLabel"><fmt:message key="custom-mode" /></span>
<input type="radio" name="modeSelect" id="targetSelected"
class="modeSelectRadio" value="target mode" onclick="changeMode('targetMode','customMode')">
<span
class="modeSelectLabel"><fmt:message key="target-mode" /></span>
</div>
<div id="customMode" class="content-frame row-fluid">
<div class="span4"> <div class="span4">
<div id="test-plan-continuous" class="form" style="float: left;"> <div id="test-plan-continuous" class="form" style="float: left;">
<div id="step-clone-continuous" class="field-line" style="display:none;"> <div id="step-clone-continuous" class="field-line"
style="display: none;">
<table id="loadConfig" class="table-margin-top"> <table id="loadConfig" class="table-margin-top">
<tr> <tr>
<td><fmt:message key="test-load" /></td> <td><fmt:message key="test-load" /></td>
<td><fmt:message key="test-excuteRange" />(s)</td> <td><fmt:message key="test-excuteRange" />(s)</td>
</tr> </tr>
<tr> <tr>
<td width="186px"><input name="RequireLoad" class="load-config-input" <td width="186px"><input name="RequireLoad"
type="text" value="10" class="load-config-input" type="text" value="10"
onblur="loadSchedulePlot();checkLoadConfig()" /></td> onblur="loadSchedulePlot();checkLoadConfig()" /></td>
<td width="186px"><input name="ExecuteRange" class="load-config-input" <td width="186px"><input name="ExecuteRange"
type="text" value="10" class="load-config-input" type="text" value="10"
onblur="loadSchedulePlot();checkLoadConfig()" /> onblur="loadSchedulePlot();checkLoadConfig()" /> <a
<a href="#" class="deleteStep" onClick="deleteStep()"><img src="/images/delete.png" alt="Delete" width="16" height="16"></a></td> href="#" class="deleteStep" onClick="deleteStep()"><img
src="/images/delete.png" alt="Delete" width="16"
height="16"></a></td>
</tr> </tr>
</table> </table>
</div> </div>
@ -108,18 +124,19 @@ body {
</tr> </tr>
<tr> <tr>
<td width="186px"><input name="RequireLoad" class="load-config-input" <td width="186px"><input name="RequireLoad"
type="text" value="10" class="load-config-input" type="text" value="10"
onblur="loadSchedulePlot();checkLoadConfig()" /></td> onblur="loadSchedulePlot();checkLoadConfig()" /></td>
<td width="186px"><input name="ExecuteRange" class="load-config-input" <td width="186px"><input name="ExecuteRange"
type="text" value="10" class="load-config-input" type="text" value="10"
onblur="loadSchedulePlot();checkLoadConfig()" /></td> onblur="loadSchedulePlot();checkLoadConfig()" /></td>
</tr> </tr>
</table> </table>
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary" id="addStep">Add step</button> <button type="submit" class="btn btn-primary" id="addStep">Add
step</button>
<span id="loadConfigMessage" class="hide">all input can <span id="loadConfigMessage" class="hide">all input can
not be empty <br />and must be greater than zero! not be empty <br />and must be greater than zero!
</span> </span>
@ -128,7 +145,17 @@ body {
<div id="highchartsPlot"></div> <div id="highchartsPlot"></div>
</div> </div>
</div> </div>
<div id="targetMode" class="hide content-frame row-fluid">
<div class="span4">
<span id="loadConfigMessage2" class="hide">all input can
not be empty <br />and must be greater than zero!
</span>
</div>
<div class="span8">
<div id="highchartsPlot2"></div>
</div>
</div>
</div>
<div class="title-frame" onClick="toggleUserScenarios()"> <div class="title-frame" onClick="toggleUserScenarios()">
<i class="icon-minus" id="icon-user"></i> <i class="icon-minus" id="icon-user"></i>
<p class="title"> <p class="title">