From: adheli.tavares Date: Thu, 1 Aug 2024 13:00:57 +0000 (+0100) Subject: Fix Drools-Apps executing policies X-Git-Tag: 3.0.1~9 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=f6d8e60eb75733cf9996bffb3c6ecb586f377da6;p=policy%2Fdrools-pdp.git Fix Drools-Apps executing policies - hibernate dependencies were causing conflicts; updated to latest hibernate-core with all the required deps. - adjusted some variables to be correctly read by properties parser. - added STDOUT option to logback.xml to be able to get logs from controllers/features when using docker logs command. Issue-ID: POLICY-4955 Change-Id: Id3475fc77a63c46697c437bd413ebc1f97b731af Signed-off-by: adheli.tavares --- diff --git a/feature-distributed-locking/pom.xml b/feature-distributed-locking/pom.xml index 04f06784..24d3e048 100644 --- a/feature-distributed-locking/pom.xml +++ b/feature-distributed-locking/pom.xml @@ -3,7 +3,7 @@ ONAP Policy Engine - Drools PDP ================================================================================ Copyright (C) 2018-2022 AT&T Intellectual Property. All rights reserved. - Modifications Copyright (C) 2020,2023 Nordix Foundation. + Modifications Copyright (C) 2020, 2023-2024 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -100,12 +100,12 @@ org.apache.commons commons-dbcp2 - 2.9.0 + 2.12.0 org.apache.commons commons-pool2 - 2.11.1 + 2.12.0 org.springframework diff --git a/feature-pooling-messages/src/main/feature/config/feature-pooling-messages.properties b/feature-pooling-messages/src/main/feature/config/feature-pooling-messages.properties index 8497538e..3870ede1 100644 --- a/feature-pooling-messages/src/main/feature/config/feature-pooling-messages.properties +++ b/feature-pooling-messages/src/main/feature/config/feature-pooling-messages.properties @@ -72,18 +72,18 @@ # be enabled at the same time. pooling.usecases.enabled=true -pooling.usecases.topic=${envd:POOLING_TOPIC} +pooling.usecases.topic=${env:POOLING_TOPIC} # the list of sources and sinks should be identical -kafka.source.topics=${envd:POOLING_TOPIC} -kafka.sink.topics=${envd:POOLING_TOPIC} +kafka.source.topics=${env:POOLING_TOPIC} +kafka.sink.topics=${env:POOLING_TOPIC} -kafka.source.topics.policy-pdp-pooling.servers=${envd:KAFKA_SERVERS} -kafka.source.topics.policy-pdp-pooling.effectiveTopic=${envd:POOLING_TOPIC} +kafka.source.topics.policy-pdp-pooling.servers=${env:KAFKA_SERVERS} +kafka.source.topics.policy-pdp-pooling.effectiveTopic=${env:POOLING_TOPIC} kafka.source.topics.policy-pdp-pooling.apiKey= kafka.source.topics.policy-pdp-pooling.apiSecret= -kafka.sink.topics.policy-pdp-pooling.servers=${envd:KAFKA_SERVERS} -kafka.sink.topics.policy-pdp-pooling.effectiveTopic=${envd:POOLING_TOPIC} +kafka.sink.topics.policy-pdp-pooling.servers=${env:KAFKA_SERVERS} +kafka.sink.topics.policy-pdp-pooling.effectiveTopic=${env:POOLING_TOPIC} kafka.sink.topics.policy-pdp-pooling.apiKey= kafka.sink.topics.policy-pdp-pooling.apiSecret= diff --git a/packages/base/src/files/bin/configure-maven b/packages/base/src/files/bin/configure-maven index 70c3d0cc..c62da818 100644 --- a/packages/base/src/files/bin/configure-maven +++ b/packages/base/src/files/bin/configure-maven @@ -4,6 +4,7 @@ # ONAP # ================================================================================ # Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright (C) 2024 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,11 +25,11 @@ if [ "${DEBUG}" = "y" ]; then set -x fi -HOME_M2="${HOME}"/.m2 -mkdir -p "${HOME_M2}" 2> /dev/null +export M2_HOME="${HOME}"/.m2 +mkdir -p "${M2_HOME}" 2> /dev/null if [ -z "${SNAPSHOT_REPOSITORY_URL}" ] && [ -z "${RELEASE_REPOSITORY_URL}" ]; then - ln -s -f "${POLICY_HOME}"/etc/m2/standalone-settings.xml "${HOME_M2}"/settings.xml + ln -s -f "${POLICY_HOME}"/etc/m2/standalone-settings.xml "${M2_HOME}"/settings.xml else - ln -s -f "${POLICY_HOME}"/etc/m2/settings.xml "${HOME_M2}"/settings.xml + ln -s -f "${POLICY_HOME}"/etc/m2/settings.xml "${M2_HOME}"/settings.xml fi diff --git a/policy-core/pom.xml b/policy-core/pom.xml index 6f1052e9..57fd613c 100644 --- a/policy-core/pom.xml +++ b/policy-core/pom.xml @@ -105,7 +105,6 @@ provided - com.sun.xml.bind jaxb-xjc @@ -132,7 +131,7 @@ org.glassfish.hk2.external - javax.inject + jakarta.inject diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerTopicTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerTopicTest.java new file mode 100644 index 00000000..aae1aec4 --- /dev/null +++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerTopicTest.java @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.drools.domain.models.controller; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class ControllerTopicTest { + + @Test + void testSinkTopic() { + var topic = new ControllerSinkTopic(ControllerSinkTopic.builder() + .topicName("SINK_TOPIC_NAME")); + Assertions.assertEquals("sink_topic_name", topic.getTopicName()); + topic.setTopicName("NEW_TOPIC_NAME"); + Assertions.assertEquals("new_topic_name", topic.getTopicName()); + } + + @Test + void testSourceTopic() { + var topic = new ControllerSourceTopic(ControllerSourceTopic.builder() + .topicName("SOURCE_TOPIC_NAME")); + Assertions.assertEquals("source_topic_name", topic.getTopicName()); + topic.setTopicName("NEW_TOPIC_NAME"); + Assertions.assertEquals("new_topic_name", topic.getTopicName()); + } +} diff --git a/policy-management/pom.xml b/policy-management/pom.xml index ed776b58..c2a3b376 100644 --- a/policy-management/pom.xml +++ b/policy-management/pom.xml @@ -299,12 +299,12 @@ mariadb-java-client - org.hibernate.orm - hibernate-core + org.postgresql + postgresql - org.hibernate.common - hibernate-commons-annotations + org.hibernate.orm + hibernate-core commons-io diff --git a/policy-management/src/main/server/config/logback.xml b/policy-management/src/main/server/config/logback.xml index 1bd7770b..4e6756d9 100644 --- a/policy-management/src/main/server/config/logback.xml +++ b/policy-management/src/main/server/config/logback.xml @@ -3,6 +3,7 @@ policy-management ================================================================================ Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + Modifications Copyright (C) 2024 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -137,11 +138,18 @@ + + + ${debugPattern} + + + + diff --git a/policy-utils/pom.xml b/policy-utils/pom.xml index 14832417..319711a1 100644 --- a/policy-utils/pom.xml +++ b/policy-utils/pom.xml @@ -45,7 +45,7 @@ org.apache.commons commons-configuration2 - 2.8.0 + 2.11.0 org.onap.policy.common diff --git a/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java b/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java index ee32cb2b..f8ffa503 100644 --- a/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java +++ b/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java @@ -71,6 +71,9 @@ class DomainMakerTest { policy.setType("policy.type.Z"); assertFalse(domainMaker.isConformant(policy)); + + assertThatThrownBy(() -> domainMaker.isConformant(null)) + .hasMessageContaining("policy is marked non-null but is null"); } @Test @@ -108,6 +111,12 @@ class DomainMakerTest { domainAPolicy.getProperties().getNested().setNested1(""); ToscaConceptIdentifier ident1 = policy1.getTypeIdentifier(); assertFalse(domainMaker.conformance(ident1, domainAPolicy)); + + var policy2 = getToscaPolicy("src/test/resources/policyA.json"); + policy2.setType("not.registered.type"); + policy2.setTypeVersion("4.2.5"); + assertFalse(domainMaker.conformance(policy2)); + assertFalse(domainMaker.conformance(policy2.getTypeIdentifier(), domainAPolicy)); } @Test @@ -125,6 +134,8 @@ class DomainMakerTest { policy.setTypeVersion("1.0.0"); assertFalse(domainMaker.isConformant(policy)); + + assertFalse(domainMaker.registerValidator(policy.getTypeIdentifier(), "$schema")); } @Test diff --git a/pom.xml b/pom.xml index e80ff124..bc188553 100644 --- a/pom.xml +++ b/pom.xml @@ -126,19 +126,14 @@ org.glassfish.hk2.external - javax.inject - 2.5.0-b62 + jakarta.inject + 2.6.1 com.jayway.jsonpath json-path ${version.json-path} - - org.hibernate.common - hibernate-commons-annotations - ${hibernate.commons.annotations.version} - xml-apis xml-apis