aboutsummaryrefslogtreecommitdiffstats
path: root/applications/guard/src/test/resources
diff options
context:
space:
mode:
authorJoshua Reich <jreich@research.att.com>2019-04-08 09:41:36 -0700
committerJoshua Reich <jreich@research.att.com>2019-04-11 16:50:54 -0700
commitfca3dd7b4bdc33b579750004c9d3bc163d20a2a7 (patch)
treed82b7935f724cd2370789bb77c3bab036ec85147 /applications/guard/src/test/resources
parent4013653daa38a7fe1b9ffcae02e27d0bc411ac8f (diff)
Add Control Loop Coordination policy.
Refactor code to support multiple pip engines. Add pip engine for outcome. Modify LegacyGuardTranslator to use coordination translator's convertPolicy function when processing coordination guard. This version of convertPolicy intentionally uses string replacement on template-like xacml coordination guard to enable future support for API-based creation of new coordination guard types. Bug fixes and code cleanup. * Unused imports, sonar problems. * Consolidation of getAttribute method * Only use TypedQuery for Pips Issue-ID: POLICY-1471 Change-Id: I4e9365b7f23bee96cf438dad44feda97c65f6ecc Signed-off-by: Joshua Reich <jreich@research.att.com> Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/guard/src/test/resources')
-rw-r--r--applications/guard/src/test/resources/META-INF/persistence.xml8
-rw-r--r--applications/guard/src/test/resources/requests/coordination.cl.1.node.1.json15
-rw-r--r--applications/guard/src/test/resources/requests/coordination.cl.1.node.2.json15
-rw-r--r--applications/guard/src/test/resources/requests/coordination.cl.2.node.1.json15
-rw-r--r--applications/guard/src/test/resources/requests/coordination.cl.2.node.2.json16
-rw-r--r--applications/guard/src/test/resources/requests/guard.vfCount.1.json16
-rw-r--r--applications/guard/src/test/resources/requests/guard.vfCount.3.json16
-rw-r--r--applications/guard/src/test/resources/requests/guard.vfCount.6.json16
-rw-r--r--applications/guard/src/test/resources/test.policy.guard.coordination.firstBlocksSecond.tosca.yaml14
-rw-r--r--applications/guard/src/test/resources/xacml.properties29
10 files changed, 141 insertions, 19 deletions
diff --git a/applications/guard/src/test/resources/META-INF/persistence.xml b/applications/guard/src/test/resources/META-INF/persistence.xml
index de399c48..8d1e08ad 100644
--- a/applications/guard/src/test/resources/META-INF/persistence.xml
+++ b/applications/guard/src/test/resources/META-INF/persistence.xml
@@ -8,9 +8,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,10 +23,11 @@
<persistence-unit name="OperationsHistoryPUTest" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
- <class>org.onap.policy.pdp.xacml.application.common.OnapOperationsHistoryDbao</class>
+ <class>org.onap.policy.pdp.xacml.application.common.operationshistory.Dbao</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.logging.level" value="FINE" />
+ <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb;DATABASE_TO_UPPER=FALSE" />
<property name="javax.persistence.jdbc.user" value="policy" />
@@ -38,4 +39,3 @@
</persistence-unit>
</persistence>
- \ No newline at end of file
diff --git a/applications/guard/src/test/resources/requests/coordination.cl.1.node.1.json b/applications/guard/src/test/resources/requests/coordination.cl.1.node.1.json
new file mode 100644
index 00000000..dd461005
--- /dev/null
+++ b/applications/guard/src/test/resources/requests/coordination.cl.1.node.1.json
@@ -0,0 +1,15 @@
+{
+ "ONAPName": "Policy",
+ "ONAPComponent": "drools-pdp",
+ "ONAPInstance": "usecase-template",
+ "requestId": "unique-request-id-47",
+ "action": "guard",
+ "resource": {
+ "guard": {
+ "actor": "SDNR",
+ "recipe": "Tilt",
+ "clname": "cl1",
+ "target": "node1"
+ }
+ }
+}
diff --git a/applications/guard/src/test/resources/requests/coordination.cl.1.node.2.json b/applications/guard/src/test/resources/requests/coordination.cl.1.node.2.json
new file mode 100644
index 00000000..dbd3a53a
--- /dev/null
+++ b/applications/guard/src/test/resources/requests/coordination.cl.1.node.2.json
@@ -0,0 +1,15 @@
+{
+ "ONAPName": "Policy",
+ "ONAPComponent": "drools-pdp",
+ "ONAPInstance": "usecase-template",
+ "requestId": "unique-request-id-4712",
+ "action": "guard",
+ "resource": {
+ "guard": {
+ "actor": "SDNR",
+ "recipe": "Tilt",
+ "clname": "cl1",
+ "target": "node2"
+ }
+ }
+}
diff --git a/applications/guard/src/test/resources/requests/coordination.cl.2.node.1.json b/applications/guard/src/test/resources/requests/coordination.cl.2.node.1.json
new file mode 100644
index 00000000..edccc45b
--- /dev/null
+++ b/applications/guard/src/test/resources/requests/coordination.cl.2.node.1.json
@@ -0,0 +1,15 @@
+{
+ "ONAPName": "Policy",
+ "ONAPComponent": "drools-pdp",
+ "ONAPInstance": "usecase-template",
+ "requestId": "unique-request-id-6877",
+ "action": "guard",
+ "resource": {
+ "guard": {
+ "actor": "SDNR",
+ "recipe": "Tilt",
+ "clname": "cl2",
+ "target": "node1"
+ }
+ }
+}
diff --git a/applications/guard/src/test/resources/requests/coordination.cl.2.node.2.json b/applications/guard/src/test/resources/requests/coordination.cl.2.node.2.json
new file mode 100644
index 00000000..c1401f22
--- /dev/null
+++ b/applications/guard/src/test/resources/requests/coordination.cl.2.node.2.json
@@ -0,0 +1,16 @@
+
+{
+ "ONAPName": "Policy",
+ "ONAPComponent": "drools-pdp",
+ "ONAPInstance": "usecase-template",
+ "requestId": "unique-request-id-6837",
+ "action": "guard",
+ "resource": {
+ "guard": {
+ "actor": "SDNR",
+ "recipe": "Tilt",
+ "clname": "cl2",
+ "target": "node2"
+ }
+ }
+}
diff --git a/applications/guard/src/test/resources/requests/guard.vfCount.1.json b/applications/guard/src/test/resources/requests/guard.vfCount.1.json
new file mode 100644
index 00000000..ef1b5f65
--- /dev/null
+++ b/applications/guard/src/test/resources/requests/guard.vfCount.1.json
@@ -0,0 +1,16 @@
+{
+ "ONAPName": "Policy",
+ "ONAPComponent": "drools-pdp",
+ "ONAPInstance": "usecase-template",
+ "requestId": "unique-request-id-1",
+ "action": "guard",
+ "resource": {
+ "guard": {
+ "actor": "SO",
+ "recipe": "VF Module Create",
+ "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
+ "target": "vLoadBalancer-00",
+ "vfCount": "1"
+ }
+ }
+}
diff --git a/applications/guard/src/test/resources/requests/guard.vfCount.3.json b/applications/guard/src/test/resources/requests/guard.vfCount.3.json
new file mode 100644
index 00000000..9faa55d6
--- /dev/null
+++ b/applications/guard/src/test/resources/requests/guard.vfCount.3.json
@@ -0,0 +1,16 @@
+{
+ "ONAPName": "Policy",
+ "ONAPComponent": "drools-pdp",
+ "ONAPInstance": "usecase-template",
+ "requestId": "unique-request-id-3",
+ "action": "guard",
+ "resource": {
+ "guard": {
+ "actor": "SO",
+ "recipe": "VF Module Create",
+ "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
+ "target": "vLoadBalancer-00",
+ "vfCount": "3"
+ }
+ }
+}
diff --git a/applications/guard/src/test/resources/requests/guard.vfCount.6.json b/applications/guard/src/test/resources/requests/guard.vfCount.6.json
new file mode 100644
index 00000000..e00d67ae
--- /dev/null
+++ b/applications/guard/src/test/resources/requests/guard.vfCount.6.json
@@ -0,0 +1,16 @@
+{
+ "ONAPName": "Policy",
+ "ONAPComponent": "drools-pdp",
+ "ONAPInstance": "usecase-template",
+ "requestId": "unique-request-id-2",
+ "action": "guard",
+ "resource": {
+ "guard": {
+ "actor": "SO",
+ "recipe": "VF Module Create",
+ "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
+ "target": "vLoadBalancer-00",
+ "vfCount" : "6"
+ }
+ }
+}
diff --git a/applications/guard/src/test/resources/test.policy.guard.coordination.firstBlocksSecond.tosca.yaml b/applications/guard/src/test/resources/test.policy.guard.coordination.firstBlocksSecond.tosca.yaml
new file mode 100644
index 00000000..649820b0
--- /dev/null
+++ b/applications/guard/src/test/resources/test.policy.guard.coordination.firstBlocksSecond.tosca.yaml
@@ -0,0 +1,14 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+topology_template:
+ policies:
+ -
+ guard.coordination.firstBlocksSecond.test:
+ type: onap.policies.controlloop.guard.coordination.FirstBlocksSecond
+ version: 1.0.0
+ metadata:
+ policy-id : guard.coordination.firstBlocksSecond.test
+ policy-version: 1
+ properties:
+ controlLoop:
+ - cl1
+ - cl2
diff --git a/applications/guard/src/test/resources/xacml.properties b/applications/guard/src/test/resources/xacml.properties
index 25dee375..534c538c 100644
--- a/applications/guard/src/test/resources/xacml.properties
+++ b/applications/guard/src/test/resources/xacml.properties
@@ -24,23 +24,22 @@ xacml.att.policyFinderFactory=org.onap.policy.pdp.xacml.application.common.OnapP
#
xacml.att.policyFinderFactory.combineRootPolicies=urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:deny-overrides
-xacml.pip.engines=historydb
-
#
-# PIP Engine Definition
+# PIP Engine Definitions
#
-historydb.classname=org.onap.policy.pdp.xacml.application.common.OnapOperationsHistoryPipEngine
-historydb.issuer=urn:org:onap:xacml:guard:historydb
-historydb.name=operationHistoryDB
-historydb.description=Returns operation counts based on time window
+count-recent-operations.classname=org.onap.policy.pdp.xacml.application.common.operationshistory.CountRecentOperationsPip
+count-recent-operations.issuer=urn:org:onap:xacml:guard:count-recent-operations
+count-recent-operations.name=CountRecentOperations
+count-recent-operations.description=Returns operation counts based on time window
+count-recent-operations.persistenceunit=OperationsHistoryPUTest
-#
-# Database persistence for PIP
-#
-historydb.persistenceunit=OperationsHistoryPUTest
+get-operation-outcome.classname=org.onap.policy.pdp.xacml.application.common.operationshistory.GetOperationOutcomePip
+get-operation-outcome.issuer=urn:org:onap:xacml:guard:get-operation-outcome
+get-operation-outcome.name=GetOperationOutcome
+get-operation-outcome.description=Returns operation outcome
+get-operation-outcome.persistenceunit=OperationsHistoryPUTest
-# Policies to load
#
-#xacml.rootPolicies=guard
-#guard.file=src/main/resources/RootGuardPolicy.xml
-
+# Make pips available to finder
+#
+xacml.pip.engines=count-recent-operations,get-operation-outcome \ No newline at end of file