use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class PollerIT 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.MockNode in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method testBug709.
@Test
public void testBug709() {
m_pollerConfig.setNodeOutageProcessingEnabled(true);
MockNode node = m_network.getNode(2);
MockService icmpService = m_network.getService(2, "192.168.1.3", "ICMP");
MockService httpService = m_network.getService(2, "192.168.1.3", "HTTP");
// start the poller
startDaemons();
//
// Bring Down the HTTP service and expect nodeLostService Event
//
resetAnticipated();
anticipateDown(httpService);
// bring down the HTTP service
httpService.bringDown();
verifyAnticipated(10000);
//
// Bring Down the ICMP (on the only interface on the node) now expect
// nodeDown
// only.
//
resetAnticipated();
anticipateDown(node);
// bring down the ICMP service
icmpService.bringDown();
// make sure the down events are received
// verifyAnticipated(10000);
sleep(5000);
//
// Bring up both the node and the httpService at the same time. Expect
// both a nodeUp and a nodeRegainedService
//
resetAnticipated();
// the order matters here
anticipateUp(httpService);
anticipateUp(node);
// bring up all the services on the node
node.bringUp();
// make sure the down events are received
verifyAnticipated(10000);
}
use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method testSendNodeGainedServices.
private void testSendNodeGainedServices(int nodeid, String nodeLabel, String ipAddr, String... svcNames) {
assertNotNull(svcNames);
assertTrue(svcNames.length > 0);
MockNode node = m_network.addNode(nodeid, nodeLabel);
m_db.writeNode(node);
MockInterface iface = m_network.addInterface(nodeid, ipAddr);
m_db.writeInterface(iface);
List<MockService> services = new ArrayList<>();
for (String svcName : svcNames) {
MockService svc = m_network.addService(nodeid, ipAddr, svcName);
m_db.writeService(svc);
m_pollerConfig.addService(svc);
services.add(svc);
}
MockVisitor gainSvcSender = new MockVisitorAdapter() {
@Override
public void visitService(MockService svc) {
Event event = MockEventUtil.createNodeGainedServiceEvent("Test", svc);
m_eventMgr.sendEventToListeners(event);
}
};
node.visit(gainSvcSender);
MockService svc1 = services.get(0);
PollAnticipator anticipator = new PollAnticipator();
svc1.addAnticipator(anticipator);
anticipator.anticipateAllServices(svc1);
final StringBuilder didNotOccur = new StringBuilder();
for (MockService service : anticipator.waitForAnticipated(10000)) {
didNotOccur.append(service.toString());
}
final StringBuilder unanticipatedStuff = new StringBuilder();
for (MockService service : anticipator.unanticipatedPolls()) {
unanticipatedStuff.append(service.toString());
}
assertEquals(unanticipatedStuff.toString(), "", didNotOccur.toString());
anticipateDown(svc1);
svc1.bringDown();
verifyAnticipated(10000);
}
use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class PollerQueryManagerDaoIT method testNullInterfaceOnNodeDown.
// public void testDemandPollService() {
// DemandPoll demandPoll = new DemandPoll();
// demandPoll.setDescription("Test Poll");
// demandPoll.setRequestTime(new Date());
// demandPoll.setUserName("admin");
//
// m_demandPollDao.save(demandPoll);
//
// assertNotNull(demandPoll.getId());
//
// MockService httpService = m_network
// .getService(2, "192.168.1.3", "HTTP");
// Event demandPollEvent = httpService.createDemandPollEvent(demandPoll.getId());
//
// }
@Test
public void testNullInterfaceOnNodeDown() {
// 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();
anticipateDown(node);
icmpService.bringDown();
smtpService.bringDown();
snmpService.bringDown();
verifyAnticipated(10000);
// node is down at this point
boolean foundNodeDown = false;
for (final Event event : m_eventMgr.getEventAnticipator().getAnticipatedEventsReceived()) {
if (EventConstants.NODE_DOWN_EVENT_UEI.equals(event.getUei())) {
foundNodeDown = true;
assertNull(event.getInterfaceAddress());
}
}
assertTrue(foundNodeDown);
}
use of org.opennms.netmgt.mock.MockNode in project opennms by OpenNMS.
the class ProvisionerIT method testSendEventsOnImport.
@Test(timeout = 300000)
public void testSendEventsOnImport() throws Exception {
final int nextNodeId = m_nodeDao.getNextNodeId();
final String nodeLabel = "node1";
final MockNetwork network = new MockNetwork();
final MockNode node = network.addNode(nextNodeId, nodeLabel);
network.addInterface("192.0.2.204");
network.addService("ICMP");
network.addService("HTTP");
network.addInterface("192.0.2.201");
network.addService("ICMP");
network.addService("SNMP");
anticipateCreationEvents(node);
m_eventAnticipator.anticipateEvent(getNodeCategoryEvent(nextNodeId, nodeLabel));
for (final Event e : m_eventAnticipator.getAnticipatedEvents()) {
System.err.println("anticipated: " + e);
}
importFromResource("classpath:/tec_dump.xml", Boolean.TRUE.toString());
for (final Event e : m_eventAnticipator.getAnticipatedEventsReceived()) {
System.err.println("received anticipated: " + e);
}
for (final Event e : m_eventAnticipator.getUnanticipatedEvents()) {
System.err.println("received unanticipated: " + e);
}
m_eventAnticipator.verifyAnticipated();
}
Aggregations