Search in sources :

Example 26 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class TrapHandlerITCase method testInterfaceReparentedModifiesIpMgr.

@Test
@DirtiesContext
public void testInterfaceReparentedModifiesIpMgr() throws Exception {
    long nodeId = 1;
    anticipateEvent("uei.opennms.org/default/trap", m_ip, nodeId);
    Event event = anticipateEvent(EventConstants.INTERFACE_REPARENTED_EVENT_UEI, m_ip, nodeId);
    m_eventMgr.sendNow(event);
    try {
        Thread.sleep(100);
    } catch (InterruptedException e) {
    // do nothing
    }
    sendTrap("v1", null, 6, 1);
    finishUp();
}
Also used : Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 27 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class MonolithicDependencyRulesIT method testDependencyAnyRules.

@Test
@DirtiesContext
@Ignore("Non Deterministic!!!")
public void testDependencyAnyRules() throws Exception {
    // Get engine
    DroolsCorrelationEngine engine = findEngineByName("monolithicDependencyRules");
    // Anticipate component lspA down event
    getAnticipator().reset();
    anticipate(createComponentImpactedEvent("ServiceElementComponent", "lspA-PE1-PE2", "NA-SvcElemComp", "8765,lspA-PE1-PE2", 17));
    // Generate down event
    Event event = createMplsLspPathDownEvent(m_pe1NodeId, "10.1.1.1", "lspA-PE1-PE2");
    event.setDbid(17);
    System.err.println("SENDING MplsLspPathDown on LspA EVENT!!");
    engine.correlate(event);
    // Check down event
    getAnticipator().verifyAnticipated();
    // Anticipate component lspB down event
    // Parent should go down too
    getAnticipator().reset();
    anticipate(createComponentImpactedEvent("ServiceElementComponent", "lspB-PE1-PE2", "NA-SvcElemComp", "8765,lspB-PE1-PE2", 18));
    anticipate(createComponentImpactedEvent("ServiceElementComponent", "jnxVpnPw-vcid(50)", "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)", 18));
    anticipate(createComponentImpactedEvent("ServiceElement", "PE1,SE1", "NA-ServiceElement", "8765", 18));
    anticipate(createComponentImpactedEvent("Service", "CokeP2P", "NA-Service", "123", 18));
    //anticipate(  createComponentImpactedEvent( "Service", "NA-Service", "123", 17 ) );
    // Generate down event
    event = createMplsLspPathDownEvent(m_pe1NodeId, "10.1.1.1", "lspB-PE1-PE2");
    event.setDbid(18);
    System.err.println("SENDING MplsLspPathDown on LspB EVENT!!");
    engine.correlate(event);
    // Check down event
    getAnticipator().verifyAnticipated();
    // Anticipate up event
    getAnticipator().reset();
    anticipate(createComponentResolvedEvent("ServiceElementComponent", "lspA-PE1-PE2", "NA-SvcElemComp", "8765,lspA-PE1-PE2", 18));
    anticipate(createComponentResolvedEvent("ServiceElementComponent", "jnxVpnPw-vcid(50)", "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)", 18));
    anticipate(createComponentResolvedEvent("ServiceElement", "PE1,SE1", "NA-ServiceElement", "8765", 18));
    anticipate(createComponentResolvedEvent("Service", "CokeP2P", "NA-Service", "123", 18));
    //Generate up event
    event = createMplsLspPathUpEvent(m_pe1NodeId, "10.1.1.1", "lspA-PE1-PE2");
    event.setDbid(17);
    System.err.println("SENDING MplsLspPathUp on LspA EVENT!!");
    engine.correlate(event);
    // Check up event
    getAnticipator().verifyAnticipated();
}
Also used : Event(org.opennms.netmgt.xml.event.Event) DroolsCorrelationEngine(org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine) Ignore(org.junit.Ignore) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 28 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class MonolithicDependencyRulesIT method testMultipleDownAndSingleUpCase.

@Test
@DirtiesContext
@Ignore("not yet implemented")
public void testMultipleDownAndSingleUpCase() throws Exception {
    // Get engine
    DroolsCorrelationEngine engine = findEngineByName("monolithicDependencyRules");
    // Anticipate down event
    getAnticipator().reset();
    anticipate(createComponentImpactedEvent("ServiceElementComponent", "jnxVpnPw-vcid(50)", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)", 17));
    anticipate(createComponentImpactedEvent("ServiceElement", "PE2,SE1", "NA-ServiceElement", "9876", 17));
    anticipate(createComponentImpactedEvent("Service", "CokeP2P", "NA-Service", "123", 17));
    // Generate down event
    Event event = createVpnPwDownEvent(m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    event.setDbid(17);
    System.err.println("SENDING VpnPwDown EVENT!!");
    engine.correlate(event);
    // Check down event
    getAnticipator().verifyAnticipated();
    // Generate additional down event - nothing should happen
    getAnticipator().reset();
    event = createVpnPwDownEvent(m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    event.setDbid(18);
    System.err.println("SENDING VpnPwDown EVENT!!");
    engine.correlate(event);
    getAnticipator().verifyAnticipated();
    // Anticipate up event
    getAnticipator().reset();
    anticipate(createComponentResolvedEvent("ServiceElementComponent", "jnxVpnPw-vcid(50)", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)", 17));
    anticipate(createComponentResolvedEvent("ServiceElement", "PE2,SE1", "NA-ServiceElement", "9876", 17));
    anticipate(createComponentResolvedEvent("Service", "CokeP2P", "NA-Service", "123", 17));
    // Generate up event
    event = createVpnPwUpEvent(m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    event.setDbid(17);
    System.err.println("SENDING VpnPwUp EVENT!!");
    engine.correlate(event);
    // Check up event
    getAnticipator().verifyAnticipated();
}
Also used : Event(org.opennms.netmgt.xml.event.Event) DroolsCorrelationEngine(org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine) Ignore(org.junit.Ignore) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 29 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class MonolithicDependencyRulesIT method testSimpleUpDownCase.

@Test
@DirtiesContext
public void testSimpleUpDownCase() throws Exception {
    // Get engine
    DroolsCorrelationEngine engine = findEngineByName("monolithicDependencyRules");
    // Antecipate down event
    getAnticipator().reset();
    anticipate(createComponentImpactedEvent("ServiceElementComponent", "jnxVpnPw-vcid(50)", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)", 17));
    anticipate(createComponentImpactedEvent("ServiceElement", "PE2,SE1", "NA-ServiceElement", "9876", 17));
    anticipate(createComponentImpactedEvent("Service", "CokeP2P", "NA-Service", "123", 17));
    // Generate down event
    Event event = createVpnPwDownEvent(m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    event.setDbid(17);
    System.err.println("SENDING VpnPwDown EVENT!!");
    engine.correlate(event);
    // Check down event
    getAnticipator().verifyAnticipated();
    // Generate additional down event - nothing should happen
    //		getAnticipator().reset();
    //        event = createVpnPwDownEvent( m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50" );
    //        event.setDbid(18);
    //        System.err.println("SENDING VpnPwDown EVENT!!");
    //        engine.correlate( event );
    //        getAnticipator().verifyAnticipated();
    // Anticipate up event
    getAnticipator().reset();
    anticipate(createComponentResolvedEvent("ServiceElementComponent", "jnxVpnPw-vcid(50)", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)", 17));
    anticipate(createComponentResolvedEvent("ServiceElement", "PE2,SE1", "NA-ServiceElement", "9876", 17));
    anticipate(createComponentResolvedEvent("Service", "CokeP2P", "NA-Service", "123", 17));
    // Generate up event
    event = createVpnPwUpEvent(m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    event.setDbid(17);
    System.err.println("SENDING VpnPwUp EVENT!!");
    engine.correlate(event);
    // Check up event
    getAnticipator().verifyAnticipated();
}
Also used : Event(org.opennms.netmgt.xml.event.Event) DroolsCorrelationEngine(org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 30 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class ImpactProgagationRulesIT method testSimpleALLRulesPropagation.

@Test
@DirtiesContext
public void testSimpleALLRulesPropagation() throws Exception {
    // 1. Assert empty workspace
    resetFacts();
    verifyFacts();
    // 2. verify Impact on ComponentDownEvent
    resetFacts();
    resetEvents();
    // component to request dependencies for
    Component c = createComponent("ServiceElementComponent", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)");
    Event downEvent = createVpnPwDownEvent(17, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    ComponentDownEvent cde = new ComponentDownEvent(c, downEvent);
    // this component depends on c
    Component parent = createComponent("ServiceElement", "NA-ServiceElement", "9876");
    DependsOn dep = new DependsOn(parent, c);
    ComponentImpacted componentImpacted = new ComponentImpacted(c, cde);
    ImpactEventSent eventSent = new ImpactEventSent(c, cde);
    anticipateFacts(dep, componentImpacted, eventSent, new ComponentImpacted(parent, cde), new DependenciesNeeded(parent, cde), new ImpactEventSent(parent, cde));
    anticipateEvent(createComponentImpactedEvent("ServiceElement", "PE2,SE1", "NA-SvcElement", "9876", 17));
    // Insert facts and fire rules
    FactHandle impactHandle = m_engine.getKieSession().insert(componentImpacted);
    FactHandle depHandle = m_engine.getKieSession().insert(dep);
    FactHandle eventSentHandle = m_engine.getKieSession().insert(eventSent);
    m_engine.getKieSession().fireAllRules();
    // pretend to be a using rule that inserts the DependenciesNeeded fact
    verifyFacts();
    verifyEvents();
    // 3. Verify resolution and memory clean up on ComponentUpEvent
    resetFacts();
    resetEvents();
    //anticipateEvent(createComponentResolvedEvent("ServiceElementComponent", "jnxVpnPw-vcid(50)", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)", 17));
    anticipateEvent(createComponentResolvedEvent("ServiceElement", "PE2,SE1", "NA-SvcElement", "9876", 17));
    // expect all facts to be resolved
    anticipateFacts();
    Event upEvent = createVpnPwUpEvent(18, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    ComponentUpEvent cue = new ComponentUpEvent(c, upEvent);
    m_engine.getKieSession().delete(impactHandle);
    m_engine.getKieSession().delete(depHandle);
    m_engine.getKieSession().delete(eventSentHandle);
    m_engine.getKieSession().insert(new ComponentEventResolved(cde, cue));
    m_engine.getKieSession().fireAllRules();
    verifyFacts();
    verifyEvents();
}
Also used : FactHandle(org.kie.api.runtime.rule.FactHandle) Event(org.opennms.netmgt.xml.event.Event) NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

DirtiesContext (org.springframework.test.annotation.DirtiesContext)78 Test (org.junit.Test)76 Exchange (org.apache.camel.Exchange)20 Event (org.opennms.netmgt.xml.event.Event)19 Processor (org.apache.camel.Processor)11 DroolsCorrelationEngine (org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine)10 IOException (java.io.IOException)9 NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)9 Ignore (org.junit.Ignore)7 LinkedHashMap (java.util.LinkedHashMap)5 CommonBindyTest (org.apache.camel.dataformat.bindy.CommonBindyTest)5 FactHandle (org.kie.api.runtime.rule.FactHandle)5 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)5 SnmpValueFactory (org.opennms.netmgt.snmp.SnmpValueFactory)5 BigDecimal (java.math.BigDecimal)3 Registration (org.opennms.core.soa.Registration)3 MyProvider (org.opennms.core.soa.support.MyProvider)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2