parent
c9bb8207a4
commit
e67a80db8d
|
@ -179,8 +179,8 @@ public class ScenarioContext implements Observer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
this.getSchedule().stop();
|
|
||||||
this.setFinished(true);
|
this.setFinished(true);
|
||||||
this.getExecutor().shutdownNow();
|
this.getExecutor().shutdownNow();
|
||||||
|
this.getSchedule().stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,4 +94,9 @@ public class Test_Shedule {
|
||||||
Schedule schedule = Schedule.build(TestBase.buildScheduleModel());
|
Schedule schedule = Schedule.build(TestBase.buildScheduleModel());
|
||||||
assertEquals(60 * 1000, schedule.getScheduleRange());
|
assertEquals(60 * 1000, schedule.getScheduleRange());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_WithShortScheduleLessThenOneSecond() {
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.bench4q.share.models.agent.RunScenarioModel;
|
||||||
import org.bench4q.share.models.agent.RunScenarioResultModel;
|
import org.bench4q.share.models.agent.RunScenarioResultModel;
|
||||||
import org.bench4q.share.models.agent.StopTestModel;
|
import org.bench4q.share.models.agent.StopTestModel;
|
||||||
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
||||||
|
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "runningAgent")
|
@Table(name = "runningAgent")
|
||||||
|
@ -180,12 +181,18 @@ public class RunningAgentDB implements RunningAgentInterface {
|
||||||
Script script2 = this.getTestPlanScript().getScript();
|
Script script2 = this.getTestPlanScript().getScript();
|
||||||
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
|
RunScenarioModel runScenarioModel = (RunScenarioModel) MarshalHelper
|
||||||
.tryUnmarshal(RunScenarioModel.class,
|
.tryUnmarshal(RunScenarioModel.class,
|
||||||
script2.getFilteredScriptCnt());
|
script2.getScriptContent());
|
||||||
runScenarioModel.setPoolSize(getLoadInUse());
|
runScenarioModel.setPoolSize(getLoadInUse());
|
||||||
RunScenarioResultModel runScenarioResultModel = this
|
RunScenarioResultModel runScenarioResultModel = this
|
||||||
.getAgentMessenger().submitScenrioWithParams(this.getAgent(),
|
.getAgentMessenger().submitScenrioWithParams(
|
||||||
this.getAgentRunId(), script2.loadParamFiles(),
|
this.getAgent(),
|
||||||
runScenarioModel, this.getRunningScript().getStartTime());
|
this.getAgentRunId(),
|
||||||
|
script2.loadParamFiles(),
|
||||||
|
runScenarioModel,
|
||||||
|
(ScheduleModel) MarshalHelper.tryUnmarshal(
|
||||||
|
ScheduleModel.class, this.getTestPlanScript()
|
||||||
|
.getScheduleContent()),
|
||||||
|
this.getRunningScript().getStartTime());
|
||||||
if (runScenarioResultModel == null) {
|
if (runScenarioResultModel == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,6 @@ public class TestPlanScript implements RunningScriptInterface {
|
||||||
ExecutionOverTask executionOverTask = new ExecutionOverTask(this);
|
ExecutionOverTask executionOverTask = new ExecutionOverTask(this);
|
||||||
timer.schedule(executionOverTask, (testScriptConfig.getExecuteRange())
|
timer.schedule(executionOverTask, (testScriptConfig.getExecuteRange())
|
||||||
* SECOND_MILISECOND_UNIT_CONVERSION);
|
* SECOND_MILISECOND_UNIT_CONVERSION);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,4 +300,9 @@ public class TestPlanScript implements RunningScriptInterface {
|
||||||
public Date getStartTime() {
|
public Date getStartTime() {
|
||||||
return this.getTestPlan().getCurrentStartTime();
|
return this.getTestPlan().getCurrentStartTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
public String getScheduleContent() {
|
||||||
|
return this.getPlanedConfig().getScheduleContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,6 +219,7 @@ public class TestPlanFactory {
|
||||||
|
|
||||||
private PlanedConfig createAPlanedConfigWithoutId(ScheduleModel schedule) {
|
private PlanedConfig createAPlanedConfigWithoutId(ScheduleModel schedule) {
|
||||||
PlanedConfig result = new PlanedConfig();
|
PlanedConfig result = new PlanedConfig();
|
||||||
|
result.setExecuteRange(schedule.getExecuteRange());
|
||||||
result.setScheduleContent(MarshalHelper.tryMarshal(schedule));
|
result.setScheduleContent(MarshalHelper.tryMarshal(schedule));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,15 @@ import org.bench4q.share.models.agent.RunScenarioResultModel;
|
||||||
import org.bench4q.share.models.agent.ServerStatusModel;
|
import org.bench4q.share.models.agent.ServerStatusModel;
|
||||||
import org.bench4q.share.models.agent.StopTestModel;
|
import org.bench4q.share.models.agent.StopTestModel;
|
||||||
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
||||||
|
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
|
||||||
|
|
||||||
public interface AgentMessenger {
|
public interface AgentMessenger {
|
||||||
public RunScenarioResultModel bookTest(Agent agent, int requireLoad);
|
public RunScenarioResultModel bookTest(Agent agent, int requireLoad);
|
||||||
|
|
||||||
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
|
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
|
||||||
UUID agentRunId, List<File> paramFiles,
|
UUID agentRunId, List<File> paramFiles,
|
||||||
final RunScenarioModel runScenarioModel, Date realStartDate);
|
final RunScenarioModel runScenarioModel,
|
||||||
|
final ScheduleModel scheduleModel, Date realStartDate);
|
||||||
|
|
||||||
public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId);
|
public RunScenarioResultModel runWithParams(Agent agent, UUID agentRunId);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.bench4q.share.models.agent.RunScenarioResultModel;
|
||||||
import org.bench4q.share.models.agent.ServerStatusModel;
|
import org.bench4q.share.models.agent.ServerStatusModel;
|
||||||
import org.bench4q.share.models.agent.StopTestModel;
|
import org.bench4q.share.models.agent.StopTestModel;
|
||||||
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
||||||
|
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -75,15 +76,16 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
|
|
||||||
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
|
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
|
||||||
UUID agentRunId, List<File> paramFiles,
|
UUID agentRunId, List<File> paramFiles,
|
||||||
final RunScenarioModel runScenarioModel, Date realStartDate) {
|
final RunScenarioModel runScenarioModel,
|
||||||
|
final ScheduleModel scheduleModel, Date realStartDate) {
|
||||||
HttpResponse httpResponse = null;
|
HttpResponse httpResponse = null;
|
||||||
try {
|
try {
|
||||||
final String modelContent = MarshalHelper
|
final String modelContent = MarshalHelper
|
||||||
.tryMarshal(runScenarioModel);
|
.tryMarshal(runScenarioModel);
|
||||||
final Map<String, String> stringParts = new LinkedHashMap<String, String>();
|
final Map<String, String> stringParts = new LinkedHashMap<String, String>();
|
||||||
stringParts.put("scenarioModel", modelContent);
|
stringParts.put("scenarioModel", modelContent);
|
||||||
stringParts.put("realStartTime",
|
stringParts.put("scheduleContent",
|
||||||
String.valueOf(realStartDate.getTime()));
|
MarshalHelper.tryMarshal(scheduleModel));
|
||||||
httpResponse = this.httpRequester.postFiles(null,
|
httpResponse = this.httpRequester.postFiles(null,
|
||||||
buildBaseUrl(agent) + "/test/submitScenarioWithParams/"
|
buildBaseUrl(agent) + "/test/submitScenarioWithParams/"
|
||||||
+ agentRunId + "/" + realStartDate.getTime(),
|
+ agentRunId + "/" + realStartDate.getTime(),
|
||||||
|
@ -99,13 +101,15 @@ public class AgentMessengerImpl implements AgentMessenger {
|
||||||
public Future<RunScenarioResultModel> submitScenarioWithParamsAsync(
|
public Future<RunScenarioResultModel> submitScenarioWithParamsAsync(
|
||||||
final Agent agent, final UUID agentRunId,
|
final Agent agent, final UUID agentRunId,
|
||||||
final List<File> paramFiles,
|
final List<File> paramFiles,
|
||||||
final RunScenarioModel runScenarioModel, final Date realStartDate) {
|
final RunScenarioModel runScenarioModel,
|
||||||
|
final ScheduleModel scheduleModel, final Date realStartDate) {
|
||||||
return this.executorService
|
return this.executorService
|
||||||
.submit(new Callable<RunScenarioResultModel>() {
|
.submit(new Callable<RunScenarioResultModel>() {
|
||||||
@Override
|
@Override
|
||||||
public RunScenarioResultModel call() throws Exception {
|
public RunScenarioResultModel call() throws Exception {
|
||||||
return submitScenrioWithParams(agent, agentRunId,
|
return submitScenrioWithParams(agent, agentRunId,
|
||||||
paramFiles, runScenarioModel, realStartDate);
|
paramFiles, runScenarioModel, scheduleModel,
|
||||||
|
realStartDate);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class Test_TestPlan extends TestBase_MakeUpTestPlan {
|
||||||
.getTestPlanInDomainBy(getTestPlanRunIdUuid());
|
.getTestPlanInDomainBy(getTestPlanRunIdUuid());
|
||||||
TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain(
|
TestPlan testPlanInDomain = this.getTestPlanFactory().convertToDomain(
|
||||||
testPlanFromRepo);
|
testPlanFromRepo);
|
||||||
|
this.getTestPlanRepository().attachRunningTestPlan(testPlanInDomain);
|
||||||
testPlanInDomain.run();
|
testPlanInDomain.run();
|
||||||
this.getTestPlanRepository().attachRunningTestPlan(testPlanInDomain);
|
this.getTestPlanRepository().attachRunningTestPlan(testPlanInDomain);
|
||||||
assertEquals(TestPlanStatus.InRunning.name(),
|
assertEquals(TestPlanStatus.InRunning.name(),
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.bench4q.master.unitTest.TestBase_MakeUpTestPlan;
|
||||||
import org.bench4q.share.helper.MarshalHelper;
|
import org.bench4q.share.helper.MarshalHelper;
|
||||||
import org.bench4q.share.models.agent.RunScenarioModel;
|
import org.bench4q.share.models.agent.RunScenarioModel;
|
||||||
import org.bench4q.share.models.agent.RunScenarioResultModel;
|
import org.bench4q.share.models.agent.RunScenarioResultModel;
|
||||||
|
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -41,6 +42,7 @@ public class Test_AgentMessenger extends TestBase_MakeUpTestPlan {
|
||||||
this.agentMessenger = agentMessenger;
|
this.agentMessenger = agentMessenger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: modify this to adapt to new code
|
||||||
@Test
|
@Test
|
||||||
public void testSubmitScenarioWithParamsAndRun() throws IOException,
|
public void testSubmitScenarioWithParamsAndRun() throws IOException,
|
||||||
JAXBException {
|
JAXBException {
|
||||||
|
@ -74,7 +76,7 @@ public class Test_AgentMessenger extends TestBase_MakeUpTestPlan {
|
||||||
System.out.println(model.getRunId());
|
System.out.println(model.getRunId());
|
||||||
RunScenarioResultModel modelAfter = this.getAgentMessenger()
|
RunScenarioResultModel modelAfter = this.getAgentMessenger()
|
||||||
.submitScenrioWithParams(agent, model.getRunId(), paramFiles,
|
.submitScenrioWithParams(agent, model.getRunId(), paramFiles,
|
||||||
inputModel, new Date());
|
inputModel, new ScheduleModel(), new Date());
|
||||||
assertEquals(model.getRunId(), modelAfter.getRunId());
|
assertEquals(model.getRunId(), modelAfter.getRunId());
|
||||||
model = this.getAgentMessenger().runWithParams(agent, model.getRunId());
|
model = this.getAgentMessenger().runWithParams(agent, model.getRunId());
|
||||||
assertNotNull(model);
|
assertNotNull(model);
|
||||||
|
|
|
@ -399,8 +399,8 @@ public class TestBase_MakeUpTestPlan extends TestBase {
|
||||||
model.setRequireLoad(EACH_SCRIPT_LOAD_SMALLSCALE);
|
model.setRequireLoad(EACH_SCRIPT_LOAD_SMALLSCALE);
|
||||||
ScheduleModel schedule = new ScheduleModel();
|
ScheduleModel schedule = new ScheduleModel();
|
||||||
schedule.getPoints().add(new PointModel(0, 0));
|
schedule.getPoints().add(new PointModel(0, 0));
|
||||||
schedule.getPoints().add(new PointModel(20, 10));
|
schedule.getPoints().add(new PointModel(20 * 1000, 10));
|
||||||
schedule.getPoints().add(new PointModel(60, 10));
|
schedule.getPoints().add(new PointModel(60 * 1000, 10));
|
||||||
model.setScheduleModel(schedule);
|
model.setScheduleModel(schedule);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.bench4q.share.models.agent.RunScenarioResultModel;
|
||||||
import org.bench4q.share.models.agent.ServerStatusModel;
|
import org.bench4q.share.models.agent.ServerStatusModel;
|
||||||
import org.bench4q.share.models.agent.StopTestModel;
|
import org.bench4q.share.models.agent.StopTestModel;
|
||||||
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
import org.bench4q.share.models.agent.TestBriefStatusModel;
|
||||||
|
import org.bench4q.share.models.agent.scriptrecord.ScheduleModel;
|
||||||
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
|
import org.bench4q.share.models.agent.statistics.AgentBehaviorsBriefModel;
|
||||||
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
|
import org.bench4q.share.models.agent.statistics.AgentBriefStatusModel;
|
||||||
import org.bench4q.share.models.agent.statistics.AgentPagesBriefModel;
|
import org.bench4q.share.models.agent.statistics.AgentPagesBriefModel;
|
||||||
|
@ -35,7 +36,8 @@ public class Mock_AgentMessenger implements AgentMessenger {
|
||||||
@Override
|
@Override
|
||||||
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
|
public RunScenarioResultModel submitScenrioWithParams(Agent agent,
|
||||||
UUID agentRunId, List<File> paramFiles,
|
UUID agentRunId, List<File> paramFiles,
|
||||||
RunScenarioModel runScenarioModel, Date realStartTime) {
|
RunScenarioModel runScenarioModel,
|
||||||
|
final ScheduleModel scheduleModel, Date realStartTime) {
|
||||||
return new RunScenarioResultModel(this.testId);
|
return new RunScenarioResultModel(this.testId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue