Merge branch 'master' of https://github.com/lostcharlie/Bench4Q.git
Conflicts: Bench4Q-Share/src/main/java/org/bench4q/share/models/agent/RunScenarioModel.java
This commit is contained in:
commit
f3816e8304
|
@ -82,13 +82,13 @@ public class TestController {
|
||||||
public String submitParams(
|
public String submitParams(
|
||||||
@PathVariable UUID runId,
|
@PathVariable UUID runId,
|
||||||
@RequestParam(value = "files[]", required = false) List<MultipartFile> files,
|
@RequestParam(value = "files[]", required = false) List<MultipartFile> files,
|
||||||
@RequestParam("scenarioModel") String scenarioModel) {
|
@RequestParam(value = "testShedule", required = false) String scheduleContent,
|
||||||
|
@RequestParam(value = "scenarioModel") String scenarioModel) {
|
||||||
try {
|
try {
|
||||||
this.getParamFileCollector().collectParamFiles(files, runId);
|
this.getParamFileCollector().collectParamFiles(files, runId);
|
||||||
System.out.println(scenarioModel);
|
System.out.println(scenarioModel);
|
||||||
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
|
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
|
||||||
.unmarshal(RunScenarioModel.class, scenarioModel);
|
.unmarshal(RunScenarioModel.class, scenarioModel);
|
||||||
|
|
||||||
this.getScenarioEngine().submitScenario(runId,
|
this.getScenarioEngine().submitScenario(runId,
|
||||||
Scenario.scenarioBuilderWithCompile(runScenarioModel));
|
Scenario.scenarioBuilderWithCompile(runScenarioModel));
|
||||||
return MarshalHelper.tryMarshal(buildWith(runId));
|
return MarshalHelper.tryMarshal(buildWith(runId));
|
||||||
|
|
|
@ -16,6 +16,7 @@ public class Scenario {
|
||||||
private UsePlugin[] usePlugins;
|
private UsePlugin[] usePlugins;
|
||||||
private Page[] pages;
|
private Page[] pages;
|
||||||
private List<Behavior> behaviors;
|
private List<Behavior> behaviors;
|
||||||
|
private TestSchedule schedule;
|
||||||
|
|
||||||
public UsePlugin[] getUsePlugins() {
|
public UsePlugin[] getUsePlugins() {
|
||||||
return usePlugins;
|
return usePlugins;
|
||||||
|
@ -41,6 +42,14 @@ public class Scenario {
|
||||||
this.behaviors = behaviors;
|
this.behaviors = behaviors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TestSchedule getSchedule() {
|
||||||
|
return schedule;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSchedule(TestSchedule schedule) {
|
||||||
|
this.schedule = schedule;
|
||||||
|
}
|
||||||
|
|
||||||
public Scenario() {
|
public Scenario() {
|
||||||
this.setBehaviors(new ArrayList<Behavior>());
|
this.setBehaviors(new ArrayList<Behavior>());
|
||||||
}
|
}
|
||||||
|
@ -88,6 +97,7 @@ public class Scenario {
|
||||||
scenario.setPages(new Page[runScenarioModel.getPages().size()]);
|
scenario.setPages(new Page[runScenarioModel.getPages().size()]);
|
||||||
extractUsePlugins(runScenarioModel, scenario);
|
extractUsePlugins(runScenarioModel, scenario);
|
||||||
extractPages(runScenarioModel, scenario);
|
extractPages(runScenarioModel, scenario);
|
||||||
|
scenario.setSchedule(TestSchedule.build(runScenarioModel.getScheduleModel()));
|
||||||
return scenario;
|
return scenario;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.bench4q.agent.scenario;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bench4q.share.models.agent.scriptrecord.TestScheduleModel;
|
||||||
|
import org.bench4q.share.models.agent.scriptrecord.TestScheduleModel.PointModel;
|
||||||
|
|
||||||
|
public class TestSchedule {
|
||||||
|
private List<Segment> points;
|
||||||
|
|
||||||
|
public List<Segment> getPoints() {
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoints(List<Segment> points) {
|
||||||
|
this.points = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Segment {
|
||||||
|
private final Point start;
|
||||||
|
private Point end;
|
||||||
|
private final int growthUnit = 0;
|
||||||
|
|
||||||
|
public Segment(Point startPoint, Point endPoint, int growthUnit) {
|
||||||
|
this.start = new Point(startPoint.time, startPoint.load);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Point {
|
||||||
|
private final int time;
|
||||||
|
private final int load;
|
||||||
|
|
||||||
|
public int getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLoad() {
|
||||||
|
return load;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point(int time, int load) {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
this.time = time;
|
||||||
|
this.load = load;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TestSchedule build(TestScheduleModel scheduleModel) {
|
||||||
|
TestSchedule schedule = new TestSchedule();
|
||||||
|
// schedule.setPoints(extractPoints(scheduleModel.getPoints()));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Point> extractPoints(List<PointModel> points) {
|
||||||
|
List<Point> result = new LinkedList<TestSchedule.Point>();
|
||||||
|
for (PointModel model : points) {
|
||||||
|
result.add(new Point(model.getTime(), model.getLoad()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -98,7 +98,7 @@ public class TestPlanController extends BaseController {
|
||||||
this.testPlanScriptResultService = testPlanScriptResultService;
|
this.testPlanScriptResultService = testPlanScriptResultService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/runTestPlanWithTestPlanModel", method = {
|
@RequestMapping(value = "/run", method = {
|
||||||
RequestMethod.POST, RequestMethod.GET })
|
RequestMethod.POST, RequestMethod.GET })
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.OK)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -108,14 +108,14 @@ public class TestPlanController extends BaseController {
|
||||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||||
throw new Bench4QException(HAVE_NO_POWER,
|
throw new Bench4QException(HAVE_NO_POWER,
|
||||||
"You don't have enough power to run a test plan!",
|
"You don't have enough power to run a test plan!",
|
||||||
"/runTestPlanWithTestPlanModel");
|
"/run");
|
||||||
}
|
}
|
||||||
UUID testPlanRunID = this.getTestPlanRunner().runWith(
|
UUID testPlanRunID = this.getTestPlanRunner().runWith(
|
||||||
testPlanBusinessModel, this.getPrincipal());
|
testPlanBusinessModel, this.getPrincipal());
|
||||||
if (testPlanRunID == null) {
|
if (testPlanRunID == null) {
|
||||||
throw new Bench4QException("TestPlan_Commit_Error",
|
throw new Bench4QException("TestPlan_Commit_Error",
|
||||||
"There is an exception when commit the test plan",
|
"There is an exception when commit the test plan",
|
||||||
"/runTestPlanWithTestPlanModel");
|
"/run");
|
||||||
}
|
}
|
||||||
return buildResponseModel(this.getTestPlanService()
|
return buildResponseModel(this.getTestPlanService()
|
||||||
.queryTestPlanStatus(testPlanRunID), testPlanRunID, null,
|
.queryTestPlanStatus(testPlanRunID), testPlanRunID, null,
|
||||||
|
|
|
@ -287,7 +287,7 @@ public class PluginEntityFactory {
|
||||||
ParamType parentContainer) {
|
ParamType parentContainer) {
|
||||||
ChoiceType choiceType = new ChoiceType();
|
ChoiceType choiceType = new ChoiceType();
|
||||||
choiceType.setValue(XmlParseHelper.getAttribute(element, "value"));
|
choiceType.setValue(XmlParseHelper.getAttribute(element, "value"));
|
||||||
choiceType.setDefaultValue(Boolean.getBoolean(XmlParseHelper
|
choiceType.setDefaultValue(Boolean.parseBoolean(XmlParseHelper
|
||||||
.getAttribute(element, "default")));
|
.getAttribute(element, "default")));
|
||||||
choiceType.setParentContainer(parentContainer);
|
choiceType.setParentContainer(parentContainer);
|
||||||
return choiceType;
|
return choiceType;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
import org.bench4q.share.models.agent.scriptrecord.PageModel;
|
import org.bench4q.share.models.agent.scriptrecord.PageModel;
|
||||||
|
import org.bench4q.share.models.agent.scriptrecord.TestScheduleModel;
|
||||||
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
|
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
|
||||||
|
|
||||||
@XmlRootElement(name = "runScenario")
|
@XmlRootElement(name = "runScenario")
|
||||||
|
@ -16,7 +17,7 @@ public class RunScenarioModel {
|
||||||
private List<UsePluginModel> usePlugins;
|
private List<UsePluginModel> usePlugins;
|
||||||
private List<PageModel> pages;
|
private List<PageModel> pages;
|
||||||
private List<String> filteredTypes;
|
private List<String> filteredTypes;
|
||||||
|
private TestScheduleModel scheduleModel;
|
||||||
@XmlElement
|
@XmlElement
|
||||||
public int getPoolSize() {
|
public int getPoolSize() {
|
||||||
return poolSize;
|
return poolSize;
|
||||||
|
@ -46,6 +47,15 @@ public class RunScenarioModel {
|
||||||
this.pages = pages;
|
this.pages = pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
public TestScheduleModel getScheduleModel() {
|
||||||
|
return scheduleModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScheduleModel(TestScheduleModel scheduleModel) {
|
||||||
|
this.scheduleModel = scheduleModel;
|
||||||
|
}
|
||||||
|
|
||||||
public RunScenarioModel() {
|
public RunScenarioModel() {
|
||||||
this.setUsePlugins(new LinkedList<UsePluginModel>());
|
this.setUsePlugins(new LinkedList<UsePluginModel>());
|
||||||
this.setPages(new LinkedList<PageModel>());
|
this.setPages(new LinkedList<PageModel>());
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
package org.bench4q.share.models.agent.scriptrecord;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
@XmlRootElement
|
|
||||||
public class RunScenarioModelNew {
|
|
||||||
private int poolSize;
|
|
||||||
private List<UsePluginModel> usePlugins;
|
|
||||||
private List<BehaviorModel> behaviors;
|
|
||||||
|
|
||||||
@XmlElement
|
|
||||||
public int getPoolSize() {
|
|
||||||
return poolSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoolSize(int poolSize) {
|
|
||||||
this.poolSize = poolSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlElementWrapper(name = "plugins")
|
|
||||||
@XmlElement(name = "plugin")
|
|
||||||
public List<UsePluginModel> getUsePlugins() {
|
|
||||||
return usePlugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsePlugins(List<UsePluginModel> usePlugins) {
|
|
||||||
this.usePlugins = usePlugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlElementWrapper(name = "behaviors")
|
|
||||||
@XmlElement(name = "behavior")
|
|
||||||
public List<BehaviorModel> getBehaviors() {
|
|
||||||
return behaviors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBehaviors(List<BehaviorModel> behaviors) {
|
|
||||||
this.behaviors = behaviors;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.bench4q.share.models.agent.scriptrecord;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
|
public class TestScheduleModel {
|
||||||
|
private List<PointModel> points;
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "points")
|
||||||
|
@XmlElement(name = "point")
|
||||||
|
public List<PointModel> getPoints() {
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoints(List<PointModel> points) {
|
||||||
|
this.points = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestScheduleModel() {
|
||||||
|
this.points = new LinkedList<PointModel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
|
public static class PointModel {
|
||||||
|
private int time;
|
||||||
|
private int load;
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
public int getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTime(int time) {
|
||||||
|
this.time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
public int getLoad() {
|
||||||
|
return load;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoad(int load) {
|
||||||
|
this.load = load;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ public class TestPlanMessager extends MasterMessager {
|
||||||
public TestPlanResultModel runTestPlan(String accessToken,
|
public TestPlanResultModel runTestPlan(String accessToken,
|
||||||
String testPlanXmlContent) {
|
String testPlanXmlContent) {
|
||||||
|
|
||||||
String url = this.getBaseUrl() + "/runTestPlanWithTestPlanModel";
|
String url = this.getBaseUrl() + "/run";
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
httpResponse = this.getHttpRequester().sendPostXml(url,
|
httpResponse = this.getHttpRequester().sendPostXml(url,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
masterAddress=localhost:8901
|
masterAddress=133.133.2.105:8901
|
|
@ -123,7 +123,7 @@ EditorFactory.prototype.createFile = function(label, name, required, size, id, v
|
||||||
var file = document.createElement("input");
|
var file = document.createElement("input");
|
||||||
$(file).attr("type", "file");
|
$(file).attr("type", "file");
|
||||||
if(required == "true"){
|
if(required == "true"){
|
||||||
$(field).attr("required", "required");
|
$(file).attr("required", "required");
|
||||||
}
|
}
|
||||||
// $(field).attr("maxlength", size);
|
// $(field).attr("maxlength", size);
|
||||||
$(fileEditor).append(fieldName.outerHTML + file.outerHTML);
|
$(fileEditor).append(fieldName.outerHTML + file.outerHTML);
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class TestPlanMessageTest extends MessagerTestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_runTestPlan() {
|
public void test_runTestPlan() {
|
||||||
String url = baseUrl + "/runTestPlanWithTestPlanModel";
|
String url = baseUrl + "/run";
|
||||||
this.getWireMock().register(
|
this.getWireMock().register(
|
||||||
post(urlEqualTo(url)).willReturn(
|
post(urlEqualTo(url)).willReturn(
|
||||||
aResponse().withStatus(200)
|
aResponse().withStatus(200)
|
||||||
|
|
Loading…
Reference in New Issue