Search in sources :

Example 6 with JUnitSnmpAgent

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.

the class SnmpCollectorIT method testCollect.

@Test
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/datacollection-config.xml", datacollectionType = "snmp", anticipateFiles = { "1", "1/fw0" }, anticipateRrds = { "1/tcpActiveOpens", "1/tcpAttemptFails", "1/tcpPassiveOpens", "1/tcpRetransSegs", "1/tcpCurrEstab", "1/tcpEstabResets", "1/tcpInErrors", "1/tcpInSegs", "1/tcpOutRsts", "1/tcpOutSegs", "1/fw0/ifInDiscards", "1/fw0/ifInErrors", "1/fw0/ifInNUcastpkts", "1/fw0/ifInOctets", "1/fw0/ifInUcastpkts", "1/fw0/ifOutErrors", "1/fw0/ifOutNUcastPkts", "1/fw0/ifOutOctets", "1/fw0/ifOutUcastPkts" })
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/snmpTestData1.properties")
public void testCollect() throws Exception {
    System.setProperty("org.opennms.netmgt.collectd.SnmpCollector.limitCollectionToInstances", "true");
    // now do the actual collection
    CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
    assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
    CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
    System.err.println("FIRST COLLECTION FINISHED");
    //need a one second time elapse to update the RRD
    Thread.sleep(1000);
    // try collecting again
    assertEquals("collection status", CollectionStatus.SUCCEEDED, m_collectionSpecification.collect(m_collectionAgent).getStatus());
    System.err.println("SECOND COLLECTION FINISHED");
}
Also used : CollectionSet(org.opennms.netmgt.collection.api.CollectionSet) JUnitCollector(org.opennms.core.collection.test.JUnitCollector) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent)

Example 7 with JUnitSnmpAgent

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.

the class SnmpCollectorIT method testBrocadeCollect.

@Test
@Transactional
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/datacollection-brocade-config.xml", datacollectionType = "snmp", anticipateRrds = { "1/brocadeFCPortIndex/1/swFCPortTxWords", "1/brocadeFCPortIndex/1/swFCPortRxWords", "1/brocadeFCPortIndex/2/swFCPortTxWords", "1/brocadeFCPortIndex/2/swFCPortRxWords", "1/brocadeFCPortIndex/3/swFCPortTxWords", "1/brocadeFCPortIndex/3/swFCPortRxWords", "1/brocadeFCPortIndex/4/swFCPortTxWords", "1/brocadeFCPortIndex/4/swFCPortRxWords", "1/brocadeFCPortIndex/5/swFCPortTxWords", "1/brocadeFCPortIndex/5/swFCPortRxWords", "1/brocadeFCPortIndex/6/swFCPortTxWords", "1/brocadeFCPortIndex/6/swFCPortRxWords", "1/brocadeFCPortIndex/7/swFCPortTxWords", "1/brocadeFCPortIndex/7/swFCPortRxWords", "1/brocadeFCPortIndex/8/swFCPortTxWords", "1/brocadeFCPortIndex/8/swFCPortRxWords" }, anticipateFiles = { "1", "1/brocadeFCPortIndex", "1/brocadeFCPortIndex/1/strings.properties", "1/brocadeFCPortIndex/1", "1/brocadeFCPortIndex/2/strings.properties", "1/brocadeFCPortIndex/2", "1/brocadeFCPortIndex/3/strings.properties", "1/brocadeFCPortIndex/3", "1/brocadeFCPortIndex/4/strings.properties", "1/brocadeFCPortIndex/4", "1/brocadeFCPortIndex/5/strings.properties", "1/brocadeFCPortIndex/5", "1/brocadeFCPortIndex/6/strings.properties", "1/brocadeFCPortIndex/6", "1/brocadeFCPortIndex/7/strings.properties", "1/brocadeFCPortIndex/7", "1/brocadeFCPortIndex/8/strings.properties", "1/brocadeFCPortIndex/8" })
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/brocadeTestData1.properties")
public void testBrocadeCollect() throws Exception {
    // now do the actual collection
    CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
    assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
    CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
    System.err.println("FIRST COLLECTION FINISHED");
    //need a one second time elapse to update the RRD
    Thread.sleep(1000);
    // try collecting again
    assertEquals("collection status", CollectionStatus.SUCCEEDED, m_collectionSpecification.collect(m_collectionAgent).getStatus());
    System.err.println("SECOND COLLECTION FINISHED");
}
Also used : CollectionSet(org.opennms.netmgt.collection.api.CollectionSet) JUnitCollector(org.opennms.core.collection.test.JUnitCollector) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with JUnitSnmpAgent

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.

the class SnmpCollectorIT method testPersist.

