Add update complete status of test plan
This commit is contained in:
parent
3ff89e72b0
commit
4c6115cdec
|
@ -10,6 +10,7 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.api.model.MonitorModel;
|
||||
import org.bench4q.master.api.model.RunningScriptModel;
|
||||
import org.bench4q.master.api.model.ScriptBriefResultModel;
|
||||
|
@ -39,6 +40,7 @@ public class TestPlanController extends BaseController {
|
|||
private TestPlanContainer testPlanContainer;
|
||||
private TestPlanService testPlanService;
|
||||
private ReportService reportService;
|
||||
private Logger logger;
|
||||
|
||||
public TestPlanRunner getTestPlanRunner() {
|
||||
return testPlanRunner;
|
||||
|
@ -85,6 +87,18 @@ public class TestPlanController extends BaseController {
|
|||
this.reportService = reportService;
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public void setLogger(Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public TestPlanController() {
|
||||
this.setLogger(Logger.getLogger(TestPlanController.class));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/runTestPlanWithTestPlanModel", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public TestPlanResultModel runTestPlanWithTestPlanModel(
|
||||
|
@ -121,6 +135,7 @@ public class TestPlanController extends BaseController {
|
|||
TestPlanContext testPlanContext = this.getTestPlanContainer()
|
||||
.getRunningTestPlans().get(testPlanId);
|
||||
if (testPlanContext == null) {
|
||||
this.getLogger().error("testPlanContext");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,10 +38,8 @@ public class TestPlanContainer {
|
|||
return testPlanContext.queryRunningScriptModel(scriptId);
|
||||
}
|
||||
|
||||
void verifyTestPlanFinishAndWindUp(TestPlanRunner testPlanRunner,
|
||||
UUID testPlanId) {
|
||||
TestPlanContext testPlanContext = testPlanRunner.getTestPlanContainer()
|
||||
.queryTestPlanContext(testPlanId);
|
||||
boolean verifyTestPlanFinish(UUID testPlanId) {
|
||||
TestPlanContext testPlanContext = this.queryTestPlanContext(testPlanId);
|
||||
boolean finish = true;
|
||||
for (RunningScriptModel model : testPlanContext.getRunningScriptMap()
|
||||
.values()) {
|
||||
|
@ -49,11 +47,7 @@ public class TestPlanContainer {
|
|||
finish = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (finish) {
|
||||
testPlanRunner.getTestPlanContainer().getRunningTestPlans()
|
||||
.remove(testPlanId);
|
||||
}
|
||||
return finish;
|
||||
}
|
||||
|
||||
// @Scheduled(cron = "15 */1 * * * *")
|
||||
|
@ -70,4 +64,5 @@ public class TestPlanContainer {
|
|||
// testPlanContext.executeScriptsBrief();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -7,13 +7,11 @@ import java.util.Map;
|
|||
import org.bench4q.master.api.model.TestPlanModel;
|
||||
import org.bench4q.master.api.model.TestPlanResultModel;
|
||||
import org.bench4q.master.api.model.RunningScriptModel;
|
||||
import org.bench4q.master.service.TestPlanScriptService;
|
||||
|
||||
public class TestPlanContext {
|
||||
private TestPlanResultModel resultModel;
|
||||
private Map<Integer, RunningScriptModel> runningScriptMap;
|
||||
private TestPlanModel testPlanModel;
|
||||
private TestPlanScriptService testPlanScriptService;
|
||||
|
||||
public TestPlanResultModel getResultModel() {
|
||||
return resultModel;
|
||||
|
@ -40,15 +38,6 @@ public class TestPlanContext {
|
|||
this.runningScriptMap = runningScriptMap;
|
||||
}
|
||||
|
||||
public TestPlanScriptService getTestPlanScriptService() {
|
||||
return testPlanScriptService;
|
||||
}
|
||||
|
||||
public void setTestPlanScriptService(
|
||||
TestPlanScriptService testPlanScriptService) {
|
||||
this.testPlanScriptService = testPlanScriptService;
|
||||
}
|
||||
|
||||
public TestPlanContext() {
|
||||
this.setRunningScriptMap(new HashMap<Integer, RunningScriptModel>());
|
||||
}
|
||||
|
|
|
@ -165,10 +165,15 @@ public class TestPlanRunner {
|
|||
long planedExecuteTime = this.testPlanService.queryExecuteTime(
|
||||
testPlanId, scriptId);
|
||||
result.setPlanedRunningTime(planedExecuteTime);
|
||||
if (result.isFinished()) {
|
||||
this.getTestPlanContainer().verifyTestPlanFinishAndWindUp(this,
|
||||
testPlanId);
|
||||
if (result.isFinished()
|
||||
&& this.getTestPlanContainer().verifyTestPlanFinish(testPlanId)) {
|
||||
clearUpAndUpdateComplete(testPlanId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void clearUpAndUpdateComplete(UUID testPlanId) {
|
||||
this.getTestPlanContainer().getRunningTestPlans().remove(testPlanId);
|
||||
this.getTestPlanService().handleTestPlanComplete(testPlanId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,15 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bench4q.master.communication.HttpRequester;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class UserTest {
|
||||
import org.bench4q.master.communication.HttpRequester;
|
||||
import org.junit.Test;
|
||||
|
||||
public class UserTest extends TestCase {
|
||||
private HttpRequester httpRequester = new HttpRequester();
|
||||
|
||||
@Test
|
||||
public void authorizeTest() throws IOException {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("userName", "chen");
|
||||
|
@ -16,6 +20,7 @@ public class UserTest {
|
|||
|
||||
org.bench4q.master.communication.HttpRequester.HttpResponse httpResponse = this.httpRequester
|
||||
.sendGet("http://localhost:8080/user/authorize", map, null);
|
||||
assertEquals(true, httpResponse != null);
|
||||
System.out.println(httpResponse.getContent());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue