Search in sources :

Example 1 with PollableNetwork

use of org.opennms.netmgt.poller.pollables.PollableNetwork in project opennms by OpenNMS.

the class PollerRpcTimeoutIT method setUp.

@Before
public void setUp() throws Exception {
    MockUtil.println("------------ Begin Test  --------------------------");
    MockLogAppender.setupLogging();
    m_network = new MockNetwork();
    m_network.setCriticalService("ICMP");
    m_network.addNode(1, "Router");
    m_network.addInterface(str(InetAddressUtils.UNPINGABLE_ADDRESS));
    m_network.addService("ICMP");
    m_network.addService("HTTP");
    m_db.populate(m_network);
    DataSourceFactory.setInstance(m_db);
    // Add a location that no systems are monitoring
    OnmsMonitoringLocation location = new OnmsMonitoringLocation(NONEXISTENT_LOCATION, "Nullsville");
    m_monitoringLocationDao.save(location);
    // Update all of the nodes to have the nonexistent location
    for (OnmsNode node : m_nodeDao.findAll()) {
        node.setLocation(location);
        m_nodeDao.save(node);
    }
    InputStream is = new FileInputStream(new File("src/test/resources/etc/rpctimeout-poller-configuration.xml"));
    PollerConfigFactory factory = new PollerConfigFactory(0, is, "localhost", false);
    PollerConfigFactory.setInstance(factory);
    IOUtils.closeQuietly(is);
    // Sanity check the config
    ServiceMonitor monitor = PollerConfigFactory.getInstance().getServiceMonitor("HTTP");
    Assert.assertNotNull(monitor);
    Package pkg = PollerConfigFactory.getInstance().getPackage("PollerRpcTimeoutIT");
    Assert.assertNotNull(pkg);
    Service svc = pkg.getServices().iterator().next();
    Assert.assertEquals("HTTP", svc.getName());
    DefaultPollContext pollContext = new DefaultPollContext();
    pollContext.setEventManager(m_eventMgr);
    pollContext.setLocalHostName("localhost");
    pollContext.setName("Test.DefaultPollContext");
    pollContext.setPollerConfig(factory);
    pollContext.setQueryManager(m_queryManager);
    pollContext.setLocationAwarePingClient(m_locationAwarePingClient);
    PollableNetwork network = new PollableNetwork(pollContext);
    m_poller = new Poller();
    m_poller.setMonitoredServiceDao(m_monitoredServiceDao);
    m_poller.setOutageDao(m_outageDao);
    m_poller.setTransactionTemplate(m_transactionTemplate);
    m_poller.setEventIpcManager(m_eventMgr);
    m_poller.setNetwork(network);
    m_poller.setQueryManager(m_queryManager);
    m_poller.setPollerConfig(factory);
    m_poller.setPollOutagesConfig(m_pollOutagesConfig);
    m_poller.setLocationAwarePollerClient(m_locationAwarePollerClient);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Service(org.opennms.netmgt.config.poller.Service) FileInputStream(java.io.FileInputStream) PollerConfigFactory(org.opennms.netmgt.config.PollerConfigFactory) MockNetwork(org.opennms.netmgt.mock.MockNetwork) Package(org.opennms.netmgt.config.poller.Package) File(java.io.File) PollableNetwork(org.opennms.netmgt.poller.pollables.PollableNetwork) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Before(org.junit.Before)

Example 2 with PollableNetwork

use of org.opennms.netmgt.poller.pollables.PollableNetwork in project opennms by OpenNMS.

the class PollerQueryManagerDaoIT method setUp.

// 
// SetUp and TearDown
// 
@Before
public void setUp() throws Exception {
    MockUtil.println("------------ Begin Test  --------------------------");
    MockLogAppender.setupLogging();
    m_network = new MockNetwork();
    m_network.setCriticalService("ICMP");
    m_network.addNode(1, "Router");
    m_network.addInterface("192.168.1.1");
    m_network.addService("ICMP");
    m_network.addService("SMTP");
    m_network.addService("SNMP");
    m_network.addInterface("192.168.1.2");
    m_network.addService("ICMP");
    m_network.addService("SMTP");
    m_network.addNode(2, "Server");
    m_network.addInterface("192.168.1.3");
    m_network.addService("ICMP");
    m_network.addService("HTTP");
    m_network.addService("SMTP");
    m_network.addService("SNMP");
    m_network.addNode(3, "Firewall");
    m_network.addInterface("192.168.1.4");
    m_network.addService("SMTP");
    m_network.addService("HTTP");
    m_network.addInterface("192.168.1.5");
    m_network.addService("SMTP");
    m_network.addService("HTTP");
    m_network.addNode(4, "DownNode");
    m_network.addInterface("192.168.1.6");
    m_network.addService("SNMP");
    // m_network.addInterface("fe80:0000:0000:0000:0231:f982:0123:4567");
    // m_network.addService("SNMP");
    m_db.populate(m_network);
    DataSourceFactory.setInstance(m_db);
    // DemandPollDao demandPollDao = new DemandPollDaoHibernate(m_db);
    // demandPollDao.setAllocateIdStmt(m_db
    // .getNextSequenceValStatement("demandPollNxtId"));
    // m_demandPollDao = demandPollDao;
    m_pollerConfig = new MockPollerConfig(m_network);
    m_pollerConfig.setNextOutageIdSql(m_db.getNextOutageIdStatement());
    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    m_pollerConfig.setCriticalService("ICMP");
    m_pollerConfig.addPackage("TestPackage");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(1000L);
    m_pollerConfig.populatePackage(m_network);
    m_pollerConfig.addPackage("TestPkg2");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(2000L);
    m_pollerConfig.addService(m_network.getService(2, "192.168.1.3", "HTTP"));
    m_outageAnticipator = new OutageAnticipator(m_db);
    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setEventWriter(m_db);
    m_eventMgr.addEventListener(m_outageAnticipator);
    m_eventMgr.setSynchronous(false);
    m_locationAwarePingClient = mock(LocationAwarePingClient.class);
    DefaultPollContext pollContext = new DefaultPollContext();
    pollContext.setEventManager(m_eventMgr);
    pollContext.setLocalHostName("localhost");
    pollContext.setName("Test.DefaultPollContext");
    pollContext.setPollerConfig(m_pollerConfig);
    pollContext.setQueryManager(m_queryManager);
    pollContext.setLocationAwarePingClient(m_locationAwarePingClient);
    PollableNetwork network = new PollableNetwork(pollContext);
    m_poller = new Poller();
    m_poller.setMonitoredServiceDao(m_monitoredServiceDao);
    m_poller.setTransactionTemplate(m_transactionTemplate);
    m_poller.setEventIpcManager(m_eventMgr);
    m_poller.setNetwork(network);
    m_poller.setQueryManager(m_queryManager);
    m_poller.setPollerConfig(m_pollerConfig);
    m_poller.setPollOutagesConfig(m_pollerConfig);
    m_poller.setLocationAwarePollerClient(m_locationAwarePollerClient);
}
Also used : LocationAwarePingClient(org.opennms.netmgt.icmp.proxy.LocationAwarePingClient) MockNetwork(org.opennms.netmgt.mock.MockNetwork) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) OutageAnticipator(org.opennms.netmgt.mock.OutageAnticipator) MockPollerConfig(org.opennms.netmgt.mock.MockPollerConfig) PollableNetwork(org.opennms.netmgt.poller.pollables.PollableNetwork) Before(org.junit.Before)

