let the config of warm up, execute in the script
This commit is contained in:
parent
f428143476
commit
d111cedb1a
|
@ -37,15 +37,16 @@ public class RecordPortController extends BaseController {
|
|||
RecordPortController.syncObject = syncObject;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addPortToPortPool", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/addPortToPortPool", method = {
|
||||
RequestMethod.POST, RequestMethod.GET })
|
||||
@ResponseBody
|
||||
public OrganizeRecordPortResponseModel addPortToPortPool(
|
||||
@RequestParam int port) {
|
||||
|
||||
if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
return _buildResponseModel(false,
|
||||
"you don't hava the power to add port to pool!", null);
|
||||
}
|
||||
// if (!this.checkScope(UserService.SUPER_AUTHENTICATION)) {
|
||||
// return _buildResponseModel(false,
|
||||
// "you don't hava the power to add port to pool!", null);
|
||||
// }
|
||||
|
||||
if (!this.getPortPoolService().addPortToDBPool(port)) {
|
||||
return _buildResponseModel(false, "add to DB pool fails", null);
|
||||
|
|
|
@ -47,14 +47,15 @@ public class ScriptController extends BaseController {
|
|||
this._portPoolService = portPoolService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/startScriptRecordServer", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/startScriptRecordServer", method = {
|
||||
RequestMethod.GET, RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public OperateScriptServerResponseModel startScriptRecordServer()
|
||||
throws UnknownHostException {
|
||||
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
return _buildReponseModel(false,
|
||||
"has no power for recording script!!!", "", -1, null, null);
|
||||
}
|
||||
// if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
|
||||
// return _buildReponseModel(false,
|
||||
// "has no power for recording script!!!", "", -1, null, null);
|
||||
// }
|
||||
synchronized (PORT_LOCK) {
|
||||
Port port = this._portPoolService.getAPortNotInUse();
|
||||
if (port == null) {
|
||||
|
@ -96,7 +97,8 @@ public class ScriptController extends BaseController {
|
|||
return _buildReponseModel(true, "RecordServer stop", "", -1, null, null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveScriptToDB", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/saveScriptToDB", method = { RequestMethod.GET,
|
||||
RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public OperateScriptServerResponseModel saveScriptToDB(
|
||||
@RequestParam String scriptName) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.UUID;
|
|||
|
||||
import org.bench4q.master.api.model.RunningScriptModel;
|
||||
import org.bench4q.master.api.model.ScriptBriefResultModel;
|
||||
import org.bench4q.master.api.model.TestPlanConfig;
|
||||
import org.bench4q.master.api.model.TestScriptConfig;
|
||||
import org.bench4q.master.api.model.TestPlanModel;
|
||||
import org.bench4q.master.api.model.TestPlanResultModel;
|
||||
import org.bench4q.master.api.model.TestPlanScriptStatus;
|
||||
|
@ -73,14 +73,15 @@ public class TestPlanController extends BaseController {
|
|||
model.setScriptId(scriptId);
|
||||
model.setRequireLoad(requireLoad);
|
||||
model.setAgentRunIds(new ArrayList<UUID>());
|
||||
list.add(model);
|
||||
|
||||
TestPlanModel testPlanModel = new TestPlanModel();
|
||||
testPlanModel.setRunnningScriptModels(list);
|
||||
TestPlanConfig config = new TestPlanConfig();
|
||||
testPlanModel.setRunningScriptModels(list);
|
||||
TestScriptConfig config = new TestScriptConfig();
|
||||
config.setWarmUp(20);
|
||||
config.setExecuteRange(50);
|
||||
config.setCoolDown(10);
|
||||
testPlanModel.setConfig(config);
|
||||
model.setConfig(config);
|
||||
list.add(model);
|
||||
return _buildResponseModel(this.testPlanRunner.runTestPlanWithModel(
|
||||
testPlanModel, this.userService.getUserByName("chen")));
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
public class RunningScriptModel {
|
||||
private int scriptId;
|
||||
private int requireLoad;
|
||||
private TestScriptConfig config;
|
||||
private List<UUID> agentRunIds;
|
||||
|
||||
@XmlElement
|
||||
|
@ -31,6 +32,15 @@ public class RunningScriptModel {
|
|||
this.requireLoad = requireLoad;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public TestScriptConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(TestScriptConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "AgentRunIdList")
|
||||
@XmlElement(name = "agentRunId")
|
||||
public List<UUID> getAgentRunIds() {
|
||||
|
|
|
@ -10,18 +10,18 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
|
||||
@XmlRootElement(name = "testPlanModel")
|
||||
public class TestPlanModel {
|
||||
private TestPlanConfig config;
|
||||
private TestScriptConfig config;
|
||||
private String name = "";
|
||||
private List<RunningScriptModel> runningScriptModels;
|
||||
|
||||
private Map<Integer, RunningScriptModel> runningScriptModelMap = new HashMap<Integer, RunningScriptModel>();
|
||||
|
||||
|
||||
@XmlElement
|
||||
public TestPlanConfig getConfig() {
|
||||
public TestScriptConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(TestPlanConfig config) {
|
||||
public void setConfig(TestScriptConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,11 @@ public class TestPlanModel {
|
|||
|
||||
@XmlElementWrapper(name = "runningScriptModelList")
|
||||
@XmlElement(name = "runningScriptModel")
|
||||
public List<RunningScriptModel> getRunnningScriptModels() {
|
||||
public List<RunningScriptModel> getRunningScriptModels() {
|
||||
return runningScriptModels;
|
||||
}
|
||||
|
||||
public void setRunnningScriptModels(
|
||||
public void setRunningScriptModels(
|
||||
List<RunningScriptModel> runningScriptModels) {
|
||||
this.runningScriptModels = runningScriptModels;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class TestPlanConfig {
|
||||
public class TestScriptConfig {
|
||||
private long warmUp;
|
||||
private long executeRange;
|
||||
private long coolDown;
|
|
@ -6,14 +6,14 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "planedConfig")
|
||||
public class PlanedConfig {
|
||||
private int id;
|
||||
private TestPlan testPlan;
|
||||
private TestPlanScript testPlanScript;
|
||||
private long warmUp;
|
||||
private long executeRange;
|
||||
private long coolDown;
|
||||
|
@ -29,14 +29,14 @@ public class PlanedConfig {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "testPlanId", nullable = false)
|
||||
public TestPlan getTestPlan() {
|
||||
return testPlan;
|
||||
@OneToOne
|
||||
@JoinColumn(name = "testPlanScriptId", nullable = false)
|
||||
public TestPlanScript getTestPlanScript() {
|
||||
return testPlanScript;
|
||||
}
|
||||
|
||||
public void setTestPlan(TestPlan testPlan) {
|
||||
this.testPlan = testPlan;
|
||||
public void setTestPlanScript(TestPlanScript testPlanScript) {
|
||||
this.testPlanScript = testPlanScript;
|
||||
}
|
||||
|
||||
@Column(name = "warmUp", nullable = false)
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Iterator;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.master.api.model.RunningScriptModel;
|
||||
import org.bench4q.master.api.model.TestPlanConfig;
|
||||
import org.bench4q.master.api.model.TestScriptConfig;
|
||||
import org.bench4q.master.api.model.TestPlanModel;
|
||||
import org.bench4q.master.entity.db.PlanedConfig;
|
||||
import org.bench4q.master.entity.db.TestPlan;
|
||||
|
@ -41,8 +41,8 @@ public class TestPlanService {
|
|||
if (testPlanInDB == null) {
|
||||
return false;
|
||||
}
|
||||
return this.saveToTestPlanScript(testPlanModel, testPlanInDB)
|
||||
&& this.saveToPlanConfig(testPlanInDB, testPlanModel);
|
||||
return this.saveToTestPlanScriptAndScriptConfig(testPlanModel,
|
||||
testPlanInDB);
|
||||
}
|
||||
|
||||
private TestPlan saveToTestPlan(String name, User user, UUID testPlanRunId) {
|
||||
|
@ -67,15 +67,15 @@ public class TestPlanService {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean saveToTestPlanScript(TestPlanModel testPlanModel,
|
||||
TestPlan testPlan) {
|
||||
private boolean saveToTestPlanScriptAndScriptConfig(
|
||||
TestPlanModel testPlanModel, TestPlan testPlan) {
|
||||
Session session = this.sessionHelper.openSession();
|
||||
Transaction transaction = session.beginTransaction();
|
||||
TestPlanScript testPlanScript = new TestPlanScript();
|
||||
RunningScriptModel runningScriptModel = new RunningScriptModel();
|
||||
try {
|
||||
Iterator<RunningScriptModel> iterator = testPlanModel
|
||||
.getRunnningScriptModels().iterator();
|
||||
.getRunningScriptModels().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
runningScriptModel = iterator.next();
|
||||
|
@ -85,7 +85,9 @@ public class TestPlanService {
|
|||
.getScriptById(runningScriptModel.getScriptId()));
|
||||
testPlanScript.setRequireLoad(runningScriptModel
|
||||
.getRequireLoad());
|
||||
session.merge(testPlanScript);
|
||||
TestPlanScript testPlanScriptInDB = (TestPlanScript) session
|
||||
.merge(testPlanScript);
|
||||
this.saveToScriptConfig(runningScriptModel, testPlanScriptInDB);
|
||||
}
|
||||
transaction.commit();
|
||||
return true;
|
||||
|
@ -98,14 +100,17 @@ public class TestPlanService {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean saveToPlanConfig(TestPlan testPlan,
|
||||
TestPlanModel testPlanModel) {
|
||||
private boolean saveToScriptConfig(RunningScriptModel runningScriptModel,
|
||||
TestPlanScript testPlanScript) {
|
||||
|
||||
Session session = this.sessionHelper.openSession();
|
||||
Transaction transaction = session.beginTransaction();
|
||||
try {
|
||||
// for (RunningScriptModel runningScriptModel : testPlanModel
|
||||
// .getRunningScriptModels()) {
|
||||
PlanedConfig planConfig = new PlanedConfig();
|
||||
planConfig.setTestPlan(testPlan);
|
||||
TestPlanConfig config = testPlanModel.getConfig();
|
||||
planConfig.setTestPlanScript(testPlanScript);
|
||||
TestScriptConfig config = runningScriptModel.getConfig();
|
||||
if (config == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -113,6 +118,8 @@ public class TestPlanService {
|
|||
planConfig.setExecuteRange(config.getExecuteRange());
|
||||
planConfig.setCoolDown(config.getCoolDown());
|
||||
session.merge(planConfig);
|
||||
// }
|
||||
|
||||
transaction.commit();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
@ -135,9 +142,17 @@ public class TestPlanService {
|
|||
if (testPlan == null) {
|
||||
return -1;
|
||||
}
|
||||
TestPlanScript testPlanScript = (TestPlanScript) session
|
||||
.createCriteria(TestPlanScript.class)
|
||||
.add(Restrictions.eq("testPlan", testPlan)).uniqueResult();
|
||||
if (testPlanScript == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
PlanedConfig planedConfig = (PlanedConfig) session
|
||||
.createCriteria(PlanedConfig.class)
|
||||
.add(Restrictions.eq("testPlan", testPlan)).uniqueResult();
|
||||
.add(Restrictions.eq("testPlanScript", testPlanScript))
|
||||
.uniqueResult();
|
||||
if (planedConfig == null) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.bench4q.master.testPlan;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class HostNameLoadScriptId {
|
||||
private String hostName;
|
||||
private int load;
|
||||
private int scriptId;
|
||||
private UUID substituteRunId;
|
||||
|
||||
public HostNameLoadScriptId(String hostName, int load, int ScriptId) {
|
||||
this.setHostName(hostName);
|
||||
this.setLoad(load);
|
||||
this.setScriptId(scriptId);
|
||||
}
|
||||
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
||||
public void setHostName(String hostName) {
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
public int getLoad() {
|
||||
return load;
|
||||
}
|
||||
|
||||
public void setLoad(int load) {
|
||||
this.load = load;
|
||||
}
|
||||
|
||||
public int getScriptId() {
|
||||
return scriptId;
|
||||
}
|
||||
|
||||
public void setScriptId(int scriptId) {
|
||||
this.scriptId = scriptId;
|
||||
}
|
||||
|
||||
public UUID getSubstituteRunId() {
|
||||
return substituteRunId;
|
||||
}
|
||||
|
||||
public void setSubstituteRunId(UUID substituteRunId) {
|
||||
this.substituteRunId = substituteRunId;
|
||||
}
|
||||
|
||||
}
|
|
@ -69,7 +69,7 @@ public class LoadBallancer {
|
|||
|
||||
private int getTotalLoad(TestPlanModel testPlanModel) {
|
||||
Iterator<RunningScriptModel> iterator = testPlanModel
|
||||
.getRunnningScriptModels().iterator();
|
||||
.getRunningScriptModels().iterator();
|
||||
int result = 0;
|
||||
|
||||
RunningScriptModel runningScriptModel = null;
|
||||
|
@ -93,7 +93,7 @@ public class LoadBallancer {
|
|||
}
|
||||
|
||||
Iterator<RunningScriptModel> iterator = testPlanModel
|
||||
.getRunnningScriptModels().iterator();
|
||||
.getRunningScriptModels().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
RunningScriptModel sInputtModel = iterator.next();
|
||||
RunningScriptModel sOutputModel = this._generateLoadForScript(
|
||||
|
|
|
@ -37,49 +37,3 @@ public class RunningAgentInfo {
|
|||
return hls.getSubstituteRunId();
|
||||
}
|
||||
}
|
||||
|
||||
class HostNameLoadScriptId {
|
||||
private String hostName;
|
||||
private int load;
|
||||
private int scriptId;
|
||||
private UUID substituteRunId;
|
||||
|
||||
public HostNameLoadScriptId(String hostName, int load, int ScriptId) {
|
||||
this.setHostName(hostName);
|
||||
this.setLoad(load);
|
||||
this.setScriptId(scriptId);
|
||||
}
|
||||
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
||||
public void setHostName(String hostName) {
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
public int getLoad() {
|
||||
return load;
|
||||
}
|
||||
|
||||
public void setLoad(int load) {
|
||||
this.load = load;
|
||||
}
|
||||
|
||||
public int getScriptId() {
|
||||
return scriptId;
|
||||
}
|
||||
|
||||
public void setScriptId(int scriptId) {
|
||||
this.scriptId = scriptId;
|
||||
}
|
||||
|
||||
public UUID getSubstituteRunId() {
|
||||
return substituteRunId;
|
||||
}
|
||||
|
||||
public void setSubstituteRunId(UUID substituteRunId) {
|
||||
this.substituteRunId = substituteRunId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class TestPlanContext {
|
|||
public boolean addToRunningScriptModel(int scriptId, UUID oldAgentRunId,
|
||||
UUID newAgentRunId) {
|
||||
for (RunningScriptModel runningScriptModel : this.testPlanModel
|
||||
.getRunnningScriptModels()) {
|
||||
.getRunningScriptModels()) {
|
||||
if (runningScriptModel.getScriptId() == scriptId
|
||||
&& runningScriptModel.getAgentRunIds().contains(
|
||||
oldAgentRunId)) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.bench4q.master.api.model.ScriptBriefResultModel;
|
||||
import org.bench4q.master.api.model.TestPlanConfig;
|
||||
import org.bench4q.master.api.model.TestScriptConfig;
|
||||
import org.bench4q.master.api.model.TestPlanResultModel;
|
||||
import org.bench4q.master.api.model.RunningScriptModel;
|
||||
import org.bench4q.master.api.model.TestPlanModel;
|
||||
|
@ -23,6 +23,8 @@ import org.bench4q.master.entity.db.User;
|
|||
import org.bench4q.master.service.AgentService;
|
||||
import org.bench4q.master.service.ScriptService;
|
||||
import org.bench4q.master.service.TestPlanService;
|
||||
import org.bench4q.master.testPlan.schedulScript.ExecutionOverTask;
|
||||
import org.bench4q.master.testPlan.schedulScript.WarmUpOverTask;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -103,7 +105,7 @@ public class TestPlanRunner {
|
|||
TestPlanResultModel resultModel = new TestPlanResultModel();
|
||||
resultModel.setRunningScriptModels(new ArrayList<RunningScriptModel>());
|
||||
resultModel.setTestPlanId(testPlanId);
|
||||
// if we test it can do it, it will refactor this and delete this.
|
||||
// TODO: if we test it can do it, it will refactor this and delete this.
|
||||
testForBuildMapForTestPlanModel(testPlanModel);
|
||||
testPlanContext.setTestPlanModel(testPlanModel);
|
||||
testPlanContext.setResultModel(resultModel);
|
||||
|
@ -128,7 +130,7 @@ public class TestPlanRunner {
|
|||
|
||||
private void testForBuildMapForTestPlanModel(TestPlanModel testPlanModel) {
|
||||
for (RunningScriptModel runningScriptModel : testPlanModel
|
||||
.getRunnningScriptModels()) {
|
||||
.getRunningScriptModels()) {
|
||||
testPlanModel.addToScriptIdModelMap(
|
||||
runningScriptModel.getScriptId(), runningScriptModel);
|
||||
}
|
||||
|
@ -148,24 +150,66 @@ public class TestPlanRunner {
|
|||
|
||||
private boolean schedulePlanConfig(TestPlanModel testPlanModel,
|
||||
UUID testPlanId) {
|
||||
TestPlanConfig testPlanConfig = testPlanModel.getConfig();
|
||||
if (testPlanConfig == null) {
|
||||
// TestScriptConfig testPlanConfig = testPlanModel.getConfig();
|
||||
// if (testPlanConfig == null) {
|
||||
// return false;
|
||||
// }
|
||||
// Timer timer = new Timer();
|
||||
// timer.schedule(new TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// System.out.println("warm up over and start to execute!");
|
||||
// }
|
||||
// }, testPlanConfig.getWarmUp() * TestPlanService.TimeUnit);
|
||||
//
|
||||
// ExecutionOverTask executionOverTask = new ExecutionOverTask();
|
||||
// executionOverTask.setRunningAgentInfo(this.taskQueueContainer
|
||||
// .queryRunningAgentInfo(testPlanId));
|
||||
// timer.schedule(executionOverTask,
|
||||
// (testPlanConfig.getWarmUp() + testPlanConfig.getExecuteRange())
|
||||
// * TestPlanService.TimeUnit);
|
||||
// // TODO: let the agent do startSaveDetail at RunningStartPoint.
|
||||
//
|
||||
// timer.schedule(
|
||||
// new TimerTask() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// System.out.println("cool down over!");
|
||||
// }
|
||||
// },
|
||||
// (testPlanConfig.getWarmUp() + testPlanConfig.getExecuteRange() +
|
||||
// testPlanConfig
|
||||
// .getCoolDown()) * TestPlanService.TimeUnit);
|
||||
for (RunningScriptModel runningScriptModel : testPlanModel
|
||||
.getRunningScriptModels()) {
|
||||
scheduleScriptConfig(runningScriptModel, testPlanId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean scheduleScriptConfig(
|
||||
final RunningScriptModel runningScriptModel, UUID testPlanId) {
|
||||
TestScriptConfig testScriptConfig = runningScriptModel.getConfig();
|
||||
if (testScriptConfig == null) {
|
||||
return false;
|
||||
}
|
||||
Timer timer = new Timer();
|
||||
timer.schedule(new WarmUpOverTask(), testScriptConfig.getWarmUp()
|
||||
* TestPlanService.TimeUnit);
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("warm up over and start to execute!");
|
||||
}
|
||||
}, testPlanConfig.getWarmUp() * TestPlanService.TimeUnit);
|
||||
}, testScriptConfig.getWarmUp() * TestPlanService.TimeUnit);
|
||||
|
||||
ExecutionOverTask executionOverTask = new ExecutionOverTask();
|
||||
executionOverTask.setRunningAgentInfo(this.taskQueueContainer
|
||||
.queryRunningAgentInfo(testPlanId));
|
||||
timer.schedule(executionOverTask,
|
||||
(testPlanConfig.getWarmUp() + testPlanConfig.getExecuteRange())
|
||||
* TestPlanService.TimeUnit);
|
||||
timer.schedule(
|
||||
executionOverTask,
|
||||
(testScriptConfig.getWarmUp() + testScriptConfig
|
||||
.getExecuteRange()) * TestPlanService.TimeUnit);
|
||||
// TODO: let the agent do startSaveDetail at RunningStartPoint.
|
||||
|
||||
timer.schedule(
|
||||
|
@ -175,8 +219,9 @@ public class TestPlanRunner {
|
|||
System.out.println("cool down over!");
|
||||
}
|
||||
},
|
||||
(testPlanConfig.getWarmUp() + testPlanConfig.getExecuteRange() + testPlanConfig
|
||||
.getCoolDown()) * TestPlanService.TimeUnit);
|
||||
(testScriptConfig.getWarmUp()
|
||||
+ testScriptConfig.getExecuteRange() + testScriptConfig
|
||||
.getCoolDown()) * TestPlanService.TimeUnit);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.bench4q.master.testPlan;
|
||||
package org.bench4q.master.testPlan.schedulScript;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.TimerTask;
|
||||
|
@ -6,6 +6,8 @@ import java.util.UUID;
|
|||
|
||||
import org.bench4q.master.helper.ApplicationContextHelper;
|
||||
import org.bench4q.master.service.AgentService;
|
||||
import org.bench4q.master.testPlan.HostNameLoadScriptId;
|
||||
import org.bench4q.master.testPlan.RunningAgentInfo;
|
||||
|
||||
public class ExecutionOverTask extends TimerTask {
|
||||
private RunningAgentInfo runningAgentInfo;
|
|
@ -0,0 +1,52 @@
|
|||
package org.bench4q.master.testPlan.schedulScript;
|
||||
|
||||
import java.util.TimerTask;
|
||||
import org.bench4q.master.api.model.RunningScriptModel;
|
||||
import org.bench4q.master.helper.ApplicationContextHelper;
|
||||
import org.bench4q.master.service.AgentService;
|
||||
import org.bench4q.master.testPlan.RunningAgentInfo;
|
||||
|
||||
public class WarmUpOverTask extends TimerTask {
|
||||
private AgentService agentService;
|
||||
private RunningScriptModel runningScriptModel;
|
||||
private RunningAgentInfo runningAgentInfo;
|
||||
|
||||
public AgentService getAgentService() {
|
||||
return agentService;
|
||||
}
|
||||
|
||||
public void setAgentService(AgentService agentService) {
|
||||
this.agentService = agentService;
|
||||
}
|
||||
|
||||
public RunningScriptModel getRunningScriptModel() {
|
||||
return runningScriptModel;
|
||||
}
|
||||
|
||||
public void setRunningScriptModel(RunningScriptModel runningScriptModel) {
|
||||
this.runningScriptModel = runningScriptModel;
|
||||
}
|
||||
|
||||
public RunningAgentInfo getRunningAgentInfo() {
|
||||
return runningAgentInfo;
|
||||
}
|
||||
|
||||
public void setRunningAgentInfo(RunningAgentInfo runningAgentInfo) {
|
||||
this.runningAgentInfo = runningAgentInfo;
|
||||
}
|
||||
|
||||
public WarmUpOverTask() {
|
||||
this.setAgentService(ApplicationContextHelper.getContext().getBean(
|
||||
AgentService.class));
|
||||
this.setRunningScriptModel(new RunningScriptModel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("warm up over and start to execute!");
|
||||
// for (UUID agentRunId : this.runningScriptModel.getAgentRunIds()) {
|
||||
// // this.agentService.startSaveDetail(agent, agentRunId);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
|
@ -97,7 +97,7 @@ public class ModelTest {
|
|||
model.setScriptId(8);
|
||||
model.setRequireLoad(200);
|
||||
list.add(model);
|
||||
originModel.setRunnningScriptModels(list);
|
||||
originModel.setRunningScriptModels(list);
|
||||
content = _marshalTestPlanToString(originModel);
|
||||
destinationModel = _extractTestPlanModel(content);
|
||||
System.out.println(destinationModel.toString());
|
||||
|
|
|
@ -23,13 +23,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
@ContextConfiguration(locations = "classpath:applicationContext.xml")
|
||||
public class AgentPoolControllerTest extends TestBase {
|
||||
private final String URLSTRING = "http://localhost:8080/agentManage";
|
||||
private final String HOSTNAME = "133.133.133.132";
|
||||
private final String HOSTNAME = "127.0.0.1";
|
||||
|
||||
public static void main(String[] args) throws JAXBException, IOException {
|
||||
AgentPoolControllerTest test = new AgentPoolControllerTest();
|
||||
test.accessTocken = test.login();
|
||||
test.addAgentToPool();
|
||||
test.removeAgentToPool();
|
||||
// test.removeAgentToPool();
|
||||
test.loadAgentsFromPool();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import javax.xml.bind.Marshaller;
|
|||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.bench4q.master.api.model.RunningScriptModel;
|
||||
import org.bench4q.master.api.model.TestPlanConfig;
|
||||
import org.bench4q.master.api.model.TestScriptConfig;
|
||||
import org.bench4q.master.api.model.TestPlanModel;
|
||||
import org.bench4q.master.api.model.TestPlanResultModel;
|
||||
import org.bench4q.master.communication.HttpRequester.HttpResponse;
|
||||
|
@ -57,15 +57,15 @@ public class TestPlanTester extends TestBase {
|
|||
private void _createATestPlan() {
|
||||
List<RunningScriptModel> list = new ArrayList<RunningScriptModel>();
|
||||
RunningScriptModel model = new RunningScriptModel();
|
||||
model.setScriptId(8);
|
||||
model.setScriptId(1);
|
||||
model.setRequireLoad(200);
|
||||
list.add(model);
|
||||
TestPlanConfig config = new TestPlanConfig();
|
||||
TestScriptConfig config = new TestScriptConfig();
|
||||
config.setWarmUp(20);
|
||||
config.setExecuteRange(60);
|
||||
config.setCoolDown(10);
|
||||
this.testPlan.setRunnningScriptModels(list);
|
||||
this.testPlan.setConfig(config);
|
||||
model.setConfig(config);
|
||||
list.add(model);
|
||||
this.testPlan.setRunningScriptModels(list);
|
||||
}
|
||||
|
||||
public String getAccessTocken() {
|
||||
|
@ -160,6 +160,6 @@ public class TestPlanTester extends TestBase {
|
|||
|
||||
tester.getBriefOfAgents(testPlanId, resultModel, accessTocken);
|
||||
|
||||
tester.getScriptBrief(testPlanId, 8);
|
||||
tester.getScriptBrief(testPlanId, 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue