use of org.opennms.netmgt.model.OnmsIpInterface in project opennms by OpenNMS.
the class PollerBackEndIT method testReportResults.
@Test
@Transactional
public void testReportResults() throws InterruptedException {
final OnmsNode node = new OnmsNode(m_monitoringLocationDao.getDefaultLocation(), "foo");
final OnmsIpInterface iface = new OnmsIpInterface(InetAddressUtils.addr("192.168.1.1"), node);
OnmsServiceType serviceType = m_serviceTypeDao.findByName("HTTP");
if (serviceType == null) {
serviceType = new OnmsServiceType("HTTP");
m_serviceTypeDao.save(serviceType);
m_serviceTypeDao.flush();
}
final OnmsMonitoredService service = new OnmsMonitoredService(iface, serviceType);
iface.setMonitoredServices(Collections.singleton(service));
m_nodeDao.save(node);
m_nodeDao.flush();
final String locationMonitorId = m_backEnd.registerLocationMonitor("RDU");
final int serviceId = service.getId();
// make sure there is no rrd data
final File rrdFile = new File("target/test-data/distributed/" + locationMonitorId + "/" + InetAddressUtils.str(iface.getIpAddress()) + "/http" + m_rrdStrategy.getDefaultFileExtension());
if (rrdFile.exists()) {
rrdFile.delete();
}
assertFalse(rrdFile.exists());
m_backEnd.reportResult(locationMonitorId, serviceId, PollStatus.available(1234.0));
Thread.sleep(1000);
m_backEnd.reportResult(locationMonitorId, serviceId, PollStatus.unavailable());
final Collection<OnmsLocationSpecificStatus> statuses = m_locationMonitorDao.getStatusChangesForLocationBetween(new Date(0L), new Date(), "RDU");
assertEquals(2, statuses.size());
final Iterator<OnmsLocationSpecificStatus> statusIterator = statuses.iterator();
final OnmsLocationSpecificStatus status1 = statusIterator.next();
final OnmsLocationSpecificStatus status2 = statusIterator.next();
assertEquals(Double.valueOf(1234D), status1.getPollResult().getResponseTime());
assertNull(status2.getPollResult().getResponseTime());
assertTrue("rrd file doesn't exist at " + rrdFile.getAbsolutePath(), rrdFile.exists());
}
use of org.opennms.netmgt.model.OnmsIpInterface in project opennms by OpenNMS.
the class InterfaceToNodeCacheDaoImplIT method setUp.
@Before
public void setUp() throws Exception {
m_databasePopulator.populateDatabase();
m_cache.dataSourceSync();
OnmsNode n = new OnmsNode(m_databasePopulator.getMonitoringLocationDao().getDefaultLocation(), "my-new-node");
n.setForeignSource("junit");
n.setForeignId("10001");
OnmsIpInterface iface = new OnmsIpInterface(InetAddress.getByName("192.168.1.3"), n);
iface.setIsManaged("M");
iface.setIsSnmpPrimary(PrimaryType.PRIMARY);
OnmsSnmpInterface snmpIf = new OnmsSnmpInterface(n, 1001);
iface.setSnmpInterface(snmpIf);
snmpIf.getIpInterfaces().add(iface);
n.addIpInterface(iface);
m_databasePopulator.getNodeDao().save(n);
m_testNodeId = n.getId();
}
use of org.opennms.netmgt.model.OnmsIpInterface in project opennms by OpenNMS.
the class IpInterfaceDaoHibernateIT method testNMS4822.
@Test
@Transactional
public void testNMS4822() throws Exception {
// Verify that test IP address exists on Node1 as non-primary
OnmsIpInterface ipIntf = m_ipInterfaceDao.findByNodeIdAndIpAddress(m_databasePopulator.getNode1().getId(), m_testAddress.getHostAddress());
assertFalse(ipIntf.isPrimary());
assertFalse(ipIntf.isManaged());
// Verify that test IP address exists on Node2 as primary
ipIntf = m_ipInterfaceDao.findByNodeIdAndIpAddress(m_databasePopulator.getNode2().getId(), m_testAddress.getHostAddress());
assertTrue(ipIntf.isPrimary());
assertTrue(ipIntf.isManaged());
// Get Interfaces For Nodes Map
Map<InetAddress, Integer> map = m_ipInterfaceDao.getInterfacesForNodes();
assertNotNull(map);
// Verify that the test address is associated with Node2 because primary addresses has precedence over non-primary addresses.
assertEquals(Integer.valueOf(m_databasePopulator.getNode2().getId()), map.get(m_testAddress));
}
use of org.opennms.netmgt.model.OnmsIpInterface in project opennms by OpenNMS.
the class OutageDaoIT method insertEntitiesAndOutage.
private OnmsOutage insertEntitiesAndOutage(final String ipAddr, final String serviceName, OnmsNode node) {
OnmsIpInterface ipInterface = getIpInterface(ipAddr, node);
OnmsServiceType serviceType = getServiceType(serviceName);
OnmsMonitoredService monitoredService = getMonitoredService(ipInterface, serviceType);
OnmsEvent event = getEvent();
OnmsOutage outage = getOutage(monitoredService, event);
return outage;
}
use of org.opennms.netmgt.model.OnmsIpInterface in project opennms by OpenNMS.
the class RrdPersistOperationBuilderTest method setUp.
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
m_rrdStrategy = new JRobinRrdStrategy();
m_fileAnticipator = new FileAnticipator();
m_intf = new OnmsIpInterface();
m_node = new OnmsNode();
m_node.setId(1);
m_intf.setNode(m_node);
m_intf.setIpAddress(InetAddressUtils.addr("1.1.1.1"));
m_intf.setId(27);
m_ifDao = EasyMock.createMock(IpInterfaceDao.class);
EasyMock.expect(m_ifDao.load(m_intf.getId())).andReturn(m_intf).anyTimes();
EasyMock.replay(m_ifDao);
}
Aggregations