Example 3 with PollableNetwork

use of org.opennms.netmgt.poller.pollables.PollableNetwork in project opennms by OpenNMS.

the class PollContextIT method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    m_mNetwork = new MockNetwork();
    m_mNetwork.addNode(1, "Router");
    m_mNetwork.addInterface("192.168.1.1");
    m_mNetwork.addService("ICMP");
    m_mNetwork.addService("SMTP");
    m_mNetwork.addInterface("192.168.1.2");
    m_mNetwork.addService("ICMP");
    m_mNetwork.addService("SMTP");
    m_mNetwork.addNode(2, "Server");
    m_mNetwork.addInterface("192.168.1.3");
    m_mNetwork.addService("ICMP");
    m_mNetwork.addService("HTTP");
    m_mNetwork.addNode(3, "Firewall");
    m_mNetwork.addInterface("192.168.1.4");
    m_mNetwork.addService("SMTP");
    m_mNetwork.addService("HTTP");
    m_mNetwork.addInterface("192.168.1.5");
    m_mNetwork.addService("SMTP");
    m_mNetwork.addService("HTTP");
    m_mSvc = m_mNetwork.getService(1, "192.168.1.1", "ICMP");
    m_db.populate(m_mNetwork);
    m_pollerConfig = new MockPollerConfig(m_mNetwork);
    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    m_pollerConfig.setCriticalService("ICMP");
    m_pollerConfig.addPackage("TestPackage");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(1000L);
    m_pollerConfig.populatePackage(m_mNetwork);
    m_pollerConfig.addPackage("TestPkg2");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(2000L);
    m_pollerConfig.addService(m_mNetwork.getService(2, "192.168.1.3", "HTTP"));
    m_pollerConfig.setNextOutageIdSql(m_db.getNextOutageIdStatement());
    m_outageAnticipator = new OutageAnticipator(m_db);
    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setEventWriter(m_db);
    m_eventMgr.addEventListener(m_outageAnticipator);
    m_locationAwarePingClient = mock(LocationAwarePingClient.class);
    m_pollContext = new DefaultPollContext();
    m_pollContext.setEventManager(m_eventMgr);
    m_pollContext.setLocalHostName("localhost");
    m_pollContext.setName("PollContextTest.DefaultPollContext");
    m_pollContext.setPollerConfig(m_pollerConfig);
    m_pollContext.setQueryManager(m_queryManager);
    m_pollContext.setLocationAwarePingClient(m_locationAwarePingClient);
    m_pNetwork = new PollableNetwork(m_pollContext);
    m_pSvc = m_pNetwork.createService(1, "Router", null, InetAddressUtils.addr("192.168.1.1"), "ICMP");
}
Also used : LocationAwarePingClient(org.opennms.netmgt.icmp.proxy.LocationAwarePingClient) MockNetwork(org.opennms.netmgt.mock.MockNetwork) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) OutageAnticipator(org.opennms.netmgt.mock.OutageAnticipator) MockPollerConfig(org.opennms.netmgt.mock.MockPollerConfig) PollableNetwork(org.opennms.netmgt.poller.pollables.PollableNetwork) Before(org.junit.Before)

