use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.
the class HttpCollectorIT method testPersistApacheStatsAlternateLocale.
public final void testPersistApacheStatsAlternateLocale() throws Exception {
final Locale defaultLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.FRANCE);
File snmpRrdDirectory = (File) m_context.getAttribute("rrdDirectory");
FileAnticipator anticipator = (FileAnticipator) m_context.getAttribute("fileAnticipator");
int numUpdates = 2;
int stepSizeInSecs = 1;
int stepSizeInMillis = stepSizeInSecs * 1000;
final int rangeSizeInMillis = stepSizeInMillis + 20000;
CollectorTestUtils.collectNTimes(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, m_collectionAgent, numUpdates);
// node level collection
File nodeDir = CollectorTestUtils.anticipatePath(anticipator, snmpRrdDirectory, "1");
File documentCountRrdFile = new File(nodeDir, CollectorTestUtils.rrd(m_rrdStrategy, "TotalAccesses"));
File someNumberRrdFile = new File(nodeDir, CollectorTestUtils.rrd(m_rrdStrategy, "IdleWorkers"));
File cpuLoadRrdFile = new File(nodeDir, CollectorTestUtils.rrd(m_rrdStrategy, "CPULoad"));
// Total Accesses: 175483
assertEquals("TotalAccesses", Double.valueOf(175483.0), m_rrdStrategy.fetchLastValueInRange(documentCountRrdFile.getAbsolutePath(), "TotalAccesses", stepSizeInMillis, rangeSizeInMillis));
// IdleWorkers: 12
assertEquals("IdleWorkers", Double.valueOf(12.0), m_rrdStrategy.fetchLastValueInRange(someNumberRrdFile.getAbsolutePath(), "IdleWorkers", stepSizeInMillis, rangeSizeInMillis));
// CPU Load: .497069
assertEquals("CPULoad", Double.valueOf(0.497069), m_rrdStrategy.fetchLastValueInRange(cpuLoadRrdFile.getAbsolutePath(), "CPULoad", stepSizeInMillis, rangeSizeInMillis));
} finally {
Locale.setDefault(defaultLocale);
}
}
use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.
the class PollerFrontEndIT method setUpAnticipator.
/**
* Use a {@link FileAnticipator} to create a temp file that will be used
* by {@link PollerSettings} to save the location ID to disk.
*/
@BeforeClass
public static void setUpAnticipator() throws IOException {
m_fileAnticipator = new FileAnticipator();
final String filename = m_fileAnticipator.expecting("remote-poller.configuration").getCanonicalPath().replace("+", "%2B");
System.setProperty("opennms.poller.configuration.resource", "file://" + filename);
}
use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.
the class PropertiesGraphDaoITCase method setUp.
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging(true);
m_dao = createPropertiesGraphDao(s_emptyMap, s_emptyMap);
ByteArrayInputStream in = new ByteArrayInputStream(s_prefab.getBytes());
m_dao.loadProperties("performance", in);
PrefabGraphTypeDao type = m_dao.findPrefabGraphTypeDaoByName("performance");
assertNotNull("could not get performance prefab graph type", type);
m_graphs = type.getReportMap();
assertNotNull("report map shouldn't be null", m_graphs);
m_fileAnticipator = new FileAnticipator();
}
use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.
the class DefaultRrdGraphServiceTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
m_mockUtils = new EasyMockUtils();
m_fileAnticipator = new FileAnticipator(false);
m_service = new DefaultRrdGraphService();
}
use of org.opennms.test.FileAnticipator in project opennms by OpenNMS.
the class JdbcDataCollectionConfigTest method setUp.
@Before
public void setUp() throws Exception {
fa = new FileAnticipator();
// Mock up a JdbcDataCollectionConfig class.
JdbcRrd jdbcRrd = new JdbcRrd();
jdbcRrd.addRra("RRA:AVERAGE:0.5:1:2016");
jdbcRrd.addRra("RRA:AVERAGE:0.5:12:1488");
jdbcRrd.addRra("RRA:AVERAGE:0.5:288:366");
jdbcRrd.addRra("RRA:MAX:0.5:288:366");
jdbcRrd.addRra("RRA:MIN:0.5:288:366");
jdbcRrd.setStep(300);
JdbcStatement jdbcStatement = new JdbcStatement();
jdbcStatement.setJdbcQuery("SELECT COUNT(eventid) as EventCount\n" + "FROM events\n" + "WHERE eventtime\n" + "BETWEEN (CURRENT_TIMESTAMP - INTERVAL '1 day')\n" + "AND CURRENT_TIMESTAMP;");
JdbcColumn column = new JdbcColumn();
column.setColumnName("eventCount");
column.setDataSourceName("EventCount");
column.setDataType(AttributeType.GAUGE);
column.setAlias("eventCount");
JdbcQuery jdbcQuery = new JdbcQuery();
jdbcQuery.setQueryName("opennmsQuery");
jdbcQuery.setJdbcStatement(jdbcStatement);
jdbcQuery.addJdbcColumn(column);
jdbcQuery.setRecheckInterval(3600000);
jdbcQuery.setIfType("all");
jdbcQuery.setResourceType("node");
JdbcDataCollection jdbcDataCollection = new JdbcDataCollection();
jdbcDataCollection.setJdbcRrd(jdbcRrd);
jdbcDataCollection.addQuery(jdbcQuery);
jdbcDataCollection.setName("default");
jdcc = new JdbcDataCollectionConfig();
jdcc.addDataCollection(jdbcDataCollection);
jdcc.setRrdRepository("/opt/opennms/share/rrd/snmp/");
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setNormalize(true);
}
Aggregations