@Test
@Transactional
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/datacollection-persistTest-config.xml", datacollectionType = "snmp", anticipateFiles = { "1", "1/fw0" }, anticipateRrds = { "1/tcpCurrEstab", "1/fw0/ifInOctets" })
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/snmpTestData1.properties")
public void testPersist() throws Exception {
    File snmpRrdDirectory = (File) m_context.getAttribute("rrdDirectory");
    // node level collection
    File nodeDir = new File(snmpRrdDirectory, "1");
    File rrdFile = new File(nodeDir, rrd("tcpCurrEstab"));
    // interface level collection
    File ifDir = new File(nodeDir, "fw0");
    File ifRrdFile = new File(ifDir, rrd("ifInOctets"));
    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);
    // This is the value from snmpTestData1.properties
    //.1.3.6.1.2.1.6.9.0 = Gauge32: 123
    assertEquals(Double.valueOf(123.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "tcpCurrEstab", stepSizeInMillis, rangeSizeInMillis));
    // This is the value from snmpTestData1.properties
    // .1.3.6.1.2.1.2.2.1.10.6 = Counter32: 1234567
    assertEquals(Double.valueOf(1234567.0), m_rrdStrategy.fetchLastValueInRange(ifRrdFile.getAbsolutePath(), "ifInOctets", stepSizeInMillis, rangeSizeInMillis));
    // now update the data in the agent
    SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.6.9.0"), SnmpUtils.getValueFactory().getInt32(456));
    SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.2.2.1.10.6"), SnmpUtils.getValueFactory().getCounter32(7654321));
    CollectorTestUtils.collectNTimes(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, m_collectionAgent, numUpdates);
    // by now the values should be the new values
    assertEquals(Double.valueOf(456.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "tcpCurrEstab", stepSizeInMillis, rangeSizeInMillis));
    assertEquals(Double.valueOf(7654321.0), m_rrdStrategy.fetchLastValueInRange(ifRrdFile.getAbsolutePath(), "ifInOctets", stepSizeInMillis, rangeSizeInMillis));
}
Also used : File(java.io.File) JUnitCollector(org.opennms.core.collection.test.JUnitCollector) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with JUnitSnmpAgent

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.

the class SnmpCollectorIT method testBug2447_GenericIndexedOnlyCollect.

@Test
@Transactional
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/datacollection-brocade-no-ifaces-config.xml", datacollectionType = "snmp", anticipateRrds = { "1/brocadeFCPortIndex/1/swFCPortTxWords", "1/brocadeFCPortIndex/1/swFCPortRxWords", "1/brocadeFCPortIndex/2/swFCPortTxWords", "1/brocadeFCPortIndex/2/swFCPortRxWords", "1/brocadeFCPortIndex/3/swFCPortTxWords", "1/brocadeFCPortIndex/3/swFCPortRxWords", "1/brocadeFCPortIndex/4/swFCPortTxWords", "1/brocadeFCPortIndex/4/swFCPortRxWords", "1/brocadeFCPortIndex/5/swFCPortTxWords", "1/brocadeFCPortIndex/5/swFCPortRxWords", "1/brocadeFCPortIndex/6/swFCPortTxWords", "1/brocadeFCPortIndex/6/swFCPortRxWords", "1/brocadeFCPortIndex/7/swFCPortTxWords", "1/brocadeFCPortIndex/7/swFCPortRxWords", "1/brocadeFCPortIndex/8/swFCPortTxWords", "1/brocadeFCPortIndex/8/swFCPortRxWords" }, anticipateFiles = { "1", "1/brocadeFCPortIndex", "1/brocadeFCPortIndex/1/strings.properties", "1/brocadeFCPortIndex/1", "1/brocadeFCPortIndex/2/strings.properties", "1/brocadeFCPortIndex/2", "1/brocadeFCPortIndex/3/strings.properties", "1/brocadeFCPortIndex/3", "1/brocadeFCPortIndex/4/strings.properties", "1/brocadeFCPortIndex/4", "1/brocadeFCPortIndex/5/strings.properties", "1/brocadeFCPortIndex/5", "1/brocadeFCPortIndex/6/strings.properties", "1/brocadeFCPortIndex/6", "1/brocadeFCPortIndex/7/strings.properties", "1/brocadeFCPortIndex/7", "1/brocadeFCPortIndex/8/strings.properties", "1/brocadeFCPortIndex/8" })
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/brocadeTestData1.properties")
public void testBug2447_GenericIndexedOnlyCollect() throws Exception {
    // now do the actual collection
    CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
    assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
    CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
    System.err.println("FIRST COLLECTION FINISHED");
    //need a one second time elapse to update the RRD
    Thread.sleep(1000);
    // try collecting again
    assertEquals("collection status", CollectionStatus.SUCCEEDED, m_collectionSpecification.collect(m_collectionAgent).getStatus());
    System.err.println("SECOND COLLECTION FINISHED");
}
Also used : CollectionSet(org.opennms.netmgt.collection.api.CollectionSet) JUnitCollector(org.opennms.core.collection.test.JUnitCollector) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with JUnitSnmpAgent

