use of org.opennms.netmgt.collectd.tca.config.TcaDataCollectionConfig in project opennms by OpenNMS.
the class TcaCollectorComplianceIT method getRequiredBeans.
@Override
public Map<String, Object> getRequiredBeans() {
TcaDataCollectionConfig config = mock(TcaDataCollectionConfig.class);
RrdRepository rrdRepository = new RrdRepository();
rrdRepository.setRrdBaseDir(new File("target"));
when(config.buildRrdRepository(COLLECTION)).thenReturn(rrdRepository);
TcaDataCollectionConfigDao tcaDataCollectionConfigDao = mock(TcaDataCollectionConfigDao.class);
when(tcaDataCollectionConfigDao.getConfig()).thenReturn(config);
ResourceStorageDao resourceStorageDao = mock(ResourceStorageDao.class);
ResourceTypesDao resourceTypesDao = mock(ResourceTypesDao.class);
ResourceType resourceType = TcaCollectorIT.getJuniperTcaEntryResourceType();
when(resourceTypesDao.getResourceTypeByName(TcaCollectionHandler.RESOURCE_TYPE_NAME)).thenReturn(resourceType);
return new ImmutableMap.Builder<String, Object>().put("tcaDataCollectionConfigDao", tcaDataCollectionConfigDao).put("resourceStorageDao", resourceStorageDao).put("resourceTypesDao", resourceTypesDao).put("locationAwareSnmpClient", m_client).build();
}
use of org.opennms.netmgt.collectd.tca.config.TcaDataCollectionConfig in project opennms by OpenNMS.
the class TcaCollectorIT method setUp.
/**
* Sets the up.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
m_tempFolder.newFolder("snmp");
m_resourceStorageDao.setRrdDirectory(m_tempFolder.getRoot());
OnmsIpInterface iface = null;
OnmsNode testNode = null;
Collection<OnmsNode> testNodes = m_nodeDao.findByLabel(TEST_NODE_LABEL);
if (testNodes == null || testNodes.size() < 1) {
NetworkBuilder builder = new NetworkBuilder();
builder.addNode(TEST_NODE_LABEL).setId(1).setSysObjectId(".1.3.6.1.4.1.1588.2.1.1.1");
InterfaceBuilder ifBldr = builder.addInterface(TEST_NODE_IP).setIsSnmpPrimary("P");
ifBldr.addSnmpInterface(6).setIfName("fw0").setPhysAddr("44:33:22:11:00").setIfType(144).setCollectionEnabled(true);
testNode = builder.getCurrentNode();
Assert.assertNotNull(testNode);
m_nodeDao.save(testNode);
m_nodeDao.flush();
} else {
testNode = testNodes.iterator().next();
}
Set<OnmsIpInterface> ifaces = testNode.getIpInterfaces();
Assert.assertEquals(1, ifaces.size());
iface = ifaces.iterator().next();
SnmpPeerFactory.setInstance(m_snmpPeerFactory);
m_collectionAgent = DefaultSnmpCollectionAgent.create(iface.getId(), m_ipInterfaceDao, m_transactionManager);
TcaRrd rrd = new TcaRrd();
rrd.addRra("RRA:AVERAGE:0.5:1:3600");
rrd.addRra("RRA:AVERAGE:0.5:300:288");
rrd.addRra("RRA:MIN:0.5:300:288");
rrd.addRra("RRA:MAX:0.5:300:288");
rrd.addRra("RRA:AVERAGE:0.5:900:2880");
rrd.addRra("RRA:MIN:0.5:900:2880");
rrd.addRra("RRA:MAX:0.5:900:2880");
rrd.addRra("RRA:AVERAGE:0.5:3600:4300");
rrd.addRra("RRA:MIN:0.5:3600:4300");
rrd.addRra("RRA:MAX:0.5:3600:4300");
TcaDataCollection tcadc = new TcaDataCollection();
tcadc.setName("default");
tcadc.setRrd(rrd);
TcaDataCollectionConfig tcadcc = new TcaDataCollectionConfig();
tcadcc.addDataCollection(tcadc);
tcadcc.setRrdRepository(getSnmpRoot().getAbsolutePath());
EasyMock.expect(m_configDao.getConfig()).andReturn(tcadcc).atLeastOnce();
EasyMock.replay(m_configDao);
// Define the resource type
ResourceType resourceType = getJuniperTcaEntryResourceType();
m_resourceTypesDao = EasyMock.createMock(ResourceTypesDao.class);
EasyMock.expect(m_resourceTypesDao.getResourceTypeByName(TcaCollectionHandler.RESOURCE_TYPE_NAME)).andReturn(resourceType).anyTimes();
EasyMock.replay(m_resourceTypesDao);
}
Aggregations