Search in sources :

Example 21 with JUnitSnmpAgent

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

the class InstanceStrategyIntegrationTest method testDynamicPackageConfig.

/*
     * Test the behaviour when packages are not explicitely defined in the
     * configuration file (i.e. dynamic packages) Verify: That the proper
     * events are sent by the daemon.
     */
@Test
@JUnitSnmpAgent(host = "10.1.0.2", resource = SNMP_DATA_PATH + "10.1.0.2-walk.txt")
public void testDynamicPackageConfig() throws Exception {
    // Add AP1 to a new package
    addNewAccessPoint("ap1", AP1_MAC, "aruba-default-pkg");
    // Add the controller in the same package
    addNewController("amc1", "10.1.0.2", "aruba-default-pkg");
    // Set the access point state
    setOidValueForAccessPoint("10.1.0.2", AP1_MAC, 1);
    // Anticipate the events
    anticipateApStatusEvent(AP1_MAC, "UP");
    // Initialize and start the daemon
    initApmdWithConfig(getDynamicPackageConfig());
    m_apm.start();
    // The AP should be reported as UP even though the package is not
    // explicitly defined
    verifyAnticipated(POLLING_INTERVAL_DELTA);
    // Delete AP1
    OnmsAccessPoint ap1 = m_accessPointDao.get(AP1_MAC);
    m_accessPointDao.delete(ap1);
    m_accessPointDao.flush();
    // Wait for the package scan to kick in
    sleep(2000);
    // Take the AP off-line
    anticipateApStatusEvent(AP1_MAC, "DOWN");
    // No event should be generated
    sleep(POLLING_INTERVAL_DELTA);
    assertEquals("Received unexpected events", 0, m_anticipator.getUnanticipatedEvents().size());
    m_anticipator.reset();
}
Also used : OnmsAccessPoint(org.opennms.netmgt.model.OnmsAccessPoint) 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