use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class DependencyRulesIT method testTwoOutagesTwoResolutionsCase.
// Test two down and two up events where the initial event that caused the propagation is
// resolved but a new component goes down. The expectation is that the service should remain
// down instead of going back up and then down again. This was reproduced with the following :
//echo "Send IfDown and PwDown"
//send-event.pl --parm "jnxVpnIfVpnName ge-1/3/2.1" --parm "jnxVpnIfVpnType 5" -n 5 uei.opennms.org/vendor/Juniper/traps/jnxVpnIfDown
//send-event.pl --parm "jnxVpnPwVpnName ge-1/3/2.1" --parm "jnxVpnPwVpnType 5" -n 5 uei.opennms.org/vendor/Juniper/traps/jnxVpnPwDown
//sleep 10
//echo "Send IfUp and PwUp in same order this causes issue with clearing"
//send-event.pl --parm "jnxVpnIfVpnName ge-1/3/2.1" --parm "jnxVpnIfVpnType 5" -n 5 uei.opennms.org/vendor/Juniper/traps/jnxVpnIfUp
//send-event.pl --parm "jnxVpnPwVpnName ge-1/3/2.1" --parm "jnxVpnPwVpnType 5" -n 5 uei.opennms.org/vendor/Juniper/traps/jnxVpnPwUp
@Test
@DirtiesContext
public void testTwoOutagesTwoResolutionsCase() throws Exception {
// Test what happens to the parent when there are two children impacted one is resolved
// Get engine
DroolsCorrelationEngine engine = findEngineByName("dependencyRules");
// Anticipate 1st down event
getAnticipator().reset();
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,jnxVpnIf"), 17));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "8765"), 17));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-Service", "123"), 17));
// Generate vpn if down event
System.err.println("SENDING VpnIfDown EVENT!!");
engine.correlate(createVpnIfDownEvent(17, m_pe1NodeId, "10.1.1.1", "5", "ge-1/0/2.50"));
// Check down event
getAnticipator().verifyAnticipated();
// Anticipate 2nd down event
getAnticipator().reset();
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)"), 18));
//anticipate( createComponentImpactedEvent( findSubcomponent (m_svc, "NA-ServiceElement", "8765"), 18 ) );
// Should we get this?
//anticipate( createComponentImpactedEvent( "Service", "CokeP2P", "NA-Service", "123", 18 ) );
// Generate vpn down event
System.err.println("SENDING VpnPwDown EVENT!!");
engine.correlate(createVpnPwDownEvent(18, m_pe1NodeId, "10.1.1.1", "5", "ge-1/0/2.50"));
// Check 2nd down event
getAnticipator().verifyAnticipated();
// Anticipate up event
getAnticipator().reset();
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,jnxVpnIf"), 17));
// The next two should not happen until the underlying subcomponents are also resolved
//anticipate( createComponentResolvedEvent( findSubcomponent (m_svc, "NA-ServiceElement", "8765"), 17 ) );
//anticipate( createComponentResolvedEvent( findSubcomponent (m_svc, "NA-Service", "123"), 17 ) );
//anticipate( createComponentImpactedEvent( findSubcomponent (m_svc, "NA-ServiceElement", "8765"), 18 ) );
//anticipate( createComponentImpactedEvent( findSubcomponent (m_svc, "NA-Service", "123"), 18 ) );
// Generate up event
System.err.println("SENDING VpnIfUp EVENT!!");
engine.correlate(createVpnIfUpEvent(19, m_pe1NodeId, "10.1.1.1", "5", "ge-1/0/2.50"));
// Check up event
getAnticipator().verifyAnticipated();
// Anticipate 2nd up event
getAnticipator().reset();
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)"), 18));
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "8765"), 18));
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-Service", "123"), 18));
// Generate up event
System.err.println("SENDING VpnPwUp EVENT!!");
engine.correlate(createVpnPwUpEvent(20, m_pe1NodeId, "10.1.1.1", "5", "ge-1/0/2.50"));
// Check up event
getAnticipator().verifyAnticipated();
// Memory should be clean!
assertEquals(0, engine.getKieSessionObjects().size());
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class DependencyRulesIT method testMultipleDownAndSingleUpCase.
@Test
@DirtiesContext
public //@Ignore("not yet implemented")
void testMultipleDownAndSingleUpCase() throws Exception {
// Get engine
DroolsCorrelationEngine engine = findEngineByName("dependencyRules");
// Anticipate down event
getAnticipator().reset();
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)"), 17));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "9876"), 17));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-Service", "123"), 17));
// Generate down event
System.err.println("SENDING VpnPwDown EVENT!!");
engine.correlate(createVpnPwDownEvent(17, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50"));
// Check down event
getAnticipator().verifyAnticipated();
// Generate additional down event - nothing should happen
getAnticipator().reset();
System.err.println("SENDING VpnPwDown EVENT!!");
engine.correlate(createVpnPwDownEvent(18, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50"));
getAnticipator().verifyAnticipated();
// Anticipate up event
getAnticipator().reset();
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)"), 17));
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "9876"), 17));
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-Service", "123"), 17));
// Generate up event
System.err.println("SENDING VpnPwUp EVENT!!");
engine.correlate(createVpnPwUpEvent(19, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50"));
// Check up event
getAnticipator().verifyAnticipated();
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class DependencyRulesIT method testTwoOutagesCase.
@Test
@DirtiesContext
public void testTwoOutagesCase() throws Exception {
// Test what happens to the parent when there are two children impacted one is resolved
// Get engine
DroolsCorrelationEngine engine = findEngineByName("dependencyRules");
// Anticipate 1st down event
getAnticipator().reset();
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)"), 17));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "8765"), 17));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-Service", "123"), 17));
// Generate down event
System.err.println("SENDING VpnPwDown EVENT!!");
engine.correlate(createVpnPwDownEvent(17, m_pe1NodeId, "10.1.1.1", "5", "ge-1/0/2.50"));
// Check down event
getAnticipator().verifyAnticipated();
// Anticipate 2nd down event
getAnticipator().reset();
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)"), 18));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "9876"), 18));
// Should we get this?
//anticipate( createComponentImpactedEvent( "Service", "CokeP2P", "NA-Service", "123", 18 ) );
// Generate another down event for the other PE
System.err.println("SENDING 2nd VpnPwDown EVENT!!");
engine.correlate(createVpnPwDownEvent(18, m_pe2NodeId, "10.1.1.2", "5", "ge-3/1/4.50"));
// Check 2nd down event
getAnticipator().verifyAnticipated();
// Anticipate up event
getAnticipator().reset();
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)"), 17));
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "8765"), 17));
// Generate up event
System.err.println("SENDING VpnPwUp EVENT!!");
engine.correlate(createVpnPwUpEvent(19, m_pe1NodeId, "10.1.1.1", "5", "ge-1/0/2.50"));
// Check up event
getAnticipator().verifyAnticipated();
// Anticipate 2nd up event
getAnticipator().reset();
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)"), 18));
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "9876"), 18));
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-Service", "123"), 18));
// Generate up event
System.err.println("SENDING VpnPwUp EVENT!!");
engine.correlate(createVpnPwUpEvent(20, m_pe2NodeId, "10.1.1.2", "5", "ge-3/1/4.50"));
// Check up event
getAnticipator().verifyAnticipated();
// Memory should be clean!
assertEquals(0, engine.getKieSessionObjects().size());
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class RuleSet method constructEngine.
public CorrelationEngine constructEngine(Resource basePath, ApplicationContext appContext, EventIpcManager eventIpcManager, MetricRegistry metricRegistry) {
final ApplicationContext configContext = new ConfigFileApplicationContext(basePath, getConfigLocation(), appContext);
final DroolsCorrelationEngine engine = new DroolsCorrelationEngine(getName(), metricRegistry);
engine.setAssertBehaviour(getAssertBehaviour());
engine.setEventProcessingMode(getEventProcessingMode());
engine.setPersistState(getPersistState());
engine.setEventIpcManager(eventIpcManager);
engine.setScheduler(new ScheduledThreadPoolExecutor(1));
engine.setInterestingEvents(getInterestingEvents());
engine.setRulesResources(getRuleResources(configContext));
engine.setGlobals(getGlobals(configContext));
try {
engine.initialize();
return engine;
} catch (final Throwable e) {
throw new RuntimeException("Unable to initialize Drools engine " + getName(), e);
}
}
Aggregations