summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java2
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java6
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java7
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java45
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java18
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java34
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java32
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java3
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java19
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java39
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java2
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java2
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java10
-rw-r--r--testsuites/performance/src/main/resources/testplans/perf.jmx70
-rw-r--r--testsuites/stability/src/main/resources/testplans/stability.jmx70
-rw-r--r--xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java8
16 files changed, 319 insertions, 48 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java
index 0b9975f7..edd33c0e 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java
@@ -89,7 +89,7 @@ public interface XacmlApplicationServiceProvider {
*
* @param toscaPolicy object
*/
- boolean loadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException;
+ void loadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException;
/**
* unloadPolicy a Tosca Policy.
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
index 12135f4a..5aea3457 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java
@@ -116,7 +116,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
}
@Override
- public synchronized boolean loadPolicy(ToscaPolicy toscaPolicy) {
+ public synchronized void loadPolicy(ToscaPolicy toscaPolicy) throws XacmlApplicationException {
try {
//
// Convert the policies first
@@ -165,10 +165,8 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica
//
this.mapLoadedPolicies.put(toscaPolicy, refPath);
} catch (IOException | ToscaPolicyConversionException e) {
- LOGGER.error("Failed to loadPolicies {}", e);
- return false;
+ throw new XacmlApplicationException("loadPolicy failed", e);
}
- return true;
}
@Override
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
index 6139a528..e7ea049a 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
@@ -190,10 +190,10 @@ public class StdXacmlApplicationServiceProviderTest {
}
@Test
- public void testLoadPolicy_ConversionError() throws ToscaPolicyConversionException {
+ public void testLoadPolicy_ConversionError() throws XacmlApplicationException, ToscaPolicyConversionException {
when(trans.convertPolicy(policy)).thenReturn(null);
- assertFalse(prov.loadPolicy(policy));
+ assertThatThrownBy(() -> prov.loadPolicy(policy)).isInstanceOf(XacmlApplicationException.class);
}
@Test
@@ -203,7 +203,8 @@ public class StdXacmlApplicationServiceProviderTest {
final Set<String> set = XACMLProperties.getRootPolicyIDs(prov.getProperties());
- assertTrue(prov.loadPolicy(policy));
+ // Load policy
+ prov.loadPolicy(policy);
// policy file should have been created
File policyFile = new File(TEMP_DIR, "my-name_1.2.3.xml");
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java
index b7aa231f..03b0e9e3 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java
@@ -21,6 +21,7 @@
package org.onap.policy.pdpx.main;
import java.util.Collections;
+import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.models.pdp.concepts.PdpMessage;
import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
@@ -32,11 +33,15 @@ import org.onap.policy.models.pdp.enums.PdpResponseStatus;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager;
import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Current state of this XACML PDP.
*/
public class XacmlState {
+ // The logger for this class
+ private static final Logger LOGGER = LoggerFactory.getLogger(XacmlState.class);
/**
* The application manager.
@@ -48,7 +53,6 @@ public class XacmlState {
*/
private final PdpStatus status;
-
/**
* Constructs the object, initializing the state.
*/
@@ -101,7 +105,10 @@ public class XacmlState {
* within a group/subgroup.
*/
- PdpStatus status2 = makeResponse(message);
+ PdpStatus status2 = makeResponse(message, "");
+
+ // start/stop rest controller based on state change
+ handleXacmlRestController();
// these fields aren't needed in the response, so clear them out to avoid sending
status2.setPolicies(null);
@@ -116,12 +123,12 @@ public class XacmlState {
* @param message message from which to update the internal state
* @return a response to the message
*/
- public PdpStatus updateInternalState(PdpUpdate message) {
+ public PdpStatus updateInternalState(PdpUpdate message, String errMessage) {
status.setPdpGroup(message.getPdpGroup());
status.setPdpSubgroup(message.getPdpSubgroup());
status.setPolicies(appManager.getToscaPolicyIdentifiers());
- return makeResponse(message);
+ return makeResponse(message, errMessage);
}
/**
@@ -138,15 +145,41 @@ public class XacmlState {
* Makes a response to the given message, based on the current state.
*
* @param message message for which the response should be made
+ * @param errMessage the error message to be sent to PAP
* @return a new response
*/
- private PdpStatus makeResponse(PdpMessage message) {
+ private PdpStatus makeResponse(PdpMessage message, String errMessage) {
PdpResponseDetails resp = new PdpResponseDetails();
- resp.setResponseStatus(PdpResponseStatus.SUCCESS);
+
+ if (StringUtils.isBlank(errMessage)) {
+ resp.setResponseStatus(PdpResponseStatus.SUCCESS);
+ } else {
+ resp.setResponseStatus(PdpResponseStatus.FAIL);
+ resp.setResponseMessage(errMessage);
+ }
resp.setResponseTo(message.getRequestId());
PdpStatus status2 = new PdpStatus(status);
status2.setResponse(resp);
return status2;
}
+
+ /**
+ * Manages the Xacml-Pdp rest controller based on the Xacml-Pdp State.
+ * Current supported states:
+ * ACTIVE - rest service is running and handling requests
+ * PASSIVE - rest service is not running
+ */
+ private void handleXacmlRestController() {
+ if (status.getState() == PdpState.ACTIVE) {
+ LOGGER.info("State change: {} - Starting rest controller", status.getState());
+ XacmlPdpActivator.getCurrent().startXacmlRestController();
+ } else if (status.getState() == PdpState.PASSIVE) {
+ LOGGER.info("State change: {} - Stopping rest controller", status.getState());
+ XacmlPdpActivator.getCurrent().stopXacmlRestController();
+ } else {
+ // unsupported state
+ LOGGER.warn("Unsupported state: {}", status.getState());
+ }
+ }
}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
index 686a8edc..a2f139d6 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
@@ -20,6 +20,7 @@
package org.onap.policy.pdpx.main.comm;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -27,6 +28,8 @@ import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
+import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
import org.onap.policy.pdpx.main.XacmlState;
import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager;
import org.onap.policy.pdpx.main.rest.XacmlPdpStatisticsManager;
@@ -73,13 +76,24 @@ public class XacmlPdpUpdatePublisher {
}
}
+ StringBuilder errorMessage = new StringBuilder();
// Deploy a policy
// if deployed policies do not contain the incoming policy load it
for (ToscaPolicy policy : incomingPolicies) {
if (!deployedPolicies.contains(policy)) {
- appManager.loadDeployedPolicy(policy);
+ try {
+ appManager.loadDeployedPolicy(policy);
+ } catch (XacmlApplicationException e) {
+ // Failed to load policy, return error(s) to PAP
+ LOGGER.error("Failed to load policy: {}", policy, e);
+ errorMessage.append("Failed to load policy: " + policy + ": "
+ + e.getMessage() + XacmlPolicyUtils.LINE_SEPARATOR);
+ }
}
}
+ // Return current deployed policies
+ message.setPolicies(new ArrayList<ToscaPolicy>(appManager.getToscaPolicies().keySet()));
+ LOGGER.debug("Returning current deployed policies: {} ", message.getPolicies());
// update the policy count statistic
XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent();
@@ -87,7 +101,7 @@ public class XacmlPdpUpdatePublisher {
stats.setTotalPolicyCount(appManager.getPolicyCount());
}
- sendPdpUpdate(state.updateInternalState(message));
+ sendPdpUpdate(state.updateInternalState(message, errorMessage.toString()));
}
private void sendPdpUpdate(PdpStatus status) {
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java
index 37132a8f..2f054bd1 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java
@@ -169,31 +169,27 @@ public class XacmlPdpApplicationManager {
}
/**
- * Finds the appropriate application and loads the policy.
+ * Finds the appropriate application and loads the policy, throws an exception if it fails.
*
* @param policy Incoming policy
+ * @throws XacmlApplicationException if loadPolicy fails
*/
- public void loadDeployedPolicy(ToscaPolicy policy) {
+ public void loadDeployedPolicy(ToscaPolicy policy) throws XacmlApplicationException {
for (XacmlApplicationServiceProvider application : applicationLoader) {
- try {
- //
- // There should be only one application per policytype. We can
- // put more logic surrounding enforcement of that later. For now,
- // just use the first one found.
- //
- if (application.canSupportPolicyType(policy.getTypeIdentifier())) {
- if (application.loadPolicy(policy)) {
- if (LOGGER.isInfoEnabled()) {
- LOGGER.info("Loaded ToscaPolicy {} into application {}", policy.getMetadata(),
- application.applicationName());
- }
- mapLoadedPolicies.put(policy, application);
- }
- return;
+ //
+ // There should be only one application per policytype. We can
+ // put more logic surrounding enforcement of that later. For now,
+ // just use the first one found.
+ //
+ if (application.canSupportPolicyType(policy.getTypeIdentifier())) {
+ application.loadPolicy(policy);
+ mapLoadedPolicies.put(policy, application);
+ if (LOGGER.isInfoEnabled()) {
+ LOGGER.info("Loaded ToscaPolicy {} into application {}", policy.getMetadata(),
+ application.applicationName());
}
- } catch (XacmlApplicationException e) {
- LOGGER.error("Failed to load the Tosca Policy", e);
+ return;
}
}
}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java
index 8d213954..396919dc 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java
@@ -62,6 +62,7 @@ public class XacmlPdpActivator extends ServiceManagerContainer {
@Getter
@Setter
private static XacmlPdpActivator current = null;
+ private final RestServer restServer;
// The parameters of this policy xacml pdp activator
private final XacmlPdpParameterGroup xacmlPdpParameterGroup;
@@ -85,7 +86,6 @@ public class XacmlPdpActivator extends ServiceManagerContainer {
final XacmlPdpHearbeatPublisher heartbeat;
final TopicSinkClient sinkClient;
final XacmlState state;
- final RestServer restServer;
try {
XacmlPdpApplicationManager appmgr =
@@ -145,10 +145,6 @@ public class XacmlPdpActivator extends ServiceManagerContainer {
heartbeat::start,
heartbeat::terminate);
- addAction("REST server",
- restServer::start,
- restServer::stop);
-
// @formatter:on
}
@@ -204,4 +200,30 @@ public class XacmlPdpActivator extends ServiceManagerContainer {
source.unregister(msgDispatcher);
}
}
+
+ /**
+ * Start the xacmlpdp rest controller.
+ */
+ public void startXacmlRestController() {
+ if (isXacmlRestControllerAlive()) {
+ LOGGER.info("Xacml rest controller already running");
+ } else {
+ restServer.start();
+ }
+ }
+
+ /**
+ * Stop the xacmlpdp rest controller.
+ */
+ public void stopXacmlRestController() {
+ if (isXacmlRestControllerAlive()) {
+ restServer.stop();
+ } else {
+ LOGGER.info("Xacml rest controller already stopped");
+ }
+ }
+
+ public boolean isXacmlRestControllerAlive() {
+ return restServer.isAlive();
+ }
}
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java b/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
index a32bc6fd..d2379e09 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
@@ -120,6 +120,9 @@ public class CommonRest {
final String[] xacmlPdpConfigParameters = {"-c", CommonRest.CONFIG_FILE};
main = new Main(xacmlPdpConfigParameters);
+ // start xacml rest controller
+ XacmlPdpActivator.getCurrent().startXacmlRestController();
+
if (!NetworkUtil.isTcpPortOpen("localhost", port, 20, 1000L)) {
throw new IllegalStateException("server is not listening on port " + port);
}
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java
index 20136bf0..12d832ac 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java
@@ -23,7 +23,9 @@ package org.onap.policy.pdpx.main;
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.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays;
@@ -135,6 +137,16 @@ public class XacmlStateTest {
// ensure info was saved
status = state.genHeartbeat();
assertEquals(PdpState.SAFE, status.getState());
+
+ req.setState(PdpState.ACTIVE);
+ status = state.updateInternalState(req);
+ assertEquals(PdpState.ACTIVE, status.getState());
+ verify(act).startXacmlRestController();
+
+ req.setState(PdpState.PASSIVE);
+ status = state.updateInternalState(req);
+ assertEquals(PdpState.PASSIVE, status.getState());
+ verify(act).stopXacmlRestController();
}
@Test
@@ -143,17 +155,22 @@ public class XacmlStateTest {
req.setPdpGroup(GROUP);
req.setPdpSubgroup(SUBGROUP);
- PdpStatus status = state.updateInternalState(req);
+ PdpStatus status = state.updateInternalState(req, "");
PdpResponseDetails resp = status.getResponse();
assertNotNull(resp);
assertEquals(req.getRequestId(), resp.getResponseTo());
assertEquals(PdpResponseStatus.SUCCESS, resp.getResponseStatus());
+ assertNull(resp.getResponseMessage());
// ensure info was saved
status = state.genHeartbeat();
assertEquals(GROUP, status.getPdpGroup());
assertEquals(SUBGROUP, status.getPdpSubgroup());
+
+ status = state.updateInternalState(req, "Failed to load policy: failLoadPolicy1: null");
+ assertEquals(status.getResponse().getResponseMessage(), "Failed to load policy: failLoadPolicy1: null");
+ assertEquals(status.getResponse().getResponseStatus(), PdpResponseStatus.FAIL);
}
@Test
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java
index 31bec51e..c8c6a816 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java
@@ -22,6 +22,8 @@ package org.onap.policy.pdpx.main.comm;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.startsWith;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -38,6 +40,7 @@ import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationServiceProvider;
import org.onap.policy.pdpx.main.XacmlState;
import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager;
@@ -82,8 +85,17 @@ public class XacmlPdpUpdatePublisherTest {
private ToscaPolicy added2;
@Mock
+ private ToscaPolicy failPolicy1;
+
+ @Mock
+ private ToscaPolicy failPolicy2;
+
+ @Mock
private PdpUpdate update;
+ @Mock
+ private PdpUpdate failurePdpUpdate;
+
private XacmlPdpUpdatePublisher publisher;
@@ -105,9 +117,12 @@ public class XacmlPdpUpdatePublisherTest {
List<ToscaPolicy> updatePolicies = Arrays.asList(added1, deployed2, deployed3, added2);
when(update.getPolicies()).thenReturn(updatePolicies);
+ List<ToscaPolicy> failureUpdatePolicies = Arrays.asList(added1, deployed2, deployed3, failPolicy1, failPolicy2);
+ when(failurePdpUpdate.getPolicies()).thenReturn(failureUpdatePolicies);
+
when(appmgr.getPolicyCount()).thenReturn(NEW_COUNT);
- when(state.updateInternalState(update)).thenReturn(status);
+ when(state.updateInternalState(any(), any())).thenReturn(status);
when(client.send(any())).thenReturn(true);
@@ -115,7 +130,7 @@ public class XacmlPdpUpdatePublisherTest {
}
@Test
- public void testHandlePdpUpdate() {
+ public void testHandlePdpUpdate() throws XacmlApplicationException {
XacmlPdpStatisticsManager statmgr = new XacmlPdpStatisticsManager();
XacmlPdpStatisticsManager.setCurrent(statmgr);
@@ -141,7 +156,25 @@ public class XacmlPdpUpdatePublisherTest {
}
@Test
- public void testHandlePdpUpdate_NullPolicies() {
+ public void testHandlePdpUpdate_LoadPolicyFailed() throws XacmlApplicationException {
+ // Set loadPolicy to fail
+ doThrow(new XacmlApplicationException()).when(appmgr).loadDeployedPolicy(failPolicy1);
+ doThrow(new XacmlApplicationException()).when(appmgr).loadDeployedPolicy(failPolicy2);
+
+ publisher.handlePdpUpdate(failurePdpUpdate);
+
+ // two removed
+ verify(appmgr).removeUndeployedPolicy(deployed1);
+ verify(appmgr).removeUndeployedPolicy(deployed4);
+
+ verify(failurePdpUpdate).setPolicies(any());
+
+ verify(state).updateInternalState(any(), startsWith("Failed to load policy"));
+ verify(client).send(status);
+ }
+
+ @Test
+ public void testHandlePdpUpdate_NullPolicies() throws XacmlApplicationException {
when(update.getPolicies()).thenReturn(null);
publisher.handlePdpUpdate(update);
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
index 37a669d2..d416cd3b 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
@@ -67,6 +67,7 @@ import org.onap.policy.pdpx.main.PolicyXacmlPdpException;
import org.onap.policy.pdpx.main.parameters.CommonTestData;
import org.onap.policy.pdpx.main.parameters.XacmlPdpParameterGroup;
import org.onap.policy.pdpx.main.startstop.Main;
+import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
import org.onap.policy.xacml.pdp.application.monitoring.MonitoringPdpApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -130,6 +131,7 @@ public class TestAbbreviateDecisionResults {
// Start the service
//
main = startXacmlPdpService(fileParams);
+ XacmlPdpActivator.getCurrent().startXacmlRestController();
//
// Make sure it is running
//
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java
index 042180b4..6c6e35b9 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java
@@ -61,6 +61,7 @@ import org.onap.policy.pdpx.main.PolicyXacmlPdpException;
import org.onap.policy.pdpx.main.parameters.CommonTestData;
import org.onap.policy.pdpx.main.parameters.XacmlPdpParameterGroup;
import org.onap.policy.pdpx.main.startstop.Main;
+import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -116,6 +117,7 @@ public class TestDecision {
// Start the service
//
main = startXacmlPdpService(fileParams);
+ XacmlPdpActivator.getCurrent().startXacmlRestController();
//
// Make sure it is running
//
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java b/main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java
index cd4b78d9..5223bcd8 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/startstop/TestXacmlPdpActivator.java
@@ -64,6 +64,7 @@ public class TestXacmlPdpActivator extends CommonRest {
/**
* Creates the activator.
*/
+ @Override
@Before
public void setUp() {
activator = new XacmlPdpActivator(parGroup);
@@ -72,11 +73,20 @@ public class TestXacmlPdpActivator extends CommonRest {
@Test
public void testXacmlPdpActivator() throws Exception {
assertFalse(activator.isAlive());
+ assertFalse(activator.isXacmlRestControllerAlive());
activator.start();
assertTrue(activator.isAlive());
+
+ // XacmlPdp starts in PASSIVE state so the rest controller should not be alive
+ assertFalse(activator.isXacmlRestControllerAlive());
assertTrue(activator.getParameterGroup().isValid());
assertEquals(CommonTestData.PDPX_GROUP_NAME, activator.getParameterGroup().getName());
+ activator.startXacmlRestController();
+ assertTrue(activator.isXacmlRestControllerAlive());
+
+ activator.stopXacmlRestController();
+ assertFalse(activator.isXacmlRestControllerAlive());
}
@Test
diff --git a/testsuites/performance/src/main/resources/testplans/perf.jmx b/testsuites/performance/src/main/resources/testplans/perf.jmx
index a53a9f43..fba609ae 100644
--- a/testsuites/performance/src/main/resources/testplans/perf.jmx
+++ b/testsuites/performance/src/main/resources/testplans/perf.jmx
@@ -709,6 +709,76 @@ if (prev.getResponseCode() == &apos;200&apos;) {
</ResponseAssertion>
<hashTree/>
</hashTree>
+ <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Fetch Monitoring Decisions with Abbreviated Results" enabled="true">
+ <boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
+ <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
+ <collectionProp name="Arguments.arguments">
+ <elementProp name="" elementType="HTTPArgument">
+ <boolProp name="HTTPArgument.always_encode">false</boolProp>
+ <stringProp name="Argument.value">{&#xd;
+ &quot;ONAPName&quot;: &quot;DCAE&quot;,&#xd;
+ &quot;ONAPComponent&quot;: &quot;PolicyHandler&quot;,&#xd;
+ &quot;ONAPInstance&quot;: &quot;622431a4-9dea-4eae-b443-3b2164639c64&quot;,&#xd;
+ &quot;action&quot;: &quot;configure&quot;,&#xd;
+ &quot;resource&quot;: {&#xd;
+ &quot;policy-id&quot;: &quot;onap.scaleout.tca&quot;&#xd;
+ }&#xd;
+}</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ </collectionProp>
+ </elementProp>
+ <stringProp name="HTTPSampler.domain">${POLICY_PDPX_HOST}</stringProp>
+ <stringProp name="HTTPSampler.port">${PDP_PORT}</stringProp>
+ <stringProp name="HTTPSampler.protocol">https</stringProp>
+ <stringProp name="HTTPSampler.contentEncoding"></stringProp>
+ <stringProp name="HTTPSampler.path">policy/pdpx/v1/decision?abbrev=true</stringProp>
+ <stringProp name="HTTPSampler.method">POST</stringProp>
+ <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
+ <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
+ <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
+ <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
+ <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
+ <stringProp name="HTTPSampler.connect_timeout"></stringProp>
+ <stringProp name="HTTPSampler.response_timeout"></stringProp>
+ <stringProp name="TestPlan.comments">Get Configuration Data for Monitoring Policy</stringProp>
+ </HTTPSamplerProxy>
+ <hashTree>
+ <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
+ <collectionProp name="Asserion.test_strings">
+ <stringProp name="49586">200</stringProp>
+ </collectionProp>
+ <stringProp name="Assertion.custom_message"></stringProp>
+ <stringProp name="Assertion.test_field">Assertion.response_code</stringProp>
+ <boolProp name="Assertion.assume_success">false</boolProp>
+ <intProp name="Assertion.test_type">1</intProp>
+ </ResponseAssertion>
+ <hashTree/>
+ <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
+ <collectionProp name="Asserion.test_strings">
+ <stringProp name="3575610">type</stringProp>
+ <stringProp name="-450004177">metadata</stringProp>
+ </collectionProp>
+ <stringProp name="Assertion.custom_message"></stringProp>
+ <stringProp name="Assertion.test_field">Assertion.response_message</stringProp>
+ <boolProp name="Assertion.assume_success">false</boolProp>
+ <intProp name="Assertion.test_type">2</intProp>
+ </ResponseAssertion>
+ <hashTree/>
+ <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
+ <collectionProp name="Asserion.test_strings">
+ <stringProp name="-583173933">type_version</stringProp>
+ <stringProp name="-926053069">properties</stringProp>
+ <stringProp name="3373707">name</stringProp>
+ <stringProp name="351608024">version</stringProp>
+ </collectionProp>
+ <stringProp name="Assertion.custom_message"></stringProp>
+ <stringProp name="Assertion.test_field">Assertion.response_message</stringProp>
+ <boolProp name="Assertion.assume_success">false</boolProp>
+ <intProp name="Assertion.test_type">6</intProp>
+ </ResponseAssertion>
+ <hashTree/>
+ </hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Fetch Frequency Limiter Guard Decisions" enabled="true">
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
diff --git a/testsuites/stability/src/main/resources/testplans/stability.jmx b/testsuites/stability/src/main/resources/testplans/stability.jmx
index c4be29be..6f8b5b9e 100644
--- a/testsuites/stability/src/main/resources/testplans/stability.jmx
+++ b/testsuites/stability/src/main/resources/testplans/stability.jmx
@@ -709,6 +709,76 @@ if (prev.getResponseCode() == &apos;200&apos;) {
</ResponseAssertion>
<hashTree/>
</hashTree>
+ <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Fetch Monitoring Decisions with Abbreviated Results" enabled="true">
+ <boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
+ <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
+ <collectionProp name="Arguments.arguments">
+ <elementProp name="" elementType="HTTPArgument">
+ <boolProp name="HTTPArgument.always_encode">false</boolProp>
+ <stringProp name="Argument.value">{&#xd;
+ &quot;ONAPName&quot;: &quot;DCAE&quot;,&#xd;
+ &quot;ONAPComponent&quot;: &quot;PolicyHandler&quot;,&#xd;
+ &quot;ONAPInstance&quot;: &quot;622431a4-9dea-4eae-b443-3b2164639c64&quot;,&#xd;
+ &quot;action&quot;: &quot;configure&quot;,&#xd;
+ &quot;resource&quot;: {&#xd;
+ &quot;policy-id&quot;: &quot;onap.scaleout.tca&quot;&#xd;
+ }&#xd;
+}</stringProp>
+ <stringProp name="Argument.metadata">=</stringProp>
+ </elementProp>
+ </collectionProp>
+ </elementProp>
+ <stringProp name="HTTPSampler.domain">${POLICY_PDPX_HOST}</stringProp>
+ <stringProp name="HTTPSampler.port">${PDP_PORT}</stringProp>
+ <stringProp name="HTTPSampler.protocol">https</stringProp>
+ <stringProp name="HTTPSampler.contentEncoding"></stringProp>
+ <stringProp name="HTTPSampler.path">policy/pdpx/v1/decision?abbrev=true</stringProp>
+ <stringProp name="HTTPSampler.method">POST</stringProp>
+ <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
+ <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
+ <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
+ <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
+ <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
+ <stringProp name="HTTPSampler.connect_timeout"></stringProp>
+ <stringProp name="HTTPSampler.response_timeout"></stringProp>
+ <stringProp name="TestPlan.comments">Get Configuration Data for Monitoring Policy</stringProp>
+ </HTTPSamplerProxy>
+ <hashTree>
+ <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
+ <collectionProp name="Asserion.test_strings">
+ <stringProp name="49586">200</stringProp>
+ </collectionProp>
+ <stringProp name="Assertion.custom_message"></stringProp>
+ <stringProp name="Assertion.test_field">Assertion.response_code</stringProp>
+ <boolProp name="Assertion.assume_success">false</boolProp>
+ <intProp name="Assertion.test_type">1</intProp>
+ </ResponseAssertion>
+ <hashTree/>
+ <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
+ <collectionProp name="Asserion.test_strings">
+ <stringProp name="3575610">type</stringProp>
+ <stringProp name="-450004177">metadata</stringProp>
+ </collectionProp>
+ <stringProp name="Assertion.custom_message"></stringProp>
+ <stringProp name="Assertion.test_field">Assertion.response_message</stringProp>
+ <boolProp name="Assertion.assume_success">false</boolProp>
+ <intProp name="Assertion.test_type">2</intProp>
+ </ResponseAssertion>
+ <hashTree/>
+ <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
+ <collectionProp name="Asserion.test_strings">
+ <stringProp name="-583173933">type_version</stringProp>
+ <stringProp name="-926053069">properties</stringProp>
+ <stringProp name="3373707">name</stringProp>
+ <stringProp name="351608024">version</stringProp>
+ </collectionProp>
+ <stringProp name="Assertion.custom_message"></stringProp>
+ <stringProp name="Assertion.test_field">Assertion.response_message</stringProp>
+ <boolProp name="Assertion.assume_success">false</boolProp>
+ <intProp name="Assertion.test_type">6</intProp>
+ </ResponseAssertion>
+ <hashTree/>
+ </hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Fetch Frequency Limiter Guard Decisions" enabled="true">
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
diff --git a/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java b/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java
index 70f9ebc0..cb12e0f6 100644
--- a/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java
+++ b/xacml-test/src/main/java/org/onap/policy/pdp/xacml/xacmltest/TestUtils.java
@@ -25,7 +25,6 @@ package org.onap.policy.pdp.xacml.xacmltest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -82,10 +81,11 @@ public class TestUtils {
//
for (Map<String, ToscaPolicy> policies : completedJtst.getToscaTopologyTemplate().getPolicies()) {
for (ToscaPolicy policy : policies.values()) {
- if (service.loadPolicy(policy)) {
+ try {
+ service.loadPolicy(policy);
loadedPolicies.add(policy);
- } else {
- LOGGER.error("Application failed to load policy");
+ } catch (XacmlApplicationException e) {
+ LOGGER.error("Application failed to load policy", e);
}
}
}