This commit is contained in:
daisyonly 2014-09-01 14:38:19 +08:00
commit 7a04393a14
13 changed files with 1140 additions and 1048 deletions

View File

@ -82,13 +82,13 @@ public class TestController {
public String submitParams(
@PathVariable UUID runId,
@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 {
this.getParamFileCollector().collectParamFiles(files, runId);
System.out.println(scenarioModel);
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
.unmarshal(RunScenarioModel.class, scenarioModel);
this.getScenarioEngine().submitScenario(runId,
Scenario.scenarioBuilderWithCompile(runScenarioModel));
return MarshalHelper.tryMarshal(buildWith(runId));

View File

@ -16,6 +16,7 @@ public class Scenario {
private UsePlugin[] usePlugins;
private Page[] pages;
private List<Behavior> behaviors;
private TestSchedule schedule;
public UsePlugin[] getUsePlugins() {
return usePlugins;
@ -41,6 +42,14 @@ public class Scenario {
this.behaviors = behaviors;
}
public TestSchedule getSchedule() {
return schedule;
}
private void setSchedule(TestSchedule schedule) {
this.schedule = schedule;
}
public Scenario() {
this.setBehaviors(new ArrayList<Behavior>());
}
@ -88,6 +97,7 @@ public class Scenario {
scenario.setPages(new Page[runScenarioModel.getPages().size()]);
extractUsePlugins(runScenarioModel, scenario);
extractPages(runScenarioModel, scenario);
scenario.setSchedule(TestSchedule.build(runScenarioModel.getScheduleModel()));
return scenario;
}

View File

@ -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 final Point end;
private final int growthUnit;
public Segment(Point startPoint, Point endPoint) {
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;
}
}

View File

@ -98,7 +98,7 @@ public class TestPlanController extends BaseController {
this.testPlanScriptResultService = testPlanScriptResultService;
}
@RequestMapping(value = "/runTestPlanWithTestPlanModel", method = {
@RequestMapping(value = "/run", method = {
RequestMethod.POST, RequestMethod.GET })
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
@ -108,14 +108,14 @@ public class TestPlanController extends BaseController {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
throw new Bench4QException(HAVE_NO_POWER,
"You don't have enough power to run a test plan!",
"/runTestPlanWithTestPlanModel");
"/run");
}
UUID testPlanRunID = this.getTestPlanRunner().runWith(
testPlanBusinessModel, this.getPrincipal());
if (testPlanRunID == null) {
throw new Bench4QException("TestPlan_Commit_Error",
"There is an exception when commit the test plan",
"/runTestPlanWithTestPlanModel");
"/run");
}
return buildResponseModel(this.getTestPlanService()
.queryTestPlanStatus(testPlanRunID), testPlanRunID, null,

View File

@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import org.bench4q.share.models.agent.scriptrecord.PageModel;
import org.bench4q.share.models.agent.scriptrecord.TestScheduleModel;
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
@XmlRootElement(name = "runScenario")
@ -15,6 +16,7 @@ public class RunScenarioModel {
private int poolSize;
private List<UsePluginModel> usePlugins;
private List<PageModel> pages;
private TestScheduleModel scheduleModel;
@XmlElement
public int getPoolSize() {
@ -45,6 +47,15 @@ public class RunScenarioModel {
this.pages = pages;
}
@XmlElement
public TestScheduleModel getScheduleModel() {
return scheduleModel;
}
public void setScheduleModel(TestScheduleModel scheduleModel) {
this.scheduleModel = scheduleModel;
}
public RunScenarioModel() {
this.setUsePlugins(new LinkedList<UsePluginModel>());
this.setPages(new LinkedList<PageModel>());

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -45,7 +45,7 @@ public class TestPlanMessager extends MasterMessager {
public TestPlanResultModel runTestPlan(String accessToken,
String testPlanXmlContent) {
String url = this.getBaseUrl() + "/runTestPlanWithTestPlanModel";
String url = this.getBaseUrl() + "/run";
HttpResponse httpResponse = null;
try {
httpResponse = this.getHttpRequester().sendPostXml(url,

View File

@ -1 +1 @@
masterAddress=localhost:8901
masterAddress=133.133.2.105:8901

View File

@ -48,7 +48,7 @@ public class TestPlanMessageTest extends MessagerTestBase {
@Test
public void test_runTestPlan() {
String url = baseUrl + "/runTestPlanWithTestPlanModel";
String url = baseUrl + "/run";
this.getWireMock().register(
post(urlEqualTo(url)).willReturn(
aResponse().withStatus(200)