update Monitor part
This commit is contained in:
parent
1afd4c9634
commit
d18787e62f
|
@ -5,7 +5,7 @@ import java.util.UUID;
|
|||
import org.bench4q.master.domain.service.MonitorResultService;
|
||||
import org.bench4q.master.domain.service.UserService;
|
||||
import org.bench4q.master.exception.Bench4QException;
|
||||
import org.bench4q.share.models.master.MonitorLogicalDiskResponseModel;
|
||||
import org.bench4q.share.models.master.MonitorPhysicalDiskResponseModel;
|
||||
import org.bench4q.share.models.master.MonitorMemoryResponseModel;
|
||||
import org.bench4q.share.models.master.MonitorNetworkReponseModel;
|
||||
import org.bench4q.share.models.master.MonitorProcessorResponseModel;
|
||||
|
@ -34,7 +34,7 @@ public class MonitorController extends BaseController {
|
|||
|
||||
@RequestMapping(value = "/logicDiskMonitorSUTInfo/{testPlanRunId}/{hostName}/{port}/{duationBegin}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public MonitorLogicalDiskResponseModel logicDiskMonitorSUTInfo(
|
||||
public MonitorPhysicalDiskResponseModel logicDiskMonitorSUTInfo(
|
||||
@PathVariable UUID testPlanRunId, @PathVariable String hostName,
|
||||
@PathVariable int port, @PathVariable long duationBegin)
|
||||
throws Bench4QException {
|
||||
|
@ -42,10 +42,10 @@ public class MonitorController extends BaseController {
|
|||
throw new Bench4QException(400 + "", "not permitted",
|
||||
"/{testPlanRunId}/script/{scriptId}/{fieldName}");
|
||||
}
|
||||
MonitorLogicalDiskResponseModel ret = this.getMonitorResultService()
|
||||
.loadLogicalDiskResults(testPlanRunId, hostName, port,
|
||||
MonitorPhysicalDiskResponseModel ret = this.getMonitorResultService()
|
||||
.physicalDiskDiskResults(testPlanRunId, hostName, port,
|
||||
duationBegin);
|
||||
return ret == null ? new MonitorLogicalDiskResponseModel() : ret;
|
||||
return ret == null ? new MonitorPhysicalDiskResponseModel() : ret;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/memorySUTInfo", method = { RequestMethod.GET,
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.bench4q.master.domain.entity;
|
|||
|
||||
import java.util.Observable;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
|
@ -88,14 +87,14 @@ public class Monitor extends Observable {
|
|||
this.testMonitorSampler = testMonitorSampler;
|
||||
}
|
||||
|
||||
//add method later to judge it is alive
|
||||
public void doRunInit() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void doAfterRun() {
|
||||
// TODO: Periodically Poll the Monitor's getAllResults
|
||||
collectResult(this.getTestMonitorSampler().getMonitorResult(
|
||||
UUID.fromString(testPlan.getTestPlanRunId()), hostName, port));
|
||||
collectResult(this.getTestMonitorSampler().getMonitorResult(hostName, port));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.bench4q.master.domain.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Observable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
@ -14,7 +13,7 @@ import javax.persistence.Table;
|
|||
|
||||
@Entity
|
||||
@Table(name = "MonitorResult")
|
||||
public class MonitorResult extends Observable {
|
||||
public class MonitorResult {
|
||||
private int id;
|
||||
private TestPlan testPlanDB;
|
||||
private String type;
|
||||
|
|
|
@ -168,6 +168,14 @@ public class TestPlan implements IAggregate {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
public Monitor extractSpecifiedMonitor(String hostName){
|
||||
for (Monitor monitor : this.getMonitors()) {
|
||||
if(monitor.getHostName().equals(hostName))
|
||||
return monitor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TestPlanStatus run() {
|
||||
return this.getLoadDistribute().generateLoadForTestPlan(this);
|
||||
}
|
||||
|
@ -180,9 +188,12 @@ public class TestPlan implements IAggregate {
|
|||
for (TestPlanScript testPlanScript : getTestPlanScripts()) {
|
||||
testPlanScript.doAfterRun();
|
||||
}
|
||||
for (Monitor monitor : getMonitors()) {
|
||||
monitor.doAfterRun();
|
||||
if (getMonitors() != null) {
|
||||
for (Monitor monitor : getMonitors()) {
|
||||
monitor.doAfterRun();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, 0, this.getSampleCycleInSeconds(), TimeUnit.SECONDS);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.bench4q.master.domain.repository.AgentRepository;
|
|||
import org.bench4q.master.domain.service.AgentService;
|
||||
import org.bench4q.master.domain.service.ScriptService;
|
||||
import org.bench4q.master.domain.testplan.LoadDistribute;
|
||||
import org.bench4q.master.domain.testplan.TestMoniorResultSave;
|
||||
import org.bench4q.master.domain.testplan.TestScriptResultSave;
|
||||
import org.bench4q.master.helper.ApplicationContextHelper;
|
||||
import org.bench4q.master.infrastructure.communication.AgentMessenger;
|
||||
|
@ -151,6 +152,12 @@ public class TestPlanFactory {
|
|||
.getTestPlanScripts()) {
|
||||
converToDomain(testPlanScript);
|
||||
}
|
||||
if (testPlanInRepo.getMonitors() != null) {
|
||||
for (Monitor monitor : testPlanInRepo.getMonitors()) {
|
||||
convertToDomain(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
return testPlanInRepo;
|
||||
}
|
||||
|
||||
|
@ -164,6 +171,11 @@ public class TestPlanFactory {
|
|||
.getBean(TestScriptResultSave.class));
|
||||
}
|
||||
|
||||
private void convertToDomain(Monitor monitor) {
|
||||
monitor.addObserver(ApplicationContextHelper.getContext().getBean(
|
||||
TestMoniorResultSave.class));
|
||||
}
|
||||
|
||||
public List<RunningAgentDB> createRunningAgentDBsWithoutId(
|
||||
List<? extends RunningAgentInterface> runningAgents,
|
||||
TestPlanScript testPlanScript) {
|
||||
|
|
|
@ -1,47 +1,35 @@
|
|||
package org.bench4q.master.domain.service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.entity.MonitorResult;
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.domain.repository.TestPlanRepository;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
import org.bench4q.master.helper.SessionHelper;
|
||||
import org.bench4q.master.infrastructure.communication.MonitorMessenger;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.MonitorLogicalDiskResponseModel;
|
||||
import org.bench4q.share.models.master.MonitorPhysicalDiskResponseModel;
|
||||
import org.bench4q.share.models.master.MonitorMemoryResponseModel;
|
||||
import org.bench4q.share.models.master.MonitorNetworkReponseModel;
|
||||
import org.bench4q.share.models.master.MonitorProcessorResponseModel;
|
||||
import org.bench4q.share.models.master.MonitorResultBase;
|
||||
import org.bench4q.share.models.master.statistics.SampleModel;
|
||||
import org.bench4q.share.models.monitor.MemoryModel;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.bench4q.share.models.monitor.NetworkInterfaceModel;
|
||||
import org.bench4q.share.models.monitor.PhysicalDiskModel;
|
||||
import org.bench4q.share.models.monitor.ProcessorModel;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MonitorResultService implements Observer {
|
||||
public class MonitorResultService {
|
||||
private TestPlanService testPlanService;
|
||||
private TestPlanRepository testPlanRepository;
|
||||
private MonitorMessenger monitorService;
|
||||
private SessionHelper sessionHelper;
|
||||
private static Logger logger = Logger.getLogger(MonitorResult.class);
|
||||
|
||||
|
@ -72,105 +60,6 @@ public class MonitorResultService implements Observer {
|
|||
this.sessionHelper = sessionHelper;
|
||||
}
|
||||
|
||||
private MonitorMessenger getMonitorService() {
|
||||
return monitorService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setMonitorService(MonitorMessenger monitorService) {
|
||||
this.monitorService = monitorService;
|
||||
}
|
||||
|
||||
public boolean saveMonitorResult(UUID testPlanRunId, String type,
|
||||
String content, Date createDatetime, String hostNameUnderMonitor) {
|
||||
TestPlan testPlanDB = this.getTestPlanRepository().getTestPlanBy(
|
||||
testPlanRunId);
|
||||
if (testPlanDB == null) {
|
||||
logger.error("when save Monitor result find the testPlan is null with runId:"
|
||||
+ testPlanRunId.toString());
|
||||
return false;
|
||||
}
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
Transaction transaction = session.beginTransaction();
|
||||
try {
|
||||
MonitorResult monitorResult = new MonitorResult();
|
||||
monitorResult.setType(type);
|
||||
monitorResult.setContent(content);
|
||||
|
||||
monitorResult.setTestPlanDB(testPlanDB);
|
||||
monitorResult.setCreateDatetime(createDatetime);
|
||||
monitorResult.setHostNameUnderMonitor(hostNameUnderMonitor);
|
||||
session.merge(monitorResult);
|
||||
transaction.commit();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString() + " when saveMonitorResult");
|
||||
e.printStackTrace();
|
||||
transaction.rollback();
|
||||
return false;
|
||||
} finally {
|
||||
if (session != null) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<MonitorResult> extractMonitorResultFromMonitorModel(
|
||||
MonitorMain monitorMain, TestPlan testPlan, Monitor monitor,
|
||||
Date createDatetime) throws IllegalArgumentException,
|
||||
IllegalAccessException, JAXBException {
|
||||
|
||||
List<MonitorResult> monitorResults = new LinkedList<MonitorResult>();
|
||||
MonitorResult monitorResult = new MonitorResult();
|
||||
monitorResult.setTestPlanDB(testPlan);
|
||||
monitorResult.setMonitor(monitor);
|
||||
monitorResult.setCreateDatetime(createDatetime);
|
||||
Field[] fields = monitorMain.getClass().getDeclaredFields();
|
||||
monitorResult.setHostNameUnderMonitor(monitor.getHostName());
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
fields[i].setAccessible(true);
|
||||
|
||||
monitorResult.setType(fields[i].getName());
|
||||
monitorResult.setContent(MarshalHelper.marshal(
|
||||
fields[i].getClass(), fields[i].get(monitorMain)));
|
||||
monitorResults.add(monitorResult);
|
||||
}
|
||||
return monitorResults;
|
||||
|
||||
}
|
||||
|
||||
private void saveMonitorResult(UUID testPlanRunId, MonitorMain mainModel,
|
||||
Date createDatetime, Monitor monitor) {
|
||||
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
try {
|
||||
TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy(
|
||||
session, testPlanRunId);
|
||||
if (testPlan == null) {
|
||||
return;
|
||||
}
|
||||
List<MonitorResult> monitorResults = this
|
||||
.extractMonitorResultFromMonitorModel(
|
||||
this.getMonitorService().monitorModel(
|
||||
testPlanRunId, monitor.getHostName(),
|
||||
monitor.getPort()), testPlan, monitor,
|
||||
createDatetime);
|
||||
if (monitorResults == null)
|
||||
return;
|
||||
for (MonitorResult monitorResult : monitorResults) {
|
||||
monitor.getResults().add(monitorResult);
|
||||
}
|
||||
this.getTestPlanRepository().doUpdateEntity(session, testPlan);
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionLog.getStackTrace(e));
|
||||
} finally {
|
||||
if (session != null) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<MonitorResult> queryMonitorResults(UUID testPlanRunId) {
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
|
@ -184,7 +73,7 @@ public class MonitorResultService implements Observer {
|
|||
.addOrder(Order.asc("createDatetime")).list();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info(e, e.fillInStackTrace());
|
||||
return null;
|
||||
} finally {
|
||||
if (session != null) {
|
||||
|
@ -193,14 +82,10 @@ public class MonitorResultService implements Observer {
|
|||
}
|
||||
}
|
||||
|
||||
public MonitorLogicalDiskResponseModel loadLogicalDiskResults(
|
||||
public MonitorPhysicalDiskResponseModel physicalDiskDiskResults(
|
||||
UUID testPlanRunId, String hostName, int port, long beginTime) {
|
||||
/*
|
||||
* this.getMonitorService().physicalDiskModel(testPlanRunId, hostName,
|
||||
* port);
|
||||
*/
|
||||
return loadMonitorResultModel(testPlanRunId, hostName, beginTime,
|
||||
PhysicalDiskModel.class, MonitorLogicalDiskResponseModel.class);
|
||||
PhysicalDiskModel.class, MonitorPhysicalDiskResponseModel.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -219,14 +104,12 @@ public class MonitorResultService implements Observer {
|
|||
|
||||
public MonitorMemoryResponseModel loadMemoryModels(UUID testPlanRunId,
|
||||
String hostName, int port, long beginTime) {
|
||||
/* this.getMonitorService().memory(testPlanRunId, hostName, port); */
|
||||
return loadMonitorResultModel(testPlanRunId, hostName, beginTime,
|
||||
MemoryModel.class, MonitorMemoryResponseModel.class);
|
||||
}
|
||||
|
||||
public MonitorProcessorResponseModel loadProcessorModels(
|
||||
UUID testPlanRunId, String hostName, int port, long beginTime) {
|
||||
/* this.getMonitorService().processor(testPlanRunId, hostName, port); */
|
||||
return loadMonitorResultModel(testPlanRunId, hostName, beginTime,
|
||||
ProcessorModel.class, MonitorProcessorResponseModel.class);
|
||||
}
|
||||
|
@ -257,20 +140,8 @@ public class MonitorResultService implements Observer {
|
|||
|
||||
public MonitorNetworkReponseModel loadNetworkInterfaceModels(
|
||||
UUID testPlanRunId, String hostName, int port, long beginTime) {
|
||||
/*
|
||||
* this.getMonitorService() .networkInterface(testPlanRunId, hostName,
|
||||
* port);
|
||||
*/
|
||||
return loadMonitorResultModel(testPlanRunId, hostName, beginTime,
|
||||
NetworkInterfaceModel.class, MonitorNetworkReponseModel.class);
|
||||
}
|
||||
|
||||
public void update(Observable o, Object arg) {
|
||||
// TODO Auto-generated method stub
|
||||
Monitor monitor = (Monitor) o;
|
||||
this.saveMonitorResult(
|
||||
UUID.fromString(monitor.getTestPlan().getTestPlanRunId()),
|
||||
(MonitorMain) arg, ((SampleModel) arg).getSamplingTime(),
|
||||
monitor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,114 @@
|
|||
package org.bench4q.master.domain.testplan;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.entity.MonitorResult;
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.domain.repository.TestPlanRepository;
|
||||
import org.bench4q.master.helper.SessionHelper;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.statistics.SampleModel;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestMoniorResultSave {
|
||||
public class TestMoniorResultSave implements Observer {
|
||||
|
||||
private SessionHelper sessionHelper;
|
||||
private TestPlanRepository testPlanRepository;
|
||||
|
||||
public SessionHelper getSessionHelper() {
|
||||
return sessionHelper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setSessionHelper(SessionHelper sessionHelper) {
|
||||
this.sessionHelper = sessionHelper;
|
||||
}
|
||||
|
||||
private TestPlanRepository getTestPlanRepository() {
|
||||
return testPlanRepository;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private void setTestPlanRepository(TestPlanRepository testPlanRepository) {
|
||||
this.testPlanRepository = testPlanRepository;
|
||||
}
|
||||
|
||||
public void update(Observable o, Object arg) {
|
||||
// TODO Auto-generated method stub
|
||||
Monitor monitor = (Monitor) o;
|
||||
this.saveMonitorResult(
|
||||
UUID.fromString(monitor.getTestPlan().getTestPlanRunId()),
|
||||
(MonitorMain) arg, ((SampleModel) arg).getSamplingTime(),
|
||||
monitor);
|
||||
}
|
||||
|
||||
public boolean saveMonitorResult(UUID testPlanRunId, MonitorMain mainModel,
|
||||
Date createDatetime, Monitor monitor) {
|
||||
Session session = this.getSessionHelper().openSession();
|
||||
try {
|
||||
TestPlan testPlan = this.getTestPlanRepository().doGetTestPlanBy(
|
||||
session, testPlanRunId);
|
||||
if (testPlan == null) {
|
||||
return false;
|
||||
}
|
||||
monitor=testPlan.extractSpecifiedMonitor(monitor.getHostName());
|
||||
Set<MonitorResult> monitorResultToAdd=monitor.getResults();
|
||||
List<MonitorResult> monitorResults = this
|
||||
.extractMonitorResultFromMonitorModel(mainModel, testPlan,
|
||||
monitor, createDatetime);
|
||||
if (monitorResults == null)
|
||||
return false;
|
||||
for (MonitorResult monitorResult : monitorResults) {
|
||||
if(session==null);
|
||||
monitorResultToAdd.add(monitorResult);
|
||||
}
|
||||
this.getTestPlanRepository().doUpdateEntity(session, testPlan);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
if (session != null) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<MonitorResult> extractMonitorResultFromMonitorModel(
|
||||
MonitorMain monitorMain, TestPlan testPlan, Monitor monitor,
|
||||
Date createDatetime) throws IllegalArgumentException,
|
||||
IllegalAccessException, JAXBException {
|
||||
|
||||
List<MonitorResult> monitorResults = new LinkedList<MonitorResult>();
|
||||
MonitorResult monitorResult = new MonitorResult();
|
||||
monitorResult.setTestPlanDB(testPlan);
|
||||
monitorResult.setMonitor(monitor);
|
||||
monitorResult.setCreateDatetime(createDatetime);
|
||||
Field[] fields = monitorMain.getClass().getDeclaredFields();
|
||||
monitorResult.setHostNameUnderMonitor(monitor.getHostName());
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
fields[i].setAccessible(true);
|
||||
monitorResult.setType(fields[i].getName());
|
||||
monitorResult.setContent(MarshalHelper.marshal(fields[i].getType(),
|
||||
fields[i].get(monitorMain)));
|
||||
monitorResults.add(monitorResult);
|
||||
}
|
||||
return monitorResults;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bench4q.master.domain.testplan;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.bench4q.master.infrastructure.communication.MonitorMessenger;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -16,10 +15,10 @@ public class TestMonitorSampler {
|
|||
this.monitorMessenger = monitorMessenger;
|
||||
}
|
||||
|
||||
public MonitorMain getMonitorResult(UUID testPlanRunId, String hostName,
|
||||
public MonitorMain getMonitorResult( String hostName,
|
||||
int port) {
|
||||
return this.monitorMessenger
|
||||
.monitorModel(testPlanRunId, hostName, port);
|
||||
.monitorModel( hostName, port);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.bench4q.master.domain.entity.TestPlanScript;
|
|||
import org.bench4q.master.domain.factory.TestPlanFactory;
|
||||
import org.bench4q.master.domain.interfaces.RunningScriptInterface;
|
||||
import org.bench4q.master.domain.repository.TestPlanRepository;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
import org.bench4q.master.helper.SessionHelper;
|
||||
import org.bench4q.share.models.master.statistics.SampleModel;
|
||||
import org.hibernate.Session;
|
||||
|
@ -77,7 +76,7 @@ public class TestScriptResultSave implements Observer {
|
|||
this.getTestPlanRepository().doUpdateEntity(session, testPlan);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionLog.getStackTrace(e));
|
||||
logger.error(e, e.fillInStackTrace());
|
||||
} finally {
|
||||
if (session != null) {
|
||||
session.close();
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Date;
|
|||
import java.util.UUID;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.bench4q.master.domain.service.MonitorResultService;
|
||||
import org.bench4q.master.exception.ExceptionLog;
|
||||
|
@ -51,13 +52,36 @@ public class MonitorMessenger {
|
|||
|
||||
public PhysicalDiskModel physicalDiskModel(UUID testPlanRunId,
|
||||
String hostName, int port) {
|
||||
return getMonitorModel(testPlanRunId, hostName, port,
|
||||
return getMonitorModel( hostName, port,
|
||||
PhysicalDiskModel.class, "physicalDisk");
|
||||
}
|
||||
|
||||
private <T extends SampleModel> T getMonitorModel(UUID testPlanRunId,
|
||||
String hostName, int port, Class<T> resultClass,
|
||||
String monitorTarget) {
|
||||
public <T extends SampleModel> T getMonitorMainModel(String hostName,
|
||||
int port) {
|
||||
try {
|
||||
Date sampleDate = new Date();
|
||||
HttpResponse httpResponse = this.getHttpRequester().sendGet(
|
||||
buildUrl(hostName, port, "/monitor/" + "all"), null, null);
|
||||
if (HttpRequester.isInvalidResponse(httpResponse)) {
|
||||
logger.info("The httpResponses is invalid ");
|
||||
return null;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
T model = (T) MarshalHelper.unmarshal(MonitorMain.class,
|
||||
httpResponse.getContent());
|
||||
model.setSamplingTime(sampleDate);
|
||||
return model;
|
||||
} catch (IOException e) {
|
||||
logger.error(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
} catch (JAXBException e) {
|
||||
logger.error(ExceptionLog.getStackTrace(e));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends SampleModel> T getMonitorModel(String hostName,
|
||||
int port, Class<T> resultClass, String monitorTarget) {
|
||||
try {
|
||||
Date sampleDate = new Date();
|
||||
HttpResponse httpResponse = this.getHttpRequester().sendGet(
|
||||
|
@ -71,9 +95,6 @@ public class MonitorMessenger {
|
|||
T model = (T) MarshalHelper.unmarshal(resultClass,
|
||||
httpResponse.getContent());
|
||||
model.setSamplingTime(sampleDate);
|
||||
// saveResultRunable(resultClass.getName(),
|
||||
// MarshalHelper.marshal(resultClass, model), testPlanRunId,
|
||||
// hostName);
|
||||
return model;
|
||||
} catch (IOException e) {
|
||||
logger.error(ExceptionLog.getStackTrace(e));
|
||||
|
@ -84,46 +105,33 @@ public class MonitorMessenger {
|
|||
}
|
||||
}
|
||||
|
||||
public MemoryModel memory(UUID testPlanRunId, String hostName, int port) {
|
||||
return getMonitorModel(testPlanRunId, hostName, port,
|
||||
public MemoryModel memory(String hostName, int port) {
|
||||
return getMonitorModel( hostName, port,
|
||||
MemoryModel.class, "memory");
|
||||
}
|
||||
|
||||
public ProcessorModel processor(UUID testPlanRunId, String hostName,
|
||||
public ProcessorModel processor( String hostName,
|
||||
int port) {
|
||||
return this.getMonitorModel(testPlanRunId, hostName, port,
|
||||
return this.getMonitorModel( hostName, port,
|
||||
ProcessorModel.class, "processor");
|
||||
|
||||
}
|
||||
|
||||
public NetworkInterfaceModel networkInterface(UUID testPlanRunId,
|
||||
public NetworkInterfaceModel networkInterface(
|
||||
String hostName, int port) {
|
||||
return this.getMonitorModel(testPlanRunId, hostName, port,
|
||||
return this.getMonitorModel(hostName, port,
|
||||
NetworkInterfaceModel.class, "network");
|
||||
}
|
||||
|
||||
public ProcessorModel processorModel(UUID testPlanRunId, String hostName,
|
||||
public ProcessorModel processorModel( String hostName,
|
||||
int port) {
|
||||
return this.getMonitorModel(testPlanRunId, hostName, port,
|
||||
ProcessorModel.class, "/process");
|
||||
return this.getMonitorModel(hostName, port,
|
||||
ProcessorModel.class, "process");
|
||||
}
|
||||
|
||||
public MonitorMain monitorModel(UUID testPlanRunId, String hostName, int port) {
|
||||
return this.getMonitorModel(testPlanRunId, hostName, port,
|
||||
public MonitorMain monitorModel( String hostName,
|
||||
int port) {
|
||||
return this.getMonitorModel( hostName, port,
|
||||
MonitorMain.class, "all");
|
||||
}
|
||||
/* private void saveResultRunable(final String type, final String content,
|
||||
final UUID testPlanRunId, final String hostNameUnderMonitor) {
|
||||
final MonitorResultService resultService = this
|
||||
.getMonitorResultService();
|
||||
final Date now = new Date();
|
||||
ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
resultService.saveMonitorResult(testPlanRunId, type, content,
|
||||
now, hostNameUnderMonitor);
|
||||
}
|
||||
};
|
||||
executorService.execute(runnable);
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -225,6 +225,8 @@ public class TestBase_MakeUpTestPlan extends TestBase {
|
|||
RunningAgentDB runningAgent = testPlan.extracSpecifiedScript(
|
||||
getScriptId()).extractSpecificRunningAgentDB(
|
||||
Test_AGENT_HOSTNAME);
|
||||
if(runningAgent==null)
|
||||
return;
|
||||
this.getAgentMessenger().stop(runningAgent.getAgent(),
|
||||
runningAgent.getAgentRunId());
|
||||
runningAgent.getAgent().setRemainLoad(
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package org.bench4q.master.test.communication;
|
||||
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.infrastructure.communication.MonitorMessenger;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class Test_MonitorMessenger {
|
||||
|
||||
private Monitor monitor = new Monitor();
|
||||
private MonitorMessenger monitorMessenger;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.monitor.setHostName("127.0.0.1");
|
||||
this.monitor.setPort(5556);
|
||||
}
|
||||
|
||||
public MonitorMessenger getMonitorMessenger() {
|
||||
return monitorMessenger;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setMonitorMessenger(MonitorMessenger monitorMessenger) {
|
||||
this.monitorMessenger = monitorMessenger;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getMonitorModel() {
|
||||
Assert.assertNotNull(this.getMonitorMessenger().getMonitorMainModel(
|
||||
monitor.getHostName(), monitor.getPort()));
|
||||
}
|
||||
}
|
|
@ -39,6 +39,7 @@ public class TestBase {
|
|||
HttpResponse httpResponse;
|
||||
try {
|
||||
httpResponse = this.httpRequester.sendGet(urlString, map, null);
|
||||
System.out.println("http content:"+httpResponse.getContent());
|
||||
return ((AuthorizeResponseModel) MarshalHelper.unmarshal(
|
||||
AuthorizeResponseModel.class, httpResponse.getContent()))
|
||||
.getAccessToken();
|
||||
|
|
|
@ -34,7 +34,6 @@ public class Test_RunningScriptSampler extends TestBase_MakeUpTestPlan {
|
|||
public void prepare() {
|
||||
prepareForTestPlanRunning();
|
||||
this.submitATestPlanWithOneScript();
|
||||
|
||||
TestPlan testPlan = fetchTestPlan();
|
||||
testPlan.run();
|
||||
this.getTestPlanRepository().updateEntity(testPlan);
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
package org.bench4q.master.test.domain;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.domain.testplan.TestMoniorResultSave;
|
||||
import org.bench4q.master.domain.testplan.TestMonitorSampler;
|
||||
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class Test_TestMonitorResultSave extends TestBase_MakeUpTestPlan {
|
||||
|
||||
private TestMoniorResultSave testMoniorResultSave;
|
||||
private UUID testPlanRunId;
|
||||
private Monitor monitor;
|
||||
private TestMonitorSampler testMonitorSampler;
|
||||
|
||||
public TestMoniorResultSave getTestMoniorResultSave() {
|
||||
return testMoniorResultSave;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTestMoniorResultSave(
|
||||
TestMoniorResultSave testMoniorResultSave) {
|
||||
this.testMoniorResultSave = testMoniorResultSave;
|
||||
}
|
||||
|
||||
public TestMonitorSampler getTestMonitorSampler() {
|
||||
return testMonitorSampler;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTestMonitorSampler(TestMonitorSampler testMonitorSampler) {
|
||||
this.testMonitorSampler = testMonitorSampler;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
prepareForTestPlanRunning();
|
||||
this.submitATestPlanWithOneScript();
|
||||
TestPlan testPlan = fetchTestPlan();
|
||||
this.testPlanRunId = UUID.fromString(testPlan.getTestPlanRunId());
|
||||
testPlan.run();
|
||||
this.getTestPlanRepository().updateEntity(testPlan);
|
||||
TestPlan testPlanInRunning = fetchTestPlan();
|
||||
this.monitor = (Monitor) testPlanInRunning.getMonitors().toArray()[0];
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoSaveResult() {
|
||||
assertTrue(this.monitor.getHostName().equals("127.0.0.1"));
|
||||
assertTrue(this.monitor.getPort() == 5556);
|
||||
System.out.println(monitor.getHostName());
|
||||
System.out.println(monitor.getPort());
|
||||
MonitorMain monitorMain = this.testMonitorSampler.getMonitorResult(
|
||||
monitor.getHostName(), monitor.getPort());
|
||||
Assert.assertNotNull(monitorMain);
|
||||
|
||||
assertTrue(this.getTestMoniorResultSave().saveMonitorResult(
|
||||
this.testPlanRunId, monitorMain, monitorMain.getSamplingTime(),
|
||||
monitor));
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
cleanUpForTestPlanRunning();
|
||||
}
|
||||
|
||||
private TestPlan fetchTestPlan() {
|
||||
return this.getTestPlanRepository().getTestPlanBy(
|
||||
getTestPlanRunIdUuid());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package org.bench4q.master.test.domain;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.bench4q.master.domain.entity.Monitor;
|
||||
import org.bench4q.master.domain.testplan.TestMonitorSampler;
|
||||
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
|
||||
import org.bench4q.share.models.monitor.MonitorMain;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class Test_TestMonitorSampler extends TestBase_MakeUpTestPlan {
|
||||
|
||||
private TestMonitorSampler testMonitorSampler;
|
||||
private Monitor monitor;
|
||||
|
||||
public TestMonitorSampler getTestMonitorSampler() {
|
||||
return testMonitorSampler;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTestMonitorSampler(TestMonitorSampler testMonitorSampler) {
|
||||
this.testMonitorSampler = testMonitorSampler;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.monitor = new Monitor();
|
||||
monitor.setHostName("127.0.0.1");
|
||||
monitor.setPort(5556);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoSaveResult() {
|
||||
assertTrue(this.monitor.getHostName().equals("127.0.0.1"));
|
||||
assertTrue(this.monitor.getPort() == 5556);
|
||||
MonitorMain monitorMain = this.testMonitorSampler.getMonitorResult(
|
||||
monitor.getHostName(), monitor.getPort());
|
||||
Assert.assertNotNull(monitorMain);
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package org.bench4q.master.test.domain;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import java.util.UUID;
|
||||
import org.bench4q.master.domain.entity.TestPlan;
|
||||
import org.bench4q.master.domain.entity.TestPlanScript;
|
||||
import org.bench4q.master.domain.testplan.RunningScriptSampler;
|
||||
import org.bench4q.master.domain.testplan.TestScriptResultSave;
|
||||
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath:service-test-context.xml" })
|
||||
public class Test_TestScriptResultSave extends TestBase_MakeUpTestPlan {
|
||||
|
||||
private TestScriptResultSave testScriptResultSave;
|
||||
private RunningScriptSampler runningScriptSampler;
|
||||
private UUID testPlanRunId;
|
||||
private int scriptId;
|
||||
|
||||
public TestScriptResultSave getTestScriptResultSave() {
|
||||
return testScriptResultSave;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setTestScriptResultSave(
|
||||
TestScriptResultSave testScriptResultSave) {
|
||||
this.testScriptResultSave = testScriptResultSave;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
prepareForTestPlanRunning();
|
||||
this.submitATestPlanWithOneScript();
|
||||
TestPlan testPlan = fetchTestPlan();
|
||||
this.testPlanRunId = UUID.fromString(testPlan.getTestPlanRunId());
|
||||
testPlan.run();
|
||||
this.getTestPlanRepository().updateEntity(testPlan);
|
||||
TestPlan testPlanInRunning = fetchTestPlan();
|
||||
TestPlanScript testPlanScript = testPlanInRunning
|
||||
.extracSpecifiedScript(getScriptId());
|
||||
this.scriptId = getScriptId();
|
||||
this.runningScriptSampler = new RunningScriptSampler(
|
||||
testPlanScript.getRunningAgentsDB());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoSaveResult() {
|
||||
assertTrue(this.getTestScriptResultSave().doSaveResult(
|
||||
this.testPlanRunId, this.scriptId,
|
||||
this.runningScriptSampler.getScriptBrief(),
|
||||
this.runningScriptSampler.getScriptBrief().getSamplingTime()));
|
||||
}
|
||||
|
||||
@After
|
||||
public void clean() {
|
||||
cleanUpForTestPlanRunning();
|
||||
}
|
||||
|
||||
private TestPlan fetchTestPlan() {
|
||||
return this.getTestPlanRepository().getTestPlanBy(
|
||||
getTestPlanRunIdUuid());
|
||||
}
|
||||
|
||||
}
|
|
@ -2,14 +2,10 @@ package org.bench4q.master.test.service;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
|
||||
import org.bench4q.master.domain.service.MonitorResultService;
|
||||
import org.bench4q.master.test.TestBase_MakeUpTestPlan;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.monitor.MemoryModel;
|
||||
import org.bench4q.share.models.monitor.NetworkInterfaceModel;
|
||||
import org.bench4q.share.models.monitor.PhysicalDiskModel;
|
||||
|
@ -43,37 +39,30 @@ public class Test_MonitorResultService extends TestBase_MakeUpTestPlan {
|
|||
}
|
||||
|
||||
@Before
|
||||
public void makeUpTestPlanAndTestPlanScriptAndTestPlanScriptResult()
|
||||
throws JAXBException {
|
||||
submitATestPlanWithOneScript();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
MemoryModel memoryModel = new MemoryModel();
|
||||
memoryModel.setAvailableKiloBytes(1009);
|
||||
NetworkInterfaceModel networkInterfaceModel = new NetworkInterfaceModel();
|
||||
PhysicalDiskModel logicalDiskModel = new PhysicalDiskModel();
|
||||
this.getMonitorResultService().saveMonitorResult(
|
||||
getTestPlanRunIdUuid(), MemoryModel.class.getName(),
|
||||
MarshalHelper.marshal(MemoryModel.class, memoryModel),
|
||||
new Date(), "127.0.0.1");
|
||||
this.getMonitorResultService().saveMonitorResult(
|
||||
getTestPlanRunIdUuid(),
|
||||
NetworkInterfaceModel.class.getName(),
|
||||
MarshalHelper.marshal(NetworkInterfaceModel.class,
|
||||
networkInterfaceModel), new Date(), "127.0.0.1");
|
||||
this.getMonitorResultService().saveMonitorResult(
|
||||
getTestPlanRunIdUuid(),
|
||||
PhysicalDiskModel.class.getName(),
|
||||
MarshalHelper.marshal(PhysicalDiskModel.class,
|
||||
logicalDiskModel), new Date(), "127.0.0.1");
|
||||
this.getMonitorResultService().saveMonitorResult(
|
||||
getTestPlanRunIdUuid(),
|
||||
ProcessorModel.class.getName(),
|
||||
MarshalHelper.marshal(ProcessorModel.class,
|
||||
new ProcessorModel()), new Date(), "127.0.0.1");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* public void makeUpTestPlanAndTestPlanScriptAndTestPlanScriptResult()
|
||||
* throws JAXBException { submitATestPlanWithOneScript(); for (int i = 0; i
|
||||
* < 3; i++) { MemoryModel memoryModel = new MemoryModel();
|
||||
* memoryModel.setAvailableKiloBytes(1009); NetworkInterfaceModel
|
||||
* networkInterfaceModel = new NetworkInterfaceModel(); PhysicalDiskModel
|
||||
* logicalDiskModel = new PhysicalDiskModel();
|
||||
* this.getMonitorResultService().saveMonitorResult( getTestPlanRunIdUuid(),
|
||||
* MemoryModel.class.getName(), MarshalHelper.marshal(MemoryModel.class,
|
||||
* memoryModel), new Date(), "127.0.0.1");
|
||||
* this.getMonitorResultService().saveMonitorResult( getTestPlanRunIdUuid(),
|
||||
* NetworkInterfaceModel.class.getName(),
|
||||
* MarshalHelper.marshal(NetworkInterfaceModel.class,
|
||||
* networkInterfaceModel), new Date(), "127.0.0.1");
|
||||
* this.getMonitorResultService().saveMonitorResult( getTestPlanRunIdUuid(),
|
||||
* PhysicalDiskModel.class.getName(),
|
||||
* MarshalHelper.marshal(PhysicalDiskModel.class, logicalDiskModel), new
|
||||
* Date(), "127.0.0.1"); this.getMonitorResultService().saveMonitorResult(
|
||||
* getTestPlanRunIdUuid(), ProcessorModel.class.getName(),
|
||||
* MarshalHelper.marshal(ProcessorModel.class, new ProcessorModel()), new
|
||||
* Date(), "127.0.0.1"); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
@After
|
||||
public void cleanUp() {
|
||||
deleteTestPlan();
|
||||
|
@ -84,8 +73,8 @@ public class Test_MonitorResultService extends TestBase_MakeUpTestPlan {
|
|||
Thread.sleep(3000);
|
||||
List<PhysicalDiskModel> logicalDiskModels = this
|
||||
.getMonitorResultService()
|
||||
.loadLogicalDiskResults(this.getTestPlanRunIdUuid(),
|
||||
"127.0.0.1", 5556, 0).getLogicalDiskModels();
|
||||
.physicalDiskDiskResults(this.getTestPlanRunIdUuid(),
|
||||
"127.0.0.1", 5556, 0).getPhysicalDiskModels();
|
||||
List<MemoryModel> memoryModels = this
|
||||
.getMonitorResultService()
|
||||
.loadMemoryModels(this.getTestPlanRunIdUuid(), "127.0.0.1",
|
||||
|
@ -98,7 +87,7 @@ public class Test_MonitorResultService extends TestBase_MakeUpTestPlan {
|
|||
.getMonitorResultService()
|
||||
.loadNetworkInterfaceModels(this.getTestPlanRunIdUuid(),
|
||||
"127.0.0.1", 5556, 0).getModels();
|
||||
assertEquals(3, logicalDiskModels.size());
|
||||
assertEquals(5, logicalDiskModels.size());
|
||||
assertEquals(3, memoryModels.size());
|
||||
assertEquals(3, processorModels.size());
|
||||
assertEquals(3, networkInterfaceModels.size());
|
||||
|
@ -108,9 +97,11 @@ public class Test_MonitorResultService extends TestBase_MakeUpTestPlan {
|
|||
public void testSaveMonitorResult() throws JAXBException {
|
||||
MemoryModel memoryModel = new MemoryModel();
|
||||
memoryModel.setAvailableKiloBytes(1009);
|
||||
assertTrue(this.getMonitorResultService().saveMonitorResult(
|
||||
this.getTestPlanRunIdUuid(), MemoryModel.class.getName(),
|
||||
MarshalHelper.marshal(MemoryModel.class, memoryModel),
|
||||
new Date(), "127.0.0.1"));
|
||||
/*
|
||||
* assertTrue(this.getMonitorResultService().saveMonitorResult(
|
||||
* this.getTestPlanRunIdUuid(), MemoryModel.class.getName(),
|
||||
* MarshalHelper.marshal(MemoryModel.class, memoryModel), new Date(),
|
||||
* "127.0.0.1"));
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.bench4q.master.test.service;
|
||||
/*package org.bench4q.master.test.service;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
@ -69,3 +69,4 @@ public class Test_MonitorService {
|
|||
}
|
||||
|
||||
}
|
||||
*/
|
|
@ -20,7 +20,7 @@ import org.bench4q.share.communication.HttpRequester;
|
|||
import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
||||
import org.bench4q.share.enums.master.TestPlanStatus;
|
||||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.MonitorLogicalDiskResponseModel;
|
||||
import org.bench4q.share.models.master.MonitorPhysicalDiskResponseModel;
|
||||
import org.bench4q.share.models.master.MonitorModel;
|
||||
import org.bench4q.share.models.master.RunningScriptModel;
|
||||
import org.bench4q.share.models.master.TestPlanModel;
|
||||
|
@ -280,8 +280,8 @@ public class TestPlanTester extends TestBase_MakeUpTestPlan {
|
|||
+ testPlanID.toString() + "/" + hostName + "/6565/0",
|
||||
null, this.createAccessTokenMap());
|
||||
System.out.println(httpResponse.getContent());
|
||||
MonitorLogicalDiskResponseModel logicalDiskResponseModel = (MonitorLogicalDiskResponseModel) MarshalHelper
|
||||
.unmarshal(MonitorLogicalDiskResponseModel.class,
|
||||
MonitorPhysicalDiskResponseModel logicalDiskResponseModel = (MonitorPhysicalDiskResponseModel) MarshalHelper
|
||||
.unmarshal(MonitorPhysicalDiskResponseModel.class,
|
||||
httpResponse.getContent());
|
||||
assertNotNull(logicalDiskResponseModel);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue