From 1480d327ff8559c1d912108f7d3353fed03fcd2c Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 24 Oct 2017 06:33:31 -0500 Subject: Change vnf-id to vnf-name These changes now allow a lookup of the source vnf-id based on the onset's vnf-name. Issue-Id: POLICY-366 Change-Id: I6f6bd500b892dddbbb9e12156b4486208309e21d Signed-off-by: Daniel Cruz --- controlloop/common/eventmanager/pom.xml | 6 +++ .../eventmanager/ControlLoopOperationManager.java | 6 ++- .../ControlLoopOperationManagerTest.java | 44 +++++++++++++++++++--- 3 files changed, 49 insertions(+), 7 deletions(-) (limited to 'controlloop/common/eventmanager') diff --git a/controlloop/common/eventmanager/pom.xml b/controlloop/common/eventmanager/pom.xml index 57de25576..7479f65ee 100644 --- a/controlloop/common/eventmanager/pom.xml +++ b/controlloop/common/eventmanager/pom.xml @@ -167,5 +167,11 @@ ${project.version} test + + org.onap.policy.drools-applications + simulators + 1.1.0-SNAPSHOT + test + diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index 1127bce3b..eeb724ad2 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -209,10 +209,12 @@ public class ControlLoopOperationManager implements Serializable { this.currentOperation = operation; if ("ModifyConfig".equalsIgnoreCase(policy.getRecipe())) { - this.operationRequest = APPCActorServiceProvider.constructRequest((VirtualControlLoopEvent)onset, operation.operation, this.policy); + this.operationRequest = APPCActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, + operation.operation, this.policy, eventManager.getVnfResponse()); } else { - this.operationRequest = AppcLcmActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, operation.operation, this.policy); + this.operationRequest = AppcLcmActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, + operation.operation, this.policy, eventManager.getVnfResponse()); } // // Save the operation diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java index c5c0bc967..caa17ff38 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java @@ -29,6 +29,8 @@ import java.time.Instant; import java.util.HashMap; import java.util.UUID; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.AAIException; import org.onap.policy.appclcm.LCMRequest; @@ -42,6 +44,8 @@ import org.onap.policy.controlloop.Util; import org.onap.policy.controlloop.policy.ControlLoopPolicy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.controlloop.processor.ControlLoopProcessor; +import org.onap.policy.drools.http.server.HttpServletServer; +import org.onap.policy.drools.system.PolicyEngine; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,16 +55,32 @@ public class ControlLoopOperationManagerTest { static { onset = new VirtualControlLoopEvent(); onset.requestID = UUID.randomUUID(); - onset.target = "vserver.selflink"; + onset.target = "generic-vnf.vnf-name"; onset.closedLoopAlarmStart = Instant.now(); onset.AAI = new HashMap<>(); - onset.AAI.put("cloud-region.identity-url", "foo"); - onset.AAI.put("vserver.selflink", "bar"); - onset.AAI.put("vserver.is-closed-loop-disabled", "false"); onset.AAI.put("generic-vnf.vnf-name", "testTriggerSource"); onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET; + + /* Set environment properties */ + PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); + PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); + PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); } + @BeforeClass + public static void setUpSimulator() { + try { + org.onap.policy.simulators.Util.buildAaiSim(); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @AfterClass + public static void tearDownSimulator() { + HttpServletServer.factory.destroy(); + } + @Test public void testRetriesFail() { // @@ -77,7 +97,14 @@ public class ControlLoopOperationManagerTest { // create the manager // ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID); - + try { + eventManager.checkEventSyntax(onset); + } + catch (ControlLoopException e) { + logger.warn(e.toString()); + fail("The onset failed the syntax check"); + } + ControlLoopOperationManager manager = new ControlLoopOperationManager(onset, processor.getCurrentPolicy(), eventManager); logger.debug("{}",manager); // @@ -192,6 +219,13 @@ public class ControlLoopOperationManagerTest { // create the manager // ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID); + try { + eventManager.checkEventSyntax(onset); + } + catch (ControlLoopException e) { + logger.warn(e.toString()); + fail("The onset failed the syntax check"); + } ControlLoopOperationManager manager = new ControlLoopOperationManager(onset, processor.getCurrentPolicy(), eventManager); // -- cgit 1.2.3-korg