use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class PollerBackEndTest method testStatusChangeFromDownToUp.
public void testStatusChangeFromDownToUp() {
expect(m_locMonDao.get(LOCATION_MONITOR_ID)).andReturn(m_locationMonitor);
expect(m_monSvcDao.get(2)).andReturn(m_dnsService);
expect(m_locMonDao.getMostRecentStatusChange(m_locationMonitor, m_dnsService)).andReturn(m_dnsCurrentStatus);
// called when saving performance data
expect(m_monitoringLocationDao.get(m_locationDefinition.getLocationName())).andReturn(m_locationDefinition);
expect(m_pollerConfig.getPackage(m_package.getName())).andReturn(m_package);
expect(m_pollerConfig.getServiceInPackage("DNS", m_package)).andReturn(m_dnsSvcConfig).times(3);
expect(m_pollerConfig.parameters(m_dnsSvcConfig)).andReturn(m_dnsSvcConfig.getParameters()).times(6);
final PollStatus newStatus = PollStatus.available(1234.0);
OnmsLocationSpecificStatus expectedStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_dnsService, newStatus);
// TODO: make anticipate method
EventBuilder eventBuilder = new EventBuilder(EventConstants.REMOTE_NODE_REGAINED_SERVICE_UEI, "PollerBackEnd").setMonitoredService(m_dnsService).addParam(EventConstants.PARM_LOCATION_MONITOR_ID, LOCATION_MONITOR_ID);
m_eventIpcManager.getEventAnticipator().anticipateEvent(eventBuilder.getEvent());
m_locMonDao.saveStatusChange(isA(OnmsLocationSpecificStatus.class));
expectLastCall().andAnswer(new StatusChecker(expectedStatus));
m_mocks.replayAll();
m_backEnd.saveResponseTimeData(m_locationMonitor.getId(), m_dnsService, 1234, m_package);
m_backEnd.reportResult(LOCATION_MONITOR_ID, 2, newStatus);
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class PollerBackEndTest method testStatusChangeFromUpToDown.
// reportResult test variations
// what if we cant' find the locationMonitor with that ID
// what if we can't find the service with that ID
// what if we can't find a current status
// do I send events for status changed
public void testStatusChangeFromUpToDown() {
expect(m_locMonDao.get(LOCATION_MONITOR_ID)).andReturn(m_locationMonitor);
expect(m_monSvcDao.get(1)).andReturn(m_httpService);
expect(m_locMonDao.getMostRecentStatusChange(m_locationMonitor, m_httpService)).andReturn(m_httpCurrentStatus);
// TODO: make anticipate method
EventBuilder eventBuilder = new EventBuilder(EventConstants.REMOTE_NODE_LOST_SERVICE_UEI, "PollerBackEnd").setMonitoredService(m_httpService).addParam(EventConstants.PARM_LOCATION_MONITOR_ID, LOCATION_MONITOR_ID);
m_eventIpcManager.getEventAnticipator().anticipateEvent(eventBuilder.getEvent());
final PollStatus newStatus = PollStatus.unavailable("Test Down");
OnmsLocationSpecificStatus expectedStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_httpService, newStatus);
m_locMonDao.saveStatusChange(isA(OnmsLocationSpecificStatus.class));
expectLastCall().andAnswer(new StatusChecker(expectedStatus));
m_mocks.replayAll();
m_backEnd.reportResult(LOCATION_MONITOR_ID, 1, newStatus);
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class PollerBackEndTest method testStatusDownWhenNoneKnown.
public void testStatusDownWhenNoneKnown() {
expect(m_locMonDao.get(LOCATION_MONITOR_ID)).andReturn(m_locationMonitor);
expect(m_monSvcDao.get(2)).andReturn(m_dnsService);
expect(m_locMonDao.getMostRecentStatusChange(m_locationMonitor, m_dnsService)).andReturn(null);
final PollStatus newStatus = PollStatus.unavailable("where'd he go?");
OnmsLocationSpecificStatus expectedStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_dnsService, newStatus);
m_locMonDao.saveStatusChange(isA(OnmsLocationSpecificStatus.class));
expectLastCall().andAnswer(new StatusChecker(expectedStatus));
// expect a status change if the node is now down and we didn't know before
EventBuilder eventBuilder = new EventBuilder(EventConstants.REMOTE_NODE_LOST_SERVICE_UEI, "PollerBackEnd").setMonitoredService(m_dnsService).addParam(EventConstants.PARM_LOCATION_MONITOR_ID, LOCATION_MONITOR_ID);
m_eventIpcManager.getEventAnticipator().anticipateEvent(eventBuilder.getEvent());
m_mocks.replayAll();
m_backEnd.reportResult(LOCATION_MONITOR_ID, 2, newStatus);
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class PassiveServiceMonitorIT method testPoll.
// inherit from PassiveStatusKeeperTest so we can inherit all the proper initialization
public void testPoll() throws UnknownHostException {
PassiveStatusKeeper psk = PassiveStatusKeeper.getInstance();
psk.setStatus("localhost", "127.0.0.1", "my-passive-service", PollStatus.get(PollStatus.SERVICE_UNAVAILABLE, "testing failure"));
ServiceMonitor sm = new PassiveServiceMonitor();
MonitoredService ms = createMonitoredService(1, "localhost", null, "127.0.0.1", "my-passive-service");
PollStatus ps = sm.poll(ms, new HashMap<String, Object>());
assertEquals(PollStatus.down("fail."), ps);
psk.setStatus("localhost", "127.0.0.1", "my-passive-service", PollStatus.get(PollStatus.SERVICE_AVAILABLE, "testing failure"));
ps = sm.poll(ms, new HashMap<String, Object>());
assertEquals(PollStatus.up(), ps);
}
use of org.opennms.netmgt.poller.PollStatus in project opennms by OpenNMS.
the class HostResourceSWRunMonitorTest method testInvalidRange.
@Test
public void testInvalidRange() throws Exception {
// warning is expected here, skip the assert in tearDown()
m_ignoreWarnings = true;
Map<String, Object> parameters = createBasicParams();
parameters.put("min-services", "8");
parameters.put("max-services", "5");
PollStatus status = monitor.poll(createMonitor(), parameters);
Assert.assertFalse(status.isAvailable());
log(status.getReason());
}
Aggregations