summaryrefslogtreecommitdiffstats
path: root/controlloop/templates/template.demo/src
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/templates/template.demo/src')
-rw-r--r--controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl107
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java12
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java4
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java12
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java292
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java12
-rw-r--r--controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml2
-rw-r--r--controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_VFC.yaml24
8 files changed, 442 insertions, 23 deletions
diff --git a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
index 82899f08b..64101ac56 100644
--- a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
+++ b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
@@ -38,6 +38,7 @@ import org.onap.policy.appclcm.LCMRequest;
import org.onap.policy.appclcm.LCMResponse;
import org.onap.policy.appclcm.LCMCommonHeader;
import org.onap.policy.vfc.VFCRequest;
+import org.onap.policy.vfc.VFCResponse;
import org.onap.policy.vfc.VFCManager;
import org.onap.policy.so.SOManager;
import org.onap.policy.so.SORequest;
@@ -506,10 +507,12 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
switch ($operation.policy.getActor()){
case "APPC":
-
- if (request instanceof Request || request instanceof LCMRequestWrapper) {
- Engine.deliver("UEB", "APPC-CL", request);
- }
+ if (request instanceof Request) {
+ Engine.deliver("UEB", "APPC-CL", request);
+ }
+ else if (request instanceof LCMRequestWrapper) {
+ Engine.deliver("UEB", "APPC-LCM-READ", request);
+ }
break;
case "SO":
// at this point the AAI named query request should have already been made, the response recieved and used
@@ -521,12 +524,12 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
}
break;
case "VFC":
- if (request instanceof VFCRequest) {
- // Start VFC thread
- Thread t = new Thread(new VFCManager((VFCRequest)request));
- t.start();
- }
- break;
+ if (request instanceof VFCRequest) {
+ // Start VFC thread
+ Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request));
+ t.start();
+ }
+ break;
}
} else {
//
@@ -589,7 +592,6 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
if(guardEnabled){
Thread t = new Thread(new org.onap.policy.guard.CallGuardTask(
- XacmlPdpEngine,
"",
drools.getWorkingMemory(),
$event.closedLoopControlName,
@@ -636,7 +638,7 @@ rule "${policyName}.GUARD.RESPONSE"
//we will permit the operation if there was no Guard for it
- if($guardResponse.result == "Indeterminate"){
+ if("Indeterminate".equals($guardResponse.result)){
$guardResponse.result = "Permit";
}
@@ -655,7 +657,7 @@ rule "${policyName}.GUARD.RESPONSE"
- if($guardResponse.result == "Permit"){
+ if("Permit".equals($guardResponse.result)){
modify($operation){setGuardApprovalStatus($guardResponse.result)};
}
@@ -1005,6 +1007,85 @@ end
/*
*
+* This rule responds to VFC Response Events
+*
+*/
+rule "${policyName}.VFC.RESPONSE"
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID )
+ $opTimer : OperationTimer( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID.toString() )
+ $lock : TargetLock (requestID == $event.requestID)
+ $response : VFCResponse( requestId.toString() == $event.requestID.toString() )
+ then
+ //
+ // Logging
+ Logger.info("------------------------------------------------------------------------------------------------");
+ Logger.metrics(Instant.now() + " " + drools.getRule().getName() + " " + drools.getRule().getPackage());
+ Logger.metrics($params);
+ Logger.metrics($event);
+ Logger.metrics($manager);
+ Logger.metrics($operation);
+ Logger.metrics($opTimer);
+ Logger.metrics($lock);
+ Logger.metrics($response);
+ // Get the result of the operation
+ //
+ PolicyResult policyResult = $operation.onResponse($response);
+ if (policyResult != null) {
+ //
+ // This Operation has completed, construct a notification showing our results
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.from = "policy";
+ notification.policyName = drools.getRule().getName();
+ notification.policyScope = "${policyScope}";
+ notification.policyVersion = "${policyVersion}";
+ notification.message = $operation.getOperationHistory();
+ notification.history = $operation.getHistory();
+ //
+ // Ensure the operation is complete
+ //
+ if ($operation.isOperationComplete() == true) {
+ //
+ // It is complete, remove it from memory
+ //
+ retract($operation);
+ //
+ // We must also retract the timer object
+ // NOTE: We could write a Rule to do this
+ //
+ retract($opTimer);
+ //
+ // Complete the operation
+ //
+ modify($manager) {finishOperation($operation)};
+ } else {
+ //
+ // Just doing this will kick off the LOCKED rule again
+ //
+ modify($operation) {};
+ }
+ } else {
+ //
+ // Its not finished yet (i.e. expecting more Response objects)
+ //
+ // Or possibly it is a leftover response that we timed the request out previously
+ //
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ retract($response);
+
+end
+
+
+
+/*
+*
* This is the timer that manages the timeout for an individual operation.
*
*/
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java
index 64ad490b2..02066d66a 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java
@@ -47,6 +47,7 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.TargetType;
+import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
import org.onap.policy.guard.PolicyGuard;
@@ -75,6 +76,7 @@ public class ControlLoopXacmlGuardTest {
@BeforeClass
public static void setPUProp(){
System.setProperty(OPSHISTPUPROP, "TestOperationsHistoryPU");
+ PolicyEngine.manager.setEnvironmentProperty("guard.url", "http://127.0.0.1:8443/pdp");
}
@AfterClass
public static void restorePUProp(){
@@ -171,7 +173,7 @@ public class ControlLoopXacmlGuardTest {
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
- Thread.sleep(4000);
+ Thread.sleep(2*4000);
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
@@ -210,7 +212,7 @@ public class ControlLoopXacmlGuardTest {
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
- Thread.sleep(4000);
+ Thread.sleep(2*4000);
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
@@ -238,9 +240,9 @@ public class ControlLoopXacmlGuardTest {
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
- Thread.sleep(1000);
+ Thread.sleep(2*1000);
- obj = engine.subscribe("UEB", "APPC-CL");
+ obj = engine.subscribe("UEB", "APPC-LCM-READ");
assertNotNull(obj);
assertTrue(obj instanceof LCMRequestWrapper);
LCMRequestWrapper dmaapRequest = (LCMRequestWrapper) obj;
@@ -277,7 +279,7 @@ public class ControlLoopXacmlGuardTest {
//
// now wait for it to finish
//
- Thread.sleep(15000);
+ Thread.sleep(2*15000);
//
// Ensure they released the lock
//
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
index 182e39828..878c6e8c1 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
@@ -195,7 +195,7 @@ public class VCPEControlLoopTest {
/*
* Obtain the request sent from the Policy Engine
*/
- obj = engine.subscribe("UEB", "APPC-CL");
+ obj = engine.subscribe("UEB", "APPC-LCM-READ");
assertNotNull(obj);
/*
@@ -235,7 +235,7 @@ public class VCPEControlLoopTest {
* Give time for processing
*/
try {
- Thread.sleep(4000);
+ Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
logger.debug("An interrupt Exception was thrown");
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
index 9608f7cf0..419ab63a0 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java
@@ -46,6 +46,7 @@ import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
+import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.guard.PolicyGuard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,6 +59,17 @@ public class VDNSControlLoopTest {
private Util.Pair<ControlLoopPolicy, String> pair;
private PolicyEngineJUnitImpl engine;
+ static {
+ /* Set environment properties */
+ PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
+ PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI");
+ PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
+
+ PolicyEngine.manager.setEnvironmentProperty("so.url", "http://localhost:6667");
+ PolicyEngine.manager.setEnvironmentProperty("so.username", "SO");
+ PolicyEngine.manager.setEnvironmentProperty("so.password", "SO");
+ }
+
@BeforeClass
public static void setUpSimulator() {
try {
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
new file mode 100644
index 000000000..d5b6e4421
--- /dev/null
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java
@@ -0,0 +1,292 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * demo
+ * ================================================================================
+ * Copyright (C) 2017 Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.template.demo;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.kie.api.KieServices;
+import org.kie.api.builder.KieBuilder;
+import org.kie.api.builder.KieFileSystem;
+import org.kie.api.builder.Message;
+import org.kie.api.builder.ReleaseId;
+import org.kie.api.builder.Results;
+import org.kie.api.builder.model.KieModuleModel;
+import org.kie.api.runtime.KieContainer;
+import org.kie.api.runtime.KieSession;
+import org.kie.api.runtime.rule.FactHandle;
+import org.onap.policy.controlloop.ControlLoopEventStatus;
+import org.onap.policy.controlloop.ControlLoopLogger;
+import org.onap.policy.controlloop.ControlLoopTargetType;
+import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.controlloop.impl.ControlLoopLoggerStdOutImpl;
+import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.drools.http.server.HttpServletServer;
+import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
+import org.onap.policy.vfc.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class VFCControlLoopTest {
+
+ private static final Logger log = LoggerFactory.getLogger(VFCControlLoopTest.class);
+ private KieSession kieSession;
+ private Util.Pair<ControlLoopPolicy, String> pair;
+ private PolicyEngineJUnitImpl engine;
+
+ @BeforeClass
+ public static void setUpSimulator() {
+ try {
+ Util.buildAaiSim();
+ Util.buildVfcSim();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
+
+ @Test
+ public void testVolte() throws IOException {
+
+ final String yaml = "src/test/resources/yaml/policy_ControlLoop_VFC.yaml";
+
+ //
+ // Pull info from the yaml
+ //
+ final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml(yaml);
+ assertNotNull(pair);
+ assertNotNull(pair.a);
+ assertNotNull(pair.a.getControlLoop());
+ assertNotNull(pair.a.getControlLoop().getControlLoopName());
+ assertTrue(pair.a.getControlLoop().getControlLoopName().length() > 0);
+ final String closedLoopControlName = pair.a.getControlLoop().getControlLoopName();
+
+ /*
+ * Start the kie session
+ */
+ try {
+ kieSession = startSession("src/main/resources/ControlLoop_Template_xacml_guard.drl",
+ "src/test/resources/yaml/policy_ControlLoop_VFC.yaml",
+ "service=ServiceTest;resource=ResourceTest;type=operational",
+ "CL_VFC",
+ "org.onap.closed_loop.ServiceTest:VNFS:1.0.0");
+ } catch (IOException e) {
+ e.printStackTrace();
+ log.debug("Could not create kieSession");
+ fail("Could not create kieSession");
+ }
+
+
+ //
+ // Insert our globals
+ //
+ final ControlLoopLogger logger = new ControlLoopLoggerStdOutImpl();
+ kieSession.setGlobal("Logger", logger);
+ final PolicyEngineJUnitImpl engine = new PolicyEngineJUnitImpl();
+ kieSession.setGlobal("Engine", engine);
+
+ //
+ // Initial fire of rules
+ //
+ kieSession.fireAllRules();
+ //
+ // Kick a thread that starts testing
+ //
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+
+ log.debug("\n************ Starting VoLTE Test *************\n");
+
+ //
+ // Generate an invalid DCAE Event with requestID=null
+ //
+ VirtualControlLoopEvent invalidEvent = new VirtualControlLoopEvent();
+ invalidEvent.closedLoopControlName = closedLoopControlName;
+ invalidEvent.requestID = null;
+ invalidEvent.closedLoopEventClient = "tca.instance00009";
+ invalidEvent.target_type = ControlLoopTargetType.VNF;
+ invalidEvent.target = "generic-vnf.vnf-id";
+ invalidEvent.from = "DCAE";
+ invalidEvent.closedLoopAlarmStart = Instant.now();
+ invalidEvent.AAI = new HashMap<String, String>();
+ invalidEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+ invalidEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ log.debug("-------- Sending Invalid ONSET --------");
+ log.debug(Serialization.gsonPretty.toJson(invalidEvent));
+
+ //
+ // Insert invalid DCAE Event into memory
+ //
+ kieSession.insert(invalidEvent);
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ }
+ //
+ // Generate first DCAE ONSET Event
+ //
+ VirtualControlLoopEvent onsetEvent = new VirtualControlLoopEvent();
+ onsetEvent.closedLoopControlName = closedLoopControlName;
+ onsetEvent.requestID = UUID.randomUUID();
+ onsetEvent.closedLoopEventClient = "tca.instance00009";
+ onsetEvent.target_type = ControlLoopTargetType.VM;
+ onsetEvent.target = "VM_NAME";
+ onsetEvent.from = "DCAE";
+ onsetEvent.closedLoopAlarmStart = Instant.now();
+ onsetEvent.AAI = new HashMap<String, String>();
+ onsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
+ onsetEvent.AAI.put("vserver.vserver-id", "vserver-id-16102016-aai3255-data-11-1");
+ onsetEvent.AAI.put("generic-vnf.vnf-id", "vnf-id-16102016-aai3255-data-11-1");
+ onsetEvent.AAI.put("service-instance.service-instance-id", "service-instance-id-16102016-aai3255-data-11-1");
+ onsetEvent.AAI.put("vserver.is-closed-loop-disabled", "false");
+ onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
+
+ log.debug("-------- Sending Valid ONSET --------");
+ log.debug(Serialization.gsonPretty.toJson(onsetEvent));
+
+ //
+ // Insert first DCAE ONSET Event into memory
+ //
+ kieSession.insert(onsetEvent);
+ //
+ // We have test for subsequent ONSET Events in testvFirewall()
+ // So no need to test it again here
+ //
+ try {
+ Thread.sleep(30000);
+ } catch (InterruptedException e) {
+ }
+ //
+ // Test is finished, so stop the kieSession
+ //
+ kieSession.halt();
+ }
+ //
+ }).start();
+ //
+ // Start firing rules
+ //
+ kieSession.fireUntilHalt();
+ //
+ // Dump working memory
+ //
+ dumpFacts(kieSession);
+
+ //
+ // See if there is anything left in memory, there SHOULD only be
+ // a params fact.
+ //
+ assertEquals("There should only be 1 Fact left in memory.", 1, kieSession.getFactCount());
+ for (FactHandle handle : kieSession.getFactHandles()) {
+ Object fact = kieSession.getObject(handle);
+ assertEquals("Non-Param Fact left in working memory", "org.onap.policy.controlloop.Params", fact.getClass().getName());
+ }
+
+ }
+
+ public static void dumpFacts(KieSession kieSession) {
+ log.debug("Fact Count: " + kieSession.getFactCount());
+ for (FactHandle handle : kieSession.getFactHandles()) {
+ log.debug("FACT: " + handle);
+ }
+ }
+
+ /**
+ * This method will start a kie session and instantiate
+ * the Policy Engine.
+ *
+ * @param droolsTemplate
+ * the DRL rules file
+ * @param yamlFile
+ * the yaml file containing the policies
+ * @param policyScope
+ * scope for policy
+ * @param policyName
+ * name of the policy
+ * @param policyVersion
+ * version of the policy
+ * @return the kieSession to be used to insert facts
+ * @throws IOException
+ */
+ private KieSession startSession(String droolsTemplate,
+ String yamlFile,
+ String policyScope,
+ String policyName,
+ String policyVersion) throws IOException {
+
+ /*
+ * Load policies from yaml
+ */
+ pair = Util.loadYaml(yamlFile);
+ assertNotNull(pair);
+ assertNotNull(pair.a);
+ assertNotNull(pair.a.getControlLoop());
+ assertNotNull(pair.a.getControlLoop().getControlLoopName());
+ assertTrue(pair.a.getControlLoop().getControlLoopName().length() > 0);
+
+ /*
+ * Construct a kie session
+ */
+ final KieSession kieSession = Util.buildContainer(droolsTemplate,
+ pair.a.getControlLoop().getControlLoopName(),
+ policyScope,
+ policyName,
+ policyVersion,
+ URLEncoder.encode(pair.b, "UTF-8"));
+
+ /*
+ * Retrieve the Policy Engine
+ */
+ engine = (PolicyEngineJUnitImpl) kieSession.getGlobal("Engine");
+
+ log.debug("============");
+ log.debug(URLEncoder.encode(pair.b, "UTF-8"));
+ log.debug("============");
+
+ return kieSession;
+ }
+
+}
+
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
index a19d9267c..453354dba 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
@@ -44,6 +44,7 @@ import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
+import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.guard.PolicyGuard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,7 +55,14 @@ public class VFWControlLoopTest {
private KieSession kieSession;
private Util.Pair<ControlLoopPolicy, String> pair;
- private PolicyEngineJUnitImpl engine;
+ private PolicyEngineJUnitImpl engine;
+
+ static {
+ /* 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() {
@@ -240,7 +248,7 @@ public class VFWControlLoopTest {
*/
Response appcResponse = new Response((Request)obj);
appcResponse.getStatus().Code = ResponseCode.SUCCESS.getValue();
- appcResponse.getStatus().Description = "AppC success";
+ appcResponse.getStatus().Value = "SUCCESS";
kieSession.insert(appcResponse);
/*
diff --git a/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml b/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml
index c3740d0b2..820874105 100644
--- a/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml
+++ b/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml
@@ -14,7 +14,7 @@
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test" />
<property name="javax.persistence.jdbc.user" value="sa" />
<property name="javax.persistence.jdbc.password" value="" />
- <property name="eclipselink.logging.level" value="ALL" />
+ <property name="eclipselink.logging.level" value="CONFIG" />
</properties>
</persistence-unit>
diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_VFC.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_VFC.yaml
new file mode 100644
index 000000000..00cced484
--- /dev/null
+++ b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_VFC.yaml
@@ -0,0 +1,24 @@
+controlLoop:
+ version: 2.0.0
+ controlLoopName: ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b
+
+ trigger_policy: unique-policy-id-1-restart
+ timeout: 3600
+
+policies:
+ - id: unique-policy-id-1-restart
+ name: Restart the VM
+ description:
+ actor: VFC
+ recipe: Restart
+ target:
+ type: VM
+ retry: 3
+ timeout: 1200
+ success: final_success
+ failure: final_failure
+ failure_timeout: final_failure_timeout
+ failure_retries: final_failure_retries
+ failure_exception: final_failure_exception
+ failure_guard: final_failure_guard
+