remove a bug when judge whether finish test plan

This commit is contained in:
Tienan Chen 2013-11-14 17:41:43 +08:00
parent 155a19561b
commit c5fa153a1b
4 changed files with 27 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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