summaryrefslogtreecommitdiffstats
path: root/controlloop/templates/template.demo.clc/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/templates/template.demo.clc/src/test')
-rw-r--r--controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopCoordinationTest.java554
-rw-r--r--controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopEventCleanupTest.java374
-rw-r--r--controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopParamsCleanupTest.java231
-rw-r--r--controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/SupportUtil.java435
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/META-INF/persistence.xml43
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/coordination/synthetic_control_loop_one_blocks_synthetic_control_loop_two.yaml20
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/properties/prototype/xacml_guard_clc.properties47
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml41
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml41
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml45
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml35
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml35
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml39
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_SyntheticOne.yaml43
-rw-r--r--controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_SyntheticTwo.yaml43
15 files changed, 0 insertions, 2026 deletions
diff --git a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopCoordinationTest.java b/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopCoordinationTest.java
deleted file mode 100644
index ee5eceba9..000000000
--- a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopCoordinationTest.java
+++ /dev/null
@@ -1,554 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * demo
- * ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. 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.clc;
-
-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 com.google.gson.Gson;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.lang.StringBuilder;
-import java.net.URLEncoder;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.time.Instant;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
-import java.util.UUID;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
-
-import org.onap.policy.appclcm.LcmRequest;
-import org.onap.policy.appclcm.LcmRequestWrapper;
-import org.onap.policy.appclcm.LcmResponse;
-import org.onap.policy.appclcm.LcmResponseWrapper;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
-import org.onap.policy.common.endpoints.event.comm.TopicListener;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
-import org.onap.policy.controlloop.ControlLoopEventStatus;
-import org.onap.policy.controlloop.ControlLoopNotificationType;
-import org.onap.policy.controlloop.ControlLoopTargetType;
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
-import org.onap.policy.controlloop.VirtualControlLoopNotification;
-import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.coordination.CoordinationDirective;
-import org.onap.policy.coordination.Util;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ControlLoopCoordinationTest implements TopicListener {
-
- private static final Logger logger = LoggerFactory.getLogger(ControlLoopCoordinationTest.class);
-
- private static List<? extends TopicSink> noopTopics;
-
- private static KieSession kieSession1;
- private static KieSession kieSession2;
- private static StringBuilder controlLoopOneName = new StringBuilder();
- private static StringBuilder controlLoopTwoName = new StringBuilder();
- private static String expectedDecision;
-
- static {
- /* Set environment properties */
- SupportUtil.setAaiProps();
- SupportUtil.setGuardPropsEmbedded();
- SupportUtil.setPuProp();
- }
-
- /**
- * Setup simulator.
- *
- * @throws IOException when thrown by buildAaiSim
- */
- @BeforeClass
- public static void setUpSimulator() throws Exception {
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-LCM-READ,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events", "org.onap.policy.appclcm.LcmRequestWrapper");
- noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events.custom.gson",
- "org.onap.policy.appclcm.util.Serialization,gson");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("APPC-LCM-READ")
- .eventClass("org.onap.policy.appclcm.LcmRequestWrapper")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- SupportUtil.buildAaiSim();
- /*
- * Apply the coordination directive
- */
- final String coordinationDir = "src/test/resources/coordination";
- final String coordinationProtoDir = "src/main/resources/coordination/prototype";
- final String coordinationDirectiveName = "synthetic_control_loop_one_blocks_synthetic_control_loop_two";
- final String propertiesDir = "src/test/resources/properties";
- final String propertiesProtoDir = "src/test/resources/properties/prototype";
- final String xacmlDir = "src/test/resources/xacml";
- final String yamlDir = "src/test/resources/yaml";
-
- String coordinationDirectiveFile = coordinationDir + File.separator + coordinationDirectiveName + ".yaml";
- /*
- * Load the coordination directive from the Yaml encoding
- */
- CoordinationDirective cd = Util.loadCoordinationDirectiveFromFile(coordinationDirectiveFile);
- logger.info("CoordinationDirective={}", cd.toString());
- /*
- * Generate the Xacml policy from the coordination directive
- */
- String xacmlPolicy = Util.generateXacmlFromCoordinationDirective(cd, coordinationProtoDir);
- /*
- * Create directory for Xacml output file, if necessary
- */
- Files.createDirectories(Paths.get(xacmlDir));
- /*
- * Write Xacml policy to file
- */
- String xacmlFilename = xacmlDir + File.separator
- + cd.getCoordinationFunction()
- + cd.getControlLoop(0)
- + cd.getControlLoop(1)
- + ".xml";
- File xacmlFile = new File(xacmlFilename);
- PrintWriter xacmlFileWriter = new PrintWriter(xacmlFile);
- xacmlFileWriter.println(xacmlPolicy);
- xacmlFileWriter.flush();
- /*
- * Remove Xacml file after test
- */
- xacmlFile.deleteOnExit();
- /*
- * Insert the Xacml policy file into the PDP
- */
- SupportUtil.insertXacmlPolicy(xacmlFilename, propertiesProtoDir, propertiesDir);
- /*
- * Start the kie sessions
- */
- kieSession1 = startSession(
- controlLoopOneName,
- "src/main/resources/__closedLoopControlName__.drl",
- yamlDir + "/policy_ControlLoop_SyntheticOne.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational",
- "SyntheticControlLoopOnePolicy",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
- kieSession2 = startSession(
- controlLoopTwoName,
- "src/main/resources/__closedLoopControlName__.drl",
- yamlDir + "/policy_ControlLoop_SyntheticTwo.yaml",
- "service=ServiceDemo;resource=Res1Demo;type=operational",
- "SyntheticControlLoopTwoPolicy",
- "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0");
- }
-
- /**
- * Tear down simulator.
- */
- @AfterClass
- public static void tearDownSimulator() {
- /*
- * Gracefully shut down the kie session
- */
- kieSession1.dispose();
- kieSession2.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
- PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
- }
-
- /**
- * Set expected decision.
- *
- * @param ed the expected decision ("PERMIT" or "DENY")
- */
- public void expectedDecisionIs(String ed) {
- expectedDecision = ed;
- logger.info("Expected decision is {}", ed);
- }
-
- /**
- * This method is used to simulate event messages from DCAE
- * that start the control loop (onset message) or end the
- * control loop (abatement message).
- *
- * @param controlLoopName the control loop name
- * @param requestId the requestId for this event
- * @param status could be onset or abated
- * @param target the target name
- * @param kieSession the kieSession to which this event is being sent
- */
- protected void sendEvent(String controlLoopName,
- UUID requestId,
- ControlLoopEventStatus status,
- String target,
- KieSession kieSession) {
- logger.debug("sendEvent controlLoopName={}", controlLoopName);
- VirtualControlLoopEvent event = new VirtualControlLoopEvent();
- event.setClosedLoopControlName(controlLoopName);
- event.setRequestId(requestId);
- event.setTarget("generic-vnf.vnf-name");
- event.setTargetType(ControlLoopTargetType.VNF);
- event.setClosedLoopAlarmStart(Instant.now());
- event.setAai(new HashMap<>());
- event.getAai().put("generic-vnf.vnf-name", target);
- event.setClosedLoopEventStatus(status);
-
- Gson gson = new Gson();
- String json = gson.toJson(event);
- logger.debug("sendEvent {}", json);
-
- kieSession.insert(event);
- }
-
-
- /**
- * Simulate an event by inserting into kieSession and firing rules as needed.
- *
- * @param cles the ControlLoopEventStatus
- * @param rid the request ID
- * @param controlLoopName the control loop name
- * @param kieSession the kieSession to which this event is being sent
- * @param expectedDecision the expected decision
- */
- protected void simulateEvent(ControlLoopEventStatus cles,
- UUID rid,
- String controlLoopName,
- String target,
- KieSession kieSession,
- String expectedDecision) {
- //
- // if onset, set expected decision
- //
- if (cles == ControlLoopEventStatus.ONSET) {
- expectedDecisionIs(expectedDecision);
- }
- //
- // simulate sending event
- //
- sendEvent(controlLoopName, rid, cles, target, kieSession);
- kieSession.fireUntilHalt();
- //
- // get dump of database entries and log
- //
- List<?> entries = SupportUtil.dumpDb();
- assertNotNull(entries);
- logger.debug("dumpDB, {} entries", entries.size());
- for (Object entry : entries) {
- logger.debug("{}", entry);
- }
- //
- // we are done
- //
- logger.info("simulateEvent: done");
- }
-
- /**
- * Simulate an onset event.
- *
- * @param rid the request ID
- * @param controlLoopName the control loop name
- * @param kieSession the kieSession to which this event is being sent
- * @param expectedDecision the expected decision
- */
- public void simulateOnset(UUID rid,
- String controlLoopName,
- String target,
- KieSession kieSession,
- String expectedDecision) {
- simulateEvent(ControlLoopEventStatus.ONSET, rid, controlLoopName, target, kieSession, expectedDecision);
- }
-
- /**
- * Simulate an abated event.
- *
- * @param rid the request ID
- * @param controlLoopName the control loop name
- * @param kieSession the kieSession to which this event is being sent
- */
- public void simulateAbatement(UUID rid,
- String controlLoopName,
- String target,
- KieSession kieSession) {
- simulateEvent(ControlLoopEventStatus.ABATED, rid, controlLoopName, target, kieSession, null);
- }
-
- /**
- * 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 throws IO exception
- */
- private static KieSession startSession(StringBuilder controlLoopName,
- String droolsTemplate,
- String yamlFile,
- String policyScope,
- String policyName,
- String policyVersion) throws IOException {
-
- /*
- * Load policies from yaml
- */
- SupportUtil.Pair<ControlLoopPolicy, String> pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(!pair.first.getControlLoop().getControlLoopName().isEmpty());
-
- controlLoopName.append(pair.first.getControlLoop().getControlLoopName());
- String yamlContents = pair.second;
-
- /*
- * Construct a kie session
- */
- final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate,
- controlLoopName.toString(),
- policyScope,
- policyName,
- policyVersion,
- URLEncoder.encode(yamlContents, "UTF-8"));
-
- /*
- * Retrieve the Policy Engine
- */
-
- logger.debug("============");
- logger.debug(URLEncoder.encode(yamlContents, "UTF-8"));
- logger.debug("============");
-
- return kieSession;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
- */
- @Override
- public void onTopicEvent(CommInfrastructure commType, String topic, String event) {
- /*
- * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation
- * of type active
- */
- Object obj = null;
- if ("POLICY-CL-MGT".equals(topic)) {
- obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event,
- org.onap.policy.controlloop.VirtualControlLoopNotification.class);
- } else if ("APPC-LCM-READ".equals(topic)) {
- obj = org.onap.policy.appclcm.util.Serialization.gsonJunit.fromJson(event,
- org.onap.policy.appclcm.LcmRequestWrapper.class);
- }
- assertNotNull(obj);
- if (obj instanceof VirtualControlLoopNotification) {
- VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj;
- String policyName = notification.getPolicyName();
- if (policyName.endsWith("EVENT")) {
- logger.debug("Rule Fired: " + notification.getPolicyName());
- assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification()));
- } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) {
- logger.debug("Rule Fired: " + notification.getPolicyName());
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
- assertNotNull(notification.getMessage());
- assertTrue(notification.getMessage().startsWith("Sending guard query"));
- } else if (policyName.endsWith("GUARD.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.getPolicyName());
- assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification()));
- assertNotNull(notification.getMessage());
- // THESE ARE THE MOST CRITICAL ASSERTS
- // TEST IF GUARD.RESPONSE IS CORRECT
- logger.debug("Testing whether decision was {} as expected", expectedDecision);
- assertTrue(notification.getMessage().toUpperCase().endsWith(expectedDecision));
- } else if (policyName.endsWith("GUARD_PERMITTED")) {
- logger.debug("Rule Fired: " + notification.getPolicyName());
- assertEquals(ControlLoopNotificationType.OPERATION,notification.getNotification());
- assertNotNull(notification.getMessage());
- assertTrue(notification.getMessage().startsWith("actor=APPC"));
- } else if (policyName.endsWith("OPERATION.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.getPolicyName());
- kieSession1.halt();
- kieSession2.halt();
- logger.debug("The operation timed out");
- fail("Operation Timed Out");
- } else if (policyName.endsWith("APPC.LCM.RESPONSE")) {
- logger.debug("Rule Fired: " + notification.getPolicyName());
- assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification()));
- assertNotNull(notification.getMessage());
- assertTrue(notification.getMessage().startsWith("actor=APPC"));
- } else if (policyName.endsWith("EVENT.MANAGER")) {
- logger.debug("Rule Fired: " + notification.getPolicyName());
- if (notification.getMessage().endsWith("Closing the control loop.")
- || notification.getMessage().equals("Waiting for abatement")) {
- if (policyName.startsWith(controlLoopOneName.toString())) {
- logger.debug("Halting kieSession1");
- kieSession1.halt();
- } else if (policyName.startsWith(controlLoopTwoName.toString())) {
- logger.debug("Halting kieSession2");
- kieSession2.halt();
- } else {
- fail("Unknown ControlLoop");
- }
- }
- } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) {
- logger.debug("Rule Fired: " + notification.getPolicyName());
- kieSession1.halt();
- kieSession2.halt();
- logger.debug("The control loop timed out");
- fail("Control Loop Timed Out");
- }
- } else if (obj instanceof LcmRequestWrapper) {
- /*
- * The request should be of type LCMRequestWrapper and the subrequestid should be 1
- */
- LcmRequestWrapper dmaapRequest = (LcmRequestWrapper) obj;
- LcmRequest appcRequest = dmaapRequest.getBody();
- assertEquals(appcRequest.getCommonHeader().getSubRequestId(),"1");
-
- logger.debug("\n============ APPC received the request!!! ===========\n");
-
- /*
- * Simulate a success response from APPC and insert the response into the working memory
- */
- LcmResponseWrapper dmaapResponse = new LcmResponseWrapper();
- LcmResponse appcResponse = new LcmResponse(appcRequest);
- appcResponse.getStatus().setCode(400);
- appcResponse.getStatus().setMessage("AppC success");
- dmaapResponse.setBody(appcResponse);
- kieSession1.insert(dmaapResponse);
- kieSession2.insert(dmaapResponse);
- }
- }
-
- /**
- * This method will dump all the facts in the working memory.
- *
- * @param kieSession the session containing the facts
- */
- public void dumpFacts(KieSession kieSession) {
- logger.debug("Fact Count: {}", kieSession.getFactCount());
- for (FactHandle handle : kieSession.getFactHandles()) {
- logger.debug("FACT: {}", handle);
- }
- }
-
- /**
- * Test that SyntheticControlLoopOne blocks SyntheticControlLoopTwo
- * is enforced correctly.
- */
- @Test
- public void testSyntheticControlLoopOneBlocksSyntheticControlLoopTwo() throws InterruptedException {
- logger.info("Beginning testSyntheticControlLoopOneBlocksSyntheticControlLoopTwo");
- /*
- * Allows the PolicyEngine to callback to this object to
- * notify that there is an event ready to be pulled
- * from the queue
- */
- for (TopicSink sink : noopTopics) {
- assertTrue(sink.start());
- sink.register(this);
- }
-
- /*
- * Create unique requestIds
- */
- final UUID requestId1 = UUID.randomUUID();
- final UUID requestId2 = UUID.randomUUID();
- final UUID requestId3 = UUID.randomUUID();
- final UUID requestId4 = UUID.randomUUID();
- final UUID requestId5 = UUID.randomUUID();
- final String cl1 = controlLoopOneName.toString();
- final String cl2 = controlLoopTwoName.toString();
- final String t1 = "TARGET_1";
- final String t2 = "TARGET_2";
-
- logger.info("@@@@@@@@@@ cl2 ONSET t1 (Success) @@@@@@@@@@");
- simulateOnset(requestId1, cl2, t1, kieSession2,"PERMIT");
-
- logger.info("@@@@@@@@@@ cl1 ONSET t1 @@@@@@@@@@");
- simulateOnset(requestId2, cl1, t1, kieSession1,"PERMIT");
-
- logger.info("@@@@@@@@@@ cl2 ABATED t1 @@@@@@@@@@");
- simulateAbatement(requestId1, cl2, t1, kieSession2);
-
- logger.info("@@@@@@@@@@ cl2 ONSET t1 (Fail) @@@@@@@@@@");
- simulateOnset(requestId3, cl2, t1, kieSession2,"DENY");
-
- logger.info("@@@@@@@@@@ cl2 ONSET t2 (Success) @@@@@@@@@@");
- simulateOnset(requestId4, cl2, t2, kieSession2,"PERMIT");
-
- logger.info("@@@@@@@@@@ cl2 ABATED t2 @@@@@@@@@@");
- simulateAbatement(requestId4, cl2, t2, kieSession2);
-
- logger.info("@@@@@@@@@@ cl1 ABATED t1 @@@@@@@@@@");
- simulateAbatement(requestId2, cl1, t1, kieSession1);
-
- logger.info("@@@@@@@@@@ cl2 ONSET t1 (Success) @@@@@@@@@@");
- simulateOnset(requestId5, cl2, t1, kieSession2,"PERMIT");
-
- logger.info("@@@@@@@@@@ cl2 ABATED t1 @@@@@@@@@@");
- simulateAbatement(requestId5, cl2, t1, kieSession2);
-
- /*
- * Print what's left in memory
- */
- dumpFacts(kieSession1);
- dumpFacts(kieSession2);
- }
-}
diff --git a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopEventCleanupTest.java b/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopEventCleanupTest.java
deleted file mode 100644
index 605732c31..000000000
--- a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopEventCleanupTest.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * demo
- * ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. 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.clc;
-
-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.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.time.Instant;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-import java.util.UUID;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
-import org.onap.policy.controlloop.ControlLoopEventStatus;
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
-import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager;
-import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
-import org.onap.policy.drools.protocol.coders.EventProtocolParams;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
-import org.onap.policy.template.demo.clc.SupportUtil.Pair;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Verifies that event objects are cleaned up when rules are updated. This loads
- * <b>two</b> copies of the rule set into a single policy to ensure that the two copies
- * interact appropriately with each other's event objects.
- */
-public class ControlLoopEventCleanupTest {
- private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventCleanupTest.class);
-
- /**
- * Number of objects per control loop, including the Params object.
- */
- private static int CL_OBJECTS = 7;
-
- private static final String YAML = "src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml";
-
- /**
- * YAML to be used when the first rule set is updated.
- */
- private static final String YAML2 = "src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml";
-
- private static final String POLICY_VERSION = "v2.0";
-
- private static final String POLICY_NAME = "CL_CleanupTest";
-
- private static final String POLICY_SCOPE = "type=operational";
-
- private static final String CONTROL_LOOP_NAME = "ControlLoop-Event-Cleanup-Test";
-
- private static final String DROOLS_TEMPLATE = "src/main/resources/__closedLoopControlName__.drl";
-
- // values specific to the second copy of the rules
-
- private static final String YAML_B = "src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml";
- private static final String POLICY_NAME_B = "CL_CleanupTest_B";
- private static final String CONTROL_LOOP_NAME_B = "ControlLoop-Event-Cleanup-Test-B";
-
- private static final String GUARD_DISABLED = "guard.disabled";
-
- private static String saveGuardFlag;
-
- private static KieSession kieSession;
- private static SupportUtil.RuleSpec[] specifications;
-
- /**
- * Setup the simulator.
- */
- @BeforeClass
- public static void setUpSimulator() {
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
-
- saveGuardFlag = PolicyEngine.manager.getEnvironmentProperty(GUARD_DISABLED);
- PolicyEngine.manager.getEnvironment().setProperty(GUARD_DISABLED, "true");
-
- SupportUtil.setAaiProps();
-
- PolicyEngine.manager.configure(new Properties());
- assertTrue(PolicyEngine.manager.start());
- Properties noopSinkProperties = new Properties();
- noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL,POLICY-CL-MGT");
- noopSinkProperties.put("noop.sink.topics.APPC-CL.events", "org.onap.policy.appc.Response");
- noopSinkProperties.put("noop.sink.topics.APPC-CL.events.custom.gson",
- "org.onap.policy.appc.util.Serialization,gsonPretty");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events",
- "org.onap.policy.controlloop.VirtualControlLoopNotification");
- noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson",
- "org.onap.policy.controlloop.util.Serialization,gsonPretty");
- final List<TopicSink> noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
-
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("POLICY-CL-MGT")
- .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
- EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
- .groupId("junit.groupId")
- .artifactId("junit.artifactId")
- .topic("APPC-CL")
- .eventClass("org.onap.policy.appc.Request")
- .protocolFilter(new JsonProtocolFilter())
- .modelClassLoaderHash(1111));
-
- try {
- SupportUtil.buildAaiSim();
-
- } catch (Exception e) {
- logger.error("Could not create simulator", e);
- fail("Could not create simulator");
- }
-
- for (TopicSink sink : noopTopics) {
- assertTrue(sink.start());
- }
-
- try {
- specifications = new SupportUtil.RuleSpec[2];
-
- specifications[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME, POLICY_SCOPE, POLICY_NAME,
- POLICY_VERSION, loadYaml(YAML));
-
- specifications[1] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME_B, POLICY_SCOPE,
- POLICY_NAME_B, POLICY_VERSION, loadYaml(YAML_B));
-
- kieSession = SupportUtil.buildContainer(POLICY_VERSION, specifications);
-
- } catch (IOException e) {
- logger.error("Could not create kieSession", e);
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down.
- */
- @AfterClass
- public static void tearDown() {
- kieSession.dispose();
-
- PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
- PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
-
- if (saveGuardFlag == null) {
- PolicyEngine.manager.getEnvironment().remove(GUARD_DISABLED);
-
- } else {
- PolicyEngine.manager.getEnvironment().setProperty(GUARD_DISABLED, saveGuardFlag);
- }
- }
-
- @Test
- public void test() throws IOException {
-
- /*
- * Let rules create Params objects.
- */
- kieSession.fireAllRules();
-
- injectEvent(CONTROL_LOOP_NAME);
- injectEvent(CONTROL_LOOP_NAME_B);
-
- kieSession.fireAllRules();
- List<Object> facts = getSessionObjects();
-
- // should have events for both control loops
- assertEquals(2 * CL_OBJECTS, facts.size());
- assertTrue(hasEvent(facts, CONTROL_LOOP_NAME));
- assertTrue(hasEvent(facts, CONTROL_LOOP_NAME_B));
-
- logger.info("UPDATING VERSION TO v3.0");
- updatePolicy(YAML2, "v3.0");
-
- /*
- * Let rules update Params objects. The Params for the first set of rules should
- * now be deleted and replaced with a new one, while the Params for the second set
- * should be unchanged.
- */
- kieSession.fireAllRules();
- facts = getSessionObjects();
-
- // should only have event for second control loop + 1 Params for first control loop
- assertEquals(CL_OBJECTS + 1, facts.size());
- assertTrue(hasEvent(facts, CONTROL_LOOP_NAME_B));
-
- // add event for first control loop again
- injectEvent(CONTROL_LOOP_NAME);
- kieSession.fireAllRules();
-
- logger.info("UPDATING VERSION TO v4.0");
- updatePolicy(YAML, "v4.0");
-
- /*
- * Let rules update Params objects. The Params for the first set of rules should
- * now be deleted and replaced with a new one, while the Params for the second set
- * should be unchanged.
- */
- kieSession.fireAllRules();
- facts = getSessionObjects();
-
- // should only have event for second control loop + 1 Params for first control loop
- assertEquals(CL_OBJECTS + 1, facts.size());
- assertTrue(hasEvent(facts, CONTROL_LOOP_NAME_B));
-
- // add event for first control loop again
- injectEvent(CONTROL_LOOP_NAME);
- kieSession.fireAllRules();
-
- logger.info("UPDATING VERSION TO v4.0 (i.e., unchanged)");
- updatePolicy(YAML, "v4.0");
-
- /*
- * Let rules update Params objects. As the version (and YAML) are unchanged for
- * either rule set, both Params objects should be unchanged.
- */
- kieSession.fireAllRules();
- facts = getSessionObjects();
-
- // should have events for both control loops
- assertEquals(2 * CL_OBJECTS, facts.size());
- assertTrue(hasEvent(facts, CONTROL_LOOP_NAME));
- assertTrue(hasEvent(facts, CONTROL_LOOP_NAME_B));
-
- /*
- * Now we'll delete the first rule set. That won't actually have any immediate
- * effect, so then we'll update the second rule set, which should trigger a
- * clean-up of both.
- */
- SupportUtil.RuleSpec[] specs = new SupportUtil.RuleSpec[1];
- specs[0] = specifications[1];
-
- logger.info("UPDATING VERSION TO v5.0 - DELETED RULE SET");
- SupportUtil.updateContainer("v5.0", specs);
-
- specs[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME_B, POLICY_SCOPE, POLICY_NAME_B,
- POLICY_VERSION, loadYaml(YAML));
-
- logger.info("UPDATING VERSION TO v6.0 - UPDATED SECOND RULE SET");
- SupportUtil.updateContainer("v6.0", specs);
-
- kieSession.fireAllRules();
- facts = getSessionObjects();
-
- // only 1 Params should remain, for second rule set, but events should be gone
- assertEquals(1, facts.size());
- assertTrue(facts.stream().anyMatch(obj -> obj.toString().startsWith("Params( ")));
- }
-
- /**
- * Updates the policy, changing the YAML associated with the first rule set.
- *
- * @param yamlFile name of the YAML file
- * @param policyVersion policy version
- * @throws IOException if an error occurs
- */
- private static void updatePolicy(String yamlFile, String policyVersion) throws IOException {
-
- specifications[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME, POLICY_SCOPE, POLICY_NAME,
- policyVersion, loadYaml(yamlFile));
-
- /*
- * Update the policy within the container.
- */
- SupportUtil.updateContainer(policyVersion, specifications);
- }
-
- /**
- * Loads a YAML file and URL-encodes it.
- *
- * @param yamlFile name of the YAML file
- * @return the contents of the specified file, URL-encoded
- * @throws UnsupportedEncodingException if an error occurs
- */
- private static String loadYaml(String yamlFile) throws UnsupportedEncodingException {
- Pair<ControlLoopPolicy, String> pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- return URLEncoder.encode(pair.second, "UTF-8");
- }
-
- /**
- * Gets the session objects.
- *
- * @return the session objects
- */
- private static List<Object> getSessionObjects() {
- // sort the objects so we know the order
- LinkedList<Object> lst = new LinkedList<>(kieSession.getObjects());
- lst.sort((left, right) -> left.toString().compareTo(right.toString()));
-
- lst.forEach(obj -> logger.info("obj={}", obj));
-
- return lst;
- }
-
- /**
- * Injects an ONSET event into the rule engine.
- *
- * @param controlLoopName the control loop name
- */
- private void injectEvent(String controlLoopName) {
- VirtualControlLoopEvent event = new VirtualControlLoopEvent();
-
- event.setClosedLoopControlName(controlLoopName);
-
- UUID reqid = UUID.randomUUID();
- event.setRequestId(reqid);
-
- event.setTarget("generic-vnf.vnf-id");
- event.setClosedLoopAlarmStart(Instant.now());
- event.setAai(new HashMap<>());
- event.getAai().put("generic-vnf.vnf-id", "vnf-" + reqid.toString());
- event.getAai().put(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, "false");
- event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
-
- kieSession.insert(event);
- }
-
- /**
- * Determines if the facts contain an event for the given control loop.
- *
- * @param facts session facts to be checked
- * @param controlLoopName name of the control loop of interest
- * @return {@code true} if the facts contain an event for the given control loop,
- * {@code false} otherwise
- */
- private boolean hasEvent(List<Object> facts, String controlLoopName) {
- return (facts.stream().anyMatch(obj -> obj instanceof VirtualControlLoopEvent
- && controlLoopName.equals(((VirtualControlLoopEvent) obj).getClosedLoopControlName())));
- }
-}
diff --git a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopParamsCleanupTest.java b/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopParamsCleanupTest.java
deleted file mode 100644
index e0696abff..000000000
--- a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopParamsCleanupTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * demo
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. 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.clc;
-
-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.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.drools.utils.logging.LoggerUtil;
-import org.onap.policy.template.demo.clc.SupportUtil.Pair;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Verifies that Params objects are cleaned up when rules are updated. This loads
- * <b>two</b> copies of the rule set into a single policy to ensure that the two copies
- * interact appropriately with each other's Params objects.
- */
-public class ControlLoopParamsCleanupTest {
- private static final Logger logger = LoggerFactory.getLogger(ControlLoopParamsCleanupTest.class);
-
- private static final String YAML = "src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml";
-
- /**
- * YAML to be used when the first rule set is updated.
- */
- private static final String YAML2 = "src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml";
-
- private static final String POLICY_VERSION = "v2.0";
-
- private static final String POLICY_NAME = "CL_CleanupTest";
-
- private static final String POLICY_SCOPE = "type=operational";
-
- private static final String CONTROL_LOOP_NAME = "ControlLoop-Params-Cleanup-Test";
-
- private static final String DROOLS_TEMPLATE = "src/main/resources/__closedLoopControlName__.drl";
-
- // values specific to the second copy of the rules
-
- private static final String YAML_B = "src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml";
- private static final String POLICY_NAME_B = "CL_CleanupTest_B";
- private static final String CONTROL_LOOP_NAME_B = "ControlLoop-Params-Cleanup-Test-B";
-
- private static KieSession kieSession;
- private static SupportUtil.RuleSpec[] specifications;
-
- /**
- * Setup the simulator.
- */
- @BeforeClass
- public static void setUpSimulator() {
- LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO");
-
- try {
- specifications = new SupportUtil.RuleSpec[2];
-
- specifications[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME, POLICY_SCOPE, POLICY_NAME,
- POLICY_VERSION, loadYaml(YAML));
-
- specifications[1] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME_B, POLICY_SCOPE,
- POLICY_NAME_B, POLICY_VERSION, loadYaml(YAML_B));
-
- kieSession = SupportUtil.buildContainer(POLICY_VERSION, specifications);
-
- } catch (IOException e) {
- logger.error("Could not create kieSession", e);
- fail("Could not create kieSession");
- }
- }
-
- /**
- * Tear down.
- */
- @AfterClass
- public static void tearDown() {
- kieSession.dispose();
- }
-
- @Test
- public void test() throws IOException {
-
- /*
- * Let rules create Params objects. There should be one object for each set of
- * rules.
- */
- kieSession.fireAllRules();
- List<Object> facts = getSessionObjects();
- assertEquals(specifications.length, facts.size());
- Iterator<Object> iter = facts.iterator();
-
- final Object fact1 = iter.next();
- assertTrue(fact1.toString().contains(loadYaml(YAML)));
-
- final Object fact1b = iter.next();
- assertTrue(fact1b.toString().contains(loadYaml(YAML_B)));
-
- logger.info("UPDATING VERSION TO v3.0");
- updatePolicy(YAML2, "v3.0");
-
- /*
- * Let rules update Params objects. The Params for the first set of rules should
- * now be deleted and replaced with a new one, while the Params for the second set
- * should be unchanged.
- */
- kieSession.fireAllRules();
- facts = getSessionObjects();
- assertEquals(specifications.length, facts.size());
- iter = facts.iterator();
-
- final Object fact2 = iter.next();
- assertTrue(fact2 != fact1);
- assertTrue(fact2 != fact1b);
- assertTrue(fact2.toString().contains(loadYaml(YAML2)));
-
- assertTrue(iter.next() == fact1b);
-
- logger.info("UPDATING VERSION TO v4.0");
- updatePolicy(YAML, "v4.0");
-
- /*
- * Let rules update Params objects. The Params for the first set of rules should
- * now be deleted and replaced with a new one, while the Params for the second set
- * should be unchanged.
- */
- kieSession.fireAllRules();
- facts = getSessionObjects();
- assertEquals(specifications.length, facts.size());
- iter = facts.iterator();
-
- final Object fact3 = iter.next();
- assertTrue(fact3.toString().contains(loadYaml(YAML)));
- assertTrue(fact3 != fact2);
- assertTrue(fact3 != fact1b);
-
- assertTrue(iter.next() == fact1b);
-
- logger.info("UPDATING VERSION TO v4.0 (i.e., unchanged)");
- updatePolicy(YAML, "v4.0");
-
- /*
- * Let rules update Params objects. As the version (and YAML) are unchanged for
- * either rule set, both Params objects should be unchanged.
- */
- kieSession.fireAllRules();
- facts = getSessionObjects();
- assertEquals(specifications.length, facts.size());
- iter = facts.iterator();
- assertTrue(iter.next() == fact3);
- assertTrue(iter.next() == fact1b);
- }
-
- /**
- * Updates the policy, changing the YAML associated with the first rule set.
- *
- * @param yamlFile name of the YAML file
- * @param policyVersion policy version
- * @throws IOException if an error occurs
- */
- private static void updatePolicy(String yamlFile, String policyVersion) throws IOException {
-
- specifications[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME, POLICY_SCOPE, POLICY_NAME,
- policyVersion, loadYaml(yamlFile));
-
- /*
- * Update the policy within the container.
- */
- SupportUtil.updateContainer(policyVersion, specifications);
- }
-
- /**
- * Loads a YAML file and URL-encodes it.
- *
- * @param yamlFile name of the YAML file
- * @return the contents of the specified file, URL-encoded
- * @throws UnsupportedEncodingException if an error occurs
- */
- private static String loadYaml(String yamlFile) throws UnsupportedEncodingException {
- Pair<ControlLoopPolicy, String> pair = SupportUtil.loadYaml(yamlFile);
- assertNotNull(pair);
- assertNotNull(pair.first);
- assertNotNull(pair.first.getControlLoop());
- assertNotNull(pair.first.getControlLoop().getControlLoopName());
- assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0);
-
- return URLEncoder.encode(pair.second, "UTF-8");
- }
-
- /**
- * Gets the session objects.
- *
- * @return the session objects
- */
- private static List<Object> getSessionObjects() {
- // sort the objects so we know the order
- LinkedList<Object> lst = new LinkedList<>(kieSession.getObjects());
- lst.sort((left, right) -> left.toString().compareTo(right.toString()));
-
- return lst;
- }
-}
diff --git a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/SupportUtil.java b/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/SupportUtil.java
deleted file mode 100644
index 8a8dd894a..000000000
--- a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/SupportUtil.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * demo
- * ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. 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.clc;
-
-import static org.junit.Assert.fail;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Stream;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import javax.persistence.Query;
-import org.apache.commons.io.IOUtils;
-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.runtime.KieContainer;
-import org.kie.api.runtime.KieSession;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
-import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
-import org.onap.policy.coordination.CoordinationDirective;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-
-public final class SupportUtil {
-
- private static final String OPSHISTPUPROP = "OperationsHistoryPU";
- private static final Logger logger = LoggerFactory.getLogger(SupportUtil.class);
-
- // values from the last call to buildContainer()
-
- private static KieServices kieServices;
- private static KieContainer keyContainer;
-
- public static class Pair<A, B> {
- public final A first;
- public final B second;
-
- public Pair(A first, B second) {
- this.first = first;
- this.second = second;
- }
- }
-
- /**
- * Load YAML.
- *
- * @param testFile test file to load
- * @return the Pair of a policy and the yaml contents
- */
- public static Pair<ControlLoopPolicy, String> loadYaml(String testFile) {
- try (InputStream is = new FileInputStream(new File(testFile))) {
- String contents = IOUtils.toString(is, StandardCharsets.UTF_8);
- //
- // Read the yaml into our Java Object
- //
- Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class));
- Object obj = yaml.load(contents);
-
- logger.debug(contents);
-
- return new Pair<ControlLoopPolicy, String>((ControlLoopPolicy) obj, contents);
- } catch (IOException e) {
- logger.error("Error while loading YAML", e);
- fail(e.getLocalizedMessage());
- }
- return null;
- }
-
- /**
- * Load the YAML guard policy.
- *
- * @param testFile the test file to load
- * @return return the guard object
- */
- public static ControlLoopGuard loadYamlGuard(String testFile) {
- try (InputStream is = new FileInputStream(new File(testFile))) {
- String contents = IOUtils.toString(is, StandardCharsets.UTF_8);
- //
- // Read the yaml into our Java Object
- //
- Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class));
- Object obj = yaml.load(contents);
- return (ControlLoopGuard) obj;
- } catch (IOException e) {
- logger.error("Error while loading YAML guard", e);
- fail(e.getLocalizedMessage());
- }
- return null;
- }
-
- /**
- * Insert the Xacml policy into the PDP.
- * Achieved by configuring the properties file to load the Xacml policy and required PIP(s).
- *
- * @param xacmlFile the Xacml policy file's path
- * @param propProtoDir the directory containing Xacml implementation prototypes
- * @param propDir the directory to which the Xacml rule should be output
- */
- public static void insertXacmlPolicy(String xacmlFile,
- String propProtoDir,
- String propDir) {
- String propName = "xacml_guard_clc";
- String propProtoFile = propProtoDir + File.separator + propName + ".properties";
- String propFilename = propDir + File.separator + propName + ".properties";
-
- String addXacmlFileToRoot = "# Policies to load\n"
- + "xacml.rootPolicies=p1\n"
- + "p1.file=" + xacmlFile + "\n";
-
- File propFile = new File(propFilename);
- try (Stream<String> stream = Files.lines(Paths.get(propProtoFile));
- PrintWriter output = new PrintWriter(propFile)) {
- /*
- * Remove file after test
- */
- propFile.deleteOnExit();
- /*
- * Copy the property prototype
- */
- stream.forEach(output::println);
- /*
- * Add the Xacml policy to the set of root policies
- */
- output.println(addXacmlFileToRoot);
- /*
- * Obtain PIP Engine definitions from Xacml policy
- * and insert into property file.
- */
- try (BufferedReader br = new BufferedReader(new FileReader(xacmlFile))) {
- boolean select = false;
- for (String line; (line = br.readLine()) != null; ) {
- if (line.contains("PIP Engine Definition")) {
- select = true;
- }
- if (line.contains("-->")) {
- select = false;
- }
- if (select) {
- output.println(line);
- }
- }
- }
- } catch (Exception e) {
- logger.error("Error when trying to create test propery file", e);
- fail(e.getMessage());
- }
- }
-
- public static HttpServletServer buildAaiSim() throws InterruptedException, IOException {
- return org.onap.policy.simulators.Util.buildAaiSim();
- }
-
- /**
- * Build a container containing a single set of rules.
- *
- * @param droolsTemplate template
- * @param closedLoopControlName control loop id
- * @param policyScope policy scope
- * @param policyName policy name
- * @param policyVersion policy version
- * @param yamlSpecification incoming yaml specification
- * @return the Kie session
- * @throws IOException if the container cannot be built
- */
- public static KieSession buildContainer(String droolsTemplate, String closedLoopControlName, String policyScope,
- String policyName, String policyVersion, String yamlSpecification) throws IOException {
-
- RuleSpec spec = new RuleSpec(droolsTemplate, closedLoopControlName, policyScope, policyName, policyVersion,
- yamlSpecification);
-
- return buildContainer(policyVersion, new RuleSpec[] {spec});
- }
-
- /**
- * Build a container containing all of the specified rules.
- *
- * @param policyVersion policy version
- * @param specifications rule specifications
- * @return the Kie session
- * @throws IOException if the container cannot be built
- */
- public static KieSession buildContainer(String policyVersion, RuleSpec[] specifications) throws IOException {
- //
- // Get our Drools Kie factory
- //
- kieServices = KieServices.Factory.get();
-
- ReleaseId releaseId = buildPolicy(policyVersion, specifications);
- logger.debug(releaseId.toString());
-
- //
- // Create our kie Session and container
- //
- keyContainer = kieServices.newKieContainer(releaseId);
-
- return keyContainer.newKieSession();
- }
-
- /**
- * Update the container with new rules.
- *
- * @param policyVersion new policy version
- * @param specifications new rule specifications
- * @throws IOException if the container cannot be built
- */
- public static void updateContainer(String policyVersion, RuleSpec[] specifications) throws IOException {
- ReleaseId releaseId = buildPolicy(policyVersion, specifications);
- logger.debug(releaseId.toString());
-
- keyContainer.updateToVersion(releaseId);
- }
-
- /**
- * Build the Policy so it can be loaded into a KIE container.
- *
- * @param policyVersion policy version
- * @param specifications rule specifications
- * @return the release
- * @throws IOException if the container cannot be built
- */
- private static ReleaseId buildPolicy(String policyVersion, RuleSpec[] specifications) throws IOException {
- //
- // Generate our drools rule from our template
- //
- KieFileSystem kfs = kieServices.newKieFileSystem();
- ReleaseId releaseId = kieServices.getRepository().getDefaultReleaseId();
- releaseId = kieServices.newReleaseId(releaseId.getGroupId(), releaseId.getArtifactId(), policyVersion);
-
- kfs.generateAndWritePomXML(releaseId);
-
- for (RuleSpec spec : specifications) {
- String drlContents = spec.generateRules();
- kfs.write("src/main/resources/" + spec.policyName + ".drl",
- kieServices.getResources().newByteArrayResource(drlContents.getBytes()));
- }
-
- //
- // Compile the rule
- //
- KieBuilder builder = kieServices.newKieBuilder(kfs).buildAll();
- Results results = builder.getResults();
- if (results.hasMessages(Message.Level.ERROR)) {
- for (Message msg : results.getMessages()) {
- logger.error(msg.toString());
- }
- throw new RuntimeException("Drools Rule has Errors");
- }
- for (Message msg : results.getMessages()) {
- logger.debug(msg.toString());
- }
-
- return releaseId;
- }
-
- /**
- * Set the A&AI properties.
- */
- public static void setAaiProps() {
- PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
- PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI");
- PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
- }
-
- /**
- * Set the Guard properties to use embedded XACML PDPEngine.
- */
- public static void setGuardPropsEmbedded() {
- /*
- * Guard PDP-x connection Properties. No URL specified -> use embedded PDPEngine.
- */
- PolicyEngine.manager.setEnvironmentProperty("prop.guard.propfile",
- "src/test/resources/properties/xacml_guard_clc.properties");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER, "python");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS, "test");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_USER, "python");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_PASS, "test");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_ENV, "TEST");
- PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_DISABLED, "false");
- }
-
- /**
- * Set the operation history properties.
- */
- public static void setPuProp() {
- System.setProperty(OPSHISTPUPROP, "OperationsHistoryPUTest");
- }
-
- /**
- * Dump the contents of the History database.
- *
- * @return a list of the database entries
- */
- public static List<?> dumpDb() {
- //
- // Connect to in-mem db
- //
- EntityManagerFactory emf = Persistence.createEntityManagerFactory("OperationsHistoryPUTest");
- EntityManager em = emf.createEntityManager();
- //
- // Create query
- //
- String sql = "select * from operationshistory";
- Query nq = em.createNativeQuery(sql);
- List<?> results = null;
- //
- // Execute query
- //
- try {
- results = nq.getResultList();
- } catch (Exception ex) {
- logger.error("getStatusFromDB threw: ", ex);
- //
- // Clean up and return null
- //
- em.close();
- emf.close();
- return null;
- }
- //
- // Clean up and return results
- //
- em.close();
- emf.close();
- return results;
- }
-
- /**
- * Rule specification.
- */
- public static class RuleSpec {
- private String droolsTemplate;
- private String closedLoopControlName;
- private String policyScope;
- private String policyName;
- private String policyVersion;
- private String yamlSpecification;
-
- /**
- * Constructs the object.
- *
- * @param droolsTemplate template
- * @param closedLoopControlName control loop id
- * @param policyScope policy scope
- * @param policyName policy name
- * @param policyVersion policy version
- * @param yamlSpecification incoming yaml specification
- */
- public RuleSpec(String droolsTemplate, String closedLoopControlName, String policyScope, String policyName,
- String policyVersion, String yamlSpecification) {
-
- this.droolsTemplate = droolsTemplate;
- this.closedLoopControlName = closedLoopControlName;
- this.policyScope = policyScope;
- this.policyName = policyName;
- this.policyVersion = policyVersion;
- this.yamlSpecification = yamlSpecification;
- }
-
- /**
- * Generates the rules by reading the template and making variable substitutions.
- *
- * @return the rules
- * @throws IOException if an error occurs
- */
- private String generateRules() throws IOException {
- Path rule = Paths.get(droolsTemplate);
- String ruleTemplate = new String(Files.readAllBytes(rule));
-
- Pattern pattern = Pattern.compile("\\$\\{closedLoopControlName\\}");
- Matcher matcher = pattern.matcher(ruleTemplate);
- ruleTemplate = matcher.replaceAll(closedLoopControlName);
-
- pattern = Pattern.compile("\\$\\{policyScope\\}");
- matcher = pattern.matcher(ruleTemplate);
- ruleTemplate = matcher.replaceAll(policyScope);
-
- pattern = Pattern.compile("\\$\\{policyName\\}");
- matcher = pattern.matcher(ruleTemplate);
- ruleTemplate = matcher.replaceAll(policyName);
-
- pattern = Pattern.compile("\\$\\{policyVersion\\}");
- matcher = pattern.matcher(ruleTemplate);
- ruleTemplate = matcher.replaceAll(policyVersion);
-
- pattern = Pattern.compile("\\$\\{controlLoopYaml\\}");
- matcher = pattern.matcher(ruleTemplate);
- ruleTemplate = matcher.replaceAll(yamlSpecification);
-
- return ruleTemplate;
- }
- }
-}
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/META-INF/persistence.xml b/controlloop/templates/template.demo.clc/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index e1aa93f51..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- drools-applications
- ================================================================================
- Copyright (C) 2018-2019 AT&T Intellectual Property. 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=========================================================
- -->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
-
- <!-- In-mem DB for junit -->
- <persistence-unit name="OperationsHistoryPUTest"
- transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-
- <class>org.onap.policy.database.operationshistory.Dbao</class>
-
- <properties>
- <property name="eclipselink.ddl-generation" value="create-tables" />
- <property name="eclipselink.logging.level" value="FINE" />
- <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
- <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
- <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb;DATABASE_TO_UPPER=FALSE" />
- <property name="javax.persistence.jdbc.user" value="policy" />
- <property name="javax.persistence.jdbc.password" value="P01icY" />
- <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
- <property name="javax.persistence.schema-generation.create-source" value="metadata"/>
- </properties>
- </persistence-unit>
-
-</persistence>
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/coordination/synthetic_control_loop_one_blocks_synthetic_control_loop_two.yaml b/controlloop/templates/template.demo.clc/src/test/resources/coordination/synthetic_control_loop_one_blocks_synthetic_control_loop_two.yaml
deleted file mode 100644
index 7b69c3a0c..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/coordination/synthetic_control_loop_one_blocks_synthetic_control_loop_two.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2019 AT&T Intellectual Property. 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.
-
-!!org.onap.policy.coordination.CoordinationDirective
-
-controlLoop:
-- SyntheticControlLoopOne
-- SyntheticControlLoopTwo
-coordinationFunction: firstBlocksSecond \ No newline at end of file
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/properties/prototype/xacml_guard_clc.properties b/controlloop/templates/template.demo.clc/src/test/resources/properties/prototype/xacml_guard_clc.properties
deleted file mode 100644
index fa9568b5c..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/properties/prototype/xacml_guard_clc.properties
+++ /dev/null
@@ -1,47 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP
-# ================================================================================
-# Copyright (C) 2018-2019 AT&T Intellectual Property. 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=========================================================
-###
-#
-#
-# Standard API Factories
-#
-xacml.dataTypeFactory=com.att.research.xacml.std.StdDataTypeFactory
-xacml.pdpEngineFactory=com.att.research.xacmlatt.pdp.ATTPDPEngineFactory
-xacml.pepEngineFactory=com.att.research.xacml.std.pep.StdEngineFactory
-xacml.pipFinderFactory=com.att.research.xacml.std.pip.StdPIPFinderFactory
-xacml.traceEngineFactory=com.att.research.xacml.std.trace.LoggingTraceEngineFactory
-#
-# AT&T PDP Implementation Factories
-#
-xacml.att.evaluationContextFactory=com.att.research.xacmlatt.pdp.std.StdEvaluationContextFactory
-xacml.att.combiningAlgorithmFactory=com.att.research.xacmlatt.pdp.std.StdCombiningAlgorithmFactory
-xacml.att.functionDefinitionFactory=com.att.research.xacmlatt.pdp.std.StdFunctionDefinitionFactory
-xacml.att.policyFinderFactory=com.att.research.xacmlatt.pdp.std.StdPolicyFinderFactory
-
-
-#
-# NOTE: If you are testing against a RESTful PDP, then the PDP must be configured with the
-# policies and PIP configuration as defined below. Otherwise, this is the configuration that
-# the embedded PDP uses.
-#
-
-# In case we have multiple applicable Guard policies, we will deny if any of them denies.
-xacml.att.policyFinderFactory.combineRootPolicies=urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-unless-deny
-
-get-operation-outcome.persistenceunit=OperationsHistoryPUTest \ No newline at end of file
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml b/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml
deleted file mode 100644
index 498ef766e..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2018 AT&T Intellectual Property. 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.
-controlLoop:
- version: 2.0.0
- controlLoopName: ControlLoop-Event-Cleanup-Test-B
- services:
- - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc
- serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24
- serviceName: 57e66ea7-0ed6-45c7-970f
- trigger_policy: unique-policy-id-1-modifyConfig
- timeout: 60
- abatement: true
-
-policies:
- - id: unique-policy-id-1-modifyConfig
- name: modify packet gen config
- description:
- actor: APPC
- recipe: ModifyConfig
- target:
- resourceID: Eace933104d443b496b8.nodes.heat.vpg
- type: VNF
- retry: 0
- timeout: 30
- 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 \ No newline at end of file
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml b/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml
deleted file mode 100644
index a19b0ef6b..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2018 AT&T Intellectual Property. 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.
-controlLoop:
- version: 2.0.0
- controlLoopName: ControlLoop-Event-Cleanup-Test
- services:
- - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc
- serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24
- serviceName: 57e66ea7-0ed6-45c7-970f
- trigger_policy: unique-policy-id-1-modifyConfig
- timeout: 60
- abatement: true
-
-policies:
- - id: unique-policy-id-1-modifyConfig
- name: modify packet gen config
- description:
- actor: APPC
- recipe: ModifyConfig
- target:
- resourceID: Eace933104d443b496b8.nodes.heat.vpg
- type: VNF
- retry: 0
- timeout: 30
- 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 \ No newline at end of file
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml b/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml
deleted file mode 100644
index 57062a47a..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2018 AT&T Intellectual Property. 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.
-
-#
-# This YAML must be slightly different from test.yaml.
-#
-controlLoop:
- version: 3.0.0
- controlLoopName: ControlLoop-Event-Cleanup-Test
- services:
- - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc
- serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24
- serviceName: 57e66ea7-0ed6-45c7-970f
- trigger_policy: unique-policy-id-1-modifyConfig
- timeout: 60
- abatement: true
-
-policies:
- - id: unique-policy-id-1-modifyConfig
- name: modify packet gen config
- description:
- actor: APPC
- recipe: ModifyConfig
- target:
- resourceID: Eace933104d443b496b8.nodes.heat.vpg
- type: VNF
- retry: 0
- timeout: 30
- 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 \ No newline at end of file
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml b/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml
deleted file mode 100644
index e19cb498e..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2018 AT&T Intellectual Property. 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.
-controlLoop:
- version: 2.0.0
- controlLoopName: ControlLoop-Params-Cleanup-Test-B
- trigger_policy: unique-policy-id-1-scale-up
- timeout: 60
-
-policies:
- - id: unique-policy-id-1-scale-up
- name: Create a new VF Module
- description:
- actor: SO
- recipe: VF Module Create
- target:
- type: VNF
- retry: 0
- timeout: 30
- 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
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml b/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml
deleted file mode 100644
index 6d89d58c4..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2018 AT&T Intellectual Property. 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.
-controlLoop:
- version: 2.0.0
- controlLoopName: ControlLoop-Params-Cleanup-Test
- trigger_policy: unique-policy-id-1-scale-up
- timeout: 60
-
-policies:
- - id: unique-policy-id-1-scale-up
- name: Create a new VF Module
- description:
- actor: SO
- recipe: VF Module Create
- target:
- type: VNF
- retry: 0
- timeout: 30
- 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
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml b/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml
deleted file mode 100644
index 358bbfbea..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2018 AT&T Intellectual Property. 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.
-
-#
-# This YAML must be slightly different from test.yaml.
-#
-controlLoop:
- version: 3.0.0
- controlLoopName: ControlLoop-Params-Cleanup-Test
- trigger_policy: unique-policy-id-1-scale-up
- timeout: 60
-
-policies:
- - id: unique-policy-id-1-scale-up
- name: Create a new VF Module
- description:
- actor: SO
- recipe: VF Module Create
- target:
- type: VNF
- retry: 0
- timeout: 30
- 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
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_SyntheticOne.yaml b/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_SyntheticOne.yaml
deleted file mode 100644
index 2a74843a0..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_SyntheticOne.yaml
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2018 AT&T Intellectual Property. 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.
-controlLoop:
- version: 2.0.0
- controlLoopName: SyntheticControlLoopOne
- services:
- - serviceName: ServiceSimple
- resources:
- - resourceName: res1
- resourceType: VFC
- - resourceName: res2
- resourceType: VFC
- trigger_policy: unique-policy-id-1
- timeout: 2500
- abatement: true
-
-policies:
- - id: unique-policy-id-1
- name: SyntheticControlLoopOnePolicy
- description:
- actor: APPC
- recipe: action_one
- target:
- type: VNF
- retry: 3
- timeout: 200
- success: final_success
- failure: final_failure
- failure_timeout: final_failure_timeout
- failure_retries: final_failure_retries
- failure_guard: final_failure_guard
- failure_exception: final_failure_exception
diff --git a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_SyntheticTwo.yaml b/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_SyntheticTwo.yaml
deleted file mode 100644
index 12e1bdf2b..000000000
--- a/controlloop/templates/template.demo.clc/src/test/resources/yaml/policy_ControlLoop_SyntheticTwo.yaml
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2018 AT&T Intellectual Property. 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.
-controlLoop:
- version: 2.0.0
- controlLoopName: SyntheticControlLoopTwo
- services:
- - serviceName: ServiceSimple
- resources:
- - resourceName: res1
- resourceType: VFC
- - resourceName: res2
- resourceType: VFC
- trigger_policy: unique-policy-id-1
- timeout: 2500
- abatement: true
-
-policies:
- - id: unique-policy-id-1
- name: SyntheticControlLoopTwoPolicy
- description:
- actor: APPC
- recipe: action_two
- target:
- type: VNF
- retry: 3
- timeout: 200
- success: final_success
- failure: final_failure
- failure_timeout: final_failure_timeout
- failure_retries: final_failure_retries
- failure_guard: final_failure_guard
- failure_exception: final_failure_exception