use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollablesIT method testAddDownServiceToUpNode.
private void testAddDownServiceToUpNode(int nodeId, String nodeLabel, String nodeLocation, String ipAddr, String existingSvcName, String newSvcName) {
PollableService pExistingSvc = m_network.getService(nodeId, getInetAddress(ipAddr), existingSvcName);
PollableInterface pIface = pExistingSvc.getInterface();
PollableNode pNode = pExistingSvc.getNode();
// first we cause a poll for the up node just be make sure everythings working
pExistingSvc.doPoll();
m_network.processStatusChange(new Date());
verifyAnticipated();
// no we add the mock serve
MockService mSvc = m_mockNetwork.addService(nodeId, ipAddr, newSvcName);
m_db.writeService(mSvc);
// bring down the service
mSvc.bringDown();
// expect a nodeLostService event
anticipateDown(mSvc);
// add the service to the PollableNetowrk (simulates nodeGainedService event)
PollableService pSvc = addServiceToNetwork(nodeId, nodeLabel, nodeLocation, ipAddr, newSvcName);
assertNotNull(pSvc);
// before the first call nothing has a cause
assertElementHasNullCause(pSvc);
assertElementHasNullCause(pExistingSvc);
assertElementHasNullCause(pIface);
assertElementHasNullCause(pNode);
// and everything is up
assertUp(pSvc);
assertUp(pExistingSvc);
assertUp(pIface);
assertUp(pNode);
// now poll
pSvc.doPoll();
// expect the svc to be down and everythign else up
assertDown(pSvc);
assertUp(pExistingSvc);
assertUp(pIface);
assertUp(pNode);
// no we send the events and update the causes
m_network.processStatusChange(new Date());
// only the svc has a cause
assertNotNull(pSvc.getCause());
assertElementHasNullCause(pExistingSvc);
assertElementHasNullCause(pIface);
assertElementHasNullCause(pNode);
verifyAnticipated();
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollablesIT method testAddUpSvcToUpNode.
private void testAddUpSvcToUpNode(int nodeId, String nodeLabel, String nodeLocation, String ipAddr, String existingSvcName, String newSvcName) {
PollableService pExistingSvc = m_network.getService(nodeId, getInetAddress(ipAddr), existingSvcName);
assertNotNull(pExistingSvc);
PollableInterface pIface = pExistingSvc.getInterface();
PollableNode pNode = pIface.getNode();
pExistingSvc.doPoll();
m_network.processStatusChange(new Date());
verifyAnticipated();
MockService mSvc = m_mockNetwork.addService(nodeId, ipAddr, newSvcName);
m_db.writeService(mSvc);
PollableService pSvc = addServiceToNetwork(nodeId, nodeLabel, nodeLocation, ipAddr, newSvcName);
assertNotNull(pSvc);
assertElementHasNullCause(pSvc);
assertElementHasNullCause(pExistingSvc);
assertElementHasNullCause(pIface);
assertElementHasNullCause(pNode);
assertUp(pSvc);
assertUp(pExistingSvc);
assertUp(pIface);
assertUp(pNode);
anticipateDown(mSvc);
mSvc.bringDown();
pSvc.doPoll();
m_network.processStatusChange(new Date());
verifyAnticipated();
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class MockPollContext method closeOutage.
public void closeOutage(PollableService pSvc, PollEvent svcRegainEvent) {
MockService mSvc = m_mockNetwork.getService(pSvc.getNodeId(), pSvc.getIpAddr(), pSvc.getSvcName());
Timestamp eventTime = new Timestamp(svcRegainEvent.getDate().getTime());
MockUtil.println("Resolving Outage for " + mSvc);
m_db.resolveOutage(mSvc, svcRegainEvent.getEventId(), eventTime);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class MockPollContext method writeOutage.
private void writeOutage(PollableService pSvc, PollEvent svcLostEvent) {
MockService mSvc = m_mockNetwork.getService(pSvc.getNodeId(), pSvc.getIpAddr(), pSvc.getSvcName());
Timestamp eventTime = new Timestamp(svcLostEvent.getDate().getTime());
MockUtil.println("Opening Outage for " + mSvc);
m_db.createOutage(mSvc, svcLostEvent.getEventId(), eventTime);
}
Aggregations