get agent's already runed time by brief
This commit is contained in:
parent
ba89338a9e
commit
0f56154c39
|
@ -205,6 +205,11 @@ public class TestController {
|
|||
long maxDate = 0, minDate = Long.MAX_VALUE;
|
||||
int validCount = 0;
|
||||
for (BehaviorResult behaviorResult : behaviorResults) {
|
||||
// TODO: remove this
|
||||
if (behaviorResult.getStartDate().getTime() < scenarioContext
|
||||
.getStartDate().getTime()) {
|
||||
continue;
|
||||
}
|
||||
if (behaviorResult.getEndDate().getTime() > maxDate) {
|
||||
maxDate = behaviorResult.getEndDate().getTime();
|
||||
}
|
||||
|
@ -225,13 +230,15 @@ public class TestController {
|
|||
/ validCount);
|
||||
testBriefStatusModel.setElapsedTime(maxDate
|
||||
- testBriefStatusModel.getStartDate().getTime());
|
||||
testBriefStatusModel.setRunningTime(maxDate - minDate);
|
||||
testBriefStatusModel.setRunningTime(maxDate
|
||||
- scenarioContext.getStartDate().getTime());
|
||||
testBriefStatusModel.setFailCount(failCount);
|
||||
testBriefStatusModel.setSuccessCount(successCount);
|
||||
testBriefStatusModel.setFinishedCount(behaviorResults.size());
|
||||
testBriefStatusModel.setTotalCount(scenarioContext.getTotalCount());
|
||||
testBriefStatusModel.setScenarioBehaviorCount(scenarioContext
|
||||
.getScenario().getUserBehaviors().length);
|
||||
testBriefStatusModel.setRunningTime(maxDate - minDate);
|
||||
return testBriefStatusModel;
|
||||
}
|
||||
|
||||
|
@ -277,4 +284,24 @@ public class TestController {
|
|||
saveTestResultModel.setSuccess(true);
|
||||
return saveTestResultModel;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/startSave/{runId}", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public SaveTestResultModel startSave(@PathVariable UUID runId) {
|
||||
this.getScenarioEngine().startSaveResultsWithEdit(runId);
|
||||
SaveTestResultModel saveTestResultModel = new SaveTestResultModel();
|
||||
saveTestResultModel.setSuccess(true);
|
||||
return saveTestResultModel;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/stopSave/{runId}", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public SaveTestResultModel stopSave(@PathVariable UUID runId) {
|
||||
this.getScenarioEngine().stopSaveResultWithEdit(runId);
|
||||
SaveTestResultModel saveTestResultModel = new SaveTestResultModel();
|
||||
saveTestResultModel.setSuccess(true);
|
||||
return saveTestResultModel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,12 @@ public class ScenarioContext {
|
|||
private int totalCount;
|
||||
private int finishedCount;
|
||||
private Date startDate;
|
||||
private Date stopDate;
|
||||
private ExecutorService executorService;
|
||||
private Scenario scenario;
|
||||
private List<BehaviorResult> results;
|
||||
private boolean finished;
|
||||
private boolean toSave;
|
||||
|
||||
public int getPoolSize() {
|
||||
return poolSize;
|
||||
|
@ -46,6 +48,14 @@ public class ScenarioContext {
|
|||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Date getStopDate() {
|
||||
return stopDate;
|
||||
}
|
||||
|
||||
public void setStopDate(Date stopDate) {
|
||||
this.stopDate = stopDate;
|
||||
}
|
||||
|
||||
public ExecutorService getExecutorService() {
|
||||
return executorService;
|
||||
}
|
||||
|
@ -78,4 +88,12 @@ public class ScenarioContext {
|
|||
this.finished = finished;
|
||||
}
|
||||
|
||||
public boolean isToSave() {
|
||||
return toSave;
|
||||
}
|
||||
|
||||
public void setToSave(boolean startToSave) {
|
||||
this.toSave = startToSave;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ public class ScenarioEngine {
|
|||
scenarioContext.setTotalCount(totalCount
|
||||
* scenario.getUserBehaviors().length);
|
||||
scenarioContext.setPoolSize(poolSize);
|
||||
// TODO: set it to null
|
||||
scenarioContext.setStartDate(new Date(System.currentTimeMillis()));
|
||||
scenarioContext.setExecutorService(executorService);
|
||||
scenarioContext.setResults(ret);
|
||||
|
@ -174,6 +175,24 @@ public class ScenarioEngine {
|
|||
return directory;
|
||||
}
|
||||
|
||||
public void startSaveResultsWithEdit(UUID runId) {
|
||||
ScenarioContext scenarioContext = this.getRunningTests().get(runId);
|
||||
if (scenarioContext == null) {
|
||||
return;
|
||||
}
|
||||
scenarioContext.setStartDate(new Date(System.currentTimeMillis()));
|
||||
scenarioContext.setToSave(true);
|
||||
}
|
||||
|
||||
public void stopSaveResultWithEdit(UUID runId) {
|
||||
ScenarioContext scenarioContext = this.getRunningTests().get(runId);
|
||||
if (scenarioContext == null) {
|
||||
return;
|
||||
}
|
||||
scenarioContext.setStopDate(new Date(System.currentTimeMillis()));
|
||||
scenarioContext.setToSave(false);
|
||||
}
|
||||
|
||||
public void saveTestResults(UUID runId) {
|
||||
ScenarioContext scenarioContext = this.getRunningTests().get(runId);
|
||||
if (scenarioContext == null) {
|
||||
|
|
Loading…
Reference in New Issue