use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class MockDatabase method populate.
public void populate(MockNetwork network) {
MockVisitor dbCreater = new MockVisitorAdapter() {
@Override
public void visitNode(MockNode node) {
writeNode(node);
}
@Override
public void visitInterface(MockInterface iface) {
writeInterface(iface);
}
@Override
public void visitService(MockService svc) {
writeService(svc);
}
@Override
public void visitPathOutage(MockPathOutage out) {
writePathOutage(out);
}
};
network.visit(dbCreater);
getJdbcTemplate().queryForObject("SELECT setval('nodeNxtId', max(nodeid)) FROM node", Integer.class);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollablesIT method testServiceEvent.
@Test
public void testServiceEvent() throws Exception {
MockService mSvc = mDot1Smtp;
PollableService pSvc = pDot1Smtp;
anticipateDown(mSvc);
mSvc.bringDown();
pSvc.doPoll();
m_network.processStatusChange(new Date());
verifyAnticipated();
// anticipate nothin since service is still down
pSvc.doPoll();
m_network.processStatusChange(new Date());
verifyAnticipated();
anticipateUp(mSvc);
mSvc.bringUp();
pSvc.doPoll();
m_network.processStatusChange(new Date());
verifyAnticipated();
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method testServiceOutagesClosedOnDelete.
@Test
public void testServiceOutagesClosedOnDelete() {
MockService element = m_network.getService(1, "192.168.1.1", "SMTP");
testOutagesClosedOnDelete(element);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method testBug1564.
@Test
@Ignore
public void testBug1564() {
// NODE processing = true;
m_pollerConfig.setNodeOutageProcessingEnabled(true);
MockNode node = m_network.getNode(2);
MockService icmpService = m_network.getService(2, "192.168.1.3", "ICMP");
MockService smtpService = m_network.getService(2, "192.168.1.3", "SMTP");
MockService snmpService = m_network.getService(2, "192.168.1.3", "SNMP");
// start the poller
startDaemons();
//
// Bring Down the HTTP service and expect nodeLostService Event
//
resetAnticipated();
anticipateDown(snmpService);
// One service works fine
snmpService.bringDown();
verifyAnticipated(10000);
// Now we simulate the restart, the node
// looses all three at the same time
resetAnticipated();
anticipateDown(node);
icmpService.bringDown();
smtpService.bringDown();
snmpService.bringDown();
verifyAnticipated(10000);
anticipateDown(smtpService);
verifyAnticipated(10000);
anticipateDown(snmpService);
verifyAnticipated(10000);
// This is to simulate a restart,
// where I turn off the node behaviour
m_pollerConfig.setNodeOutageProcessingEnabled(false);
anticipateUp(snmpService);
snmpService.bringUp();
verifyAnticipated(10000);
anticipateUp(smtpService);
smtpService.bringUp();
verifyAnticipated(10000);
// Another restart - let's see if this will work?
m_pollerConfig.setNodeOutageProcessingEnabled(true);
// So everything is down, now
// SNMP will regain and SMTP will regain
// will the node come up?
smtpService.bringDown();
anticipateUp(smtpService);
smtpService.bringUp();
verifyAnticipated(10000, true);
anticipateUp(snmpService);
snmpService.bringUp();
verifyAnticipated(10000);
}
use of org.opennms.netmgt.mock.MockService in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT 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());
}
Aggregations