use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class AvailabilityCalculatorIT method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
// Reset the FilterDaoFactory so we don't get screwed by having the JdbcFilterDao be connected to an older database
FilterDaoFactory.setInstance(null);
Locale.setDefault(Locale.US);
m_calendar = new GregorianCalendar();
// date for report run is 18th May 2005
m_calendar.set(2005, Calendar.MAY, 18);
MockLogAppender.setupLogging();
m_categories = new Categories();
m_db = new MockDatabase();
DataSourceFactory.setInstance(m_db);
InputStream is = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(is));
is.close();
m_catFactory = new MockCategoryFactory();
CategoryFactory.setInstance(m_catFactory);
m_db.update("insert into node (location, nodeID, nodelabel, nodeCreateTime, nodeType) values ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 1,'test1.availability.opennms.org','2004-03-01 09:00:00','A')");
m_db.update("insert into node (location, nodeID, nodelabel, nodeCreateTime, nodeType) values ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 2,'test2.availability.opennms.org','2004-03-01 09:00:00','A')");
m_db.update("insert into service (serviceid, servicename) values\n" + "(1, 'ICMP');");
m_db.update("insert into service (serviceid, servicename) values\n" + "(2, 'HTTP');");
m_db.update("insert into service (serviceid, servicename) values\n" + "(3, 'SNMP');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(1, 1,'192.168.100.1','M');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(2, 2,'192.168.100.2','M');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(3, 2,'192.168.100.3','M');");
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + // 1:192.168.100.1:1
"(1, 1,'A', 1);");
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + // 2:192.168.100.2:1
"(2, 1,'A', 2);");
/*
* m_db.update("insert into ifservices (serviceid, status, ipInterfaceId) values " + "(2,'A', 2);"); //2:192.168.100.2:2
*/
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + // 2:192.168.100.3:1
"(3, 1,'A', 3);");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(1,1,'2005-05-01 09:00:00','2005-05-01 09:30:00');");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(2,2,'2005-05-01 10:00:00','2005-05-02 10:00:00');");
// test data for LastMonthsDailyAvailability report
// insert 30 minute outage on one node - 99.3056% availability
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(3,1,'2005-04-02 10:00:00','2005-04-02 10:30:00');");
// insert 60 minute outage on one interface and 59 minute outages on
// another - 97.2454
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(4,1,'2005-04-03 11:30:00','2005-04-03 12:30:00');");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(5,2,'2005-04-03 23:00:00','2005-04-03 23:59:00');");
// test an outage that spans 60 minutes across midnight - 99.3056% on
// each day, well, not exactly
// its 29 minutes 99.3059 on the fist day and 31 minutes 99.3052 on
// the second.
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(6,3,'2005-04-04 23:30:00','2005-04-05 00:30:00');");
}
use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class AvailabilityReportIT method setUp.
@Override
protected void setUp() throws Exception {
System.err.println("------------------- begin " + getName() + " ---------------------");
// Reset the FilterDaoFactory so we don't get screwed by having the JdbcFilterDao be connected to an older database
FilterDaoFactory.setInstance(null);
super.setUp();
Locale.setDefault(Locale.US);
calendar = new GregorianCalendar();
// date for report run is 18th May 2005
calendar.set(2005, 4, 18);
MockLogAppender.setupLogging();
m_categories = new Categories();
m_db = new MockDatabase();
DataSourceFactory.setInstance(m_db);
InputStream is = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(is));
is.close();
m_catFactory = new MockCategoryFactory();
CategoryFactory.setInstance(m_catFactory);
m_db.update("insert into node (location, nodeID, nodelabel, nodeCreateTime, nodeType) values ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 1,'test1.availability.opennms.org','2004-03-01 09:00:00','A')");
m_db.update("insert into node (location, nodeID, nodelabel, nodeCreateTime, nodeType) values ('" + MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID + "', 2,'test2.availability.opennms.org','2004-03-01 09:00:00','A')");
m_db.update("insert into service (serviceid, servicename) values\n" + "(1, 'ICMP');");
m_db.update("insert into service (serviceid, servicename) values\n" + "(2, 'HTTP');");
m_db.update("insert into service (serviceid, servicename) values\n" + "(3, 'SNMP');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(1, 1,'192.168.100.1','M');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(2, 2,'192.168.100.2','M');");
m_db.update("insert into ipinterface (id, nodeid, ipaddr, ismanaged) values\n" + "(3, 2,'192.168.100.3','M');");
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + // 1:192.168.100.1:1
"(1,1,'A',1);");
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + // 2:192.168.100.2:1
"(2,1,'A',2);");
/*
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " +
"(3,2,'A',2);"); // 2:192.168.100.2:2
*/
m_db.update("insert into ifservices (id, serviceid, status, ipInterfaceId) values " + // 2:192.168.100.3:1
"(4,1,'A',3);");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(1,1,'2005-05-01 09:00:00','2005-05-01 09:30:00');");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(2,2,'2005-05-01 10:00:00','2005-05-02 10:00:00');");
// test data for LastMonthsDailyAvailability report
// insert 30 minute outage on one node - 99.3056% availability
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(3,1,'2005-04-02 10:00:00','2005-04-02 10:30:00');");
// insert 60 minute outage on one interface and 59 minute outages on another - 97.2454
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(4,1,'2005-04-03 11:30:00','2005-04-03 12:30:00');");
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(5,2,'2005-04-03 23:00:00','2005-04-03 23:59:00');");
// test an outage that spans 60 minutes across midnight - 99.3056% on each day, well, not exactly
// its 29 minutes 99.3059 on the fist day and 31 minutes 99.3052 on the second.
m_db.update("insert into outages (outageid, ifServiceId, ifLostService, ifRegainedService) values " + "(6,4,'2005-04-04 23:30:00','2005-04-05 00:30:00');");
}
use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class PollablesIT method setUp.
@Before
public void setUp() throws Exception {
DaoTestConfigBean bean = new DaoTestConfigBean();
bean.afterPropertiesSet();
MockUtil.println("------------ Begin Test --------------------------");
MockLogAppender.setupLogging();
m_mockNetwork = new MockNetwork();
m_mockNetwork.addNode(1, "Router");
m_mockNetwork.addInterface("192.168.1.1");
m_mockNetwork.addService("ICMP");
m_mockNetwork.addService("SMTP");
m_mockNetwork.addInterface("192.168.1.2");
m_mockNetwork.addService("ICMP");
m_mockNetwork.addService("SMTP");
m_mockNetwork.addNode(2, "Server");
m_mockNetwork.addInterface("192.168.1.3");
m_mockNetwork.addService("ICMP");
m_mockNetwork.addService("HTTP");
m_mockNetwork.addNode(3, "Firewall");
m_mockNetwork.addInterface("192.168.1.4");
m_mockNetwork.addService("SMTP");
m_mockNetwork.addService("HTTP");
m_mockNetwork.addInterface("192.168.1.5");
m_mockNetwork.addService("SMTP");
m_mockNetwork.addService("SNMP");
m_db = new MockDatabase();
m_db.populate(m_mockNetwork);
m_outageAnticipator = new OutageAnticipator(m_db);
m_eventMgr = new MockEventIpcManager();
m_eventMgr.setEventWriter(m_db);
m_eventMgr.addEventListener(m_outageAnticipator);
m_pollContext = new MockPollContext();
m_pollContext.setDatabase(m_db);
m_pollContext.setCriticalServiceName("ICMP");
m_pollContext.setNodeProcessingEnabled(true);
m_pollContext.setPollingAllIfCritServiceUndefined(true);
m_pollContext.setServiceUnresponsiveEnabled(true);
m_pollContext.setEventMgr(m_eventMgr);
m_pollContext.setMockNetwork(m_mockNetwork);
m_pollerConfig = new MockPollerConfig(m_mockNetwork);
m_pollerConfig.setNodeOutageProcessingEnabled(true);
m_pollerConfig.setCriticalService("ICMP");
m_pollerConfig.addPackage("TestPackage");
m_pollerConfig.addDowntime(100L, 0L, 500L, false);
m_pollerConfig.addDowntime(200L, 500L, 1500L, false);
m_pollerConfig.addDowntime(500L, 1500L, -1L, true);
m_pollerConfig.setDefaultPollInterval(1000L);
m_pollerConfig.populatePackage(m_mockNetwork);
m_pollerConfig.addPackage("TestPkg2");
m_pollerConfig.addDowntime(500L, 0L, 1000L, false);
m_pollerConfig.addDowntime(500L, 1000L, -1L, true);
m_pollerConfig.setDefaultPollInterval(2000L);
m_pollerConfig.addService(m_mockNetwork.getService(2, "192.168.1.3", "HTTP"));
m_timer = new MockTimer();
m_scheduler = new MockScheduler(m_timer);
m_network = createPollableNetwork(m_db, m_scheduler, m_pollerConfig, m_pollerConfig, m_pollContext);
// set members to make the tests easier
mNode1 = m_mockNetwork.getNode(1);
mDot1 = mNode1.getInterface("192.168.1.1");
mDot1Smtp = mDot1.getService("SMTP");
mDot1Icmp = mDot1.getService("ICMP");
mDot2 = mNode1.getInterface("192.168.1.2");
mDot2Icmp = mDot2.getService("ICMP");
mNode2 = m_mockNetwork.getNode(2);
mDot3 = mNode2.getInterface("192.168.1.3");
mDot3Http = mDot3.getService("HTTP");
mNode3 = m_mockNetwork.getNode(3);
mDot4 = mNode3.getInterface("192.168.1.4");
mDot4Smtp = mDot4.getService("SMTP");
mDot4Http = mDot4.getService("HTTP");
assignPollableMembers(m_network);
}
use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class CollectorConfigDaoImplIT method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
MockUtil.println("------------ Begin Test " + getName() + " --------------------------");
MockLogAppender.setupLogging();
MockDatabase m_db = new MockDatabase();
// m_db.populate(m_network);
DataSourceFactory.setInstance(m_db);
}
use of org.opennms.core.test.db.MockDatabase in project opennms by OpenNMS.
the class SyslogdConfigFactoryIT method setUp.
@Before
public void setUp() throws Exception {
DaoTestConfigBean daoTestConfig = new DaoTestConfigBean();
daoTestConfig.setRelativeHomeDirectory("src/test/resources");
daoTestConfig.afterPropertiesSet();
MockNetwork network = new MockNetwork();
MockDatabase db = new MockDatabase();
db.populate(network);
DataSourceFactory.setInstance(db);
m_factory = new SyslogdConfigFactory(ConfigurationTestUtils.getInputStreamForResource(this, "/etc/syslogd-configuration.xml"));
}
Aggregations