From 91a64883d05b5c412cd31419be2cede8254f9747 Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Sat, 11 Oct 2014 16:22:44 +0800 Subject: [PATCH] Add briefCycleInMillis to bookTest Add briefCycleInMillis to bookTest q --- .../org/bench4q/agent/api/TestController.java | 8 ++--- .../scenario/engine/ScenarioContext.java | 29 +++++++++---------- .../agent/scenario/engine/ScenarioEngine.java | 6 ++-- .../java/org/bench4q/agent/test/TestBase.java | 3 +- .../agent/test/TestWithScriptFile.java | 5 +++- .../test/scenario/Test_ScenarioContext.java | 3 +- .../main/java/org/bench4q/master/Main.java | 3 ++ .../bench4q/master/domain/entity/Monitor.java | 15 +++++----- .../master/domain/entity/RunningAgentDB.java | 4 +-- .../domain/service/MonitorResultService.java | 29 +------------------ .../communication/AgentMessenger.java | 8 ++--- .../impl/AgentMessengerImpl.java | 19 +++++++----- .../impl/HighAvailablePoolImpl.java | 4 +-- .../master/config/ServerPort.properties | 3 +- ...Test_HighAvailableWithActualMessenger.java | 2 +- .../communication/Test_AgentMessenger.java | 4 +-- .../service/Test_MonitorResultService.java | 2 +- .../unitTest/service/Test_TestPlanEngine.java | 2 +- .../test/java/stubs/Mock_AgentMessenger.java | 10 +++---- 19 files changed, 70 insertions(+), 89 deletions(-) diff --git a/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java index c8dd5d76..24fcf2e5 100644 --- a/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/api/TestController.java @@ -3,7 +3,6 @@ package org.bench4q.agent.api; import java.util.Date; import java.util.List; import java.util.UUID; -import java.util.concurrent.TimeUnit; import org.apache.log4j.Logger; import org.bench4q.agent.plugin.ParameterFileCollector; @@ -59,14 +58,11 @@ public class TestController { RequestMethod.GET, RequestMethod.POST }) @ResponseBody public RunScenarioResultModel bookTest(@PathVariable int poolSize, - @RequestParam(value = "briefCycle") int briefCycle, - @RequestParam(value = "briefUnit") String briefUnit) { + @RequestParam(value = "briefCycleInMillis") long briefCycleInMillis) { try { UUID runId = UUID.randomUUID(); - long sampleCycleInMillis = TimeUnit.valueOf(briefUnit).toMillis( - briefCycle); this.getScenarioEngine().addRunningTestWithoutScenario(runId, - poolSize); + poolSize, briefCycleInMillis); RunScenarioResultModel runScenarioResultModel = new RunScenarioResultModel(); runScenarioResultModel.setRunId(runId); return runScenarioResultModel; diff --git a/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/ScenarioContext.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/ScenarioContext.java index 4ba276aa..a3d44642 100644 --- a/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/ScenarioContext.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/ScenarioContext.java @@ -30,20 +30,23 @@ import org.bench4q.share.models.agent.statistics.BehaviorBriefModel; public class ScenarioContext implements Observer { private static final long keepAliveTime = 10; private final UUID testId; + private final long briefCycleInMillis; private final Date startDate; private Date endDate; private final ThreadPoolExecutor executor; - private Scenario scenario; + private final Scenario scenario; private boolean finished; private final DataCollector dataCollector; private final PluginManager pluginManager; private Schedule schedule; private Logger logger = Logger.getLogger(this.getClass()); - private ScenarioContext(UUID testId, Date startDate, + private ScenarioContext(UUID testId, Scenario scenario, Date startDate, ThreadPoolExecutor executor, DataCollector dataCollector, - PluginManager pluginManager) { + PluginManager pluginManager, long briefCycleInMillis) { this.testId = testId; + this.briefCycleInMillis = briefCycleInMillis; + this.scenario = scenario; this.startDate = startDate; this.executor = executor; this.dataCollector = dataCollector; @@ -74,10 +77,6 @@ public class ScenarioContext implements Observer { return scenario; } - private void setScenario(Scenario scenario) { - this.scenario = scenario; - } - public boolean isFinished() { return finished; } @@ -104,29 +103,29 @@ public class ScenarioContext implements Observer { public static ScenarioContext buildScenarioContextWithoutScenario( UUID testId, int poolSize, PluginManager pluginManager, - StorageHelper storageHelper) { + StorageHelper storageHelper, long briefCycleInMillis) { final ArrayBlockingQueue workQueue = new ArrayBlockingQueue( poolSize); ThreadPoolExecutor executor = new ThreadPoolExecutor(poolSize, poolSize, keepAliveTime, TimeUnit.MINUTES, workQueue, new DiscardPolicy()); - ScenarioContext scenarioContext = new ScenarioContext(testId, new Date( - System.currentTimeMillis()), executor, new DataCollectorImpl( - testId, storageHelper), pluginManager); + ScenarioContext scenarioContext = new ScenarioContext(testId, null, + new Date(System.currentTimeMillis()), executor, + new DataCollectorImpl(testId, storageHelper), pluginManager, + briefCycleInMillis); return scenarioContext; } public ScenarioContext addScenrio(final Scenario scenario, Schedule schedule, final long realStartTime) { - ScenarioContext result = new ScenarioContext(this.testId, new Date( - realStartTime), this.executor, this.dataCollector, - this.pluginManager); + ScenarioContext result = new ScenarioContext(this.testId, scenario, + new Date(realStartTime), this.executor, this.dataCollector, + this.pluginManager, this.briefCycleInMillis); result.setSchedule(schedule); result.setEndDate(new Date(result.getSchedule() .getScheduleRangeInMilliSecond() + result.getStartDate().getTime())); result.setFinished(this.isFinished()); - result.setScenario(scenario); result.getSchedule().addObserver(result); return result; } diff --git a/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/ScenarioEngine.java b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/ScenarioEngine.java index a21783e0..5e83d78f 100644 --- a/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/ScenarioEngine.java +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/scenario/engine/ScenarioEngine.java @@ -50,11 +50,13 @@ public class ScenarioEngine implements Observer { this.storageHelper = storageHelper; } - public void addRunningTestWithoutScenario(UUID runId, int poolSize) { + public void addRunningTestWithoutScenario(UUID runId, int poolSize, + long sampleCycleInMillis) { try { final ScenarioContext scenarioContext = ScenarioContext .buildScenarioContextWithoutScenario(runId, poolSize, - getPluginManager(), this.getStorageHelper()); + getPluginManager(), this.getStorageHelper(), + sampleCycleInMillis); this.getRunningTests().put(runId, scenarioContext); } catch (Exception e) { e.printStackTrace(); diff --git a/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestBase.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestBase.java index ccb2d0a0..f1e09e79 100644 --- a/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestBase.java +++ b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestBase.java @@ -28,6 +28,7 @@ import org.bench4q.share.models.agent.scriptrecord.ScheduleModel.PointModel; import org.springframework.beans.factory.annotation.Autowired; public abstract class TestBase { + protected static final int BRIEF_CYCLE_IN_MILLIS = 3000; private ParameterBarn basePara; private PluginManager pluginManager; private StorageHelper storageHelper; @@ -137,7 +138,7 @@ public abstract class TestBase { StorageHelper storageHelper) { ScenarioContext scenarioContext = ScenarioContext .buildScenarioContextWithoutScenario(testId, poolSize, - pluginManager, storageHelper); + pluginManager, storageHelper, BRIEF_CYCLE_IN_MILLIS); return scenarioContext.addScenrio(scenario, Schedule.build(buildScheduleModel()), new Date().getTime()); } diff --git a/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java index 649d9c6b..5143f004 100644 --- a/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java +++ b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/TestWithScriptFile.java @@ -6,6 +6,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -191,8 +192,10 @@ public class TestWithScriptFile extends TestBase { + "testForBrief.xml")); files.add(new File("Scripts" + System.getProperty("file.separator") + "testJD.xml")); + Map params = new HashMap(); + params.put("briefCycleInMillis", String.valueOf(BRIEF_CYCLE_IN_MILLIS)); HttpResponse httpResponse1 = this.getHttpRequester().sendPost( - url + "/bookTest/20", null, null); + url + "/bookTest/20", params, null); RunScenarioResultModel bookResponse = MarshalHelper.tryUnmarshal( RunScenarioResultModel.class, httpResponse1.getContent()); assertNotNull(bookResponse); diff --git a/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/Test_ScenarioContext.java b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/Test_ScenarioContext.java index 23de8a5c..35319baf 100644 --- a/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/Test_ScenarioContext.java +++ b/Bench4Q-Agent/src/test/java/org/bench4q/agent/test/scenario/Test_ScenarioContext.java @@ -49,7 +49,8 @@ public class Test_ScenarioContext extends TestBase { private ScenarioContext getScenarioWithScenarioAndSchedule() { ScenarioContext scenarioContext = ScenarioContext .buildScenarioContextWithoutScenario(UUID.randomUUID(), 100, - pluginManager, this.storageHelper); + pluginManager, this.storageHelper, + BRIEF_CYCLE_IN_MILLIS); scenarioContext = scenarioContext .addScenrio( Scenario.scenarioCompiler(buildRunScenarioModelWith(new LinkedList())), diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/Main.java b/Bench4Q-Master/src/main/java/org/bench4q/master/Main.java index 8cc40b06..b76c3aac 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/Main.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/Main.java @@ -17,6 +17,7 @@ public class Main { public static int PICK_CYCLE_IN_SECONDS = 60; public static String SCRIPT_PARAM_ROOT_FOLDER = "ScriptParameterization"; public static String FILE_SEPARATOR = System.getProperty("file.separator"); + public static long briefCycleInMillis = 10000; public static void main(String[] args) { try { @@ -47,6 +48,8 @@ public class Main { .getProperty("minSampleCycleInSeconds")); SCRIPT_PARAM_ROOT_FOLDER = prop .getProperty("scriptParamRootFolder"); + briefCycleInMillis = Long.parseLong(prop + .getProperty("briefCycleInMillis")); } catch (Exception e) { e.printStackTrace(); MAX_FAIL_TIMES = 10; diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java index 9c918e15..f222aa67 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java @@ -5,7 +5,6 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; -import java.util.UUID; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -25,7 +24,6 @@ import org.bench4q.master.domain.factory.TestPlanFactory; import org.bench4q.master.domain.valueobject.datastatistics.TestMonitorSampler; import org.bench4q.master.exception.ExceptionLog; import org.bench4q.master.helper.ApplicationContextHelper; -import org.bench4q.master.infrastructure.communication.MonitorMessenger; import org.bench4q.share.helper.MarshalHelper; import org.bench4q.share.models.monitor.MemoryModel; import org.bench4q.share.models.monitor.MonitorMain; @@ -35,7 +33,6 @@ import org.bench4q.share.models.monitor.ProcessModel; import org.bench4q.share.models.monitor.ProcessModelChild; import org.bench4q.share.models.monitor.ProcessorModel; import org.bench4q.share.models.monitor.ProcessorModelChild; -import org.springframework.beans.factory.annotation.Autowired; @Entity @Table(name = "monitor") @@ -105,7 +102,7 @@ public class Monitor { return ApplicationContextHelper.getContext().getBean( TestMonitorSampler.class); } - + @Transient public TestPlanFactory getTestPlanFactory() { return testPlanFactory; @@ -124,7 +121,7 @@ public class Monitor { MonitorMain monitorMain = getTestMonitorSampler().getMonitorResult( hostName, port, this.testPlan.getTestPlanRunId()); System.out.println(MarshalHelper.tryMarshal(monitorMain)); - //tell test plan has to stop itself + // tell test plan has to stop itself testPlan.setHasToStop(monitorMain.isTouchLimit()); List monitorResults = this.getTestPlanFactory() .createMonitorResultListWithOutId(monitorMain, testPlan, @@ -136,9 +133,11 @@ public class Monitor { return null; } } - - public void start(){ - this.getTestMonitorSampler().startMonitor(hostName, port, this.testPlan.getTestPlanRunId(), this.testPlan.getLimitModel()); + + public void start() { + this.getTestMonitorSampler() + .startMonitor(hostName, port, this.testPlan.getTestPlanRunId(), + this.testPlan.getLimitModel()); } public List createFinishedResult() { diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/RunningAgentDB.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/RunningAgentDB.java index a53404f8..9e96c6da 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/RunningAgentDB.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/RunningAgentDB.java @@ -223,7 +223,7 @@ public class RunningAgentDB implements RunningAgentInterface { public boolean run() { // TODO: refactor this function to transaction RunScenarioResultModel runScenarioResultModel = this - .getAgentMessenger().runWithParams(this.getAgent(), + .getAgentMessenger().run(this.getAgent(), this.getAgentRunId()); return runScenarioResultModel != null; } @@ -253,7 +253,7 @@ public class RunningAgentDB implements RunningAgentInterface { // if (this.isStoped()) { // return null; // } - return this.getAgentMessenger().scriptBriefAll(this.getAgent(), + return this.getAgentMessenger().brief(this.getAgent(), this.getAgentRunId()); } } diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/MonitorResultService.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/MonitorResultService.java index 17ea1115..6c18dfae 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/MonitorResultService.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/MonitorResultService.java @@ -1,7 +1,5 @@ package org.bench4q.master.domain.service; -import java.io.IOException; -import java.io.InputStream; import java.util.Date; import java.util.List; import java.util.UUID; @@ -13,7 +11,6 @@ import org.bench4q.master.exception.Bench4QException; import org.bench4q.master.exception.ExceptionLog; import org.bench4q.master.helper.SessionHelper; import org.bench4q.master.infrastructure.communication.MonitorMessenger; -import org.bench4q.recorder.httpcapture.generator.HtmlDocumentParser; import org.bench4q.share.helper.MarshalHelper; import org.bench4q.share.models.master.MonitorMemoryResponseModel; import org.bench4q.share.models.master.MonitorNetworkReponseModel; @@ -29,7 +26,6 @@ import org.bench4q.share.models.monitor.ProcessorModel; import org.hibernate.Session; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; -import org.python.antlr.PythonParser.return_stmt_return; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -37,7 +33,6 @@ import org.springframework.stereotype.Component; public class MonitorResultService { private TestPlanRepository testPlanRepository; private SessionHelper sessionHelper; - private LimitableFieldsModel limitableField = null; @Autowired private MonitorMessenger monitorMessenger; private static Logger logger = Logger.getLogger(MonitorResult.class); @@ -181,29 +176,7 @@ public class MonitorResultService { } } - private void initLimitableFields(){ - String pathSep = System.getProperty("file.separator"); - String limitableFieldsPath = "org" + pathSep + "bench4q" + pathSep - + "master" + pathSep + "config" + pathSep + "MonitorLimitableFields.xml"; - - InputStream is = HtmlDocumentParser.class.getClassLoader() - .getResourceAsStream(limitableFieldsPath); - if (is == null) - return; - StringBuffer out = new StringBuffer(); - byte[] b = new byte[4096]; - int n; - try { - while ((n = is.read(b)) != -1) { - out.append(new String(b, 0, n)); - } - limitableField = MarshalHelper.tryUnmarshal(LimitableFieldsModel.class, out.toString()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - public LimitableFieldsModel getLimitableFields(String hostName, int port){ + public LimitableFieldsModel getLimitableFields(String hostName, int port) { return monitorMessenger.getLimitableFields(hostName, port); } } diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/AgentMessenger.java b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/AgentMessenger.java index c8f8c99f..40826bcd 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/AgentMessenger.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/AgentMessenger.java @@ -22,13 +22,13 @@ public interface AgentMessenger { final RunScenarioModel runScenarioModel, final ScheduleModel scheduleModel, Date realStartDate); - public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId); + public RunScenarioResultModel run(Agent agent, UUID agentRunId); - public TestBriefStatusModel scriptBriefAll(Agent agent, UUID runId); + public TestBriefStatusModel brief(Agent agent, UUID runId); public StopTestModel stop(Agent agent, UUID runId); - public ServerStatusModel getStatus(Agent agent); + public ServerStatusModel status(Agent agent); - public Future getStatusAsync(Agent agent); + public Future statusAsync(Agent agent); } diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/AgentMessengerImpl.java b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/AgentMessengerImpl.java index 3e2e9738..d26cf9d0 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/AgentMessengerImpl.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/AgentMessengerImpl.java @@ -2,6 +2,7 @@ package org.bench4q.master.infrastructure.communication.impl; import java.io.File; import java.util.Date; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -50,6 +51,8 @@ public class AgentMessengerImpl implements AgentMessenger { public RunScenarioResultModel bookTest(Agent agent, int requireLoad) { HttpResponse httpResponse = null; try { + Map parms = new HashMap(1); + parms.put("briefCycleInMillis", String.valueOf(3000)); httpResponse = this.getHttpRequester().sendGet( buildBaseUrl(agent) + "/test/bookTest/" + requireLoad, null, null); @@ -113,7 +116,7 @@ public class AgentMessengerImpl implements AgentMessenger { }); } - public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId) { + public RunScenarioResultModel run(Agent agent, UUID agentRunId) { HttpResponse httpResponse = null; try { if (agent == null || agentRunId == null) { @@ -139,13 +142,13 @@ public class AgentMessengerImpl implements AgentMessenger { return this.executorService .submit(new Callable() { public RunScenarioResultModel call() throws Exception { - return runWithParams(agent, agentRunId); + return run(agent, agentRunId); } }); } // there is bug in here - public TestBriefStatusModel scriptBriefAll(Agent agent, UUID runId) { + public TestBriefStatusModel brief(Agent agent, UUID runId) { HttpResponse httpResponse = null; try { if (agent == null || runId == null) { @@ -169,13 +172,13 @@ public class AgentMessengerImpl implements AgentMessenger { } } - public Future scriptBriefAsync(final Agent agent, + public Future briefAsync(final Agent agent, final UUID runId) { return this.executorService .submit(new Callable() { public TestBriefStatusModel call() throws Exception { - return scriptBriefAll(agent, runId); + return brief(agent, runId); } }); } @@ -214,7 +217,7 @@ public class AgentMessengerImpl implements AgentMessenger { return agent.getHostName() + ":" + agent.getPort(); } - public ServerStatusModel getStatus(Agent agent) { + public ServerStatusModel status(Agent agent) { try { HttpResponse httpResponse = this.getHttpRequester().sendGet( agent.getHostName() + ":" + agent.getPort() + "/", null, @@ -230,11 +233,11 @@ public class AgentMessengerImpl implements AgentMessenger { } } - public Future getStatusAsync(final Agent agent) { + public Future statusAsync(final Agent agent) { return this.executorService.submit(new Callable() { public ServerStatusModel call() throws Exception { - return getStatus(agent); + return status(agent); } }); } diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/highavailable/impl/HighAvailablePoolImpl.java b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/highavailable/impl/HighAvailablePoolImpl.java index 5aa2dd95..b9cac0d1 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/highavailable/impl/HighAvailablePoolImpl.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/highavailable/impl/HighAvailablePoolImpl.java @@ -147,7 +147,7 @@ public class HighAvailablePoolImpl extends CurrentLoadSubject implements private void heartBeatsAndUpdateHAPool() { Map> map = new HashMap>(); for (Agent agent : this.getPool().values()) { - map.put(agent, this.getAgentMessenger().getStatusAsync(agent)); + map.put(agent, this.getAgentMessenger().statusAsync(agent)); } this.updateAgentPoolByHeart(map); } @@ -338,7 +338,7 @@ public class HighAvailablePoolImpl extends CurrentLoadSubject implements } public ServerStatusModel queryAgentStatus(Agent agent) { - return this.getAgentMessenger().getStatus(agent); + return this.getAgentMessenger().status(agent); } } diff --git a/Bench4Q-Master/src/main/resources/org/bench4q/master/config/ServerPort.properties b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/ServerPort.properties index 16806fe6..c0375e8a 100644 --- a/Bench4Q-Master/src/main/resources/org/bench4q/master/config/ServerPort.properties +++ b/Bench4Q-Master/src/main/resources/org/bench4q/master/config/ServerPort.properties @@ -3,4 +3,5 @@ pickTestPlanCycleInSeconds=60 maxFailTime=10 minExcuteIntervalInSeconds=600 minSampleCycleInSeconds=10 -scriptParamRootFolder=ScriptParameterization \ No newline at end of file +scriptParamRootFolder=ScriptParameterization +briefCycleInMillis=3000 \ No newline at end of file diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_HighAvailableWithActualMessenger.java b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_HighAvailableWithActualMessenger.java index d6a97dfc..cbaf4c6e 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_HighAvailableWithActualMessenger.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/Test_HighAvailableWithActualMessenger.java @@ -54,7 +54,7 @@ public class Test_HighAvailableWithActualMessenger extends this.getHaPool().checkAllHeartBeat(); for (RunningAgentInterface runingAgent : agentRunBlottersBeforeKill .values()) { - while (this.getAgentMessenger().getStatus(runingAgent.getAgent()) != null) { + while (this.getAgentMessenger().status(runingAgent.getAgent()) != null) { System.out.println("This need agent " + runingAgent.getAgent().getHostName() + " to be killed"); diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/communication/Test_AgentMessenger.java b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/communication/Test_AgentMessenger.java index 0bec4b2a..6961d8cf 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/communication/Test_AgentMessenger.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/integrated/communication/Test_AgentMessenger.java @@ -84,13 +84,13 @@ public class Test_AgentMessenger extends TestBase_MakeUpTestPlan { .submitScenrioWithParams(agent, model.getRunId(), paramFiles, inputModel, scheduleModel, new Date()); assertEquals(model.getRunId(), modelAfter.getRunId()); - model = this.getAgentMessenger().runWithParams(agent, model.getRunId()); + model = this.getAgentMessenger().run(agent, model.getRunId()); assertNotNull(model); assertNotNull(model.getRunId()); System.out.println(model.getRunId()); // Thread.sleep(2000); TestBriefStatusModel briefModel = this.getAgentMessenger() - .scriptBriefAll(agent, model.getRunId()); + .brief(agent, model.getRunId()); assertNotNull(briefModel); } diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/service/Test_MonitorResultService.java b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/service/Test_MonitorResultService.java index e6b3026a..abf163ba 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/service/Test_MonitorResultService.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/service/Test_MonitorResultService.java @@ -91,7 +91,7 @@ public class Test_MonitorResultService extends TestBase_MakeUpTestPlan { public void testLoadMemoryResults() throws InterruptedException, Bench4QException { assertNotNull(this.getAgentMessenger() - .getStatus( + .status( Agent.createAgentWithoutId(Test_AGENT_HOSTNAME, TEST_PORT, 500))); User user = this.getUserRepository().getUser("admin"); diff --git a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/service/Test_TestPlanEngine.java b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/service/Test_TestPlanEngine.java index 52cfb91c..34d06fe6 100644 --- a/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/service/Test_TestPlanEngine.java +++ b/Bench4Q-Master/src/test/java/org/bench4q/master/unitTest/service/Test_TestPlanEngine.java @@ -83,7 +83,7 @@ public class Test_TestPlanEngine extends TestBase_MakeUpTestPlan { @Test public void testRunTestPlanRightly() throws InterruptedException { assertNotNull(this.getAgentMessenger() - .getStatus( + .status( Agent.createAgentWithoutId(Test_AGENT_HOSTNAME, TEST_PORT, 500))); User user = this.getUserRepository().getUser("admin"); diff --git a/Bench4Q-Master/src/test/java/stubs/Mock_AgentMessenger.java b/Bench4Q-Master/src/test/java/stubs/Mock_AgentMessenger.java index 84bcaff5..e7670e6c 100644 --- a/Bench4Q-Master/src/test/java/stubs/Mock_AgentMessenger.java +++ b/Bench4Q-Master/src/test/java/stubs/Mock_AgentMessenger.java @@ -42,12 +42,12 @@ public class Mock_AgentMessenger implements AgentMessenger { } - public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId) { + public RunScenarioResultModel run(Agent agent, UUID agentRunId) { return new RunScenarioResultModel(this.testId); } - public TestBriefStatusModel scriptBriefAll(Agent agent, UUID runId) { + public TestBriefStatusModel brief(Agent agent, UUID runId) { if (isDead(agent)) { return null; } @@ -76,7 +76,7 @@ public class Mock_AgentMessenger implements AgentMessenger { } - public ServerStatusModel getStatus(Agent agent) { + public ServerStatusModel status(Agent agent) { ServerStatusModel result = new ServerStatusModel(); if (agent.getCurrentEnumStatus() == AgentStatus.InIdle) { return result; @@ -90,7 +90,7 @@ public class Mock_AgentMessenger implements AgentMessenger { } - public Future getStatusAsync(Agent agent) { - return new AsyncResult(getStatus(agent)); + public Future statusAsync(Agent agent) { + return new AsyncResult(status(agent)); } }