summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-03-26 11:19:12 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-03-26 11:45:42 -0400
commitd3438454879ec3f3c31ca8af2fc5903b7f8697ae (patch)
tree68abbf250babf352e9cc2b08a7cac0a04729e2b1
parent2c847e0855b316c162c9fd31456fdf8e338a5dba (diff)
Fix comments and add debugging
Added some fixes from previous review and some debugging for the JUnits. The merge failed in the JUnits and I could not see why. I think the wrong request was sent, but I'm not sure why the JUnits woulnd't fail locally or in the verify job. We need to do a lot of testing with these policy translations. Also fixed the guard policies to use correct VF Module Create recipe. Issue-ID: POLICY-1273 Change-Id: I813bcca92436d356c43da5613eab7ba7746a4e3d Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java2
-rw-r--r--applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java103
-rw-r--r--applications/guard/src/test/resources/vDNS.policy.guard.frequency.output.tosca.yaml2
-rw-r--r--applications/guard/src/test/resources/vDNS.policy.guard.minmax.output.tosca.yaml2
-rw-r--r--main/src/test/resources/decisions/decision.guard.shoulddeny.input.json2
-rw-r--r--main/src/test/resources/decisions/decision.guard.shoulddeny.input2.json2
-rw-r--r--main/src/test/resources/decisions/decision.guard.shouldpermit.input.json2
7 files changed, 60 insertions, 55 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
index 8550b12e..6ff1566b 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
@@ -182,7 +182,7 @@ public class StdMatchableTranslator implements ToscaPolicyTranslator {
//
Object stringContents = assignment.getAttributeValue().getValue();
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("DCAE contents: {}{}", System.lineSeparator(), stringContents);
+ LOGGER.debug("Policy contents: {}{}", System.lineSeparator(), stringContents);
}
//
// Let's parse it into a map using Gson
diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
index ff137e13..981afee7 100644
--- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
+++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
@@ -75,6 +75,7 @@ public class GuardPdpApplicationTest {
*/
@BeforeClass
public static void setUp() throws Exception {
+ LOGGER.info("Setting up class");
//
// Setup our temporary folder
//
@@ -108,7 +109,7 @@ public class GuardPdpApplicationTest {
strDump.append(application.supportedPolicyTypes());
strDump.append(System.lineSeparator());
}
- LOGGER.debug("{}", strDump);
+ LOGGER.info("{}", strDump);
//
// Tell it to initialize based on the properties file
// we just built for it.
@@ -118,6 +119,7 @@ public class GuardPdpApplicationTest {
@Test
public void test1Basics() throws CoderException, IOException {
+ LOGGER.info("**************** Running test1 ****************");
//
// Load Single Decision Request
//
@@ -163,6 +165,7 @@ public class GuardPdpApplicationTest {
@Test
public void test2NoPolicies() {
+ LOGGER.info("**************** Running test2 ****************");
//
// Ask for a decision
//
@@ -175,6 +178,7 @@ public class GuardPdpApplicationTest {
@Test
public void test3FrequencyLimiter() throws CoderException, FileNotFoundException, IOException {
+ LOGGER.info("**************** Running test3 ****************");
//
// Now load the vDNS frequency limiter Policy - make sure
// the pdp can support it and have it load
@@ -190,36 +194,37 @@ public class GuardPdpApplicationTest {
// Load the policies
//
service.loadPolicies(toscaObject);
- //
- // Ask for a decision - should get permit
- //
- DecisionResponse response = service.makeDecision(requestGuardPermit);
- LOGGER.info("Looking for Permit Decision {}", response);
-
- assertThat(response).isNotNull();
- assertThat(response.getStatus()).isNotNull();
- assertThat(response.getStatus()).isEqualTo("Permit");
- //
- // Dump it out as Json
- //
- LOGGER.info(gson.encode(response));
- //
- // Ask for a decision - should get deny
- //
- response = service.makeDecision(requestGuardDeny2);
- LOGGER.info("Looking for Deny Decision {}", response);
- assertThat(response).isNotNull();
- assertThat(response.getStatus()).isNotNull();
- assertThat(response.getStatus()).isEqualTo("Deny");
- //
- // Dump it out as Json
- //
- LOGGER.info(gson.encode(response));
}
+ //
+ // Ask for a decision - should get permit
+ //
+ DecisionResponse response = service.makeDecision(requestGuardPermit);
+ LOGGER.info("Looking for Permit Decision {}", response);
+
+ assertThat(response).isNotNull();
+ assertThat(response.getStatus()).isNotNull();
+ assertThat(response.getStatus()).isEqualTo("Permit");
+ //
+ // Dump it out as Json
+ //
+ LOGGER.info(gson.encode(response));
+ //
+ // Ask for a decision - should get deny
+ //
+ response = service.makeDecision(requestGuardDeny);
+ LOGGER.info("Looking for Deny Decision {}", response);
+ assertThat(response).isNotNull();
+ assertThat(response.getStatus()).isNotNull();
+ assertThat(response.getStatus()).isEqualTo("Deny");
+ //
+ // Dump it out as Json
+ //
+ LOGGER.info(gson.encode(response));
}
@Test
public void test4MinMax() throws CoderException, FileNotFoundException, IOException {
+ LOGGER.info("**************** Running test4 ****************");
//
// Now load the vDNS min max Policy - make sure
// the pdp can support it and have it load
@@ -238,34 +243,34 @@ public class GuardPdpApplicationTest {
//
// Ask for a decision - should get permit
//
- DecisionResponse response = service.makeDecision(requestGuardPermit);
- LOGGER.info("Looking for Permit Decision {}", response);
-
- assertThat(response).isNotNull();
- assertThat(response.getStatus()).isNotNull();
- assertThat(response.getStatus()).isEqualTo("Permit");
- //
- // Dump it out as Json
- //
- LOGGER.info(gson.encode(response));
- //
- // Ask for a decision - should get deny
- //
- response = service.makeDecision(requestGuardDeny);
- LOGGER.info("Looking for Deny Decision {}", response);
- assertThat(response).isNotNull();
- assertThat(response.getStatus()).isNotNull();
- assertThat(response.getStatus()).isEqualTo("Deny");
- //
- // Dump it out as Json
- //
- LOGGER.info(gson.encode(response));
}
+ DecisionResponse response = service.makeDecision(requestGuardPermit);
+ LOGGER.info("Looking for Permit Decision {}", response);
+
+ assertThat(response).isNotNull();
+ assertThat(response.getStatus()).isNotNull();
+ assertThat(response.getStatus()).isEqualTo("Permit");
+ //
+ // Dump it out as Json
+ //
+ LOGGER.info(gson.encode(response));
+ //
+ // Ask for a decision - should get deny
+ //
+ response = service.makeDecision(requestGuardDeny);
+ LOGGER.info("Looking for Deny Decision {}", response);
+ assertThat(response).isNotNull();
+ assertThat(response.getStatus()).isNotNull();
+ assertThat(response.getStatus()).isEqualTo("Deny");
+ //
+ // Dump it out as Json
+ //
+ LOGGER.info(gson.encode(response));
}
@Test
public void test5MissingFields() throws FileNotFoundException, IOException {
- LOGGER.debug("Running test5");
+ LOGGER.info("**************** Running test5 ****************");
//
// Most likely we would not get a policy with missing fields passed to
// us from the API. But in case that happens, or we decide that some fields
diff --git a/applications/guard/src/test/resources/vDNS.policy.guard.frequency.output.tosca.yaml b/applications/guard/src/test/resources/vDNS.policy.guard.frequency.output.tosca.yaml
index 03afd5e2..a0552d42 100644
--- a/applications/guard/src/test/resources/vDNS.policy.guard.frequency.output.tosca.yaml
+++ b/applications/guard/src/test/resources/vDNS.policy.guard.frequency.output.tosca.yaml
@@ -10,7 +10,7 @@ topology_template:
policy-version: 1
properties:
actor: SO
- recipe: scaleOut
+ recipe: VF Module Create
targets: .*
clname: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
limit: 1
diff --git a/applications/guard/src/test/resources/vDNS.policy.guard.minmax.output.tosca.yaml b/applications/guard/src/test/resources/vDNS.policy.guard.minmax.output.tosca.yaml
index 5ac76015..97282a6f 100644
--- a/applications/guard/src/test/resources/vDNS.policy.guard.minmax.output.tosca.yaml
+++ b/applications/guard/src/test/resources/vDNS.policy.guard.minmax.output.tosca.yaml
@@ -10,7 +10,7 @@ topology_template:
policy-version: 1
properties:
actor: SO
- recipe: scaleOut
+ recipe: VF Module Create
targets: .*
clname: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3
min: 1
diff --git a/main/src/test/resources/decisions/decision.guard.shoulddeny.input.json b/main/src/test/resources/decisions/decision.guard.shoulddeny.input.json
index 65d40c0a..5906382c 100644
--- a/main/src/test/resources/decisions/decision.guard.shoulddeny.input.json
+++ b/main/src/test/resources/decisions/decision.guard.shoulddeny.input.json
@@ -7,7 +7,7 @@
"resource": {
"guard": {
"actor": "SO",
- "recipe": "scaleOut",
+ "recipe": "VF Module Create",
"clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
"operationCount" : "1"
}
diff --git a/main/src/test/resources/decisions/decision.guard.shoulddeny.input2.json b/main/src/test/resources/decisions/decision.guard.shoulddeny.input2.json
index 29dfc3dc..a97fc16e 100644
--- a/main/src/test/resources/decisions/decision.guard.shoulddeny.input2.json
+++ b/main/src/test/resources/decisions/decision.guard.shoulddeny.input2.json
@@ -7,7 +7,7 @@
"resource": {
"guard": {
"actor": "SO",
- "recipe": "scaleOut",
+ "recipe": "VF Module Create",
"clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
"vfCount" : "6"
}
diff --git a/main/src/test/resources/decisions/decision.guard.shouldpermit.input.json b/main/src/test/resources/decisions/decision.guard.shouldpermit.input.json
index 92e933f7..a80a4cfa 100644
--- a/main/src/test/resources/decisions/decision.guard.shouldpermit.input.json
+++ b/main/src/test/resources/decisions/decision.guard.shouldpermit.input.json
@@ -7,7 +7,7 @@
"resource": {
"guard": {
"actor": "SO",
- "recipe": "scaleOut",
+ "recipe": "VF Module Create",
"clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
"operationCount": "0",
"vfCount": "1"