use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgent in project opennms by OpenNMS.

the class SnmpCollectorMinMaxValIT method testPersist.

@Test
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/datacollection-minmax-persistTest-config.xml", datacollectionType = "snmp", anticipateFiles = { "1", "1/fw0" }, anticipateRrds = { "1/tcpCurrEstab", "1/fw0/ifInOctets" })
@JUnitSnmpAgent(host = TEST_HOST_ADDRESS, resource = "/org/opennms/netmgt/snmp/snmpTestData1.properties")
public void testPersist() throws Exception {
    final File snmpRrdDirectory = (File) m_context.getAttribute("rrdDirectory");
    // node level collection
    final File nodeDir = new File(snmpRrdDirectory, "1");
    final File rrdFile = new File(nodeDir, rrd("tcpCurrEstab"));
    // interface level collection
    final File ifDir = new File(nodeDir, "fw0");
    final File ifRrdFile = new File(ifDir, rrd("ifInOctets"));
    final int numUpdates = 2;
    final int stepSizeInSecs = 1;
    final int stepSizeInMillis = stepSizeInSecs * 1000;
    final int rangeSizeInMillis = stepSizeInMillis + 20000;
    CollectorTestUtils.collectNTimes(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, m_collectionAgent, numUpdates);
    // This is the value from snmpTestData1.properties
    //.1.3.6.1.2.1.6.9.0 = Gauge32: 123
    assertEquals(Double.valueOf(123.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "tcpCurrEstab", stepSizeInMillis, rangeSizeInMillis));
    // This is the value from snmpTestData1.properties
    // .1.3.6.1.2.1.2.2.1.10.6 = Counter32: 1234567
    assertEquals(Double.valueOf(1234567.0), m_rrdStrategy.fetchLastValueInRange(ifRrdFile.getAbsolutePath(), "ifInOctets", stepSizeInMillis, rangeSizeInMillis));
    // now update the data in the agent
    SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.6.9.0"), SnmpUtils.getValueFactory().getInt32(456));
    SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.2.2.1.10.6"), SnmpUtils.getValueFactory().getCounter32(7654321));
    CollectorTestUtils.collectNTimes(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, m_collectionAgent, numUpdates);
    // by now the values should be the new values
    assertEquals(Double.valueOf(456.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "tcpCurrEstab", stepSizeInMillis, rangeSizeInMillis));
    assertEquals(Double.valueOf(1234567.0), m_rrdStrategy.fetchLastValueInRange(ifRrdFile.getAbsolutePath(), "ifInOctets", stepSizeInMillis, rangeSizeInMillis));
    // now update the data in the agent
    SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.6.9.0"), SnmpUtils.getValueFactory().getInt32(456));
    SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.2.2.1.10.6"), SnmpUtils.getValueFactory().getCounter32(1234567));
    CollectorTestUtils.collectNTimes(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, m_collectionAgent, numUpdates);
    // by now the values should be the new values
    assertEquals(Double.valueOf(456.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "tcpCurrEstab", stepSizeInMillis, rangeSizeInMillis));
    assertEquals(Double.valueOf(1234567.0), m_rrdStrategy.fetchLastValueInRange(ifRrdFile.getAbsolutePath(), "ifInOctets", stepSizeInMillis, rangeSizeInMillis));
}
Also used : File(java.io.File) JUnitCollector(org.opennms.core.collection.test.JUnitCollector) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent)

Aggregations

JUnitSnmpAgent (org.opennms.core.test.snmp.annotations.JUnitSnmpAgent)21 Test (org.junit.Test)19 JUnitCollector (org.opennms.core.collection.test.JUnitCollector)8 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)6 OnmsNode (org.opennms.netmgt.model.OnmsNode)5 OnmsAccessPoint (org.opennms.netmgt.model.OnmsAccessPoint)4 Transactional (org.springframework.transaction.annotation.Transactional)4 File (java.io.File)2 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)2 SnmpAgentAddress (org.opennms.netmgt.snmp.SnmpAgentAddress)2 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)2 Method (java.lang.reflect.Method)1 InetAddress (java.net.InetAddress)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Ignore (org.junit.Ignore)1 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)1 EventAnticipator (org.opennms.netmgt.dao.mock.EventAnticipator)1 LldpRemTableTracker (org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker)1 LldpLink (org.opennms.netmgt.model.LldpLink)1 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)1