diff options
author | Michael Borokhovich <michael@research.att.com> | 2017-07-20 09:53:57 -0400 |
---|---|---|
committer | Michael Borokhovich <michael@research.att.com> | 2017-07-20 12:11:23 -0400 |
commit | fa09813ca39cbdb7a0ac6a38507d4ea96e28879f (patch) | |
tree | c9b2cc4bdf2c109ab43f79afd1af4909f813636b /controlloop/common/policy-yaml/src/test | |
parent | d3c335e97b9d262588696784551e8bd02ce8331f (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')
8 files changed, 76 insertions, 67 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"); } diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml new file mode 100644 index 000000000..f2390fae0 --- /dev/null +++ b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml @@ -0,0 +1,19 @@ +guard: + version: 2.0.0 + +guards: + - id: unique_guard_ONAP_vDNS_1 + name: MSO Spinup + description: We only spin up 1 instance over a 10 minute window + match_parameters: + actor: MSO + recipe: VF Module Create + limit_constraints: + - freq_limit_per_target: 1 + # + # https://www.w3.org/TR/xmlschema-2/#duration + # + time_window: + value: 10 + units: hour +
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml deleted file mode 100644 index 7b5f17c61..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml +++ /dev/null @@ -1,14 +0,0 @@ -guard: - version: 2.0.0 - -guards: - - id: unique_guard_ONAP_vDNS_1 - name: MSO Spinup - description: We only spin up 1 instance over a 10 minute window - actor: MSO - recipe: VF Module Create - limit_constraints: - - num: 1 - duration: - value: 15 - units: minute diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml~ b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml~ deleted file mode 100644 index a0d76d225..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_OpenECOMP_demo_vDNS.yaml~ +++ /dev/null @@ -1,12 +0,0 @@ -guard: - version: 2.0.0 - -guards: - - id: unique_guard_ONAP_vDNS_1 - name: MSO Spinup - description: We only spin up 1 instance over a 10 minute window - actor: MSO - recipe: VF Module Create - limit_constraints: - - num: 1 - duration: PT10M diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml new file mode 100644 index 000000000..6e47ca2b4 --- /dev/null +++ b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml @@ -0,0 +1,24 @@ +guard: + version: 2.0.0 + +guards: + - id: unique_guard_1 + name: APPC 5 Restart + description: + We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) + match_parameters: + controlLoopName: CL_NAME_ABC_123 + actor: APPC + recipe: Restart + targets: + - s1 + s2 + s3 + limit_constraints: + - freq_limit_per_target: 5 + time_window: + value: 15 + units: minute + active_time_range: + start: 00:00:00-05:00 + end: 23:59:59-05:00
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_vUSP_1707_appc.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_vUSP_1707_appc.yaml deleted file mode 100644 index a487210cd..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_vUSP_1707_appc.yaml +++ /dev/null @@ -1,26 +0,0 @@ -guard: - version: 2.0.0 - -guards: - - id: unique_guard_vUSP_1 - name: APPC 5 Restart - description: - We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) - actor: APPC - recipe: Restart - limit_constraints: - - num: 5 - # - # https://www.w3.org/TR/xmlschema-2/#duration - # - duration: - value: 15 - units: minute - # - # XACML function time-in-range - # - # Assumption is that the "current time" is the 1st argument - # - time_in_range: - arg2: PT5H - arg3: PT24H
\ No newline at end of file |