diff --git a/Bench4Q-Agent/.gitignore b/Bench4Q-Agent/.gitignore
index 5e56e040..7738863b 100644
--- a/Bench4Q-Agent/.gitignore
+++ b/Bench4Q-Agent/.gitignore
@@ -1 +1,2 @@
/bin
+/ScenarioParameters
diff --git a/Bench4Q-Agent/Scripts/HBaseScript.xml b/Bench4Q-Agent/Scripts/HBaseScript.xml
index 6b88dc4f..078a3275 100644
--- a/Bench4Q-Agent/Scripts/HBaseScript.xml
+++ b/Bench4Q-Agent/Scripts/HBaseScript.xml
@@ -1,265 +1,397 @@
-
-
-
-
-
-
-
- 0
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 1
-
-
- endUser
- 100
-
-
- USERBEHAVIOR
-
-
-
- 1
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 1001
-
-
- endUser
- 1100
-
-
- USERBEHAVIOR
-
-
-
- 2
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 2001
-
-
- endUser
- 2100
-
-
- USERBEHAVIOR
-
-
-
- 3
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 3001
-
-
- endUser
- 3100
-
-
- USERBEHAVIOR
-
-
-
- 4
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 4001
-
-
- endUser
- 4100
-
-
- USERBEHAVIOR
-
-
-
- 5
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 5001
-
-
- endUser
- 5100
-
-
- USERBEHAVIOR
-
-
-
- 6
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 6001
-
-
- endUser
- 6100
-
-
- USERBEHAVIOR
-
-
-
- 7
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 7001
-
-
- endUser
- 7100
-
-
- USERBEHAVIOR
-
-
-
- 8
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 8001
-
-
- endUser
- 8100
-
-
- USERBEHAVIOR
-
-
-
- 9
- Send
-
-
- beginTime
- 201309111715001
-
-
- endTime
- 201309112215001
-
-
- beginUser
- 9001
-
-
- endUser
- 9100
-
-
- USERBEHAVIOR
-
-
-
- -1
- 0
- -1
-
-
-
-
- 1
-
-
- hBase
- Hbase
-
-
-
+
+
+ param_HBase
+ sequencial
+ Ppara_Table
+ Once
+
+
+
+
+
+
+
+
+ 0
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 1
+
+
+ endUser
+ 100
+
+
+ USERBEHAVIOR
+
+
+
+ 1
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 2
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 2001
+
+
+ endUser
+ 2100
+
+
+ USERBEHAVIOR
+
+
+
+ 3
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 4
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 4001
+
+
+ endUser
+ 4100
+
+
+ USERBEHAVIOR
+
+
+
+ 5
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 6
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 6001
+
+
+ endUser
+ 6100
+
+
+ USERBEHAVIOR
+
+
+
+ 7
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 8
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 8001
+
+
+ endUser
+ 8100
+
+
+ USERBEHAVIOR
+
+
+
+ 9
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 10
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 10001
+
+
+ endUser
+ 10100
+
+
+ USERBEHAVIOR
+
+
+
+ 11
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 12
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 12001
+
+
+ endUser
+ 12100
+
+
+ USERBEHAVIOR
+
+
+
+ 13
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 14
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 14001
+
+
+ endUser
+ 14100
+
+
+ USERBEHAVIOR
+
+
+
+ 15
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 16
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 16001
+
+
+ endUser
+ 16100
+
+
+ USERBEHAVIOR
+
+
+
+ 17
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 18
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 18001
+
+
+ endUser
+ 18100
+
+
+ USERBEHAVIOR
+
+
+
+ 19
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ -1
+ 0
+ -1
+
+
+
+
+ 1
+
+
+ hBase
+ Hbase
+
+
+
+ timer
+ ConstantTimer
+
+
+
diff --git a/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/plugin/Test_HBasePlugin.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/plugin/Test_HBasePlugin.java
index ea3a5b4e..d9ec09be 100644
--- a/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/plugin/Test_HBasePlugin.java
+++ b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/plugin/Test_HBasePlugin.java
@@ -14,6 +14,7 @@ import org.apache.commons.io.FileUtils;
import org.bench4q.agent.plugin.basic.hbase.HBasePlugin;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.helper.TestHelper;
+import org.bench4q.share.models.agent.DefinedParameterModel;
import org.bench4q.share.models.agent.ParameterModel;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.scriptrecord.BatchModel;
@@ -24,34 +25,53 @@ import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
public class Test_HBasePlugin {
@Test
public void testBuildScenario() {
- RunScenarioModel result = buildScenario(10);
- assertEquals(1, result.getUsePlugins().size());
+ int behaviorSize = 20;
+ RunScenarioModel result = buildScenario(behaviorSize);
+ assertEquals(1, result.getDefinedParameters().size());
+ assertEquals("param_HBase", result.getDefinedParameters().get(0)
+ .getName());
+ assertEquals(2, result.getUsePlugins().size());
assertEquals("hBase", result.getUsePlugins().get(0).getId());
assertEquals("Hbase", result.getUsePlugins().get(0).getName());
+ assertEquals("timer", result.getUsePlugins().get(1).getId());
+ assertEquals("ConstantTimer", result.getUsePlugins().get(1).getName());
+
assertEquals(1, result.getPages().size());
assertEquals(1, result.getPages().get(0).getBatches().size());
- assertEquals(10, result.getPages().get(0).getBatches().get(0)
+ assertEquals(behaviorSize, result.getPages().get(0).getBatches().get(0)
.getBehaviors().size());
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < behaviorSize; i++) {
BehaviorModel behavior = result.getPages().get(0).getBatches()
.get(0).getBehaviors().get(i);
assertEquals(i, behavior.getId());
- assertEquals("Send", behavior.getName());
- assertEquals(4, behavior.getParameters().size());
- assertEquals("USERBEHAVIOR", behavior.getType());
- assertEquals("hBase", behavior.getUse());
- assertEquals("beginTime", behavior.getParameters().get(0).getKey());
- assertEquals("201309111715001", behavior.getParameters().get(0)
- .getValue());
- assertEquals("endTime", behavior.getParameters().get(1).getKey());
- assertEquals("201309112215001", behavior.getParameters().get(1)
- .getValue());
- assertEquals(1000 * i + 1 + "", behavior.getParameters().get(2)
- .getValue());
- assertEquals("beginUser", behavior.getParameters().get(2).getKey());
- assertEquals(1000 * i + 100 + "", behavior.getParameters().get(3)
- .getValue());
- assertEquals("endUser", behavior.getParameters().get(3).getKey());
+ if (i % 2 == 0) {
+ assertEquals("Send", behavior.getName());
+ assertEquals(4, behavior.getParameters().size());
+ assertEquals("USERBEHAVIOR", behavior.getType());
+ assertEquals("hBase", behavior.getUse());
+ assertEquals("beginTime", behavior.getParameters().get(0)
+ .getKey());
+ assertEquals("201309111715001", behavior.getParameters().get(0)
+ .getValue());
+ assertEquals("endTime", behavior.getParameters().get(1)
+ .getKey());
+ assertEquals("201309112215001", behavior.getParameters().get(1)
+ .getValue());
+ assertEquals(1000 * i + 1 + "", behavior.getParameters().get(2)
+ .getValue());
+ assertEquals("beginUser", behavior.getParameters().get(2)
+ .getKey());
+ assertEquals(1000 * i + 100 + "",
+ behavior.getParameters().get(3).getValue());
+ assertEquals("endUser", behavior.getParameters().get(3)
+ .getKey());
+ } else {
+ assertEquals("Sleep", behavior.getName());
+ assertEquals(1, behavior.getParameters().size());
+ assertEquals("TIMERBEHAVIOR", behavior.getType());
+ assertEquals("time", behavior.getParameters().get(0).getKey());
+ assertEquals("5000", behavior.getParameters().get(0).getValue());
+ }
}
try {
result.setPoolSize(1);
@@ -67,13 +87,15 @@ public class Test_HBasePlugin {
public static RunScenarioModel buildScenario(int behaviorSize) {
RunScenarioModel runScenarioModel = new RunScenarioModel();
+ DefinedParameterModel dp = new DefinedParameterModel("param_HBase",
+ "Ppara_Table", "sequencial", "Once");
+ List definedParamters = new ArrayList();
+ definedParamters.add(dp);
+ runScenarioModel.setDefinedParameters(definedParamters);
List usePluginList = new ArrayList();
- UsePluginModel plugin = new UsePluginModel();
- plugin.setId("hBase");
- plugin.setName("Hbase");
- plugin.setParameters(Collections. emptyList());
- usePluginList.add(plugin);
+ usePluginList.add(buildUpPlugin("hBase", "Hbase"));
+ usePluginList.add(buildUpPlugin("timer", "ConstantTimer"));
runScenarioModel.setUsePlugins(usePluginList);
List pageList = new ArrayList();
@@ -86,7 +108,10 @@ public class Test_HBasePlugin {
List behaviorList = new ArrayList();
for (int i = 0; i < behaviorSize; i++) {
- behaviorList.add(createABehavior(i));
+ if (i % 2 == 0)
+ behaviorList.add(createABehavior(i));
+ else
+ behaviorList.add(createTimer(i));
}
batch.setBehaviors(behaviorList);
batchModelList.add(batch);
@@ -96,6 +121,21 @@ public class Test_HBasePlugin {
return runScenarioModel;
}
+ private static BehaviorModel createTimer(int i) {
+ List parameters = new ArrayList();
+ parameters.add(ParameterModel.createParameter("time", "5000"));
+ return BehaviorModel.TimerBehaviorBuilder(i, "Sleep", "timer",
+ parameters);
+ }
+
+ private static UsePluginModel buildUpPlugin(String id, String name) {
+ UsePluginModel plugin = new UsePluginModel();
+ plugin.setId(id);
+ plugin.setName(name);
+ plugin.setParameters(Collections. emptyList());
+ return plugin;
+ }
+
private static BehaviorModel createABehavior(int i) {
List parameters = new ArrayList();
parameters.add(ParameterModel.createParameter("beginTime",
diff --git a/Bench4Q-Master/Scripts/HBaseScript.xml b/Bench4Q-Master/Scripts/HBaseScript.xml
new file mode 100644
index 00000000..d937cbb1
--- /dev/null
+++ b/Bench4Q-Master/Scripts/HBaseScript.xml
@@ -0,0 +1,390 @@
+
+
+
+
+
+
+
+
+
+ 0
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 1
+
+
+ endUser
+ 100
+
+
+ USERBEHAVIOR
+
+
+
+ 1
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 2
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 2001
+
+
+ endUser
+ 2100
+
+
+ USERBEHAVIOR
+
+
+
+ 3
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 4
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 4001
+
+
+ endUser
+ 4100
+
+
+ USERBEHAVIOR
+
+
+
+ 5
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 6
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 6001
+
+
+ endUser
+ 6100
+
+
+ USERBEHAVIOR
+
+
+
+ 7
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 8
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 8001
+
+
+ endUser
+ 8100
+
+
+ USERBEHAVIOR
+
+
+
+ 9
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 10
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 10001
+
+
+ endUser
+ 10100
+
+
+ USERBEHAVIOR
+
+
+
+ 11
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 12
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 12001
+
+
+ endUser
+ 12100
+
+
+ USERBEHAVIOR
+
+
+
+ 13
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 14
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 14001
+
+
+ endUser
+ 14100
+
+
+ USERBEHAVIOR
+
+
+
+ 15
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 16
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 16001
+
+
+ endUser
+ 16100
+
+
+ USERBEHAVIOR
+
+
+
+ 17
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ 18
+ Send
+
+
+ beginTime
+ 201309111715001
+
+
+ endTime
+ 201309112215001
+
+
+ beginUser
+ 18001
+
+
+ endUser
+ 18100
+
+
+ USERBEHAVIOR
+
+
+
+ 19
+ Sleep
+
+
+ time
+ 5000
+
+
+ TIMERBEHAVIOR
+
+
+
+ -1
+ 0
+ -1
+
+
+
+
+ 1
+
+
+ hBase
+ Hbase
+
+
+
+ timer
+ ConstantTimer
+
+
+
+
diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_ScriptService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_ScriptService.java
index 3bc29f54..d8f953a6 100644
--- a/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_ScriptService.java
+++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/service/Test_ScriptService.java
@@ -2,12 +2,15 @@ package org.bench4q.master.test.service;
import static org.junit.Assert.*;
+import java.io.File;
+import java.io.IOException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.xml.bind.JAXBException;
+import org.apache.commons.io.FileUtils;
import org.bench4q.master.domain.entity.Script;
import org.bench4q.master.domain.entity.User;
import org.bench4q.master.domain.repository.UserRepository;
@@ -74,6 +77,17 @@ public class Test_ScriptService {
assertTrue(doSaveAScript(user));
}
+ @Test
+ public void testSaveScriptWithDefinedParameters() throws IOException {
+ User user = this.getUserRepository().getUser("admin");
+ this.getScriptService().saveScript(
+ "HBaseScript",
+ user.getId(),
+ FileUtils.readFileToString(new File("Scripts"
+ + System.getProperty("file.separator")
+ + "HBaseScript.xml")));
+ }
+
private boolean doSaveAScript(User user) throws JAXBException {
return this.getScriptService().saveScript(
"ad",
@@ -156,9 +170,13 @@ public class Test_ScriptService {
@After
public void cleanUp() {
- User user = this.getUserRepository().getUser("test1");
- assertTrue(this.getScriptService().deleteScript(
- getUploadScriptId(user), user.getId()));
- this.getUserRepository().detach("test1");
+ try {
+ User user = this.getUserRepository().getUser("test1");
+ int uploadScriptId = getUploadScriptId(user);
+ assertTrue(this.getScriptService().deleteScript(uploadScriptId,
+ user.getId()));
+ this.getUserRepository().detach("test1");
+ } catch (Exception e) {
+ }
}
}
diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java b/Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java
index 01ab04af..dbb128be 100644
--- a/Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java
+++ b/Bench4Q-Master/src/test/java/org/bench4q/master/test/testplan/TestPlanTester.java
@@ -40,7 +40,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
private TestPlanModel testPlanBusinessModel = new TestPlanModel();
private String _url = TestBase.BASE_URL + "/testPlan";
private int scriptSumNum;
- public static int SCRIPTID1 = 78;
+ public static int SCRIPTID1 = 3;
private static int SCRIPTID2 = 2;
private static String Monitor_Host_Name = "133.133.12.3";
private static String monitor_port = "5556";
@@ -49,8 +49,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
return testPlanBusinessModel;
}
- public void setTestPlanBusinessModel(
- TestPlanModel testPlanBusinessModel) {
+ public void setTestPlanBusinessModel(TestPlanModel testPlanBusinessModel) {
this.testPlanBusinessModel = testPlanBusinessModel;
}
@@ -159,8 +158,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
return stringWriter.toString();
}
- public static TestPlanModel createATestPlanWithZeroMonitor(
- int scriptId) {
+ public static TestPlanModel createATestPlanWithZeroMonitor(int scriptId) {
TestPlanModel testPlanBusinessModel = new TestPlanModel();
testPlanBusinessModel.setMonitorModels(new ArrayList());
testPlanBusinessModel
@@ -168,8 +166,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
return testPlanBusinessModel;
}
- public static TestPlanModel createATestPlanWithNullMonitorList(
- int scriptId) {
+ public static TestPlanModel createATestPlanWithNullMonitorList(int scriptId) {
TestPlanModel testPlanBusinessModel = new TestPlanModel();
testPlanBusinessModel.setMonitorModels(null);
testPlanBusinessModel
diff --git a/Bench4Q-Web/src/main/webapp/bench4q-css/editor.css b/Bench4Q-Web/src/main/webapp/bench4q-css/editor.css
index 87715c1c..65261e9b 100644
--- a/Bench4Q-Web/src/main/webapp/bench4q-css/editor.css
+++ b/Bench4Q-Web/src/main/webapp/bench4q-css/editor.css
@@ -172,4 +172,24 @@ td {
font-weight:bold;
color: #3689BB;
+}
+
+.sample_frame {
+ padding:10px;
+ margin: 10px 10px 10px 10px;
+ border: #3689BB solid thin;
+}
+
+.sample_sub_frame {
+ border: #F0ECE0 solid thin;
+ margin-top: 5px;
+ margin-bottom: 5px;
+ margin-left: 10px;
+ margin-right: 10px;
+ padding-top:10px;
+ padding-left:10px;
+ padding-bottom:10px;
+}
+p{
+ color: #4E9BCB;
}
\ No newline at end of file
diff --git a/Bench4Q-Web/src/main/webapp/plugin.jsp b/Bench4Q-Web/src/main/webapp/plugin.jsp
index 6480af63..cb37edc3 100644
--- a/Bench4Q-Web/src/main/webapp/plugin.jsp
+++ b/Bench4Q-Web/src/main/webapp/plugin.jsp
@@ -272,8 +272,8 @@ body {
-
+