summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java6
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java12
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java64
-rw-r--r--feature-eelf/src/main/feature/config/logback-eelf.xml9
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java2
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java25
-rw-r--r--feature-lifecycle/src/test/resources/tosca-policy-compliant-vcpe-bad-integer.json36
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java3
-rw-r--r--feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Server.java1
-rw-r--r--feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java8
-rw-r--r--feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/persistence/Persistence.java8
-rw-r--r--policy-management/src/main/server/config/logback.xml9
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java42
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java23
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java69
15 files changed, 246 insertions, 71 deletions
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
index 2616ac34..9457ce18 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.drools.activestandby;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -337,8 +338,7 @@ public class AllSeemsWellTest {
logger.debug("testAllSeemsWell: After isStalled=true, PDP= {} "
+ "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
-
- assertTrue(smf.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
+ assertEquals(StateManagement.COLD_STANDBY, smf.getStandbyStatus());
//Now lets resume the election handler
DroolsPdpsElectionHandler.setIsStalled(false);
@@ -349,7 +349,7 @@ public class AllSeemsWellTest {
logger.debug("testAllSeemsWell: After isStalled=false, PDP= {} "
+ "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
- assertTrue(smf.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+ assertEquals(StateManagement.PROVIDING_SERVICE, smf.getStandbyStatus());
//resumedElectionHandlerSleepTime = 5000;
logger.debug("\n\ntestAllSeemsWell: Exiting\n\n");
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
index 52000fd5..3f4a31b2 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
@@ -22,7 +22,7 @@ package org.onap.policy.drools.activestandby;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotEquals;
import java.util.Date;
import lombok.Getter;
@@ -50,19 +50,19 @@ public class DroolsPdpObjectTest {
@Test
public void testEqualsObject() {
// self
- assertTrue(pdp.equals(pdp));
+ assertEquals(pdp,pdp);
// same id
MyPdp pdp2 = new MyPdp();
pdp2.setPdpId(PDP_ID);
- assertTrue(pdp.equals(pdp2));
+ assertEquals(pdp,pdp2);
// different id
pdp2.setPdpId(PDP_ID2);
- assertFalse(pdp.equals(pdp2));
+ assertNotEquals(pdp,pdp2);
// different type of object
- assertFalse(pdp.equals(""));
+ assertNotEquals(pdp,"");
}
@Test
@@ -74,7 +74,7 @@ public class DroolsPdpObjectTest {
assertEquals(hc, makePdp(PDP_ID, SITE, PRIORITY).hashCode());
// different data should yield different hash code
- assertTrue(makePdp(PDP_ID2, SITE, PRIORITY).hashCode() != hc);
+ assertNotEquals(hc, makePdp(PDP_ID2, SITE, PRIORITY).hashCode());
// these fields have no impact on hash code
assertEquals(hc, makePdp(PDP_ID, SITE, PRIORITY2).hashCode());
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
index f51d620f..866ad5ef 100644
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
+++ b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
@@ -20,8 +20,10 @@
package org.onap.policy.drools.activestandby;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -261,55 +263,55 @@ public class StandbyStateManagementTest {
//At this point the standbystatus = 'null'
sm.lock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.NULL_VALUE));
+ assertEquals(StateManagement.NULL_VALUE, pmNotifier.getPreviousStandbyStatus());
sm.unlock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.NULL_VALUE));
+ assertEquals(StateManagement.NULL_VALUE, pmNotifier.getPreviousStandbyStatus());
//Adding standbystatus=hotstandby
sm.demote();
System.out.println(pmNotifier.getPreviousStandbyStatus());
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//Now making standbystatus=coldstandby
sm.lock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//standbystatus = hotstandby
sm.unlock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//standbystatus = providingservice
sm.promote();
//The previousStandbyStatus is not updated until after the delay activation expires
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//Sleep long enough for the delayActivationTimer to run
sleep(5000);
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+ assertEquals(StateManagement.PROVIDING_SERVICE, pmNotifier.getPreviousStandbyStatus());
//standbystatus = providingservice
sm.promote();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
+ assertEquals(StateManagement.PROVIDING_SERVICE, pmNotifier.getPreviousStandbyStatus());
//standbystatus = coldstandby
sm.lock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//standbystatus = hotstandby
sm.unlock();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
//standbystatus = hotstandby
sm.demote();
- assertTrue(pmNotifier.getPreviousStandbyStatus().equals(
- PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY));
+ assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
+ pmNotifier.getPreviousStandbyStatus());
}
/**
@@ -359,7 +361,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size = {}\n\n",listOfDesignated.size());
- assertTrue(listOfDesignated.size() == 4);
+ assertEquals(4, listOfDesignated.size());
// Now make 2 designated
@@ -371,7 +373,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after 2 designated = {}\n\n",
listOfDesignated.size());
- assertTrue(listOfDesignated.size() == 2);
+ assertEquals(2, listOfDesignated.size());
assertTrue(listOfDesignated.contains(pdp1));
assertTrue(listOfDesignated.contains(pdp2));
@@ -388,7 +390,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after all designated = {}\n\n",
listOfDesignated.size());
- assertTrue(listOfDesignated.size() == 4);
+ assertEquals(4, listOfDesignated.size());
}
@@ -465,7 +467,7 @@ public class StandbyStateManagementTest {
// the one which has the most recent designated date.
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
// Now let's designate all of those on the listOfDesignated. It will choose the first one designated
@@ -487,7 +489,7 @@ public class StandbyStateManagementTest {
// the one which was designated first
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp2"));
+ assertEquals("pdp2", mostRecentPrimary.getPdpId());
// Now we will designate only 2 and put just them in the listOfDesignated. The algorithm will now
@@ -505,7 +507,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestComputeMostRecentPrimary: mostRecentPrimary.getPdpId() = {}\n\n",
mostRecentPrimary.getPdpId());
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
@@ -521,7 +523,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestComputeMostRecentPrimary: 2 on list mostRecentPrimary.getPdpId() = {}\n\n",
mostRecentPrimary.getPdpId());
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
// If we have only one pdp on in the listOfDesignated,
@@ -536,7 +538,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestComputeMostRecentPrimary: 1 on list mostRecentPrimary.getPdpId() = {}\n\n",
mostRecentPrimary.getPdpId());
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
// Finally, if none are on the listOfDesignated, it will again choose the most recently designated pdp.
@@ -549,7 +551,7 @@ public class StandbyStateManagementTest {
logger.debug("\n\ntestComputeMostRecentPrimary: 0 on list mostRecentPrimary.getPdpId() = {}\n\n",
mostRecentPrimary.getPdpId());
- assertTrue(mostRecentPrimary.getPdpId().equals("pdp4"));
+ assertEquals("pdp4", mostRecentPrimary.getPdpId());
}
@@ -624,7 +626,7 @@ public class StandbyStateManagementTest {
// The designatedPdp should be null
- assertTrue(designatedPdp == null);
+ assertNull(designatedPdp);
// Now let's try having only one pdp in listOfDesignated, but not in the same site as the most recent primary
@@ -637,7 +639,7 @@ public class StandbyStateManagementTest {
// Now the designatedPdp should be the one and only selection in the listOfDesignated
- assertTrue(designatedPdp.getPdpId().equals(pdp2.getPdpId()));
+ assertEquals(designatedPdp.getPdpId(), pdp2.getPdpId());
// Now let's put 2 pdps in the listOfDesignated, neither in the same site as the mostRecentPrimary
@@ -651,7 +653,7 @@ public class StandbyStateManagementTest {
// The designatedPdp should now be the one with the lowest lexiographic score - pdp1
- assertTrue(designatedPdp.getPdpId().equals(pdp1.getPdpId()));
+ assertEquals(designatedPdp.getPdpId(), pdp1.getPdpId());
// Finally, we will have 2 pdps in the listOfDesignated, one in the same site with the mostRecentPrimary
@@ -666,7 +668,7 @@ public class StandbyStateManagementTest {
// The designatedPdp should now be the one on the same site as the mostRecentPrimary
- assertTrue(designatedPdp.getPdpId().equals(pdp3.getPdpId()));
+ assertEquals(designatedPdp.getPdpId(), pdp3.getPdpId());
}
/**
diff --git a/feature-eelf/src/main/feature/config/logback-eelf.xml b/feature-eelf/src/main/feature/config/logback-eelf.xml
index 8a7dcb25..7acd33fa 100644
--- a/feature-eelf/src/main/feature/config/logback-eelf.xml
+++ b/feature-eelf/src/main/feature/config/logback-eelf.xml
@@ -2,7 +2,7 @@
============LICENSE_START=======================================================
feature-eelf
================================================================================
- Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2017-2020 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.
@@ -27,14 +27,13 @@
<property name="networkLogName" value="network" />
<property name="defaultPattern"
- value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+ value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity:-NA}|%X{TargetServiceName:-NA}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%class||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
<property name="defaultMetricPattern"
- value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+ value="${defaultPattern}" />
<property name="defaultAuditPattern"
- value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+ value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%class|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
<property name="defaultErrorPattern"
value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%X{RequestID}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{ErrorCategory}|%X{ErrorCode}|%X{ErrorDescription}|%msg%replace(%xException){'\n',' - '}%nopex%n" />
-
<property name="networkPattern" value="[%d|%t]%m%n" />
<property name="abstractNetworkPattern"
value="[%d] [%X{networkEventType:-NULL}|%X{networkProtocol:-NULL}|%X{networkTopic:-NULL}|%X{requestID:-NULL}]%n" />
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
index f762bff0..503c0c11 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
@@ -168,7 +168,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
continue;
}
- success = sync.test(controller, policy) && success;
+ success = fsm.getDomainMaker().isConformant(policy) && sync.test(controller, policy) && success;
}
return success;
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
index 54f7d68f..54f4b6a6 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -53,6 +54,15 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
*/
public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
+ private static final String POLICY_COMPLIANT_VCPE_BAD_INTEGER_JSON =
+ "src/test/resources/tosca-policy-compliant-vcpe-bad-integer.json";
+ private static final String POLICY_OPERATIONAL_FIREWALL_JSON =
+ "src/test/resources/tosca-policy-operational-firewall.json";
+ private static final String POLICY_OPERATIONAL_RESTART_V_2_JSON =
+ "src/test/resources/tosca-policy-operational-restart.v2.json";
+ private static final String POLICY_OPERATIONAL_RESTART_JSON =
+ "src/test/resources/tosca-policy-operational-restart.json";
+
/**
* Start tests in the Active state.
*/
@@ -199,7 +209,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
assertEquals("w", fsm.getSubgroup());
String restartV1 =
- new String(Files.readAllBytes(Paths.get("src/test/resources/tosca-policy-operational-restart.json")));
+ Files.readString(Paths.get(POLICY_OPERATIONAL_RESTART_JSON), StandardCharsets.UTF_8);
ToscaPolicy toscaPolicyRestartV1 = new StandardCoder().decode(restartV1, ToscaPolicy.class);
update.setPolicies(Arrays.asList(toscaPolicyRestartV1));
@@ -237,7 +247,6 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
.decode(fsm.client.getSink().getRecentEvents()[qlength + 1], PdpStatus.class);
assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
-
factPolicies = controllerSupport.getFacts(ToscaPolicy.class);
assertEquals(1, factPolicies.size());
assertEquals(toscaPolicyRestartV1, factPolicies.get(0));
@@ -275,7 +284,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
// deploy a new version of the operational.restart policy
String restartV2 =
- new String(Files.readAllBytes(Paths.get("src/test/resources/tosca-policy-operational-restart.v2.json")));
+ Files.readString(Paths.get(POLICY_OPERATIONAL_RESTART_V_2_JSON), StandardCharsets.UTF_8);
ToscaPolicy toscaPolicyRestartV2 = new StandardCoder().decode(restartV2, ToscaPolicy.class);
update.setPolicies(Arrays.asList(toscaPolicyRestartV2));
assertTrue(fsm.update(update));
@@ -294,7 +303,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
// deploy another policy : firewall
String firewall =
- new String(Files.readAllBytes(Paths.get("src/test/resources/tosca-policy-operational-firewall.json")));
+ Files.readString(Paths.get(POLICY_OPERATIONAL_FIREWALL_JSON), StandardCharsets.UTF_8);
ToscaPolicy toscaPolicyFirewall = new StandardCoder().decode(firewall, ToscaPolicy.class);
update.setPolicies(Arrays.asList(toscaPolicyRestartV2, toscaPolicyFirewall));
assertTrue(fsm.update(update));
@@ -320,6 +329,14 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
assertEquals(PdpState.ACTIVE, fsm.state());
assertEquals(interval, fsm.getStatusTimerSeconds());
+ // bad policy deployment
+
+ String badIntegerPolicy =
+ Files.readString(Paths.get(POLICY_COMPLIANT_VCPE_BAD_INTEGER_JSON), StandardCharsets.UTF_8);
+ ToscaPolicy toscaPolicyRestartBad = new StandardCoder().decode(badIntegerPolicy, ToscaPolicy.class);
+ update.setPolicies(Arrays.asList(toscaPolicyRestartBad));
+ assertFalse(fsm.update(update));
+
assertTrue(controllerSupport.getController().getDrools().delete(ToscaPolicy.class));
fsm.shutdown();
diff --git a/feature-lifecycle/src/test/resources/tosca-policy-compliant-vcpe-bad-integer.json b/feature-lifecycle/src/test/resources/tosca-policy-compliant-vcpe-bad-integer.json
new file mode 100644
index 00000000..3ff7dbb2
--- /dev/null
+++ b/feature-lifecycle/src/test/resources/tosca-policy-compliant-vcpe-bad-integer.json
@@ -0,0 +1,36 @@
+{
+ "type": "onap.policies.controlloop.operational.common.Drools",
+ "type_version": "1.0.0",
+ "name": "vcpe.timeout.integer.as.string",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "vcpe.timeout.integer.as.string"
+ },
+ "properties": {
+ "id": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "timeout": "3600",
+ "abatement": true,
+ "trigger": "unique-policy-id-1-restart",
+ "operations": [
+ {
+ "id": "unique-policy-id-1-restart",
+ "description": "Restart the VM",
+ "operation": {
+ "actor": "APPC",
+ "operation": "Restart",
+ "target": {
+ "targetType": "VNF"
+ }
+ },
+ "timeout": "1200",
+ "retries": 3,
+ "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/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
index 14784fc2..3682dcb4 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
@@ -23,6 +23,7 @@ package org.onap.policy.drools.pooling.state;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -268,7 +269,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
String[] arr = captureHostArray();
- assertTrue(arr != HOST_ARR3);
+ assertNotSame(arr, HOST_ARR3);
assertEquals(Arrays.asList(HOST_ARR3), Arrays.asList(arr));
}
diff --git a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Server.java b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Server.java
index 8ee0f2d2..ad0e25ee 100644
--- a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Server.java
+++ b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Server.java
@@ -72,7 +72,6 @@ import java.util.Properties;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.UUID;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.LinkedTransferQueue;
diff --git a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java
index 65804082..dc4c0a79 100644
--- a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java
+++ b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java
@@ -2576,14 +2576,14 @@ public class TargetLock implements Lock, Serializable {
Bucket bucket = Bucket.getBucket(i);
// client data
- build_clientData(bucket);
+ buildClientData(bucket);
// server data
- build_serverData(bucket);
+ buildServerData(bucket);
}
}
- private void build_clientData(Bucket bucket) {
+ private void buildClientData(Bucket bucket) {
// client data
LocalLocks localLocks =
bucket.getAdjunctDontCreate(LocalLocks.class);
@@ -2603,7 +2603,7 @@ public class TargetLock implements Lock, Serializable {
}
}
- private void build_serverData(Bucket bucket) {
+ private void buildServerData(Bucket bucket) {
// server data
GlobalLocks globalLocks =
bucket.getAdjunctDontCreate(GlobalLocks.class);
diff --git a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/persistence/Persistence.java b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/persistence/Persistence.java
index 60e740c5..0f7321de 100644
--- a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/persistence/Persistence.java
+++ b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/persistence/Persistence.java
@@ -667,10 +667,10 @@ public class Persistence implements PolicySessionFeatureApi, ServerPoolApi {
// one entry for each Drools session being restored --
// indicates when the restore is complete (restore runs within
// the Drools session thread)
- List<CountDownLatch> sessionLatches = restoreBucket_droolsSessions();
+ List<CountDownLatch> sessionLatches = restoreBucketDroolsSessions();
// restore lock data
- restoreBucket_locks(bucket);
+ restoreBucketLocks(bucket);
// wait for all of the sessions to update
try {
@@ -686,7 +686,7 @@ public class Persistence implements PolicySessionFeatureApi, ServerPoolApi {
}
}
- private List<CountDownLatch> restoreBucket_droolsSessions() {
+ private List<CountDownLatch> restoreBucketDroolsSessions() {
List<CountDownLatch> sessionLatches = new LinkedList<>();
for (Map.Entry<String, ReceiverSessionBucketData> entry : sessionData.entrySet()) {
String sessionName = entry.getKey();
@@ -769,7 +769,7 @@ public class Persistence implements PolicySessionFeatureApi, ServerPoolApi {
return sessionLatches;
}
- private void restoreBucket_locks(Bucket bucket) {
+ private void restoreBucketLocks(Bucket bucket) {
if (lockData != null) {
Object obj = null;
try {
diff --git a/policy-management/src/main/server/config/logback.xml b/policy-management/src/main/server/config/logback.xml
index 04ec8937..2d0697d0 100644
--- a/policy-management/src/main/server/config/logback.xml
+++ b/policy-management/src/main/server/config/logback.xml
@@ -2,7 +2,7 @@
============LICENSE_START=======================================================
policy-management
================================================================================
- Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2017-2020 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.
@@ -35,11 +35,10 @@
<property name="networkPattern" value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%t]%m%n" />
<property name="abstractNetworkPattern"
value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}] [%X{networkEventType:-NULL}|%X{networkProtocol:-NULL}|%X{networkTopic:-NULL}|%X{requestID:-NULL}]%n" />
-
<property name="metricPattern"
- value="%X{RequestID}|%X{InvocationID}|%X{ServiceName}|%X{PartnerName}|%X{BeginTimestamp}|%X{EndTimestamp}|%X{ElapsedTime}|%X{ServiceInstanceID}|%X{VirtualServerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%X{Severity}|%X{TargetEntity}|%X{TargetServiceName}|%X{Server}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ProcessKey}|%X{RemoteHost}||%X{TargetVirtualEntity}|%level|%thread| %msg%n" />
- <property name="transactionPattern" value="${metricPattern}" />
-
+ value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity:-NA}|%X{TargetServiceName:-NA}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%class|%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
+ <property name="transactionPattern"
+ value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%class|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n" />
<appender name="ErrorOut" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDir}/${errorLog}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
index a2cf07fb..94fc9769 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-utils
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -197,6 +197,26 @@ public interface MdcTransaction {
MdcTransaction setRemoteHost(String remoteHost);
/**
+ * sets CustomField1 data.
+ */
+ MdcTransaction setCustomField1(String customField1);
+
+ /**
+ * sets CustomField2 data.
+ */
+ MdcTransaction setCustomField2(String customField2);
+
+ /**
+ * sets CustomField3 data.
+ */
+ MdcTransaction setCustomField3(String customField3);
+
+ /**
+ * sets CustomField4 data.
+ */
+ MdcTransaction setCustomField4(String customField4);
+
+ /**
* get start time.
*/
Instant getStartTime();
@@ -312,6 +332,26 @@ public interface MdcTransaction {
String getServerIpAddress();
/**
+ * get customer field1.
+ */
+ String getCustomField1();
+
+ /**
+ * get customer field2.
+ */
+ String getCustomField2();
+
+ /**
+ * get customer field3 which contains notification info.
+ */
+ String getCustomField3();
+
+ /**
+ * get customer field4.
+ */
+ String getCustomField4();
+
+ /**
* generate timestamp used for logging.
*/
String timestamp(Instant time);
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
index eb37d0c7..936449c8 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-utils
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -144,6 +144,26 @@ public class MdcTransactionConstants {
public static final String TARGET_VIRTUAL_ENTITY = "TargetVirtualEntity";
/**
+ * Custom Field1.
+ */
+ public static final String CUSTOM_FIELD1 = "CustomField1";
+
+ /**
+ * Custom Field2.
+ */
+ public static final String CUSTOM_FIELD2 = "CustomField2";
+
+ /**
+ * Custom Field3.
+ */
+ public static final String CUSTOM_FIELD3 = "CustomField3";
+
+ /**
+ * Custom Field4.
+ */
+ public static final String CUSTOM_FIELD4 = "CustomField4";
+
+ /**
* Default Service Name.
*/
public static final String DEFAULT_SERVICE_NAME = "PDP-D";
@@ -168,7 +188,6 @@ public class MdcTransactionConstants {
*/
public static final String STATUS_CODE_FAILURE = "ERROR";
-
private MdcTransactionConstants() {
// do nothing
}
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
index 4e1690ba..7af6c0cb 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -22,6 +22,10 @@ package org.onap.policy.drools.utils.logging;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.BEGIN_TIMESTAMP;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CLIENT_IP_ADDRESS;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CUSTOM_FIELD1;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CUSTOM_FIELD2;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CUSTOM_FIELD3;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CUSTOM_FIELD4;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_HOSTIP;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_HOSTNAME;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_SERVICE_NAME;
@@ -100,6 +104,10 @@ class MdcTransactionImpl implements MdcTransaction {
private String targetVirtualEntity;
private String clientIpAddress;
private String remoteHost;
+ private String customField1;
+ private String customField2;
+ private String customField3;
+ private String customField4;
/**
* Transaction with no information set.
@@ -145,8 +153,8 @@ class MdcTransactionImpl implements MdcTransaction {
this.setServerFqdn(MDC.get(SERVER_FQDN));
this.setVirtualServerName(MDC.get(VIRTUAL_SERVER_NAME));
- this.setStartTime(Instant.now());
this.setInvocationId(invocationId);
+ this.setStartTime(Instant.now());
}
/**
@@ -179,6 +187,10 @@ class MdcTransactionImpl implements MdcTransaction {
this.setTargetServiceName(transaction.getTargetServiceName());
this.setTargetVirtualEntity(transaction.getTargetVirtualEntity());
this.setVirtualServerName(transaction.getVirtualServerName());
+ this.setCustomField1(transaction.getCustomField1());
+ this.setCustomField2(transaction.getCustomField2());
+ this.setCustomField3(transaction.getCustomField3());
+ this.setCustomField4(transaction.getCustomField4());
}
/**
@@ -248,6 +260,10 @@ class MdcTransactionImpl implements MdcTransaction {
setMdc(TARGET_VIRTUAL_ENTITY, this.targetVirtualEntity);
setMdc(CLIENT_IP_ADDRESS, this.clientIpAddress);
setMdc(REMOTE_HOST, this.remoteHost);
+ setMdc(CUSTOM_FIELD1, this.customField1);
+ setMdc(CUSTOM_FIELD2, this.customField2);
+ setMdc(CUSTOM_FIELD3, this.customField3);
+ setMdc(CUSTOM_FIELD4, this.customField4);
return this;
}
@@ -352,6 +368,26 @@ class MdcTransactionImpl implements MdcTransaction {
return this.serviceInstanceId;
}
+ @Override
+ public String getCustomField1() {
+ return this.customField1;
+ }
+
+ @Override
+ public String getCustomField2() {
+ return this.customField2;
+ }
+
+ @Override
+ public String getCustomField3() {
+ return this.customField3;
+ }
+
+ @Override
+ public String getCustomField4() {
+ return this.customField4;
+ }
+
/* transaction and subtransaction fields */
@Override
@@ -458,6 +494,30 @@ class MdcTransactionImpl implements MdcTransaction {
}
@Override
+ public MdcTransaction setCustomField1(String customField1) {
+ this.customField1 = customField1;
+ return this;
+ }
+
+ @Override
+ public MdcTransaction setCustomField2(String customField2) {
+ this.customField2 = customField2;
+ return this;
+ }
+
+ @Override
+ public MdcTransaction setCustomField3(String customField3) {
+ this.customField3 = customField3;
+ return this;
+ }
+
+ @Override
+ public MdcTransaction setCustomField4(String customField4) {
+ this.customField4 = customField4;
+ return this;
+ }
+
+ @Override
public String getInvocationId() {
return invocationId;
}
@@ -641,8 +701,11 @@ class MdcTransactionImpl implements MdcTransaction {
sb.append(", targetVirtualEntity='").append(targetVirtualEntity).append('\'');
sb.append(", clientIpAddress='").append(clientIpAddress).append('\'');
sb.append(", remoteHost='").append(remoteHost).append('\'');
+ sb.append(", customField1='").append(customField1).append('\'');
+ sb.append(", customField2='").append(customField2).append('\'');
+ sb.append(", customField3='").append(customField3).append('\'');
+ sb.append(", customField4='").append(customField4).append('\'');
sb.append('}');
return sb.toString();
}
-
}