private OnmsIpInterface createIpInterface(OnmsSnmpInterface snmp, InetAddress inetAddress) { OnmsIpInterface ip = new OnmsIpInterface(); ip.setSnmpInterface(snmp); ip.setIpLastCapsdPoll(new Date()); ip.setNode(snmp.getNode()); ip.setIpAddress(inetAddress); return ip; }
@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); }
iface.setId(42); iface.setNode(node); iface.setIpAddress(InetAddressUtils.ONE_TWENTY_SEVEN);
protected void createAgent(int ifIndex, PrimaryType ifCollType) { m_node = new OnmsNode(); m_node.setSysObjectId(".1.2.3.4.5.6.7"); OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(m_node, ifIndex); m_iface = new OnmsIpInterface(); m_iface.setId(123); m_iface.setIpAddress(myLocalHost()); m_iface.setIsSnmpPrimary(ifCollType); m_iface.setSnmpInterface(snmpIface); m_node.addIpInterface(m_iface); EasyMock.expect(m_ifaceDao.load(m_iface.getId())).andReturn(m_iface).anyTimes(); m_easyMockUtils.replayAll(); m_agent = DefaultSnmpCollectionAgent.create(m_iface.getId(), m_ifaceDao, new MockPlatformTransactionManager()); }
iface1_1.setIpAddress(InetAddress.getByName("172.16.0.1")); iface1_1.setIsSnmpPrimary(PrimaryType.PRIMARY); iface1_2.setIpAddress(InetAddress.getByName("172.17.0.1")); iface1_2.setIsSnmpPrimary(PrimaryType.SECONDARY); iface1_3.setIpAddress(InetAddress.getByName("192.168.0.10")); iface1_3.setIsSnmpPrimary(PrimaryType.NOT_ELIGIBLE);
@Before public void setUp() throws Exception { MockUtil.println("------------ Begin Test " + m_testName.getMethodName() + " --------------------------"); MockLogAppender.setupLogging(); m_fileAnticipator = new FileAnticipator(); m_rrdStrategy = new JRobinRrdStrategy(); m_resourceStorageDao = new FilesystemResourceStorageDao(); m_resourceStorageDao.setRrdDirectory(m_fileAnticipator.getTempDir()); m_intf = new OnmsIpInterface(); m_node = new OnmsNode(); m_node.setId(1); m_intf.setId(25); m_intf.setNode(m_node); m_intf.setIpAddress(InetAddressUtils.addr("1.1.1.1")); m_ifDao = m_easyMockUtils.createMock(IpInterfaceDao.class); m_serviceParams = new ServiceParameters(new HashMap<String,Object>()); }
ipInterface.setId(1); ipInterface.setNode(node); ipInterface.setIpAddress(InetAddressUtils.addr("192.168.1.1"));
iface1_1.setIpAddress(InetAddress.getByName("172.16.0.1")); iface1_1.setIsSnmpPrimary(PrimaryType.PRIMARY); iface1_2.setIpAddress(InetAddress.getByName("172.17.0.1")); iface1_2.setIsSnmpPrimary(PrimaryType.SECONDARY); iface1_3.setIpAddress(InetAddress.getByName("192.168.0.10")); iface1_3.setIsSnmpPrimary(PrimaryType.NOT_ELIGIBLE); iface2_1.setIpAddress(InetAddress.getByName("172.16.0.1")); iface2_1.setIsSnmpPrimary(PrimaryType.PRIMARY); iface2_2.setIpAddress(InetAddress.getByName("172.17.0.1")); iface2_2.setIsSnmpPrimary(PrimaryType.SECONDARY); iface2_3.setIpAddress(InetAddress.getByName("192.168.0.20")); iface2_3.setIsSnmpPrimary(PrimaryType.NOT_ELIGIBLE);
@Test public void canHandleInterfaceDeletedEvents() { // Handle a interfaceDeleted event targeting svc1 OnmsNode node = new OnmsNode(); node.setId(svc1.getNodeId()); OnmsIpInterface iface = new OnmsIpInterface(); iface.setId(99); iface.setNode(node); iface.setIpAddress(svc1.getAddress()); Event e = new EventBuilder(EventConstants.INTERFACE_DELETED_EVENT_UEI, "test") .setIpInterface(iface) .getEvent(); collectd.onEvent(e); // The delete flag should be set (and only set) on svc1 assertTrue("deletion flag was not set on svc1!", svc1.getCollectorUpdates().isDeletionFlagSet()); assertFalse("deletion flag was set on svc2!", svc2.getCollectorUpdates().isDeletionFlagSet()); }
@Test public void canHandleServiceDeletedEvents() { // Handle a serviceDeleted event targeting svc2 OnmsNode node = new OnmsNode(); node.setId(svc2.getNodeId()); OnmsIpInterface iface = new OnmsIpInterface(); iface.setId(101); iface.setNode(node); iface.setIpAddress(svc2.getAddress()); Event e = new EventBuilder(EventConstants.SERVICE_DELETED_EVENT_UEI, "test") .setIpInterface(iface) .setService(svc2.getServiceName()) .getEvent(); collectd.onEvent(e); // The delete flag should be set (and only set) on svc2 assertFalse("deletion flag was set on svc1!", svc1.getCollectorUpdates().isDeletionFlagSet()); assertTrue("deletion flag was not set on svc2!", svc2.getCollectorUpdates().isDeletionFlagSet()); } }