summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-12-09 15:31:20 +0000
committerGerrit Code Review <gerrit@onap.org>2019-12-09 15:31:20 +0000
commit00f1e3597d3fd4f62386470a36d943029c167990 (patch)
tree034ff227160f94d1d330d3750a8c8ac3f585488c
parent9780a369f50d5e1cad9e5a013c4cb353fa09f01d (diff)
parent772c73244e6036635cf0861cea08034a932ffad8 (diff)
Merge "Refactor optimization policies"
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml16
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml23
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml15
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml (renamed from models-examples/src/main/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml)4
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml (renamed from models-examples/src/main/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml)4
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml (renamed from models-examples/src/main/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml)4
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml (renamed from models-examples/src/main/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml)4
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml (renamed from models-examples/src/main/resources/policytypes/onap.policies.optimization.PciPolicy.yaml)4
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml (renamed from models-examples/src/main/resources/policytypes/onap.policies.optimization.Vim_fit.yaml)4
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml (renamed from models-examples/src/main/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml)4
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml (renamed from models-examples/src/main/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml)4
-rw-r--r--models-examples/src/main/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml (renamed from models-examples/src/main/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml)4
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java18
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java20
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java64
15 files changed, 122 insertions, 70 deletions
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml b/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml
index f88239d73..2cd391ff0 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.Optimization.yaml
@@ -13,22 +13,6 @@ policy_types:
required: true
entry_schema:
type: string
- services:
- description: One or more services that the policy applies to.
- type: list
- metadata:
- matchable: true
- required: true
- entry_schema:
- type: string
- resources:
- description: One or more VNF resources that the policy applies to.
- type: list
- metadata:
- matchable: true
- required: true
- entry_schema:
- type: string
geography:
description: One or more geographic regions
type: list
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml
new file mode 100644
index 000000000..1d8135162
--- /dev/null
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Resource.yaml
@@ -0,0 +1,23 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+policy_types:
+ onap.policies.optimization.Resource:
+ derived_from: onap.policies.Optimization
+ version: 1.0.0
+ description: The base policy type for all policies that govern optimization for a Resource in a Service.
+ properties:
+ services:
+ description: One or more services that the policy applies to.
+ type: list
+ metadata:
+ matchable: true
+ required: true
+ entry_schema:
+ type: string
+ resources:
+ description: One or more VNF resources that the policy applies to.
+ type: list
+ metadata:
+ matchable: true
+ required: true
+ entry_schema:
+ type: string \ No newline at end of file
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml
new file mode 100644
index 000000000..8e7b724da
--- /dev/null
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.Service.yaml
@@ -0,0 +1,15 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+policy_types:
+ onap.policies.optimization.Service:
+ derived_from: onap.policies.Optimization
+ version: 1.0.0
+ description: The base policy type for all policies that govern optimization for a Service.
+ properties:
+ services:
+ description: One or more services that the policy applies to.
+ type: list
+ metadata:
+ matchable: true
+ required: true
+ entry_schema:
+ type: string \ No newline at end of file
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml
index abac21922..173691f21 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.AffinityPolicy.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml
@@ -1,7 +1,7 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- onap.policies.optimization.AffinityPolicy:
- derived_from: onap.policies.Optimization
+ onap.policies.optimization.resource.AffinityPolicy:
+ derived_from: onap.policies.optimization.Resource
version: 1.0.0
properties:
applicableResources:
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml
index 3c9150d9e..060c4f97c 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.DistancePolicy.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.DistancePolicy.yaml
@@ -1,7 +1,7 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- onap.policies.optimization.DistancePolicy:
- derived_from: onap.policies.Optimization
+ onap.policies.optimization.resource.DistancePolicy:
+ derived_from: onap.policies.optimization.Resource
version: 1.0.0
properties:
applicableResources:
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml
index dbb5e9ef1..d35552f10 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.HpaPolicy.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.HpaPolicy.yaml
@@ -1,7 +1,7 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- onap.policies.optimization.HpaPolicy:
- derived_from: onap.policies.Optimization
+ onap.policies.optimization.resource.HpaPolicy:
+ derived_from: onap.policies.optimization.Resource
version: 1.0.0
properties:
flavorFeatures:
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml
index e03ceeea6..abc329ccd 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.OptimizationPolicy.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml
@@ -1,7 +1,7 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- onap.policies.optimization.OptimizationPolicy:
- derived_from: onap.policies.Optimization
+ onap.policies.optimization.resource.OptimizationPolicy:
+ derived_from: onap.policies.optimization.Resource
version: 1.0.0
properties:
objective:
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.PciPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml
index 097a5f173..887e372df 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.PciPolicy.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.PciPolicy.yaml
@@ -1,7 +1,7 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- onap.policies.optimization.PciPolicy:
- derived_from: onap.policies.Optimization
+ onap.policies.optimization.resource.PciPolicy:
+ derived_from: onap.policies.optimization.Resource
version: 1.0.0
properties:
pciProperties:
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Vim_fit.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml
index b70dddb2f..fd851248f 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.Vim_fit.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.Vim_fit.yaml
@@ -1,7 +1,7 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- onap.policies.optimization.Vim_fit:
- derived_from: onap.policies.Optimization
+ onap.policies.optimization.resource.Vim_fit:
+ derived_from: onap.policies.optimization.Resource
version: 1.0.0
properties:
applicableResources:
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml
index 18a0ccfd0..960ee15f4 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.VnfPolicy.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.resource.VnfPolicy.yaml
@@ -1,7 +1,7 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- onap.policies.optimization.VnfPolicy:
- derived_from: onap.policies.Optimization
+ onap.policies.optimization.resource.VnfPolicy:
+ derived_from: onap.policies.optimization.Resource
version: 1.0.0
properties:
applicableResources:
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml
index 41b923ad7..68c6636b4 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.QueryPolicy.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.QueryPolicy.yaml
@@ -1,7 +1,7 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- onap.policies.optimization.QueryPolicy:
- derived_from: onap.policies.Optimization
+ onap.policies.optimization.service.QueryPolicy:
+ derived_from: onap.policies.optimization.Service
version: 1.0.0
properties:
queryProperties:
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml b/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml
index 010a1534b..b6327c87b 100644
--- a/models-examples/src/main/resources/policytypes/onap.policies.optimization.SubscriberPolicy.yaml
+++ b/models-examples/src/main/resources/policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml
@@ -1,7 +1,7 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- onap.policies.optimization.SubscriberPolicy:
- derived_from: onap.policies.Optimization
+ onap.policies.optimization.service.SubscriberPolicy:
+ derived_from: onap.policies.optimization.Service
version: 1.0.0
properties:
subscriberProperties:
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
index 2ccf215c9..75f21d2f8 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
@@ -64,17 +64,17 @@ public class PolicyTypePersistenceTest {
// @formatter:off
private String[] policyTypeResourceNames = {
"policytypes/onap.policies.controlloop.Operational.yaml",
- "policytypes/onap.policies.optimization.DistancePolicy.yaml",
- "policytypes/onap.policies.optimization.VnfPolicy.yaml",
- "policytypes/onap.policies.optimization.PciPolicy.yaml",
- "policytypes/onap.policies.optimization.OptimizationPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.DistancePolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.VnfPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.PciPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml",
"policytypes/onap.policies.controlloop.guard.Blacklist.yaml",
"policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml",
- "policytypes/onap.policies.optimization.HpaPolicy.yaml",
- "policytypes/onap.policies.optimization.Vim_fit.yaml",
- "policytypes/onap.policies.optimization.SubscriberPolicy.yaml",
- "policytypes/onap.policies.optimization.AffinityPolicy.yaml",
- "policytypes/onap.policies.optimization.QueryPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.HpaPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.Vim_fit.yaml",
+ "policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml",
+ "policytypes/onap.policies.optimization.service.QueryPolicy.yaml",
"policytypes/onap.policies.controlloop.guard.MinMax.yaml",
"policytypes/onap.policies.controlloop.guard.FrequencyLimiter.yaml",
"policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml",
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java
index d9ffec566..f4f822c20 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java
@@ -27,12 +27,10 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import com.google.gson.GsonBuilder;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.utils.coder.CoderException;
@@ -59,17 +57,17 @@ public class ToscaPolicyTypeFilterTest {
// @formatter:off
private static final String[] policyTypeResourceNames = {
"policytypes/onap.policies.controlloop.Operational.yaml",
- "policytypes/onap.policies.optimization.DistancePolicy.yaml",
- "policytypes/onap.policies.optimization.VnfPolicy.yaml",
- "policytypes/onap.policies.optimization.PciPolicy.yaml",
- "policytypes/onap.policies.optimization.OptimizationPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.DistancePolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.VnfPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.PciPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.OptimizationPolicy.yaml",
"policytypes/onap.policies.controlloop.guard.Blacklist.yaml",
"policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml",
- "policytypes/onap.policies.optimization.HpaPolicy.yaml",
- "policytypes/onap.policies.optimization.Vim_fit.yaml",
- "policytypes/onap.policies.optimization.SubscriberPolicy.yaml",
- "policytypes/onap.policies.optimization.AffinityPolicy.yaml",
- "policytypes/onap.policies.optimization.QueryPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.HpaPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.Vim_fit.yaml",
+ "policytypes/onap.policies.optimization.service.SubscriberPolicy.yaml",
+ "policytypes/onap.policies.optimization.resource.AffinityPolicy.yaml",
+ "policytypes/onap.policies.optimization.service.QueryPolicy.yaml",
"policytypes/onap.policies.controlloop.guard.MinMax.yaml",
"policytypes/onap.policies.controlloop.guard.FrequencyLimiter.yaml",
"policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml",
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java
index 9f9906930..e710faa31 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/OptimizationPolicyTypeSerializationTest.java
@@ -44,7 +44,10 @@ public class OptimizationPolicyTypeSerializationTest {
private static final String TYPE_ROOT = "tosca.policies.Root";
private static final String VERSION = "1.0.0";
- private static final String INPUT_YAML = "policytypes/onap.policies.Optimization.yaml";
+ private static final String INPUT_OPTIMIZATION_YAML = "policytypes/onap.policies.Optimization.yaml";
+ private static final String INPUT_OPTIMIZATION_RESOURCE_YAML =
+ "policytypes/onap.policies.optimization.Resource.yaml";
+ private static final String INPUT_OPTIMIZATION_SERVICE_YAML = "policytypes/onap.policies.optimization.Service.yaml";
private StandardCoder coder;
@@ -54,13 +57,39 @@ public class OptimizationPolicyTypeSerializationTest {
}
@Test
- public void test() throws CoderException {
- JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_YAML);
- validate("initial object", svctmpl);
+ public void testOptimization() throws CoderException {
+ JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_OPTIMIZATION_YAML);
+ validate("initial object", svctmpl, TYPE_ROOT, "onap.policies.Optimization", false, false);
String ser = serialize(svctmpl);
JpaToscaServiceTemplate svctmpl2 = deserialize(ser);
- validate("copy", svctmpl2);
+ validate("copy", svctmpl2, TYPE_ROOT, "onap.policies.Optimization", false, false);
+
+ assertEquals(svctmpl, svctmpl2);
+ }
+
+ @Test
+ public void testOptimizationResource() throws CoderException {
+ JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_OPTIMIZATION_RESOURCE_YAML);
+ validate("initial object", svctmpl, "onap.policies.Optimization", "onap.policies.optimization.Resource", true,
+ true);
+
+ String ser = serialize(svctmpl);
+ JpaToscaServiceTemplate svctmpl2 = deserialize(ser);
+ validate("copy", svctmpl2, "onap.policies.Optimization", "onap.policies.optimization.Resource", true, true);
+
+ assertEquals(svctmpl, svctmpl2);
+ }
+
+ @Test
+ public void testOptimizationService() throws CoderException {
+ JpaToscaServiceTemplate svctmpl = loadYaml(INPUT_OPTIMIZATION_SERVICE_YAML);
+ validate("initial object", svctmpl, "onap.policies.Optimization", "onap.policies.optimization.Service", false,
+ true);
+
+ String ser = serialize(svctmpl);
+ JpaToscaServiceTemplate svctmpl2 = deserialize(ser);
+ validate("copy", svctmpl2, "onap.policies.Optimization", "onap.policies.optimization.Service", false, true);
assertEquals(svctmpl, svctmpl2);
}
@@ -86,29 +115,32 @@ public class OptimizationPolicyTypeSerializationTest {
return coder.encode(auth);
}
- private void validate(String testnm, JpaToscaServiceTemplate svctmpl) {
+ private void validate(String testnm, JpaToscaServiceTemplate svctmpl, String derivedFrom,
+ String typeName, boolean checkResource, boolean checkService) {
JpaToscaPolicyTypes policyTypes = svctmpl.getPolicyTypes();
assertEquals(testnm + " type count", 1, policyTypes.getConceptMap().size());
JpaToscaPolicyType policyType = policyTypes.getConceptMap().values().iterator().next();
- assertEquals(testnm + " name", "onap.policies.Optimization", policyType.getName());
+ assertEquals(testnm + " name", typeName, policyType.getName());
assertEquals(testnm + " version", VERSION, policyType.getVersion());
assertNotNull(testnm + " derived from", policyType.getDerivedFrom());
- assertEquals(testnm + " derived from name", TYPE_ROOT, policyType.getDerivedFrom().getName());
-
- assertEquals(testnm + " description", "The base policy type for all policies that govern optimization",
- policyType.getDescription());
+ assertEquals(testnm + " derived from name", derivedFrom, policyType.getDerivedFrom().getName());
Map<String, JpaToscaProperty> props = policyType.getProperties();
assertNotNull(testnm + " properties", props);
- validateScope(testnm, props.get("scope"));
- validateServices(testnm, props.get("services"));
- validateResources(testnm, props.get("resources"));
- validateGeography(testnm, props.get("geography"));
- validateIdentity(testnm, props.get("identity"));
+ if (checkResource && checkService) {
+ validateResources(testnm, props.get("resources"));
+ validateServices(testnm, props.get("services"));
+ } else if (checkService && !checkResource) {
+ validateServices(testnm, props.get("services"));
+ } else {
+ validateScope(testnm, props.get("scope"));
+ validateGeography(testnm, props.get("geography"));
+ validateIdentity(testnm, props.get("identity"));
+ }
}
// only need to validate deep match of one of these; geography is the most interesting