use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine 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();
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine 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();
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine 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();
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class EventMappingRulesIT method testEventMapping.
private void testEventMapping(Event event, 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("expected " + eventObj + " to be an instance of " + componentEventClass, 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());
}
use of org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine in project opennms by OpenNMS.
the class EventMappingRulesIT method testNodeEventMapping.
private void testNodeEventMapping(Event event, Class<? extends ComponentEvent> componentEventClass, Set<String> componentIds) {
// 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();
// expect an ComponentX event for each component
assertEquals("Unexpected number of events added to memory " + memObjects, componentIds.size(), memObjects.size());
Set<String> remainingIds = new HashSet<String>(componentIds);
for (Object eventObj : memObjects) {
assertTrue("expected " + eventObj + " to be an instance of " + componentEventClass, componentEventClass.isInstance(eventObj));
assertTrue(eventObj instanceof ComponentEvent);
ComponentEvent c = (ComponentEvent) eventObj;
assertSame(event, c.getEvent());
Component component = c.getComponent();
String id = component.getForeignSource() + ":" + component.getForeignId();
assertTrue("Expected an event for component " + id, remainingIds.remove(id));
}
}
Aggregations