Search in sources :

Example 1 with FileAnticipator

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);
    }
}
Also used : Locale(java.util.Locale) File(java.io.File) FileAnticipator(org.opennms.test.FileAnticipator)

Example 2 with FileAnticipator

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);
}
Also used : FileAnticipator(org.opennms.test.FileAnticipator) BeforeClass(org.junit.BeforeClass)

Example 3 with FileAnticipator

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();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileAnticipator(org.opennms.test.FileAnticipator) PrefabGraphTypeDao(org.opennms.netmgt.dao.support.PropertiesGraphDao.PrefabGraphTypeDao) Before(org.junit.Before)

Example 4 with 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();
}
Also used : EasyMockUtils(org.opennms.test.mock.EasyMockUtils) FileAnticipator(org.opennms.test.FileAnticipator)

Example 5 with FileAnticipator

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);
}
Also used : FileAnticipator(org.opennms.test.FileAnticipator) Before(org.junit.Before)

Aggregations

FileAnticipator (org.opennms.test.FileAnticipator)24 Before (org.junit.Before)15 File (java.io.File)7 JRobinRrdStrategy (org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy)6 FilterDao (org.opennms.netmgt.filter.api.FilterDao)4 ArrayList (java.util.ArrayList)3 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)3 FilesystemResourceStorageDao (org.opennms.netmgt.dao.support.FilesystemResourceStorageDao)3 EasyMockUtils (org.opennms.test.mock.EasyMockUtils)3 FileSystemResource (org.springframework.core.io.FileSystemResource)3 FileWriter (java.io.FileWriter)2 InputStream (java.io.InputStream)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 PollOutagesConfigFactory (org.opennms.netmgt.config.PollOutagesConfigFactory)2 ResourceTypesDao (org.opennms.netmgt.config.api.ResourceTypesDao)2 LocationMonitorDao (org.opennms.netmgt.dao.api.LocationMonitorDao)2 NodeDao (org.opennms.netmgt.dao.api.NodeDao)2 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)2