modify the api, and need to be tested
modify the api, and need to be tested
This commit is contained in:
parent
9157b793fc
commit
6c19a07c61
|
@ -61,7 +61,7 @@ public class TestController {
|
||||||
@RequestMapping(value = "/bookTest/{poolSize}", method = {
|
@RequestMapping(value = "/bookTest/{poolSize}", method = {
|
||||||
RequestMethod.GET, RequestMethod.POST })
|
RequestMethod.GET, RequestMethod.POST })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public RunScenarioResultModel bookTest(@PathVariable int poolSize, @RequestParam long startTime) {
|
public RunScenarioResultModel bookTest(@PathVariable int poolSize) {
|
||||||
try {
|
try {
|
||||||
UUID runId = UUID.randomUUID();
|
UUID runId = UUID.randomUUID();
|
||||||
this.getScenarioEngine().addRunningTestWithoutScenario(runId,
|
this.getScenarioEngine().addRunningTestWithoutScenario(runId,
|
||||||
|
@ -75,10 +75,11 @@ public class TestController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/submitScenarioWithParams/{runId}", method = RequestMethod.POST)
|
@RequestMapping(value = "/submitScenarioWithParams/{runId}/{realStartTime}", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String submitParams(
|
public String submitParams(
|
||||||
@PathVariable UUID runId,
|
@PathVariable UUID runId,
|
||||||
|
@PathVariable long realStartTime,
|
||||||
@RequestParam(value = "files[]", required = false) List<MultipartFile> files,
|
@RequestParam(value = "files[]", required = false) List<MultipartFile> files,
|
||||||
@RequestParam(value = "testShedule", required = false) String scheduleContent,
|
@RequestParam(value = "testShedule", required = false) String scheduleContent,
|
||||||
@RequestParam(value = "scenarioModel") String scenarioModel) {
|
@RequestParam(value = "scenarioModel") String scenarioModel) {
|
||||||
|
@ -88,7 +89,7 @@ public class TestController {
|
||||||
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), realStartTime);
|
||||||
return MarshalHelper.tryMarshal(buildWith(runId));
|
return MarshalHelper.tryMarshal(buildWith(runId));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("/submitScenarioWithParams", e);
|
logger.error("/submitScenarioWithParams", e);
|
||||||
|
|
|
@ -28,7 +28,6 @@ import com.mongodb.ServerAddress;
|
||||||
@Plugin("MongoDBPlugin")
|
@Plugin("MongoDBPlugin")
|
||||||
public class MongoDBPlugin {
|
public class MongoDBPlugin {
|
||||||
private final String hostName;
|
private final String hostName;
|
||||||
private final int port;
|
|
||||||
private final String dbName;
|
private final String dbName;
|
||||||
private final String tableUnderTest = "users";
|
private final String tableUnderTest = "users";
|
||||||
|
|
||||||
|
@ -38,7 +37,6 @@ public class MongoDBPlugin {
|
||||||
@Parameter(value = "port", type = SupportTypes.Field) int port,
|
@Parameter(value = "port", type = SupportTypes.Field) int port,
|
||||||
@Parameter(value = "dbName", type = SupportTypes.Field) String dbName) {
|
@Parameter(value = "dbName", type = SupportTypes.Field) String dbName) {
|
||||||
this.hostName = hostName;
|
this.hostName = hostName;
|
||||||
this.port = port;
|
|
||||||
this.dbName = dbName;
|
this.dbName = dbName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,8 +101,8 @@ public class ScenarioContext implements Observer {
|
||||||
return scenarioContext;
|
return scenarioContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScenarioContext addScenrio(final Scenario scenario) {
|
public ScenarioContext addScenrio(final Scenario scenario, final long realStartTime) {
|
||||||
ScenarioContext result = new ScenarioContext(this.testId, startDate, executor, this.dataCollector, pluginManager);
|
ScenarioContext result = new ScenarioContext(this.testId, new Date(realStartTime), executor, this.dataCollector, pluginManager);
|
||||||
result.setEndDate(new Date(scenario.getSchedule().getScheduleRange() + this.getStartDate().getTime()));
|
result.setEndDate(new Date(scenario.getSchedule().getScheduleRange() + this.getStartDate().getTime()));
|
||||||
result.setFinished(this.isFinished());
|
result.setFinished(this.isFinished());
|
||||||
result.setScenario(scenario);
|
result.setScenario(scenario);
|
||||||
|
|
|
@ -50,10 +50,10 @@ public class ScenarioEngine implements Observer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void submitScenario(UUID runId, final Scenario scenario) {
|
public void submitScenario(final UUID runId, final Scenario scenario, final long realStartTime) {
|
||||||
try {
|
try {
|
||||||
ScenarioContext old = this.getRunningTests().get(runId);
|
ScenarioContext old = this.getRunningTests().get(runId);
|
||||||
this.getRunningTests().put(runId, old.addScenrio(scenario));
|
this.getRunningTests().put(runId, old.addScenrio(scenario, realStartTime));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue