use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class EventMappingRulesIT method testEventDup.
private void testEventDup(Event event, Event event2, Class<? extends ComponentEvent> componentEventClass, String componentType, String componentForeignSource, String componentForeignId) {
// Get engine
DroolsCorrelationEngine engine = findEngineByName("eventMappingRules");
assertEquals("Expected nothing but got " + engine.getKieSessionObjects(), 0, engine.getKieSessionObjects().size());
engine.correlate(event);
Collection<? extends Object> memObjects = engine.getKieSessionObjects();
assertEquals("Unexpected size of workingMemory " + memObjects, 1, memObjects.size());
Object eventObj = Iterables.getFirst(memObjects, null);
assertTrue(componentEventClass.isInstance(eventObj));
assertTrue(eventObj instanceof ComponentEvent);
ComponentEvent c = (ComponentEvent) eventObj;
assertSame(event, c.getEvent());
Component component = c.getComponent();
assertEquals(componentType, component.getType());
assertEquals(componentForeignSource, component.getForeignSource());
assertEquals(componentForeignId, component.getForeignId());
// Adding a copy of the event should not add to working memory
engine.correlate(event2);
memObjects = engine.getKieSessionObjects();
assertEquals("Unexpected size of workingMemory " + memObjects, 1, memObjects.size());
eventObj = Iterables.getFirst(memObjects, null);
assertTrue(componentEventClass.isInstance(eventObj));
assertTrue(eventObj instanceof ComponentEvent);
c = (ComponentEvent) eventObj;
assertSame(event, c.getEvent());
component = c.getComponent();
assertEquals(componentType, component.getType());
assertEquals(componentForeignSource, component.getForeignSource());
assertEquals(componentForeignId, component.getForeignId());
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class DependencyRulesIT method testNodeDownUpCase.
@Test
@DirtiesContext
public void testNodeDownUpCase() throws Exception {
// Get engine
DroolsCorrelationEngine engine = findEngineByName("dependencyRules");
// Antecipate down event
getAnticipator().reset();
Set<NCSComponent> impactedByNodeDown = new LinkedHashSet<NCSComponent>();
for (NCSComponent c : findSubcomponentsOnNode(m_svc, "space", "1111-PE1")) {
impactedByNodeDown.addAll(findPathToSubcomponent(m_svc, c.getForeignSource(), c.getForeignId()));
}
impactedByNodeDown = uniq(impactedByNodeDown);
anticipate(transform(impactedByNodeDown, toComponentImpactedEvent(17)));
// Generate down event
System.err.println("SENDING nodeDown EVENT!!");
engine.correlate(createNodeDownEvent(17, m_pe1NodeId));
// Check down event
getAnticipator().verifyAnticipated();
// Anticipate up event
getAnticipator().reset();
anticipate(transform(impactedByNodeDown, toComponentResolvedEvent(19)));
// Generate up event
System.err.println("SENDING nodeUpEvent EVENT!!");
engine.correlate(createNodeUpEvent(19, m_pe1NodeId));
// Check up event
getAnticipator().verifyAnticipated();
// Memory should be clean!
assertEquals("Unexpected objects in memory" + engine.getKieSessionObjects(), 0, engine.getKieSessionObjects().size());
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class DependencyRulesIT method testDependencyAnyRules.
@Test
@DirtiesContext
@Ignore("Non Deterministic!!!")
public void testDependencyAnyRules() throws Exception {
// Get engine
DroolsCorrelationEngine engine = findEngineByName("dependencyRules");
// Anticipate component lspA down event
getAnticipator().reset();
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,lspA-PE1-PE2"), 17));
// Generate down event
System.err.println("SENDING MplsLspPathDown on LspA EVENT!!");
engine.correlate(createMplsLspPathDownEvent(17, m_pe1NodeId, "10.1.1.1", "lspA-PE1-PE2"));
// Check lspA component impacted
getAnticipator().verifyAnticipated();
// Anticipate component lspB down event
// Parent should go down too
getAnticipator().reset();
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,lspB-PE1-PE2"), 18));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,jnxVpnPw-vcid(50)"), 18));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-ServiceElement", "8765"), 18));
anticipate(createComponentImpactedEvent(findSubcomponent(m_svc, "NA-Service", "123"), 18));
// Generate down event
System.err.println("SENDING MplsLspPathDown on LspB EVENT!!");
engine.correlate(createMplsLspPathDownEvent(18, m_pe1NodeId, "10.1.1.1", "lspB-PE1-PE2"));
// verify components were impacted
getAnticipator().verifyAnticipated();
// Anticipate impacted resolved when we send up event
getAnticipator().reset();
anticipate(createComponentResolvedEvent(findSubcomponent(m_svc, "NA-SvcElemComp", "8765,lspA-PE1-PE2"), 18));
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 MplsLspPathUp on LspA EVENT!!");
engine.correlate(createMplsLspPathUpEvent(19, m_pe1NodeId, "10.1.1.1", "lspA-PE1-PE2"));
// verify components are resolved
getAnticipator().verifyAnticipated();
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class DependencyRulesIT method testTwoCauseDownUpCase.
@Test
@DirtiesContext
public void testTwoCauseDownUpCase() throws Exception {
// Get engine
DroolsCorrelationEngine engine = findEngineByName("dependencyRules");
// Antecipate down event
getAnticipator().reset();
anticipate(transform(findPathToSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)"), toComponentImpactedEvent(17)));
// Generate down event
System.err.println("SENDING VpnPwDown EVENT!!");
// "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)"
engine.correlate(createVpnPwDownEvent(17, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50"));
// Check down event
getAnticipator().verifyAnticipated();
getAnticipator().reset();
// Second outage
anticipate(transform(singleton(findSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnIf")), toComponentImpactedEvent(18)));
System.err.println("SENDING VpnIfDown EVENT!!");
engine.correlate(createVpnIfDownEvent(18, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50"));
getAnticipator().verifyAnticipated();
getAnticipator().reset();
// expect only the resolved subelement to come back up
anticipate(transform(singleton(findSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)")), toComponentResolvedEvent(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();
getAnticipator().reset();
anticipate(transform(findPathToSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnIf"), toComponentResolvedEvent(18)));
System.err.println("SENDING VpnIfUp EVENT!!");
engine.correlate(createVpnIfUpEvent(20, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50"));
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 testSimpleDownUpCase.
@Test
@DirtiesContext
public void testSimpleDownUpCase() throws Exception {
// Get engine
DroolsCorrelationEngine engine = findEngineByName("dependencyRules");
// Antecipate down event
getAnticipator().reset();
anticipate(transform(findPathToSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)"), toComponentImpactedEvent(17)));
// Generate down event
System.err.println("SENDING VpnPwDown EVENT!!");
// "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)"
engine.correlate(createVpnPwDownEvent(17, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50"));
// Check down event
getAnticipator().verifyAnticipated();
// Anticipate up event
getAnticipator().reset();
anticipate(transform(findPathToSubcomponent(m_svc, "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)"), toComponentResolvedEvent(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();
// Memory should be clean!
assertEquals(0, engine.getKieSessionObjects().size());
}
Aggregations