From a7553c3c9840f79fa45d465cdd9b2af5055aad9d Mon Sep 17 00:00:00 2001 From: hmm Date: Wed, 24 Sep 2014 11:09:47 +0800 Subject: [PATCH] get test plan schedule model from chart --- .../RecordScriptTestCase/baidu.html | 1 - .../httpcapture/generator/ResponseParser.java | 4 +- .../webapp/WEB-INF/classes/i18n_en.properties | 5 +- .../webapp/WEB-INF/classes/i18n_zh.properties | 5 +- Bench4Q-Web/src/main/webapp/css/test.css | 15 +++ Bench4Q-Web/src/main/webapp/homepage.jsp | 2 +- .../src/main/webapp/i18n/i18n.properties | 4 +- .../main/webapp/i18n/i18n_zh-CN.properties | 2 + .../webapp/script/TestPlan/TestPlanModels.js | 12 +- .../webapp/script/TestPlan/TestPlanServer.js | 36 +++--- .../main/webapp/script/TestPlan/TestPlanUI.js | 6 + .../src/main/webapp/script/TestPlan/test.js | 1 + Bench4Q-Web/src/main/webapp/test.jsp | 105 +++++++++++------- 13 files changed, 136 insertions(+), 62 deletions(-) delete mode 100644 Bench4Q-Master/RecordScriptTestCase/baidu.html diff --git a/Bench4Q-Master/RecordScriptTestCase/baidu.html b/Bench4Q-Master/RecordScriptTestCase/baidu.html deleted file mode 100644 index 8824626a..00000000 --- a/Bench4Q-Master/RecordScriptTestCase/baidu.html +++ /dev/null @@ -1 +0,0 @@ -

- +

3 diff --git a/Bench4Q-Web/src/main/webapp/i18n/i18n.properties b/Bench4Q-Web/src/main/webapp/i18n/i18n.properties index c7711697..8af7b292 100644 --- a/Bench4Q-Web/src/main/webapp/i18n/i18n.properties +++ b/Bench4Q-Web/src/main/webapp/i18n/i18n.properties @@ -49,4 +49,6 @@ stopTestPlan_fail=Stop running test plan fail startRecordingMessage=Please click start recording stopRecordingMessage=Please click stop recording failed-connect-server=failed to connect server -close-proxy-setting=clear the proxy setting \ No newline at end of file +close-proxy-setting=clear the proxy setting +custom-mode=custom mode +target-mode=target mode \ No newline at end of file diff --git a/Bench4Q-Web/src/main/webapp/i18n/i18n_zh-CN.properties b/Bench4Q-Web/src/main/webapp/i18n/i18n_zh-CN.properties index dc947403..13e2e1e1 100644 --- a/Bench4Q-Web/src/main/webapp/i18n/i18n_zh-CN.properties +++ b/Bench4Q-Web/src/main/webapp/i18n/i18n_zh-CN.properties @@ -46,3 +46,5 @@ startRecordingMessage=\u8bf7\u70b9\u51fb\u5f00\u59cb\u5f55\u5236 stopRecordingMessage=\u8bf7\u70b9\u51fb\u505c\u6b62\u5f55\u5236 failed-connect-server=\u8FDE\u63A5\u670D\u52A1\u5668\u5931\u8D25\uFF01 close-proxy-setting=\u8BF7\u5173\u95ED\u4EE3\u7406 +custom-mode=\u5E38\u89C4\u6A21\u5F0F +target-mode=\u76EE\u6807\u6A21\u5F0F \ No newline at end of file diff --git a/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanModels.js b/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanModels.js index c65fdd4d..4cd87345 100644 --- a/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanModels.js +++ b/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanModels.js @@ -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.ipList = ipList; this.testPlanName = testPlanName; + this.limitModel = limitModel; }; function WebScheduleModel(points){ @@ -19,4 +20,13 @@ function WebScheduleModel(points){ function WebPointModel(timeInSecond, load){ this.timeInSecond = timeInSecond; this.load = load; +} + +function LimitModel(params){ + this.params = params; +} + +function ParameterModel(name, limit){ + this.name = name; + this.limit = limit; } \ No newline at end of file diff --git a/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanServer.js b/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanServer.js index cf47e6ab..b082f423 100644 --- a/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanServer.js +++ b/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanServer.js @@ -71,14 +71,11 @@ function getScriptId(scriptName) { return scriptId; } -function getPointModelList(allocation,requireLoadArrayObj,executeRangeArrayObj){ +function getPointModelList(allocation,chartPoint){ var pointModelList = new Array(); - var preExeRange = 0; - var zeroPointModel = new WebPointModel(0,0); - pointModelList.push(zeroPointModel); - 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); + for(var i=0;i< chartPoint.length;i++){ + var realLoad = parseInt(parseInt(chartPoint[i][1])*allocation/100); + var pointModel = new WebPointModel(parseInt(chartPoint[i][0]),realLoad); pointModelList.push(pointModel); } return pointModelList; @@ -93,10 +90,6 @@ function start() { var scriptList = 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++) allocationList.push(parseInt(input[i].value)); @@ -118,13 +111,15 @@ function start() { //delete last | if(filterTypeMatches != "") 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++){ - 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)); } - + //collect limit + var name = $("#testConfigurationName").val(); var testPlan = new TestPlanRequestModel(scriptList, ipList, name); $.ajax({ @@ -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, limitable fields' name + } + }).error(function(){ + information($.i18n.prop('failed-connect-server')); + }); +} function createNewScript(){ window.open("script.jsp"); } diff --git a/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanUI.js b/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanUI.js index 60724bfb..beac6fe3 100644 --- a/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanUI.js +++ b/Bench4Q-Web/src/main/webapp/script/TestPlan/TestPlanUI.js @@ -81,6 +81,7 @@ function loadSchedulePlot() { options.series[0].data.push([ExecuteRange,RequireLoad]); } var chart = new Highcharts.Chart(options); + currentChart = chart; } @@ -108,4 +109,9 @@ function toggleIpConfig() { $("#icon-ip").attr("class", "icon-minus"); else $("#icon-ip").attr("class", "icon-plus"); +} + +function changeMode(newModeId, oldModeId){ + $("#"+oldModeId).addClass("hide"); + $("#"+newModeId).removeClass("hide"); } \ No newline at end of file diff --git a/Bench4Q-Web/src/main/webapp/script/TestPlan/test.js b/Bench4Q-Web/src/main/webapp/script/TestPlan/test.js index dd2580c1..2b958663 100644 --- a/Bench4Q-Web/src/main/webapp/script/TestPlan/test.js +++ b/Bench4Q-Web/src/main/webapp/script/TestPlan/test.js @@ -1,3 +1,4 @@ +var currentChart; $(document).ready(function() { loadScripts(); loadSchedulePlot(); diff --git a/Bench4Q-Web/src/main/webapp/test.jsp b/Bench4Q-Web/src/main/webapp/test.jsp index d982a884..a4ea254b 100644 --- a/Bench4Q-Web/src/main/webapp/test.jsp +++ b/Bench4Q-Web/src/main/webapp/test.jsp @@ -80,55 +80,82 @@ body {

-
-
-
- + + all input can + not be empty
and must be greater than zero! +
+
+
+
+
+
+
+
+ all input can + not be empty
and must be greater than zero! +
+
+
+
+
+
+