remove a bug when judge whether finish test plan
This commit is contained in:
parent
155a19561b
commit
c5fa153a1b
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.api.model.RunningScriptModel;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -11,6 +12,8 @@ import org.springframework.stereotype.Component;
|
|||
public class TestPlanContainer {
|
||||
private Map<UUID, TestPlanContext> runningTestPlans = new HashMap<UUID, TestPlanContext>();
|
||||
|
||||
private Logger logger = Logger.getLogger(TestPlanContainer.class);
|
||||
|
||||
public Map<UUID, TestPlanContext> getRunningTestPlans() {
|
||||
return runningTestPlans;
|
||||
}
|
||||
|
@ -43,7 +46,9 @@ public class TestPlanContainer {
|
|||
boolean finish = true;
|
||||
if (testPlanContext == null
|
||||
|| testPlanContext.getRunningScriptMap().size() == 0) {
|
||||
|
||||
logger.error("testPlanContext is null or scriptMap size is 0, where the testPlanID is"
|
||||
+ testPlanId);
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
for (RunningScriptModel model : testPlanContext
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.bench4q.master.testPlan;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.master.api.model.TestPlanModel;
|
||||
import org.bench4q.master.api.model.TestPlanResultModel;
|
||||
|
@ -42,11 +43,18 @@ public class TestPlanContext {
|
|||
this.setRunningScriptMap(new HashMap<Integer, RunningScriptModel>());
|
||||
}
|
||||
|
||||
public void fillScriptMap(List<RunningScriptModel> list) {
|
||||
public TestPlanContext(TestPlanModel model, UUID testPlanID) {
|
||||
this.setRunningScriptMap(new HashMap<Integer, RunningScriptModel>());
|
||||
this.fillScriptMap(model.getRunningScriptModels(), testPlanID);
|
||||
this.setTestPlanModel(model);
|
||||
}
|
||||
|
||||
public void fillScriptMap(List<RunningScriptModel> list, UUID testPlanID) {
|
||||
if (runningScriptMap == null) {
|
||||
this.setRunningScriptMap(new HashMap<Integer, RunningScriptModel>());
|
||||
}
|
||||
for (RunningScriptModel runningScriptModel : list) {
|
||||
runningScriptModel.setTestPlanID(testPlanID);
|
||||
this.runningScriptMap.put(
|
||||
new Integer(runningScriptModel.getScriptId()),
|
||||
runningScriptModel);
|
||||
|
|
|
@ -97,9 +97,12 @@ public class TestPlanRunner implements TaskCompleteCallback,
|
|||
ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
final UUID testPlanId = UUID.randomUUID();
|
||||
|
||||
final TestPlanContext testPlanContext = new TestPlanContext();
|
||||
testPlanContext.fillScriptMap(testPlanModel.getRunningScriptModels());
|
||||
testPlanContext.setTestPlanModel(testPlanModel);
|
||||
// final TestPlanContext testPlanContext = new TestPlanContext();
|
||||
// testPlanContext.fillScriptMap(testPlanModel.getRunningScriptModels(),
|
||||
// testPlanId);
|
||||
// testPlanContext.setTestPlanModel(testPlanModel);
|
||||
final TestPlanContext testPlanContext = new TestPlanContext(
|
||||
testPlanModel, testPlanId);
|
||||
if (!this.testPlanService.saveTestPlanToDB(testPlanModel, user,
|
||||
testPlanId, testPlanContext.getRunningScriptMap().values())) {
|
||||
return null;
|
||||
|
@ -176,6 +179,11 @@ public class TestPlanRunner implements TaskCompleteCallback,
|
|||
}
|
||||
TestPlanContext context = this.getTestPlanContainer()
|
||||
.getRunningTestPlans().get(testPlanID);
|
||||
if (context == null) {
|
||||
logger.error("testPlanContext with testPlanID "
|
||||
+ testPlanID.toString() + " is null!");
|
||||
return;
|
||||
}
|
||||
for (RunningScriptModel runningScriptModel : context
|
||||
.getRunningScriptMap().values()) {
|
||||
for (RunningAgentModel runningAgentModel : runningScriptModel
|
||||
|
|
|
@ -150,7 +150,7 @@ public class TestPlanTester extends TestBase {
|
|||
model.setRequireLoad(EACH_SCRIPT_LOAD_SMALLSCALE);
|
||||
TestScriptConfig config = new TestScriptConfig();
|
||||
config.setWarmUp(20);
|
||||
config.setExecuteRange(600);
|
||||
config.setExecuteRange(60);
|
||||
config.setCoolDown(10);
|
||||
model.setConfig(config);
|
||||
return model;
|
||||
|
|
Loading…
Reference in New Issue