summaryrefslogtreecommitdiffstats
path: root/controlloop/common/policy-yaml/src/test/java
diff options
context:
space:
mode:
authorMichael Borokhovich <michael@research.att.com>2017-07-20 09:53:57 -0400
committerMichael Borokhovich <michael@research.att.com>2017-07-20 12:11:23 -0400
commitfa09813ca39cbdb7a0ac6a38507d4ea96e28879f (patch)
treec9b2cc4bdf2c109ab43f79afd1af4909f813636b /controlloop/common/policy-yaml/src/test/java
parentd3c335e97b9d262588696784551e8bd02ce8331f (diff)
[POLICY-80] Adding the Policy Guard features
Two Policy Guard features added: Frequency-limiter and Blacklist. Change-Id: I48184ab0ae9760c9ea7594cd7346b456aa964d48 Signed-off-by: Michael Borokhovich <michael@research.att.com>
Diffstat (limited to 'controlloop/common/policy-yaml/src/test/java')
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java13
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java31
-rw-r--r--controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java4
3 files changed, 33 insertions, 15 deletions
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java
index ddee23cef..f381aa207 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java
@@ -33,11 +33,20 @@ import org.junit.Test;
import org.onap.policy.controlloop.guard.compiler.ControlLoopGuardCompiler;
public class ControlLoopGuardCompilerTest {
-
+
@Test
public void testTest1() {
try {
- this.test("src/test/resources/v2.0.0-guard/policy_guard_vUSP_1707_appc.yaml");
+ this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml");
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testTest2() {
+ try {
+ this.test("src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml");
} catch (Exception e) {
fail(e.getMessage());
}
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
index 28e3622f8..9cc1bbd6a 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java
@@ -20,7 +20,6 @@
package org.onap.policy.controlloop.policy.guard;
-import org.junit.Ignore;
import org.junit.Test;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
@@ -47,7 +46,6 @@ import org.onap.policy.controlloop.poligy.guard.builder.ControlLoopGuardBuilder;
public class ControlLoopGuardBuilderTest {
- @Ignore
@Test
public void testControlLoopGuard() {
try {
@@ -70,7 +68,13 @@ public class ControlLoopGuardBuilderTest {
//
// Add a guard policy without limit constraint
//
- GuardPolicy policy1 = new GuardPolicy("1111", "guardpolicy1", "guardpolicy1", "APPC", "restart");
+ String clname = "CL_vUSP123";
+ LinkedList<String> targets = new LinkedList<String>();
+ targets.add("s1");
+ targets.add("s2");
+ targets.add("s3");
+ MatchParameters matchParameters = new MatchParameters(clname, "APPC", "Restart", targets);
+ GuardPolicy policy1 = new GuardPolicy("id123", "guardpolicy1", "description aaa", matchParameters);
builder = builder.addGuardPolicy(policy1);
//
// Assert there is no limit constraint associated with the only guard policy
@@ -87,16 +91,16 @@ public class ControlLoopGuardBuilderTest {
//
// Add a constraint to policy1
//
- Map<String, String> time_in_range = new HashMap<String, String>();
- time_in_range.put("arg2", "PT5H");
- time_in_range.put("arg3", "PT24H");
+ Map<String, String> active_time_range = new HashMap<String, String>();
+ active_time_range.put("start", "00:00:00-05:00");
+ active_time_range.put("end", "23:59:59-05:00");
List<String> blacklist = new LinkedList<String>();
blacklist.add("eNodeB_common_id1");
blacklist.add("eNodeB_common_id2");
- Map<String, String> duration = new HashMap<String, String>();
- duration.put("value", "10");
- duration.put("units", "minute");
- Constraint cons = new Constraint(5, duration, time_in_range, blacklist);
+ Map<String, String> time_window = new HashMap<String, String>();
+ time_window.put("value", "10");
+ time_window.put("units", "minute");
+ Constraint cons = new Constraint(5, time_window, active_time_range, blacklist);
builder = builder.addLimitConstraint(policy1.id, cons);
//
// Add a duplicate constraint to policy1
@@ -152,7 +156,12 @@ public class ControlLoopGuardBuilderTest {
@Test
public void test1() {
- this.test("src/test/resources/v2.0.0-guard/policy_guard_vUSP_1707_appc.yaml");
+ this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml");
+ }
+
+ @Test
+ public void test2() {
+ this.test("src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml");
}
public void test(String testFile) {
diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
index 1475553d4..61ad4dfbf 100644
--- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
+++ b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
@@ -39,12 +39,12 @@ public class ControlLoopGuardTest {
@Test
public void testGuardvDNS() {
- this.test("src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml");
+ this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml");
}
@Test
public void testGuardvUSP() {
- this.test("src/test/resources/v2.0.0-guard/policy_guard_vUSP_1707_appc.yaml");
+ this.test("src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml");
}