Fix comments and add debugging 65/83365/2
authorPamela Dragosh <pdragosh@research.att.com>
Tue, 26 Mar 2019 15:19:12 +0000 (11:19 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Tue, 26 Mar 2019 15:45:42 +0000 (11:45 -0400)
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>
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java
applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
applications/guard/src/test/resources/vDNS.policy.guard.frequency.output.tosca.yaml
applications/guard/src/test/resources/vDNS.policy.guard.minmax.output.tosca.yaml
main/src/test/resources/decisions/decision.guard.shoulddeny.input.json
main/src/test/resources/decisions/decision.guard.shoulddeny.input2.json
main/src/test/resources/decisions/decision.guard.shouldpermit.input.json

index 8550b12..6ff1566 100644 (file)
@@ -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
index ff137e1..981afee 100644 (file)
@@ -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
index 03afd5e..a0552d4 100644 (file)
@@ -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
index 5ac7601..97282a6 100644 (file)
@@ -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
index 65d40c0..5906382 100644 (file)
@@ -7,7 +7,7 @@
   "resource": {
       "guard": {
           "actor": "SO",
-          "recipe": "scaleOut",
+          "recipe": "VF Module Create",
           "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
           "operationCount" : "1"
       }
index 29dfc3d..a97fc16 100644 (file)
@@ -7,7 +7,7 @@
   "resource": {
       "guard": {
           "actor": "SO",
-          "recipe": "scaleOut",
+          "recipe": "VF Module Create",
           "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
           "vfCount" : "6"
       }
index 92e933f..a80a4cf 100644 (file)
@@ -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"