edit the getBehaviorsBrief to just get the latest sampling point.
This commit is contained in:
parent
fec54f5eea
commit
6ee0b610bf
|
@ -27,7 +27,6 @@ import org.bench4q.master.testplan.TestPlanEngine;
|
|||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
import org.bench4q.share.models.master.MonitorModel;
|
||||
import org.bench4q.share.models.master.RunningScriptModel;
|
||||
import org.bench4q.share.models.master.TestPlanBehaviorsBriefResultModel;
|
||||
import org.bench4q.share.models.master.TestPlanPagesBriefResultModel;
|
||||
import org.bench4q.share.models.master.TestPlanScriptBriefResultModel;
|
||||
import org.bench4q.share.models.master.TestPlanBusinessModel;
|
||||
|
@ -230,38 +229,46 @@ public class TestPlanController extends BaseController {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getBehaviorsBrief/{testPlanRunID}/{scriptId}/{duationBegin}")
|
||||
@RequestMapping(value = "/getBehaviorsBrief/{testPlanRunID}/{scriptId}")
|
||||
@ResponseBody
|
||||
public TestPlanBehaviorsBriefResultModel getBehaviorsBrief(
|
||||
@PathVariable UUID testPlanRunID, @PathVariable int scriptId,
|
||||
@PathVariable long duationBegin) throws Bench4QException,
|
||||
NullPointerException {
|
||||
public ScriptBehaviorsBriefModel getBehaviorsBrief(
|
||||
@PathVariable UUID testPlanRunID, @PathVariable int scriptId)
|
||||
throws Bench4QException, NullPointerException {
|
||||
guardForTestPlan(testPlanRunID);
|
||||
List<ScriptBehaviorsBriefModel> behaviorsBriefModels = this
|
||||
.getTestPlanScriptResultService().loadScriptBehaviorsBriefs(
|
||||
testPlanRunID, scriptId, duationBegin);
|
||||
TestPlanBehaviorsBriefResultModel result = new TestPlanBehaviorsBriefResultModel();
|
||||
result.setScriptBehaviorsBriefModels(behaviorsBriefModels);
|
||||
ScriptBehaviorsBriefModel result = this
|
||||
.getTestPlanScriptResultService().loadScriptBehaviorsBrief(
|
||||
testPlanRunID, scriptId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/behaviorBrief/{testPlanRunID}/{scriptId}/{behaviorId}/{duationBegin}")
|
||||
@ResponseBody
|
||||
public ScriptBehaviorsBriefModel getBehaviorBrief(
|
||||
@PathVariable UUID testPlanRunID, @PathVariable int scriptId,
|
||||
@PathVariable int behaviorId, @PathVariable long duactionBegin)
|
||||
throws Bench4QException {
|
||||
guardForTestPlan(testPlanRunID);
|
||||
// ScriptBriefResultModel result = this
|
||||
return null;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/pageBrief/{testPlanRunId}/{scriptId}/{pageId}")
|
||||
@ResponseBody
|
||||
public ScriptPageBriefModel getPageBrief(@PathVariable UUID testPlanRunId,
|
||||
public ScriptPageBriefModel pageBrief(@PathVariable UUID testPlanRunId,
|
||||
@PathVariable int scriptId, @PathVariable int pageId)
|
||||
throws Bench4QException, NullPointerException {
|
||||
guardForTestPlan(testPlanRunId);
|
||||
// TestPlanContext context = this.getTestPlanContainer()
|
||||
// .queryTestPlanContext(testPlanRunId);
|
||||
// RunningScript runningScript = context.queryRunningScript(scriptId);
|
||||
// if (RunningScript.notValidScript(runningScript)) {
|
||||
// throw new Bench4QException(EXCEPTION_HAPPEND + " RunningScript",
|
||||
// "", "/pageBrief/{testPlanRunId}/{scriptId}/{pageId}");
|
||||
// }
|
||||
return null;
|
||||
TestPlanContext context = this.getTestPlanContainer()
|
||||
.queryTestPlanContext(testPlanRunId);
|
||||
RunningScript runningScript = context.queryRunningScript(scriptId);
|
||||
if (RunningScript.notValidScript(runningScript)) {
|
||||
throw new Bench4QException(EXCEPTION_HAPPEND + " RunningScript",
|
||||
"", "/pageBrief/{testPlanRunId}/{scriptId}/{pageId}");
|
||||
}
|
||||
return runningScript.getPageBrief(pageId);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "pagesBrief/{testPlanRunId}/{scriptId}/{duationBegin}")
|
||||
@RequestMapping(value = "/pagesBrief/{testPlanRunId}/{scriptId}")
|
||||
@ResponseBody
|
||||
public TestPlanPagesBriefResultModel getPagesBrief(
|
||||
@PathVariable UUID testPlanRunId, @PathVariable int scriptId,
|
||||
|
|
|
@ -224,7 +224,7 @@ public class RunningScript extends Observable {
|
|||
};
|
||||
}
|
||||
|
||||
public ScriptBriefResultModel getScriptBrief() {
|
||||
private ScriptBriefResultModel getScriptBrief() {
|
||||
for (RunningAgent runningAgent : getRunningAgents()) {
|
||||
if (runningAgent.isBreakDown()) {
|
||||
continue;
|
||||
|
@ -246,7 +246,7 @@ public class RunningScript extends Observable {
|
|||
return result;
|
||||
}
|
||||
|
||||
public ScriptBehaviorsBriefModel getBehaviorsBrief() {
|
||||
private ScriptBehaviorsBriefModel getBehaviorsBrief() {
|
||||
for (RunningAgent runningAgent : getRunningAgents()) {
|
||||
getBehaviorsBriefStatistics().add(
|
||||
this.getRunningAgentService().behaviorsBrief(
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
|
|||
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
|
||||
import org.bench4q.share.models.master.statistics.ScriptPageBriefModel;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -135,25 +136,55 @@ public class TestPlanScriptResultService {
|
|||
return results;
|
||||
}
|
||||
|
||||
public List<ScriptBehaviorsBriefModel> loadScriptBehaviorsBriefs(
|
||||
UUID testPlanId, int scriptId, long startTime) {
|
||||
public ScriptBehaviorsBriefModel loadScriptBehaviorsBrief(UUID testPlanId,
|
||||
int scriptId) {
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
List<ScriptBehaviorsBriefModel> resultModels = new ArrayList<ScriptBehaviorsBriefModel>();
|
||||
try {
|
||||
List<TestPlanScriptResult> results = doGetTestPlanScriptResults(
|
||||
testPlanId, scriptId, startTime,
|
||||
ScriptBehaviorsBriefModel.class, session);
|
||||
for (TestPlanScriptResult testPlanScriptResult : results) {
|
||||
resultModels.add((ScriptBehaviorsBriefModel) MarshalHelper
|
||||
.unmarshal(ScriptBehaviorsBriefModel.class,
|
||||
testPlanScriptResult.getResultContent()));
|
||||
}
|
||||
TestPlanScriptResult testPlanScriptResult = doGetLastSampleResult(
|
||||
testPlanId, scriptId, session);
|
||||
return (ScriptBehaviorsBriefModel) MarshalHelper.unmarshal(
|
||||
ScriptBehaviorsBriefModel.class,
|
||||
testPlanScriptResult.getResultContent());
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionLog.getExceptionStackTrace(e));
|
||||
}
|
||||
return resultModels;
|
||||
return new ScriptBehaviorsBriefModel();
|
||||
}
|
||||
|
||||
private TestPlanScriptResult doGetLastSampleResult(UUID testPlanId,
|
||||
int scriptId, Session session) {
|
||||
return (TestPlanScriptResult) session
|
||||
.createCriteria(TestPlanScriptResult.class)
|
||||
.add(Restrictions.eq(
|
||||
"testPlanScript",
|
||||
this.getTestPlanScriptService().getTestPlanScript(
|
||||
scriptId, testPlanId)))
|
||||
.add(Restrictions.eq("resultType",
|
||||
ScriptBehaviorsBriefModel.class.getName()))
|
||||
.addOrder(Order.desc("createDatetime")).setFetchSize(1).list()
|
||||
.get(0);
|
||||
}
|
||||
|
||||
// public List<ScriptBehaviorsBriefModel> loadScriptBehaviorsBriefs(
|
||||
// UUID testPlanId, int scriptId, long startTime) {
|
||||
// Session session = this.getSessionHelper().openSession();
|
||||
// List<ScriptBehaviorsBriefModel> resultModels = new
|
||||
// ArrayList<ScriptBehaviorsBriefModel>();
|
||||
// try {
|
||||
// List<TestPlanScriptResult> results = doGetTestPlanScriptResults(
|
||||
// testPlanId, scriptId, startTime,
|
||||
// ScriptBehaviorsBriefModel.class, session);
|
||||
// for (TestPlanScriptResult testPlanScriptResult : results) {
|
||||
// resultModels.add((ScriptBehaviorsBriefModel) MarshalHelper
|
||||
// .unmarshal(ScriptBehaviorsBriefModel.class,
|
||||
// testPlanScriptResult.getResultContent()));
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error(ExceptionLog.getExceptionStackTrace(e));
|
||||
// }
|
||||
// return resultModels;
|
||||
// }
|
||||
|
||||
public List<ScriptPageBriefModel> loadScriptPageBriefs(UUID testPlanId,
|
||||
int scriptId, long startTime) {
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
|
|
|
@ -76,12 +76,13 @@ public class TestTestPlanScriptResultService extends TestBase_MakeUpTestPlan {
|
|||
List<ScriptPageBriefModel> resultsPageBriefModels = this
|
||||
.getTestPlanScriptResultService().loadScriptPageBriefs(
|
||||
this.getTestPlanRunIdUuid(), this.getScriptId(), 0);
|
||||
List<ScriptBehaviorsBriefModel> behavirosResults = this
|
||||
.getTestPlanScriptResultService().loadScriptBehaviorsBriefs(
|
||||
this.getTestPlanRunIdUuid(), this.getScriptId(), 0);
|
||||
ScriptBehaviorsBriefModel behavirosResults = this
|
||||
.getTestPlanScriptResultService().loadScriptBehaviorsBrief(
|
||||
this.getTestPlanRunIdUuid(), this.getScriptId());
|
||||
assertEquals(3, results.size());
|
||||
assertEquals(3, resultsPageBriefModels.size());
|
||||
assertEquals(3, behavirosResults.size());
|
||||
assertNotNull(behavirosResults);
|
||||
assertNotNull(behavirosResults.isFinished());
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.bench4q.master.test.testplan;
|
|||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -13,8 +12,6 @@ import javax.xml.bind.JAXBContext;
|
|||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
|
||||
import org.bench4q.master.test.controller.TestBase;
|
||||
import org.bench4q.share.communication.HttpRequester;
|
||||
|
@ -33,7 +30,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class TestPlanTester extends TestBase_MakeUpTestPlan {
|
||||
|
@ -82,6 +78,7 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
|
|||
this.setScriptSumNum(1);
|
||||
this.setAccessTocken(this.login());
|
||||
this.setTestPlanRunIdUuid(testWithTestPlanModel());
|
||||
@SuppressWarnings("unused")
|
||||
TestPlanResultModel resultModel = this.getRunningInfo(this
|
||||
.getTestPlanRunIdUuid());
|
||||
// System.out.println(MarshalHelper.marshal(TestPlanResultModel.class,
|
||||
|
@ -99,10 +96,6 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
|
|||
System.out.println("Invalid response in behaviorsBrief");
|
||||
return;
|
||||
}
|
||||
// ScriptBehaviorsBriefModel resultModel = (ScriptBehaviorsBriefModel)
|
||||
// MarshalHelper
|
||||
// .unmarshal(ScriptBehaviorsBriefModel.class,
|
||||
// httpResponse.getContent());
|
||||
System.out.println(httpResponse.getContent());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue