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);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerIT method createOutages.
private void createOutages(MockElement element, final Event event) {
MockVisitor outageCreater = new MockVisitorAdapter() {
@Override
public void visitService(MockService svc) {
if (svc.getMgmtStatus().equals(SvcMgmtStatus.ACTIVE)) {
m_db.createOutage(svc, event);
}
}
};
element.visit(outageCreater);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerIT method testNodeLostServiceIncludesReason.
@Test
public void testNodeLostServiceIncludesReason() throws Exception {
MockService element = m_network.getService(1, "192.168.1.1", "SMTP");
String expectedReason = "Oh No!! An Outage!!";
startDaemons();
resetAnticipated();
anticipateDown(element);
MockUtil.println("Bringing down element: " + element);
element.bringDown(expectedReason);
MockUtil.println("Finished bringing down element: " + element);
verifyAnticipated(8000);
Collection<Event> receivedEvents = m_eventMgr.getEventAnticipator().getAnticipatedEventsReceived();
assertEquals(2, receivedEvents.size());
Iterator<Event> receivedEventsIter = receivedEvents.iterator();
Event event1 = receivedEventsIter.next();
assertEquals(expectedReason, EventUtils.getParm(event1, EventConstants.PARM_LOSTSERVICE_REASON));
Event event2 = receivedEventsIter.next();
assertNotNull(event2);
assertEquals(EventConstants.OUTAGE_CREATED_EVENT_UEI, event2.getUei());
assertEquals("SMTP", event2.getService());
assertEquals("192.168.1.1", event2.getInterface());
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method testNodeGainedServiceWhileNodeDownAndServiceDown.
@Test
public void testNodeGainedServiceWhileNodeDownAndServiceDown() {
startDaemons();
MockNode node = m_network.getNode(4);
MockService svc = m_network.getService(4, "192.168.1.6", "SNMP");
anticipateDown(node);
node.bringDown();
verifyAnticipated(5000);
resetAnticipated();
MockService newSvc = m_network.addService(4, "192.168.1.6", "SMTP");
m_db.writeService(newSvc);
newSvc.bringDown();
Event e = MockEventUtil.createNodeGainedServiceEvent("Test", newSvc);
m_eventMgr.sendEventToListeners(e);
sleep(5000);
System.err.println(m_db.getOutages());
verifyAnticipated(8000);
anticipateUp(node);
anticipateDown(svc, true);
newSvc.bringUp();
verifyAnticipated(5000);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method anticipateServicesUp.
private void anticipateServicesUp(MockElement node) {
MockVisitor eventCreator = new MockVisitorAdapter() {
@Override
public void visitService(MockService svc) {
anticipateUp(svc);
}
};
node.visit(eventCreator);
}
Aggregations