success to filter behavior

This commit is contained in:
hmm 2014-09-03 13:35:02 +08:00
parent 4e01cf19db
commit 8b0e7a1985
10 changed files with 377 additions and 743 deletions

View File

@ -4,6 +4,7 @@ import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@ -166,8 +167,7 @@ public class TestPlanFactory {
private Script createAScriptWithFilter(
ScriptFilterOptionsModel scriptFilterOptionsModel, Script script) {
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.tryUnmarshal(RunScenarioModel.class,
script.getFilteredScriptCnt());
.tryUnmarshal(RunScenarioModel.class, script.getScriptContent());
List<String> filterPluginId = new ArrayList<String>();
if (scriptFilterOptionsModel.isFilterTimer()) {
for (UsePluginModel pluginModel : runScenarioModel.getUsePlugins()) {
@ -180,20 +180,23 @@ public class TestPlanFactory {
&& !scriptFilterOptionsModel.getFilterTypeMatches().equals("")) {
for (PageModel pageModel : runScenarioModel.getPages()) {
for (BatchModel batchModel : pageModel.getBatches()) {
for (BehaviorModel behaviorModel : batchModel
.getBehaviors()) {
Iterator<BehaviorModel> behaviIterator = batchModel
.getBehaviors().iterator();
while (behaviIterator.hasNext()) {
BehaviorModel behaviorModel = behaviIterator.next();
if (filterPluginId.contains(behaviorModel.getUse())
|| isFilterType(
scriptFilterOptionsModel
.getFilterTypeMatches(),
behaviorModel)) {
batchModel.getBehaviors().remove(behaviorModel);
behaviIterator.remove();
}
}
}
}
}
String contentString = MarshalHelper.tryMarshal(runScenarioModel);
System.out.println(contentString);
script.setFilteredScriptCnt(contentString);
return script;
}

View File

@ -1 +1 @@
filter.type.list=text/css,text/html,text/plain,image/*,*javascript,application/json,application/xml,think-time
filter.type.list=text/css,text/html,text/plain,image/.*,.*javascript,application/json,application/xml,think-time

View File

@ -233,6 +233,7 @@ public class TestPlanMessager extends MasterMessager {
handleInvalidatedResponse(url);
return null;
}
System.out.println("getLatestScriptBriefResult:\r\n"+httpResponse.getContent());
return (ScriptBriefResultModel) MarshalHelper.tryUnmarshal(
ScriptBriefResultModel.class, httpResponse.getContent());

View File

@ -18,6 +18,7 @@
}
.title-frame{
margin-top:30px;
cursor:pointer;
}
i{
float:left;

View File

@ -36,4 +36,144 @@ function getScriptFilterOptions(){
}
return scriptFilterOptions;
}
function checkTotalAllocation() {
if (document.getElementById("totalNumber").childNodes[0].nodeValue == "100%") {
$("#totalNumber").attr("class","total-right");
$("#alertMessage").attr("class", "hide");
} else {
$("#totalNumber").attr("class","total-false");
$("#alertMessage").attr("class", "show");
}
}
function checkRequireLoad() {
if (parseInt($("#RequireLoad").val()) <= 0
|| $("#RequireLoad").val() == "")
$("#RequireLoad").attr("class",
"load-config-input-alert");
else
$("#RequireLoad").attr("class",
"load-config-input");
}
function checkWarmUp() {
if (parseInt($("#WarmUp").val()) <= 0
|| $("#WarmUp").val() == "")
$("#WarmUp").attr("class",
"load-config-input-alert");
else
$("#WarmUp").attr("class",
"load-config-input");
}
function checkCoolDown() {
if (parseInt($("#CoolDown").val()) <= 0
|| $("#CoolDown").val() == "")
$("#CoolDown").attr("class",
"load-config-input-alert");
else
$("#CoolDown").attr("class",
"load-config-input");
}
function checkExecuteRange() {
if (parseInt($("#ExecuteRange").val()) <= 0
|| $("#ExecuteRange").val() == "")
$("#ExecuteRange").attr("class",
"load-config-input-alert");
else
$("#ExecuteRange").attr("class",
"load-config-input");
}
function checkLoadConfig() {
checkExecuteRange();
checkCoolDown();
checkRequireLoad();
checkWarmUp();
if ($("#ExecuteRange").attr("class") == "load-config-input"
&& $("#CoolDown").attr("class") == "load-config-input"
&& $("#WarmUp").attr("class") == "load-config-input"
&& $("#RequireLoad").attr("class") == "load-config-input")
$("#loadConfigMessage").attr("class",
"hide");
else
$("#loadConfigMessage").attr("class",
"show");
}
function checkUserScenarios() {
var input= $("#userScenarios").find("input");
var boolean = 0;
var number = 0;
for ( var i = 0; i < input.length; i++) {
if (input[i].value == "" || parseInt(input[i].value) <= 0) {
// input[i].setAttribute("class", "allocation-input-alert");
boolean = 1;
}
// else
// input[i].setAttribute("class", "allocation-input");
}
for ( var k = 0; k < input.length; k++) {
if ($(input[k]).attr("class") == "allocation-input")
number++;
}
if (number == input.length)
boolean = 0;
if (boolean == 1)
$("#userConfigMessage").attr("class",
"show");
else
$("#userConfigMessage").attr("class",
"hide");
}
function checkIP() {
var input = $("#ipConfig").find("input");
var patrn = /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
var boolean = 0;
var number = 0;
for ( var i = 0; i < input.length; i++) {
if (input[i].value == "" || patrn.exec(input[i].value) == null) {
input[i].setAttribute("class", "ip-input-alert");
boolean = 1;
} else
input[i].setAttribute("class", "ip-input");
}
for ( var k = 0; k < input.length; k++) {
if (input[k].getAttribute("class") == "ip-input")
number++;
}
if (number == input.length)
boolean = 0;
if (boolean == 1)
$("#ipConfigMessage")
.attr("class", "show");
else
$("#ipConfigMessage")
.attr("class", "hide");
}
function checkName() {
if ($("#testConfigurationName").val() == "") {
$("#testConfigurationName").attr("class",
"name-input-alert");
$("#nameMessage").attr("class", "show");
} else {
$("#testConfigurationName").attr("class",
"name-input");
$("#nameMessage").attr("class", "hide");
}
}
function checkAllInpute() {
checkLoadConfig();
checkUserScenarios();
checkIP();
checkName();
}

View File

@ -85,14 +85,29 @@ function start() {
for ( var j = 0; j < input.length; j++)
loadList.push(parseInt(requireLoad * allocationList[j] / 100));
scriptIdList = getScriptIdList();
// var scriptFilterOptions=getScriptFilterOptions();
var isFilterTimer = false;
var filterTypeMatches = "";
var filterSelected = $("#filterList").find("input[name='filterList']:checked");
for(var i=0;i<filterSelected.length;i++)
{
var id = filterSelected[i].id;
if(id == "think-time"){
isFilterTimer = true;
continue;
}
filterTypeMatches += id+"|";
}
//delete last |
if(filterTypeMatches != "")
filterTypeMatches = filterTypeMatches.substring(0,filterTypeMatches.length-1);
for ( var k = 0; k < input.length; k++){
scriptList.push(new ScriptModel(scriptIdList[k], loadList[k], warmUp,
coolDown, executeRange));
coolDown, executeRange,isFilterTimer,filterTypeMatches));
}
var filterSelected = $("#filterList div input[name='filterList']:checked");
for(var i=0;i<filterSelected.length;i++)
filterArray.push(filterSelected[i].id);
var name = $("#testConfigurationName").val();
var testPlan = new TestPlanRequestModel(scriptList, ipList, name);
@ -110,4 +125,18 @@ function start() {
error : function(request, status, error) {
}
});
}
}
function createNewScript(){
window.open("script.jsp");
}
function viewScript(node) {
var scriptId;
var scriptName;
var selectNodes = document.getElementsByName("select");
var index = node.parentNode.parentNode.rowIndex - 1;
scriptName = selectNodes[index].options[selectNodes[index].selectedIndex].value;
scriptId = getScriptId(scriptName);
window.open("editScript.jsp?name=" + scriptName + "&scriptId=" + scriptId);
}

View File

@ -1,17 +1,104 @@
function createCheckbox(id,text){
var line = $("<td style=\"cursor:pointer;\"></td>");
line.click(function(){
if(document.getElementById(id).checked){
document.getElementById(id).checked = false;
}else{
document.getElementById(id).checked = true;
}
})
line.click(function(){checkBoxClick(id)});
var input = $("<input type='checkbox' name='filterList' id="+id+">");
input.attr("text",text);
input.click(function(){checkBoxClick(id)});
line.append(input);
line.append(document.createTextNode(text));
line.addClass("line");
return line;
}
function checkBoxClick(id){
if(document.getElementById(id).checked){
document.getElementById(id).checked = false;
}else{
document.getElementById(id).checked = true;
}
}
function loadSchedulePlot() {
var options = {
chart : {
renderTo : 'highchartsPlot',
defaultSeriesType : 'line',
type : 'area',
height : 300,
},
plotOptions : {
series : {
fillOpacity : 0.5,
}
},
credits : {
enabled : false
},
legend : {
enabled : false
},
title : {
text : $.i18n.prop('test-loadSchedule') ,
x : -50
},
xAxis : {
categories : [ 0 ],
min : 0,
},
yAxis : {
plotLines : [ {
value : 0,
width : 1,
color : '#808080'
} ],
min : 0
},
tooltip : {
formatter : function() {
var formatStr = '<b>'+this.y+ ' users after ' + this.x + ' seconds</b>';
return formatStr;
}
},
series : [ {
data : [ 0 ]
} ]
};
var RequireLoad = parseInt($("#RequireLoad").val());
var WarmUp = parseInt($("#WarmUp").val());
var CoolDown = parseInt($("#CoolDown").val());
var ExecuteRange = parseInt($("#ExecuteRange").val());
options.xAxis.categories.push(WarmUp);
options.xAxis.categories.push(WarmUp + ExecuteRange);
options.xAxis.categories.push(WarmUp + ExecuteRange + CoolDown);
options.series[0].data.push(RequireLoad);
options.series[0].data.push(RequireLoad);
options.series[0].data.push(0);
var chart = new Highcharts.Chart(options);
}
function toggleTestExecutionPlan() {
$("#loadTestExecutionPlan").slideToggle();
$('#loadConfigMessage').attr("class", "hide");
if ($("#icon-load").attr("class") == "icon-plus")
$("#icon-load").attr("class", "icon-minus");
else
$("#icon-load").attr("class", "icon-plus");
}
function toggleUserScenarios() {
$("#userScenarios").slideToggle();
$('#alertMessage').attr("class", "hide");
$('#userConfigMessage').attr("class", "hide");
if ($("#icon-user").attr("class") == "icon-plus")
$("#icon-user").attr("class", "icon-minus");
else
$("#icon-user").attr("class", "icon-plus");
}
function toggleIpConfig() {
$("#ipConfig").slideToggle();
$('#ipConfigMessage').attr("class", "hide");
if ($("#icon-ip").attr("class").indexOf("icon-plus") >= 0)
$("#icon-ip").attr("class", "icon-minus");
else
$("#icon-ip").attr("class", "icon-plus");
}

View File

@ -3,104 +3,72 @@ $(document).ready(function() {
loadSchedulePlot();
loadFilterTypeList();
});
$("#selectFilter #ok").click(function() {
$("#selectFilter").hide();
// $("#selectFilter #ok").addClass("clicked");
// filter=[];
});
$("#createFilter").click(function(){
$("#createFilter").click(function() {
$("#selectFilter").show();
})
function toggleTestExecutionPlan() {
$("#loadTestExecutionPlan").slideToggle();
$('#loadConfigMessage').attr("class", "hide");
if ($("#icon-load").attr("class") == "icon-plus")
$("#icon-load").attr("class", "icon-minus");
else
$("#icon-load").attr("class", "icon-plus");
}
function toggleUserScenarios() {
$("#userScenarios").slideToggle();
$('#alertMessage').attr("class", "hide");
$('#userConfigMessage').attr("class", "hide");
if ($("#icon-user").attr("class") == "icon-plus")
$("#icon-user").attr("class", "icon-minus");
else
$("#icon-user").attr("class", "icon-plus");
}
function toggleIpConfig() {
$("#ipConfig").slideToggle();
$('#ipConfigMessage').attr("class", "hide");
if ($("#icon-ip").attr("class").indexOf("icon-plus") >= 0)
$("#icon-ip").attr("class", "icon-minus");
else
$("#icon-ip").attr("class", "icon-plus");
}
var scenarioConfigContent;
function addScenario() {
//create delete button
var newTdNode = document.createElement("td");
var newINode = document.createElement("i");
newINode.setAttribute("class", "icon-trash");
newINode.setAttribute("style", "cursor:pointer");
newINode.setAttribute("onClick", "deleteScenarios(this)");
newTdNode.appendChild(newINode);
var lastInputNodeValue;
var lengthBeforAddAction = $("#userConfig").find("input").length;
lastInputNodeValue = document.getElementById("userConfig").getElementsByTagName("input")[lengthBeforAddAction - 1].value;
if (document.getElementById("userConfig").childNodes.length == 2) {
scenarioConfigContent = $("#userConfig").html();
document.getElementById("userConfig").innerHTML = $("#userConfig").html()+ scenarioConfigContent;
var length = $("#userConfig").find("tr").length;
document.getElementById("userConfig").getElementsByTagName("tr")[length - 1].appendChild(newTdNode);
//end
var lastScaleValue;
var scaleObject = $("#userConfig").find("input");
var numOfScript = scaleObject.length;
lastScaleValue = scaleObject[numOfScript - 1].value;
//create new tr
if (numOfScript == 1) {
$("#userConfig")[0].children[1].children[0].appendChild(newTdNode);
scenarioConfigContent = $("#userConfig")[0].children[1].innerHTML;
$("#userConfig")[0].children[1].innerHTML += scenarioConfigContent;
} else {
document.getElementById("userConfig").innerHTML =$("#userConfig").html()+ scenarioConfigContent;
var length = $("#userConfig").find("tr").length;
document.getElementById("userConfig").getElementsByTagName("tr")[length - 1].appendChild(newTdNode);
$("#userConfig")[0].children[1].innerHTML += scenarioConfigContent;
}
if (lengthBeforAddAction <= 2) {
var allocationLess = parseInt(100 / (lengthBeforAddAction + 1));
var allocationMore = 100 - parseInt(100 / (lengthBeforAddAction + 1))
* lengthBeforAddAction;
for ( var i = 0; i < lengthBeforAddAction; i++) {
document.getElementById("userConfig").getElementsByTagName("input")[i]
.setAttribute("value", allocationLess);
scaleObject = $("#userConfig").find("input");
if (numOfScript == 1) {
var allocationLess = parseInt(100 / (numOfScript + 1));
var allocationMore = 100 - parseInt(100 / (numOfScript + 1))
* numOfScript;
for (var i = 0; i < numOfScript; i++) {
scaleObject[i].setAttribute("value", allocationLess);
}
document.getElementById("userConfig").getElementsByTagName("input")[lengthBeforAddAction]
.setAttribute("value", allocationMore);
scaleObject[numOfScript].setAttribute("value", allocationMore);
} else {
var allocationLess = parseInt(lastInputNodeValue / 2);
var allocationMore = lastInputNodeValue - allocationLess;
document.getElementById("userConfig").getElementsByTagName("input")[lengthBeforAddAction - 1]
.setAttribute("value", allocationLess);
document.getElementById("userConfig").getElementsByTagName("input")[lengthBeforAddAction]
.setAttribute("value", allocationMore);
var allocationLess = parseInt(lastScaleValue / 2);
var allocationMore = lastScaleValue - allocationLess;
scaleObject[numOfScript - 1].setAttribute("value", allocationLess);
scaleObject[numOfScript].setAttribute("value", allocationMore);
}
if ($("#userConfig").find("input").length == 10) {
$("#userScenariosButton").attr("class",
"btn disabled");
$("#userScenariosButton").attr("onClick",
"");
$("#userScenariosButton").attr("class", "btn disabled");
$("#userScenariosButton").attr("onClick", "");
}
changeTotal();
checkUserScenarios();
}
function deleteScenarios(selectedNode) {
var deleteNode = selectedNode.parentNode.parentNode.parentNode;
var Node = deleteNode.parentNode;
var previousSiblingNode = deleteNode.previousSibling;
var deleteNode = selectedNode.parentNode.parentNode;//tr
var Node = deleteNode.parentNode;//tbody
Node.removeChild(deleteNode);
Node.removeChild(previousSiblingNode);
if ($("#userConfig").find("input").length < 10) {
$("#userScenariosButton").attr("class",
"btn btn-primary");
$("#userScenariosButton").attr("onClick",
"addScenario()");
var scaleObject = $("#userConfig").find("input");
var numOfScript = scaleObject.length;
if (numOfScript < 10) {
$("#userScenariosButton").attr("class", "btn btn-primary");
$("#userScenariosButton").attr("onClick", "addScenario()");
if(numOfScript == 1){
//remove delete button
var onlyOneTrNode = scaleObject[0].parentNode.parentNode;
var deleteNode = onlyOneTrNode.children[3];
onlyOneTrNode.removeChild(deleteNode);
}
}
changeTotal();
checkUserScenarios();
@ -113,9 +81,9 @@ function addIP() {
var textNode = document.createTextNode("IP:");
var inputNode = document.createElement("input");
var tr = document.createElement("tr");
// inputNode.attr({type:"text",class:"ip-input",onblur:"checkIP()"});
inputNode.setAttribute("type", "text");
inputNode.setAttribute("class", "ip-input");
inputNode.setAttribute("onblur", "checkIP()");
@ -144,235 +112,19 @@ function changeTotal() {
var inputNode = $("#userConfig").find(".allocation-input");
var total = 0;
var length = inputNode.length;
for ( var i = 0; i < length; i++) {
for (var i = 0; i < length; i++) {
total = parseInt(total) + parseInt(inputNode[i].value);
}
document.getElementById("totalNumber").innerHTML = total + "%";
checkTotalAllocation();
}
function viewScript(node) {
var scriptId;
var scriptName;
var selectNodes = document.getElementsByName("select");
var index = node.parentNode.parentNode.rowIndex - 1;
scriptName = selectNodes[index].options[selectNodes[index].selectedIndex].value;
scriptId = getScriptId(scriptName);
window.open("editScript.jsp?name=" + scriptName + "&scriptId=" + scriptId);
}
function checkTotalAllocation() {
if (document.getElementById("totalNumber").childNodes[0].nodeValue == "100%") {
$("#totalNumber").attr("class","total-right");
$("#alertMessage").attr("class", "hide");
} else {
$("#totalNumber").attr("class","total-false");
$("#alertMessage").attr("class", "show");
}
}
function checkRequireLoad() {
if (parseInt($("#RequireLoad").val()) <= 0
|| $("#RequireLoad").val() == "")
$("#RequireLoad").attr("class",
"load-config-input-alert");
else
$("#RequireLoad").attr("class",
"load-config-input");
}
function checkWarmUp() {
if (parseInt($("#WarmUp").val()) <= 0
|| $("#WarmUp").val() == "")
$("#WarmUp").attr("class",
"load-config-input-alert");
else
$("#WarmUp").attr("class",
"load-config-input");
}
function checkCoolDown() {
if (parseInt($("#CoolDown").val()) <= 0
|| $("#CoolDown").val() == "")
$("#CoolDown").attr("class",
"load-config-input-alert");
else
$("#CoolDown").attr("class",
"load-config-input");
}
function checkExecuteRange() {
if (parseInt($("#ExecuteRange").val()) <= 0
|| $("#ExecuteRange").val() == "")
$("#ExecuteRange").attr("class",
"load-config-input-alert");
else
$("#ExecuteRange").attr("class",
"load-config-input");
}
function checkLoadConfig() {
checkExecuteRange();
checkCoolDown();
checkRequireLoad();
checkWarmUp();
if ($("#ExecuteRange").attr("class") == "load-config-input"
&& $("#CoolDown").attr("class") == "load-config-input"
&& $("#WarmUp").attr("class") == "load-config-input"
&& $("#RequireLoad").attr("class") == "load-config-input")
$("#loadConfigMessage").attr("class",
"hide");
else
$("#loadConfigMessage").attr("class",
"show");
}
function checkUserScenarios() {
var input= $("#userScenarios").find("input");
var boolean = 0;
var number = 0;
for ( var i = 0; i < input.length; i++) {
if (input[i].value == "" || parseInt(input[i].value) <= 0) {
// input[i].setAttribute("class", "allocation-input-alert");
boolean = 1;
}
// else
// input[i].setAttribute("class", "allocation-input");
}
for ( var k = 0; k < input.length; k++) {
if ($(input[k]).attr("class") == "allocation-input")
number++;
}
if (number == input.length)
boolean = 0;
if (boolean == 1)
$("#userConfigMessage").attr("class",
"show");
else
$("#userConfigMessage").attr("class",
"hide");
}
function checkIP() {
var input = $("#ipConfig").find("input");
var patrn = /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
var boolean = 0;
var number = 0;
for ( var i = 0; i < input.length; i++) {
if (input[i].value == "" || patrn.exec(input[i].value) == null) {
input[i].setAttribute("class", "ip-input-alert");
boolean = 1;
} else
input[i].setAttribute("class", "ip-input");
}
for ( var k = 0; k < input.length; k++) {
if (input[k].getAttribute("class") == "ip-input")
number++;
}
if (number == input.length)
boolean = 0;
if (boolean == 1)
$("#ipConfigMessage")
.attr("class", "show");
else
$("#ipConfigMessage")
.attr("class", "hide");
}
function checkName() {
if ($("#testConfigurationName").val() == "") {
$("#testConfigurationName").attr("class",
"name-input-alert");
$("#nameMessage").attr("class", "show");
} else {
$("#testConfigurationName").attr("class",
"name-input");
$("#nameMessage").attr("class", "hide");
}
}
function checkAllInpute() {
checkLoadConfig();
checkUserScenarios();
checkIP();
checkName();
}
function loadSchedulePlot() {
var options = {
chart : {
renderTo : 'highchartsPlot',
defaultSeriesType : 'line',
type : 'area',
height : 300,
},
plotOptions : {
series : {
fillOpacity : 0.5,
}
},
credits : {
enabled : false
},
legend : {
enabled : false
},
title : {
text : $.i18n.prop('test-loadSchedule') ,
x : -50
},
xAxis : {
categories : [ 0 ],
min : 0,
},
yAxis : {
plotLines : [ {
value : 0,
width : 1,
color : '#808080'
} ],
min : 0
},
tooltip : {
formatter : function() {
return '<b>' + + '</b><br/>' + this.y
+ 'users after' + this.x + 'seconds';
}
},
series : [ {
data : [ 0 ]
} ]
};
var RequireLoad = parseInt($("#RequireLoad").val());
var WarmUp = parseInt($("#WarmUp").val());
var CoolDown = parseInt($("#CoolDown").val());
var ExecuteRange = parseInt($("#ExecuteRange").val());
options.xAxis.categories.push(WarmUp);
options.xAxis.categories.push(WarmUp + ExecuteRange);
options.xAxis.categories.push(WarmUp + ExecuteRange + CoolDown);
options.series[0].data.push(RequireLoad);
options.series[0].data.push(RequireLoad);
options.series[0].data.push(0);
var chart = new Highcharts.Chart(options);
}
function startTest() {
checkAllInpute();
if ($("#nameMessage").attr("class") == "hide"
&& $("#loadConfigMessage").attr(
"class") == "hide"
&& $("#loadConfigMessage").attr("class") == "hide"
&& $("#alertMessage").attr("class") == "hide"
&& $("#userConfigMessage").attr(
"class") == "hide"
&& $("#userConfigMessage").attr("class") == "hide"
&& $("#ipConfigMessage").attr("class") == "hide")
start();
}
function createNewScript(){
window.open("script.jsp");
}

View File

@ -1,376 +0,0 @@
$(document).ready(function() {
loadScripts();
loadSchedulePlot();
loadFilterTypeList();
});
$("#selectFilter #ok").click(function() {
$("#selectFilter").hide();
// $("#selectFilter #ok").addClass("clicked");
// filter=[];
});
function toggleTestExecutionPlan() {
$("#loadTestExecutionPlan").slideToggle();
$('#loadConfigMessage').attr("class", "hide");
if ($("#icon-load").attr("class") == "icon-plus")
$("#icon-load").attr("class", "icon-minus");
else
$("#icon-load").attr("class", "icon-plus");
}
function toggleUserScenarios() {
$("#userScenarios").slideToggle();
$('#alertMessage').attr("class", "hide");
$('#userConfigMessage').attr("class", "hide");
if ($("#icon-user").attr("class") == "icon-plus")
$("#icon-user").attr("class", "icon-minus");
else
$("#icon-user").attr("class", "icon-plus");
}
function toggleIpConfig() {
$("#ipConfig").slideToggle();
$('#ipConfigMessage').attr("class", "hide");
if ($("#icon-ip").attr("class").indexOf("icon-plus") >= 0)
$("#icon-ip").attr("class", "icon-minus");
else
$("#icon-ip").attr("class", "icon-plus");
}
var scenarioConfigContent;
function addScenario() {
var newTdNode = document.createElement("td");
var newINode = document.createElement("i");
newINode.setAttribute("class", "icon-trash");
newINode.setAttribute("style", "cursor:pointer");
newINode.setAttribute("onClick", "deleteScenarios(this)");
newTdNode.appendChild(newINode);
var lastInputNodeValue;
var lengthBeforAddAction = $("#userConfig").find("input").length;
lastInputNodeValue = document.getElementById("userConfig").getElementsByTagName("input")[lengthBeforAddAction - 1].value;
if (document.getElementById("userConfig").childNodes.length == 2) {
scenarioConfigContent = $("#userConfig").html();
document.getElementById("userConfig").innerHTML = $("#userConfig").html()+ scenarioConfigContent;
var length = $("#userConfig").find("tr").length;
document.getElementById("userConfig").getElementsByTagName("tr")[length - 1].appendChild(newTdNode);
} else {
document.getElementById("userConfig").innerHTML =$("#userConfig").html()+ scenarioConfigContent;
var length = $("#userConfig").find("tr").length;
document.getElementById("userConfig").getElementsByTagName("tr")[length - 1].appendChild(newTdNode);
}
if (lengthBeforAddAction <= 2) {
var allocationLess = parseInt(100 / (lengthBeforAddAction + 1));
var allocationMore = 100 - parseInt(100 / (lengthBeforAddAction + 1))
* lengthBeforAddAction;
for ( var i = 0; i < lengthBeforAddAction; i++) {
document.getElementById("userConfig").getElementsByTagName("input")[i]
.setAttribute("value", allocationLess);
}
document.getElementById("userConfig").getElementsByTagName("input")[lengthBeforAddAction]
.setAttribute("value", allocationMore);
} else {
var allocationLess = parseInt(lastInputNodeValue / 2);
var allocationMore = lastInputNodeValue - allocationLess;
document.getElementById("userConfig").getElementsByTagName("input")[lengthBeforAddAction - 1]
.setAttribute("value", allocationLess);
document.getElementById("userConfig").getElementsByTagName("input")[lengthBeforAddAction]
.setAttribute("value", allocationMore);
}
if ($("#userConfig").find("input").length == 10) {
$("#userScenariosButton").attr("class",
"btn disabled");
$("#userScenariosButton").attr("onClick",
"");
}
changeTotal();
checkUserScenarios();
}
function deleteScenarios(selectedNode) {
var deleteNode = selectedNode.parentNode.parentNode.parentNode;
var Node = deleteNode.parentNode;
var previousSiblingNode = deleteNode.previousSibling;
Node.removeChild(deleteNode);
Node.removeChild(previousSiblingNode);
if ($("#userConfig").find("input").length < 10) {
$("#userScenariosButton").attr("class",
"btn btn-primary");
$("#userScenariosButton").attr("onClick",
"addScenario()");
}
changeTotal();
checkUserScenarios();
}
function addIP() {
var th1 = document.createElement("th");
var th2 = document.createElement("th");
var th3 = document.createElement("th");
var textNode = document.createTextNode("IP:");
var inputNode = document.createElement("input");
var tr = document.createElement("tr");
// inputNode.attr({type:"text",class:"ip-input",onblur:"checkIP()"});
inputNode.setAttribute("type", "text");
inputNode.setAttribute("class", "ip-input");
inputNode.setAttribute("onblur", "checkIP()");
var i = document.createElement("i");
i.setAttribute("class", "icon-trash");
i.setAttribute("style", "cursor:pointer");
i.setAttribute("onClick", "deleteIP(this)");
th1.appendChild(textNode);
th2.appendChild(inputNode);
th3.appendChild(i);
tr.appendChild(th1);
tr.appendChild(th2);
tr.appendChild(th3);
document.getElementById("ipConfigTable").appendChild(tr);
checkIP();
}
function deleteIP(selectedNode) {
var deletedNode = selectedNode.parentNode.parentNode;
var parentNode = deletedNode.parentNode;
parentNode.removeChild(deletedNode);
checkIP();
}
function changeTotal() {
var inputNode = $("#userConfig").find(".allocation-input");
var total = 0;
var length = inputNode.length;
for ( var i = 0; i < length; i++) {
total = parseInt(total) + parseInt(inputNode[i].value);
}
document.getElementById("totalNumber").innerHTML = total + "%";
checkTotalAllocation();
}
function viewScript(node) {
var scriptId;
var scriptName;
var selectNodes = document.getElementsByName("select");
var index = node.parentNode.parentNode.rowIndex - 1;
scriptName = selectNodes[index].options[selectNodes[index].selectedIndex].value;
scriptId = getScriptId(scriptName);
window.open("editScript.jsp?name=" + scriptName + "&scriptId=" + scriptId);
}
function checkTotalAllocation() {
if (document.getElementById("totalNumber").childNodes[0].nodeValue == "100%") {
$("#totalNumber").attr("class","total-right");
$("#alertMessage").attr("class", "hide");
} else {
$("#totalNumber").attr("class","total-false");
$("#alertMessage").attr("class", "show");
}
}
function checkRequireLoad() {
if (parseInt($("#RequireLoad").val()) <= 0
|| $("#RequireLoad").val() == "")
$("#RequireLoad").attr("class",
"load-config-input-alert");
else
$("#RequireLoad").attr("class",
"load-config-input");
}
function checkWarmUp() {
if (parseInt($("#WarmUp").val()) <= 0
|| $("#WarmUp").val() == "")
$("#WarmUp").attr("class",
"load-config-input-alert");
else
$("#WarmUp").attr("class",
"load-config-input");
}
function checkCoolDown() {
if (parseInt($("#CoolDown").val()) <= 0
|| $("#CoolDown").val() == "")
$("#CoolDown").attr("class",
"load-config-input-alert");
else
$("#CoolDown").attr("class",
"load-config-input");
}
function checkExecuteRange() {
if (parseInt($("#ExecuteRange").val()) <= 0
|| $("#ExecuteRange").val() == "")
$("#ExecuteRange").attr("class",
"load-config-input-alert");
else
$("#ExecuteRange").attr("class",
"load-config-input");
}
function checkLoadConfig() {
checkExecuteRange();
checkCoolDown();
checkRequireLoad();
checkWarmUp();
if ($("#ExecuteRange").attr("class") == "load-config-input"
&& $("#CoolDown").attr("class") == "load-config-input"
&& $("#WarmUp").attr("class") == "load-config-input"
&& $("#RequireLoad").attr("class") == "load-config-input")
$("#loadConfigMessage").attr("class",
"hide");
else
$("#loadConfigMessage").attr("class",
"show");
}
function checkUserScenarios() {
var input= $("#userScenarios").find("input");
var boolean = 0;
var number = 0;
for ( var i = 0; i < input.length; i++) {
if (input[i].value == "" || parseInt(input[i].value) <= 0) {
// input[i].setAttribute("class", "allocation-input-alert");
boolean = 1;
}
// else
// input[i].setAttribute("class", "allocation-input");
}
for ( var k = 0; k < input.length; k++) {
if ($(input[k]).attr("class") == "allocation-input")
number++;
}
if (number == input.length)
boolean = 0;
if (boolean == 1)
$("#userConfigMessage").attr("class",
"show");
else
$("#userConfigMessage").attr("class",
"hide");
}
function checkIP() {
var input = $("#ipConfig").find("input");
var patrn = /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
var boolean = 0;
var number = 0;
for ( var i = 0; i < input.length; i++) {
if (input[i].value == "" || patrn.exec(input[i].value) == null) {
input[i].setAttribute("class", "ip-input-alert");
boolean = 1;
} else
input[i].setAttribute("class", "ip-input");
}
for ( var k = 0; k < input.length; k++) {
if (input[k].getAttribute("class") == "ip-input")
number++;
}
if (number == input.length)
boolean = 0;
if (boolean == 1)
$("#ipConfigMessage")
.attr("class", "show");
else
$("#ipConfigMessage")
.attr("class", "hide");
}
function checkName() {
if ($("#testConfigurationName").val() == "") {
$("#testConfigurationName").attr("class",
"name-input-alert");
$("#nameMessage").attr("class", "show");
} else {
$("#testConfigurationName").attr("class",
"name-input");
$("#nameMessage").attr("class", "hide");
}
}
function checkAllInpute() {
checkLoadConfig();
checkUserScenarios();
checkIP();
checkName();
}
function loadSchedulePlot() {
var options = {
chart : {
renderTo : 'highchartsPlot',
defaultSeriesType : 'line',
type : 'area',
height : 300,
},
plotOptions : {
series : {
fillOpacity : 0.5,
}
},
credits : {
enabled : false
},
legend : {
enabled : false
},
title : {
text : $.i18n.prop('test-loadSchedule') ,
x : -50
},
xAxis : {
categories : [ 0 ],
min : 0,
},
yAxis : {
plotLines : [ {
value : 0,
width : 1,
color : '#808080'
} ],
min : 0
},
tooltip : {
formatter : function() {
return '<b>' + + '</b><br/>' + this.y
+ 'users after' + this.x + 'seconds';
}
},
series : [ {
data : [ 0 ]
} ]
};
var RequireLoad = parseInt($("#RequireLoad").val());
var WarmUp = parseInt($("#WarmUp").val());
var CoolDown = parseInt($("#CoolDown").val());
var ExecuteRange = parseInt($("#ExecuteRange").val());
options.xAxis.categories.push(WarmUp);
options.xAxis.categories.push(WarmUp + ExecuteRange);
options.xAxis.categories.push(WarmUp + ExecuteRange + CoolDown);
options.series[0].data.push(RequireLoad);
options.series[0].data.push(RequireLoad);
options.series[0].data.push(0);
var chart = new Highcharts.Chart(options);
}
function startTest() {
checkAllInpute();
if ($("#nameMessage").attr("class") == "hide"
&& $("#loadConfigMessage").attr(
"class") == "hide"
&& $("#alertMessage").attr("class") == "hide"
&& $("#userConfigMessage").attr(
"class") == "hide"
&& $("#ipConfigMessage").attr("class") == "hide")
start();
}
function createNewScript(){
window.open("script.jsp");
}

View File

@ -25,10 +25,10 @@ body {
padding: 9px 0;
}
.modal{
position:absolute;
left:617px;
top:850px
.modal {
position: absolute;
left: 617px;
top: 850px
}
</style>
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
@ -74,9 +74,8 @@ body {
</div>
<!--box content-->
<div class="title-frame">
<a href="#"><i class="icon-minus" id="icon-load"
onClick="toggleTestExecutionPlan()"></i></a>
<div class="title-frame" onClick="toggleTestExecutionPlan()">
<i class="icon-minus" id="icon-load"></i>
<p class="title">
<fmt:message key="testPlanConfig" />
</p>
@ -127,9 +126,8 @@ body {
</div>
</div>
<div class="title-frame">
<a href="#"><i class="icon-minus" id="icon-user"
onClick="toggleUserScenarios()"></i></a>
<div class="title-frame" onClick="toggleUserScenarios()">
<i class="icon-minus" id="icon-user"></i>
<p class="title">
<fmt:message key="script" />
</p>
@ -163,54 +161,53 @@ body {
</table>
<div id="alertMessage" class="hide">The total allocation
needs to be 100%</div>
<button type="submit" class="btn btn-primary"
id="userScenariosButton"
onClick="addScenario();checkUserScenarios()">
<fmt:message key="addScript" />
</button>
<button type="submit" class="btn btn-primary" id="createNewScript"
onClick="createNewScript()">
<fmt:message key="test_jsp_makeNewScript" />
</button>
<button type="submit" class="btn btn-primary" id="createFilter">
<fmt:message key="plugin_jsp_filter" />
</button>
<div class="modal hide" id="selectFilter">
<div class="modal-body">
<div class="inset scroll" id="filterList"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btn-width" id="ok">
<fmt:message key="plugin_jsp_finish" />
</button>
</div>
<button type="submit" class="btn btn-primary"
id="userScenariosButton"
onClick="addScenario();checkUserScenarios()">
<fmt:message key="addScript" />
</button>
<button type="submit" class="btn btn-primary" id="createNewScript"
onClick="createNewScript()">
<fmt:message key="test_jsp_makeNewScript" />
</button>
<button type="submit" class="btn btn-primary" id="createFilter">
<fmt:message key="plugin_jsp_filter" />
</button>
<div class="modal hide" id="selectFilter">
<div class="modal-body">
<div class="inset scroll" id="filterList"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btn-width" id="ok">
<fmt:message key="plugin_jsp_finish" />
</button>
</div>
<div id="userConfigMessage" class="hide">all input can not
be empty and must be greater than zero!</div>
</div>
<div id="userConfigMessage" class="hide">all input can not
be empty and must be greater than zero!</div>
</div>
<div class="title-frame">
<a href="#"><i class="icon-plus float-left" id="icon-ip"
onClick="toggleIpConfig()"></i></a>
<p class="title">
<fmt:message key="sutIp" />
</p>
</div>
<div id="ipConfig" class="content-frame hide">
<table id="ipConfigTable" class="table-margin-top"></table>
<button type="submit" class="btn btn-primary add-button"
onClick="addIP();checkIP()">
<fmt:message key="addIp" />
</button>
<div id="ipConfigMessage" class="hide">
<fmt:message key="test-iptip" />
</div>
</div>
<div class="span12 center">
<button class="btn btn-large btn-primary" onClick="startTest()">
<fmt:message key="startTest" />
</button>
<div class="title-frame" onClick="toggleIpConfig()">
<i class="icon-plus float-left" id="icon-ip"></i>
<p class="title">
<fmt:message key="sutIp" />
</p>
</div>
<div id="ipConfig" class="content-frame hide">
<table id="ipConfigTable" class="table-margin-top"></table>
<button type="submit" class="btn btn-primary add-button"
onClick="addIP();checkIP()">
<fmt:message key="addIp" />
</button>
<div id="ipConfigMessage" class="hide">
<fmt:message key="test-iptip" />
</div>
</div>
<div class="span12 center">
<button class="btn btn-large btn-primary" onClick="startTest()">
<fmt:message key="startTest" />
</button>
</div>
</div>
</div>
<hr>