diff options
author | daniel <dc443y@att.com> | 2017-09-28 10:01:21 -0500 |
---|---|---|
committer | daniel <dc443y@att.com> | 2017-09-28 10:57:26 -0500 |
commit | 788289af4cbe6d288f6dadb9e1eca4ee2740a30d (patch) | |
tree | f99cb9f83fcba03ca5e74be49ee9a5b5f64838da /controlloop/templates/template.demo/src/test/java | |
parent | 400ca9b5ebb98c42c0c497d917f3cf139b03888a (diff) |
Fix Retries for Policies
This applies changes to make retries work properly
for all control loops. The current design was ignoring
the upper bound of the retries and retrying until either
a success or control loop timeout occured. This is now
fixed to only do retries until the limit is reached that
is specified from the policy.
The operation is now started in the GUARD.PERMITTED rule.
I think this is better because it stops Policy from doing
extra processing if there is a guard deny. This is also
needed so that we can properly do retries for all cases.
The notifications sent in GUARD_NOT_YET_QUERIED and
GUARD.RESPONSE are now more informative with the
message specifying the actor and recipe. The not queried
rule has a message stating that we are sending a query
to guard and the guard response message in the guard
response rule specifices the result from guard.
During a retest of vDNS it appeared that the archetype
template was no longer working, this was because there
were changes in the JUnit template that were not
reflected in the archetype template. These were added
to archetype and vDNS is verified to work again.
Another small fix needed was making sure the action for
vCPE is "Restart" instead of "restart". APPC will
reject our request if "Restart" is not sent as the
action.
Issue-ID: POLICY-259
Change-Id: I28dd3c9a629d297b408775a01afadd5c19351e37
Signed-off-by: Daniel Cruz <dc443y@att.com>
Diffstat (limited to 'controlloop/templates/template.demo/src/test/java')
6 files changed, 21 insertions, 17 deletions
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java index a6a4d3fc6..77a1ac063 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopXacmlGuardTest.java @@ -76,7 +76,7 @@ public class ControlLoopXacmlGuardTest { @BeforeClass public static void setPUProp(){ System.setProperty(OPSHISTPUPROP, "TestOperationsHistoryPU"); - Util.setTestGuardProps(); + Util.setGuardProps(); } @AfterClass public static void restorePUProp(){ diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java index df10714b9..66a72bc2b 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java @@ -275,18 +275,26 @@ public final class Util { PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); } + public static void setSOProps(){ PolicyEngine.manager.setEnvironmentProperty("so.url", "http://localhost:6667"); PolicyEngine.manager.setEnvironmentProperty("so.username", "SO"); PolicyEngine.manager.setEnvironmentProperty("so.password", "SO"); } - public static void setTestGuardProps(){ + + public static void setGuardProps(){ PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_URL, "http://localhost:6669/pdp/api/getDecision"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER, "python"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS, "test"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_USER, "python"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_CLIENT_PASS, "test"); PolicyEngine.manager.setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_ENV, "TEST"); + } + + public static void setVFCProps() { + PolicyEngine.manager.setEnvironmentProperty("vfc.url", "http://localhost:6668"); + PolicyEngine.manager.setEnvironmentProperty("vfc.username", "VFC"); + PolicyEngine.manager.setEnvironmentProperty("vfc.password", "VFC"); } - + } diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java index 9743f8808..d43537b80 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java @@ -45,7 +45,6 @@ import org.onap.policy.controlloop.policy.ControlLoopPolicy; import org.onap.policy.controlloop.policy.TargetType; import org.onap.policy.drools.http.server.HttpServletServer; import org.onap.policy.drools.impl.PolicyEngineJUnitImpl; -import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.guard.PolicyGuard; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,13 +59,8 @@ public class VCPEControlLoopTest { static { /* Set environment properties */ - PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); - PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); - PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); - - PolicyEngine.manager.setEnvironmentProperty("guard.url", "http://localhost:6669/pdp/api/getDecision"); - PolicyEngine.manager.setEnvironmentProperty("guard.username", "GUARD"); - PolicyEngine.manager.setEnvironmentProperty("guard.password", "GUARD"); + Util.setAAIProps(); + Util.setGuardProps(); } @BeforeClass @@ -198,7 +192,7 @@ public class VCPEControlLoopTest { * See if Guard permits this action, if it does * not then the test should fail */ - if (((VirtualControlLoopNotification)obj).message.contains("Guard result: PERMIT")) { + if (((VirtualControlLoopNotification)obj).message.contains("PERMIT")) { /* * A notification should be sent out of the Policy diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java index a8a4bf398..0b0cb6d1f 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VDNSControlLoopTest.java @@ -61,6 +61,7 @@ public class VDNSControlLoopTest { /* Set environment properties */ Util.setAAIProps(); Util.setSOProps(); + Util.setGuardProps(); } @BeforeClass @@ -68,6 +69,7 @@ public class VDNSControlLoopTest { try { Util.buildAaiSim(); Util.buildSoSim(); + Util.buildGuardSim(); } catch (Exception e) { fail(e.getMessage()); } diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java index a4845693c..fbe9129bd 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFCControlLoopTest.java @@ -59,10 +59,8 @@ public class VFCControlLoopTest { static { /* Set environment properties */ Util.setAAIProps(); - - PolicyEngine.manager.setEnvironmentProperty("vfc.url", "http://localhost:6668"); - PolicyEngine.manager.setEnvironmentProperty("vfc.username", "VFC"); - PolicyEngine.manager.setEnvironmentProperty("vfc.password", "VFC"); + Util.setVFCProps(); + Util.setGuardProps(); } @BeforeClass diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java index a63344d35..2569768f9 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java @@ -62,12 +62,14 @@ public class VFWControlLoopTest { static { /* Set environment properties */ Util.setAAIProps(); + Util.setGuardProps(); } @BeforeClass public static void setUpSimulator() { try { Util.buildAaiSim(); + Util.buildGuardSim(); } catch (Exception e) { fail(e.getMessage()); } @@ -192,7 +194,7 @@ public class VFWControlLoopTest { * See if Guard permits this action, if it does * not then the test should fail */ - if (((VirtualControlLoopNotification)obj).message.contains("Guard result: Permit")) { + if (((VirtualControlLoopNotification)obj).message.contains("PERMIT")) { /* * Obtain the ControlLoopNoticiation, it should be of type operation |