Example 4 with PollableNetwork

use of org.opennms.netmgt.poller.pollables.PollableNetwork in project opennms by OpenNMS.

the class PollerIT method setUp.

// 
// SetUp and TearDown
// 
@Before
public void setUp() throws Exception {
    MockUtil.println("------------ Begin Test  --------------------------");
    MockLogAppender.setupLogging();
    m_network = new MockNetwork();
    m_network.setCriticalService("ICMP");
    m_network.addNode(1, "Router");
    m_network.addInterface("192.168.1.1");
    m_network.addService("ICMP");
    m_network.addService("SMTP");
    m_network.addService("SNMP");
    m_network.addInterface("192.168.1.2");
    m_network.addService("ICMP");
    m_network.addService("SMTP");
    m_network.addNode(2, "Server");
    m_network.addInterface("192.168.1.3");
    m_network.addService("ICMP");
    m_network.addService("HTTP");
    m_network.addService("SMTP");
    m_network.addService("SNMP");
    m_network.addNode(3, "Firewall");
    m_network.addInterface("192.168.1.4");
    m_network.addService("SMTP");
    m_network.addService("HTTP");
    m_network.addInterface("192.168.1.5");
    m_network.addService("SMTP");
    m_network.addService("HTTP");
    m_network.addNode(4, "DownNode");
    m_network.addInterface("192.168.1.6");
    m_network.addService("SNMP");
    m_network.addNode(5, "Loner");
    m_network.addInterface("192.168.1.7");
    m_network.addService("ICMP");
    m_network.addService("SNMP");
    MockService unmonitoredService = m_network.addService("NotMonitored");
    m_db.populate(m_network);
    DataSourceFactory.setInstance(m_db);
    m_pollerConfig = new MockPollerConfig(m_network);
    m_pollerConfig.setNextOutageIdSql(m_db.getNextOutageIdStatement());
    m_pollerConfig.setNodeOutageProcessingEnabled(true);
    m_pollerConfig.setCriticalService("ICMP");
    m_pollerConfig.addPackage("TestPackage");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(1000L);
    m_pollerConfig.populatePackage(m_network, unmonitoredService);
    m_pollerConfig.addPackage("TestPkg2");
    m_pollerConfig.addDowntime(1000L, 0L, -1L, false);
    m_pollerConfig.setDefaultPollInterval(2000L);
    m_pollerConfig.addService(m_network.getService(2, "192.168.1.3", "HTTP"));
    m_outageAnticipator = new OutageAnticipator(m_db);
    m_eventMgr = new MockEventIpcManager();
    m_eventMgr.setEventWriter(m_db);
    m_eventMgr.setEventAnticipator(m_eventMgr.getEventAnticipator());
    m_eventMgr.addEventListener(m_outageAnticipator);
    m_eventMgr.setSynchronous(false);
    m_eventMgr.setNumSchedulerThreads(2);
    m_locationAwarePingClient = mock(LocationAwarePingClient.class);
    DefaultPollContext pollContext = new DefaultPollContext();
    pollContext.setEventManager(m_eventMgr);
    pollContext.setLocalHostName("localhost");
    pollContext.setName("Test.DefaultPollContext");
    pollContext.setPollerConfig(m_pollerConfig);
    pollContext.setQueryManager(m_queryManager);
    pollContext.setLocationAwarePingClient(m_locationAwarePingClient);
    PollableNetwork network = new PollableNetwork(pollContext);
    m_poller = new Poller();
    m_poller.setMonitoredServiceDao(m_monitoredServiceDao);
    m_poller.setOutageDao(m_outageDao);
    m_poller.setTransactionTemplate(m_transactionTemplate);
    m_poller.setEventIpcManager(m_eventMgr);
    m_poller.setNetwork(network);
    m_poller.setQueryManager(m_queryManager);
    m_poller.setPollerConfig(m_pollerConfig);
    m_poller.setPollOutagesConfig(m_pollerConfig);
    m_poller.setLocationAwarePollerClient(m_locationAwarePollerClient);
}
Also used : LocationAwarePingClient(org.opennms.netmgt.icmp.proxy.LocationAwarePingClient) MockNetwork(org.opennms.netmgt.mock.MockNetwork) MockEventIpcManager(org.opennms.netmgt.dao.mock.MockEventIpcManager) MockService(org.opennms.netmgt.mock.MockService) OutageAnticipator(org.opennms.netmgt.mock.OutageAnticipator) MockPollerConfig(org.opennms.netmgt.mock.MockPollerConfig) PollableNetwork(org.opennms.netmgt.poller.pollables.PollableNetwork) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)4 MockNetwork (org.opennms.netmgt.mock.MockNetwork)4 PollableNetwork (org.opennms.netmgt.poller.pollables.PollableNetwork)4 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)3 LocationAwarePingClient (org.opennms.netmgt.icmp.proxy.LocationAwarePingClient)3 MockPollerConfig (org.opennms.netmgt.mock.MockPollerConfig)3 OutageAnticipator (org.opennms.netmgt.mock.OutageAnticipator)3 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 PollerConfigFactory (org.opennms.netmgt.config.PollerConfigFactory)1 Package (org.opennms.netmgt.config.poller.Package)1 Service (org.opennms.netmgt.config.poller.Service)1 MockService (org.opennms.netmgt.mock.MockService)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)1