support pdp-type configuration for PAP status 74/118074/3
authorjhh <jorge.hernandez-herrero@att.com>
Thu, 18 Feb 2021 18:01:05 +0000 (12:01 -0600)
committerJorge Hernandez <jorge.hernandez-herrero@att.com>
Thu, 18 Feb 2021 18:57:04 +0000 (18:57 +0000)
Issue-ID: POLICY-3070
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: Iaddd9bac102cbe79626fe91d78a457dcfd4cb1fb
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
feature-lifecycle/src/test/resources/feature-lifecycle.properties
packages/install/src/files/base.conf

index b495664..fc8127b 100644 (file)
@@ -1,7 +1,7 @@
 # ============LICENSE_START=======================================================
 # ONAP
 # ================================================================================
-# Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+# 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.
@@ -17,6 +17,7 @@
 # ============LICENSE_END=========================================================
 
 lifecycle.pdp.group=${envd:POLICY_PDP_PAP_GROUP:defaultGroup}
+lifecycle.pdp.type=${envd:POLICY_PDP_PAP_TYPE:drools}
 
 # Mandatory policy types that this PDP-D must support at a minimum
 lifecycle.pdp.policytypes=${envd:POLICY_PDP_PAP_POLICYTYPES}
index e2c50d4..a595877 100644 (file)
@@ -85,8 +85,12 @@ public class LifecycleFsm implements Startable {
 
     protected static final String CONFIGURATION_PROPERTIES_NAME = "feature-lifecycle";
     protected static final String GROUP_NAME = "lifecycle.pdp.group";
+    protected static final String PDP_TYPE = "lifecycle.pdp.type";
     protected static final String MANDATORY_POLICY_TYPES = "lifecycle.pdp.policytypes";
+
     protected static final String DEFAULT_PDP_GROUP = "defaultGroup";
+    protected static final String DEFAULT_PDP_TYPE = "drools";
+
     protected static final long MIN_STATUS_INTERVAL_SECONDS = 5L;
     protected static final String PDP_MESSAGE_NAME = "messageName";
 
@@ -135,6 +139,10 @@ public class LifecycleFsm implements Startable {
     @Getter
     protected String subGroup;
 
+    @Getter
+    @Setter
+    protected String pdpType;
+
     @Getter
     protected Set<String> mandatoryPolicyTypes = new HashSet<>();
 
@@ -153,6 +161,7 @@ public class LifecycleFsm implements Startable {
     public LifecycleFsm() {
         properties = SystemPersistenceConstants.getManager().getProperties(CONFIGURATION_PROPERTIES_NAME);
         setGroup(properties.getProperty(GROUP_NAME, DEFAULT_PDP_GROUP));
+        setPdpType(properties.getProperty(PDP_TYPE, DEFAULT_PDP_TYPE));
 
         policyTypesMap.put(POLICY_TYPE_DROOLS_NATIVE_CONTROLLER,
                 new PolicyTypeNativeDroolsController(this, POLICY_TYPE_DROOLS_NATIVE_CONTROLLER));
@@ -580,7 +589,7 @@ public class LifecycleFsm implements Startable {
         status.setPdpSubgroup(subGroup);
         status.setState(state);
         status.setHealthy(isAlive() ? PdpHealthStatus.HEALTHY : PdpHealthStatus.NOT_HEALTHY);
-        status.setPdpType("drools");
+        status.setPdpType(getPdpType());
         status.setPolicies(new ArrayList<>(policiesMap.keySet()));
         status.setStatistics(statisticsPayload());
         return status;
index 9dda01d..54e32d3 100644 (file)
@@ -177,6 +177,11 @@ public class LifecycleFsmTest {
         assertEquals("foo", fsm.getStats().getPdpSubGroupName());
     }
 
+    @Test
+    public void testPdpType() {
+        assertEquals("foo", fsm.getPdpType());
+    }
+
     @Test
     public void testDeployedPolicyAction() {
         fsm.deployedPolicyAction(controllerPolicy);
index 0ce1f82..ac0859e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2021 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -224,6 +224,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
                 "1.0.0")));
         PdpStatus cachedStatus = new StandardCoder()
                                     .decode(fsm.client.getSink().getRecentEvents()[qlength], PdpStatus.class);
+        assertEquals("foo", cachedStatus.getPdpType());
         assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
 
         List<ToscaPolicy> factPolicies = controllerSupport.getFacts(ToscaPolicy.class);
index 6945f10..ef01a59 100644 (file)
@@ -158,6 +158,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
         int qlength = fsm.client.getSink().getRecentEvents().length;
         PdpStatus lastStatus = new StandardCoder().decode(fsm.client.getSink().getRecentEvents()[qlength - 1],
                         PdpStatus.class);
+        assertEquals("foo", lastStatus.getPdpType());
         assertEquals(update.getRequestId(), lastStatus.getRequestId());
         assertEquals(update.getRequestId(), lastStatus.getResponse().getResponseTo());
 
@@ -327,7 +328,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
 
         String[] events = fsm.client.getSink().getRecentEvents();
         PdpStatus status = new StandardCoder().decode(events[events.length - 1], PdpStatus.class);
-        assertEquals("drools", status.getPdpType());
+        assertEquals("foo", status.getPdpType());
         assertEquals(PdpState.TERMINATED, status.getState());
         assertEquals(PdpHealthStatus.HEALTHY, status.getHealthy());
         assertEquals(NetworkUtil.getHostname(), status.getName());
index 052b016..da3ad55 100644 (file)
@@ -1,7 +1,7 @@
 # ============LICENSE_START=======================================================
 # ONAP
 # ================================================================================
-# Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+# 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.
@@ -17,6 +17,7 @@
 # ============LICENSE_END=========================================================
 
 lifecycle.pdp.group=${envd:POLICY_PDP_PAP_GROUP:defaultGroup}
+lifecycle.pdp.type=${envd:POLICY_PDP_PAP_TYPE:foo}
 lifecycle.pdp.policytypes=${envd:POLICY_PDP_PAP_POLICYTYPES:onap.policies.native.drools.Controller,onap.policies.native.drools.Artifact}
 
 noop.source.topics=POLICY-PDP-PAP
index 19a5e44..a154639 100644 (file)
@@ -1,16 +1,16 @@
 ###
 # ============LICENSE_START=======================================================
-# ONAP POLICY
+# ONAP
 # ================================================================================
-# Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
 # Modifications Copyright (C) 2020 Bell Canada.
 # ================================================================================
 # 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.
@@ -101,6 +101,7 @@ PAP_HOST=
 PAP_USERNAME=
 PAP_PASSWORD=
 POLICY_PDP_PAP_GROUP=defaultGroup
+POLICY_PDP_PAP_TYPE=
 POLICY_PDP_PAP_POLICYTYPES=
 
 # PDP-X