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();
}
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();
}
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();
}
use of org.springframework.test.annotation.DirtiesContext 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<>();
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.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.
the class EventMappingRulesIT method testDupPwDown.
@Test
// @Ignore( "Not ready for this yet")
@DirtiesContext
public void testDupPwDown() throws Exception {
Event event = createVpnPwDownEvent(17, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
Event event2 = createVpnPwDownEvent(18, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
testEventDup(event, event2, ComponentDownEvent.class, "ServiceElementComponent", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)");
}
Aggregations