From f4d465bc7391a39410836ceb1c1d25b20eaae74a Mon Sep 17 00:00:00 2001 From: jhh Date: Tue, 8 Mar 2022 19:24:14 -0600 Subject: remove init, mdc, and controller logging features Issue-ID: POLICY-3922 Signed-off-by: jhh Change-Id: I8267ea17c3340e47f85b54c641ddb14672776f70 --- feature-controller-logging/pom.xml | 103 --------- .../src/assembly/assemble_zip.xml | 68 ------ .../src/main/feature/install/disable | 26 --- .../src/main/feature/install/enable | 29 --- .../logging/ControllerLoggingFeature.java | 100 --------- ...licy.drools.features.DroolsControllerFeatureApi | 1 - ...licy.drools.features.PolicyControllerFeatureApi | 1 - ...p.policy.drools.features.PolicyEngineFeatureApi | 1 - .../controller/logging/ControllerLoggingTest.java | 230 --------------------- .../src/test/resources/kmodule.xml | 26 --- .../src/test/resources/logback-test.xml | 41 ---- .../src/test/resources/test.drl | 35 ---- .../src/test/resources/test.pom | 32 --- 13 files changed, 693 deletions(-) delete mode 100755 feature-controller-logging/pom.xml delete mode 100755 feature-controller-logging/src/assembly/assemble_zip.xml delete mode 100644 feature-controller-logging/src/main/feature/install/disable delete mode 100644 feature-controller-logging/src/main/feature/install/enable delete mode 100755 feature-controller-logging/src/main/java/org/onap/policy/drools/controller/logging/ControllerLoggingFeature.java delete mode 100755 feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi delete mode 100755 feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi delete mode 100755 feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi delete mode 100755 feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java delete mode 100755 feature-controller-logging/src/test/resources/kmodule.xml delete mode 100755 feature-controller-logging/src/test/resources/logback-test.xml delete mode 100755 feature-controller-logging/src/test/resources/test.drl delete mode 100755 feature-controller-logging/src/test/resources/test.pom (limited to 'feature-controller-logging') diff --git a/feature-controller-logging/pom.xml b/feature-controller-logging/pom.xml deleted file mode 100755 index 053633cf..00000000 --- a/feature-controller-logging/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - 4.0.0 - - - org.onap.policy.drools-pdp - drools-pdp - 1.10.1-SNAPSHOT - - - feature-controller-logging - - feature-controller-logging - Loadable module that enables individual network logs per controller - - - 1.8 - 1.8 - - - - - - maven-assembly-plugin - - - zipfile - - single - - package - - true - ${project.artifactId}-${project.version} - - src/assembly/assemble_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - ${project.build.directory}/assembly/lib - false - true - true - false - false - false - runtime - true - - - - - - - - - - org.onap.policy.drools-pdp - policy-management - ${project.version} - provided - - - junit - junit - test - - - diff --git a/feature-controller-logging/src/assembly/assemble_zip.xml b/feature-controller-logging/src/assembly/assemble_zip.xml deleted file mode 100755 index 6832604d..00000000 --- a/feature-controller-logging/src/assembly/assemble_zip.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - feature-controller-logging - - zip - - - false - - - - target - lib/feature - - feature-controller-logging-${project.version}.jar - - - - target/assembly/lib - lib/dependencies - - *.jar - - - - src/main/feature/config - config - 0644 - - - - src/main/feature/bin - bin - 0744 - - - - src/main/feature/install - install - 0744 - - - - - diff --git a/feature-controller-logging/src/main/feature/install/disable b/feature-controller-logging/src/main/feature/install/disable deleted file mode 100644 index f35c1dac..00000000 --- a/feature-controller-logging/src/main/feature/install/disable +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env sh - -# ============LICENSE_START======================================================= -# feature-controller-logging -# ================================================================================ -# Copyright (C) 2019-2021 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========================================================= - -configDir=${POLICY_HOME}/config -for mainConfig in ${configDir}/logback.xml ${configDir}/logback-eelf.xml; do - if [ -e "${mainConfig}" ]; then - sed -i --follow-symlinks "/\/d" "${mainConfig}" - fi -done diff --git a/feature-controller-logging/src/main/feature/install/enable b/feature-controller-logging/src/main/feature/install/enable deleted file mode 100644 index 55ae942c..00000000 --- a/feature-controller-logging/src/main/feature/install/enable +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env sh - -# ============LICENSE_START======================================================= -# feature-controller-logging -# ================================================================================ -# Copyright (C) 2019-2021 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========================================================= - -configDir=${POLICY_HOME}/config -for includedConfig in $(ls "${configDir}" | grep "logback-include-.*.xml"); do - include="\t\" - for mainConfig in ${configDir}/logback.xml ${configDir}/logback-eelf.xml; do - if [ -e "${mainConfig}" ]; then - sed -i --follow-symlinks "/\ /a\ ${include}" "${mainConfig}" - fi - done -done diff --git a/feature-controller-logging/src/main/java/org/onap/policy/drools/controller/logging/ControllerLoggingFeature.java b/feature-controller-logging/src/main/java/org/onap/policy/drools/controller/logging/ControllerLoggingFeature.java deleted file mode 100755 index 6cca9cef..00000000 --- a/feature-controller-logging/src/main/java/org/onap/policy/drools/controller/logging/ControllerLoggingFeature.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * feature-controller-logging - * ================================================================================ - * Copyright (C) 2019-2021 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.drools.controller.logging; - -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.drools.controller.DroolsController; -import org.onap.policy.drools.features.DroolsControllerFeatureApi; -import org.onap.policy.drools.features.PolicyControllerFeatureApi; -import org.onap.policy.drools.features.PolicyEngineFeatureApi; -import org.onap.policy.drools.protocol.configuration.ControllerConfiguration; -import org.onap.policy.drools.protocol.configuration.PdpdConfiguration; -import org.onap.policy.drools.system.PolicyController; -import org.onap.policy.drools.system.PolicyControllerConstants; -import org.onap.policy.drools.system.PolicyEngine; -import org.slf4j.LoggerFactory; - -/** - * This class hooks the network logging implementation into DroolsPDP. It will disable the - * default network logger where all topic traffic is logged and segregates the topic - * traffic by controller for each supported control loop use case. - */ - -/* - * PolicyControllerFeatureAPI - the 'beforeStart' hook is used to shut off the default - * network logger and the 'beforeOffer' hook is used to log incoming topic messages - * - * DroolsControllerFeatureAPI - the 'afterDeliver' hook is where the outgoing topic - * messages are logged - * - */ -public class ControllerLoggingFeature - implements PolicyEngineFeatureApi, DroolsControllerFeatureApi, PolicyControllerFeatureApi { - - private static final String LINE_SEP = System.lineSeparator(); - - @Override - public int getSequenceNumber() { - return 1000; - } - - /** - * The 'beforeOffer' hook will intercept an incoming topic message and append it to - * the log file that is configured for the controller logger. - */ - @Override - public boolean beforeOffer(PolicyController controller, CommInfrastructure protocol, String topic, String event) { - var controllerLogger = LoggerFactory.getLogger(controller.getName()); - controllerLogger.info("[IN|{}|{}]{}{}", protocol, topic, LINE_SEP, event); - return false; - } - - /** - * The 'afterDeliver' hook will intercept an outgoing topic message and append it to - * the log file that is configured for the controller logger. - */ - @Override - public boolean afterDeliver(DroolsController controller, TopicSink sink, Object fact, String json, - boolean success) { - if (success) { - var controllerLogger = LoggerFactory - .getLogger(PolicyControllerConstants.getFactory().get(controller).getName()); - controllerLogger.info("[OUT|{}|{}]{}{}", sink.getTopicCommInfrastructure(), sink.getTopic(), - LINE_SEP, json); - } - return false; - } - - /** - * The 'afterOnTopicEvent' hook will determine which controllers were updated and log - * the event to the appropriate controller logs. - */ - @Override - public boolean afterOnTopicEvent(PolicyEngine engine, PdpdConfiguration configuration, CommInfrastructure commType, - String topic, String event) { - for (ControllerConfiguration controller : configuration.getControllers()) { - var controllerLogger = LoggerFactory.getLogger(controller.getName()); - controllerLogger.info("[IN|{}|{}]{}{}", commType, topic, LINE_SEP, event); - } - return false; - } -} diff --git a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi b/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi deleted file mode 100755 index dbde0a80..00000000 --- a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.drools.controller.logging.ControllerLoggingFeature diff --git a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi b/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi deleted file mode 100755 index dbde0a80..00000000 --- a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.drools.controller.logging.ControllerLoggingFeature diff --git a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi b/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi deleted file mode 100755 index dbde0a80..00000000 --- a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.drools.controller.logging.ControllerLoggingFeature diff --git a/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java b/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java deleted file mode 100755 index ecbb320d..00000000 --- a/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * feature-controller-logging - * ================================================================================ - * Copyright (C) 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.drools.controller.logging; - -import static org.junit.Assert.assertEquals; - -import ch.qos.logback.classic.spi.LoggingEvent; -import ch.qos.logback.core.AppenderBase; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import java.io.IOException; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.event.comm.Topic; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink; -import org.onap.policy.drools.controller.DroolsController; -import org.onap.policy.drools.controller.DroolsControllerConstants; -import org.onap.policy.drools.properties.DroolsPropertyConstants; -import org.onap.policy.drools.protocol.configuration.ControllerConfiguration; -import org.onap.policy.drools.protocol.configuration.PdpdConfiguration; -import org.onap.policy.drools.system.PolicyController; -import org.onap.policy.drools.system.PolicyEngineConstants; -import org.onap.policy.drools.util.KieUtils; - -/** - * Controller Logger Tests. - */ -public class ControllerLoggingTest { - - /** - * These properties are for installing a test artifact that the drools controller can - * fetch while testing. - */ - private static final String JUNIT_KMODULE_DRL_PATH = "src/test/resources/test.drl"; - private static final String JUNIT_KMODULE_POM_PATH = "src/test/resources/test.pom"; - private static final String JUNIT_KMODULE_PATH = "src/test/resources/kmodule.xml"; - private static final String JUNIT_KJAR_DRL_PATH = "src/main/resources/org/onap/policy/drools/test/"; - - /** - * These properties are used for the Policy Controller to point to the test artifact. - */ - private static final String TEST_CONTROLLER_NAME = "test-controller"; - private static final String TEST_GROUP_ID = "org.onap.policy.drools.test"; - private static final String TEST_ARTIFACT_ID = "test"; - private static final String TEST_VERSION = "1.0.0"; - - /** - * A test topic used for delivery and network logging. - */ - private static final String TEST_TOPIC = "test-topic"; - private static final String TEST_SERVER = "http://test.com"; - - private static String message = null; - private static PdpdConfiguration pdpdNotification = null; - private static PolicyController policyController = null; - - /** - * This is a list of events that are appended to the controller-test logger. - */ - private static List events = new ArrayList<>(); - - /** - * A custom appender used to intercept events and add them to a list of events that - * the junits can use to determine logging was successful. - */ - public static class NetworkAppender extends AppenderBase { - - @Override - protected void append(LoggingEvent event) { - events.add(event); - } - - } - - /** - * Runs before all the test cases to install the drools artifact, create a policy - * controller, and create a PDPD configuration notification. - */ - @BeforeClass - public static void setUp() throws IOException { - KieUtils.installArtifact(Paths.get(JUNIT_KMODULE_PATH).toFile(), Paths.get(JUNIT_KMODULE_POM_PATH).toFile(), - JUNIT_KJAR_DRL_PATH, Paths.get(JUNIT_KMODULE_DRL_PATH).toFile()); - - // These properties are used for sending PDPD configuration notifications to a policy controller. - Properties controllerProps = new Properties(); - controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME); - controllerProps.put(DroolsPropertyConstants.RULES_GROUPID, TEST_GROUP_ID); - controllerProps.put(DroolsPropertyConstants.RULES_ARTIFACTID, TEST_ARTIFACT_ID); - controllerProps.put(DroolsPropertyConstants.RULES_VERSION, TEST_VERSION); - - policyController = - PolicyEngineConstants.getManager().createPolicyController(TEST_CONTROLLER_NAME, controllerProps); - - message = "{\"requestID\":\"38adde30-cc22-11e8-a8d5-f2801f1b9fd1\",\"entity\":\"controller\",\"controllers\":" - + "[{\"name\":\"test-controller\",\"drools\":{\"groupId\":\"org.onap.policy.drools.test\"," - + "\"artifactId\":\"test\",\"version\":\"0.0.1\"},\"operation\":\"update\"}]}"; - - Gson decoder = new GsonBuilder().disableHtmlEscaping().create(); - pdpdNotification = decoder.fromJson(message, PdpdConfiguration.class); - } - - /** - * Runs after every test case to clean up the events added to the event list during - * unit test. - */ - @After - public void cleanUpLogs() { - events.clear(); - } - - /** - * Obtains the sequence number of the controller logging feature. This should return - * 1000. - */ - @Test - public void getSequenceNumberTest() { - ControllerLoggingFeature nlf = new ControllerLoggingFeature(); - assertEquals(1000, nlf.getSequenceNumber()); - } - - /** - * Asserts that the controller-test logger appends the incoming message to the event - * list. - */ - @Test - public void beforeOffer() { - ControllerLoggingFeature nlf = new ControllerLoggingFeature(); - - nlf.beforeOffer(policyController, Topic.CommInfrastructure.UEB, TEST_TOPIC, "{\"test\":\"test\"}"); - - assertEquals(1, events.size()); - } - - /** - * Asserts that the controller-test logger appends the outgoing message to the event - * list. - */ - @Test - public void afterDeliverSuccess() { - - final ControllerLoggingFeature nlf = new ControllerLoggingFeature(); - - DroolsController droolsController = - DroolsControllerConstants.getFactory().get(TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION); - - NoopTopicSink sinkTopic = new NoopTopicSink(Arrays.asList(TEST_SERVER), TEST_TOPIC); - - nlf.afterDeliver(droolsController, sinkTopic, null, "{\"test\":\"test\"}", true); - - assertEquals(1, events.size()); - - } - - /** - * Asserts that the controller-test logger does not append the outgoing message to the - * event list if there was a failure. - */ - @Test - public void afterDeliverFailure() { - - final ControllerLoggingFeature nlf = new ControllerLoggingFeature(); - - DroolsController droolsController = - DroolsControllerConstants.getFactory().get(TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION); - - NoopTopicSink sinkTopic = new NoopTopicSink(Arrays.asList(TEST_SERVER), TEST_TOPIC); - - nlf.afterDeliver(droolsController, sinkTopic, null, "{\"test\":\"test\"}", false); - - assertEquals(0, events.size()); - } - - /** - * Asserts that the controller logging feature can log the messages to the proper - * controller based on the message containing the controller name. - */ - @Test - public void afterOnTopicEventSuccess() { - final ControllerLoggingFeature nlf = new ControllerLoggingFeature(); - - nlf.afterOnTopicEvent(PolicyEngineConstants.getManager(), pdpdNotification, CommInfrastructure.UEB, TEST_TOPIC, - message); - - assertEquals(1, events.size()); - } - - /** - * Asserts that the controller logging feature can skip logging messages that don't - * contain the controller names in it. - */ - @Test - public void afterOnTopicEventFailure() { - final ControllerLoggingFeature nlf = new ControllerLoggingFeature(); - - PdpdConfiguration notification = new PdpdConfiguration(); - ControllerConfiguration config = new ControllerConfiguration(); - config.setName("test-controller-2"); - notification.setControllers(Arrays.asList(config)); - - nlf.afterOnTopicEvent(PolicyEngineConstants.getManager(), notification, CommInfrastructure.UEB, TEST_TOPIC, - message); - - assertEquals(0, events.size()); - } -} diff --git a/feature-controller-logging/src/test/resources/kmodule.xml b/feature-controller-logging/src/test/resources/kmodule.xml deleted file mode 100755 index 2410a0f7..00000000 --- a/feature-controller-logging/src/test/resources/kmodule.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - diff --git a/feature-controller-logging/src/test/resources/logback-test.xml b/feature-controller-logging/src/test/resources/logback-test.xml deleted file mode 100755 index dfe9a459..00000000 --- a/feature-controller-logging/src/test/resources/logback-test.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/feature-controller-logging/src/test/resources/test.drl b/feature-controller-logging/src/test/resources/test.drl deleted file mode 100755 index dcae7fa3..00000000 --- a/feature-controller-logging/src/test/resources/test.drl +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * feature-controller-logging - * ================================================================================ - * Copyright (C) 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.drools.test; - -rule "INIT" -when -then - insert("This is a test"); -end - -rule "PRINT_MSG" -when - $o : Object(); -then - System.out.println("MSG: " + $o); - retract($o); -end diff --git a/feature-controller-logging/src/test/resources/test.pom b/feature-controller-logging/src/test/resources/test.pom deleted file mode 100755 index 64be32f0..00000000 --- a/feature-controller-logging/src/test/resources/test.pom +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - 4.0.0 - - org.onap.policy.drools.test - test - - 1.0.0 - - -- cgit 1.2.3-korg