aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/rules-test
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/rules-test')
-rw-r--r--controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTest.java37
-rw-r--r--controlloop/common/rules-test/src/main/resources/vdns/tosca-compliant-vdns-rainy.json48
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTestTest.java20
3 files changed, 105 insertions, 0 deletions
diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTest.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTest.java
index 0baac9e8c..7c34fc875 100644
--- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTest.java
+++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTest.java
@@ -88,6 +88,7 @@ public abstract class BaseRuleTest {
// VDNS
private static final String VDNS_TOSCA_LEGACY_POLICY = "vdns/tosca-legacy-vdns.json";
private static final String VDNS_TOSCA_COMPLIANT_POLICY = "vdns/tosca-compliant-vdns.json";
+ private static final String VDNS_TOSCA_COMPLIANT_RAINY_POLICY = "vdns/tosca-compliant-vdns-rainy.json";
private static final String VDNS_ONSET = "vdns/vdns.onset.json";
// VFW
@@ -334,6 +335,15 @@ public abstract class BaseRuleTest {
httpSunnyDay(VDNS_TOSCA_COMPLIANT_POLICY, VDNS_ONSET);
}
+ /**
+ * Vdns Rainy Day with Compliant Tosca Policy.
+ */
+ @Test
+ public void testVdnsRainyDayCompliant() {
+ httpRainyDay(VDNS_TOSCA_COMPLIANT_RAINY_POLICY, VDNS_ONSET);
+ }
+
+
// VFW
/**
@@ -647,6 +657,33 @@ public abstract class BaseRuleTest {
waitForFinalSuccess(policy, policyClMgt);
}
+ /**
+ * Rainy day scenario for use cases that use an HTTP simulator.
+ *
+ * @param policyFile file containing the ToscaPolicy to be loaded
+ * @param onsetFile file containing the ONSET to be injected
+ * @param operation expected APPC operation request
+ */
+ protected void httpRainyDay(String policyFile, String onsetFile) {
+ policyClMgt = topics.createListener(POLICY_CL_MGT_TOPIC, VirtualControlLoopNotification.class, controller);
+
+ assertEquals(0, controller.getDrools().factCount(rules.getControllerName()));
+ policy = rules.setupPolicyFromFile(policyFile);
+ assertEquals(2, controller.getDrools().factCount(rules.getControllerName()));
+
+ /* Inject an ONSET event over the DCAE topic */
+ topics.inject(DCAE_TOPIC, onsetFile);
+
+ /* Wait to acquire a LOCK and a PDP-X PERMIT */
+ waitForLockAndPermit(policy, policyClMgt);
+
+ /* --- Operation Completed --- */
+ waitForOperationFailure();
+
+ /* --- Transaction Completed --- */
+ waitForFinalFailure(policy, policyClMgt);
+ }
+
protected long getCreateCount() {
return ControlLoopEventManager2.getCreateCount();
}
diff --git a/controlloop/common/rules-test/src/main/resources/vdns/tosca-compliant-vdns-rainy.json b/controlloop/common/rules-test/src/main/resources/vdns/tosca-compliant-vdns-rainy.json
new file mode 100644
index 000000000..53fd5f1ce
--- /dev/null
+++ b/controlloop/common/rules-test/src/main/resources/vdns/tosca-compliant-vdns-rainy.json
@@ -0,0 +1,48 @@
+{
+ "type": "onap.policies.controlloop.operational.common.Drools",
+ "type_version": "1.0.0",
+ "version": "1.0.0",
+ "name": "operational.scale.up",
+ "metadata": {
+ "policy-id": "operational.scale.up"
+ },
+ "properties": {
+ "controllerName": "usecases",
+ "id": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
+ "timeout": 60,
+ "abatement": false,
+ "trigger": "unique-policy-id-1-scale-up",
+ "operations": [
+ {
+ "id": "unique-policy-id-1-scale-up",
+ "description": "Scale up",
+ "operation": {
+ "actor": "SO",
+ "operation": "VF Module Create",
+ "target": {
+ "targetType": "VFMODULE",
+ "entityIds": {
+ "modelInvariantId": "e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e",
+ "modelVersionId": "94b18b1d-cc91-4f43-911a-e6348665f292",
+ "modelName": "VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0",
+ "modelVersion": 1,
+ "modelCustomizationId": "47958575-138f-452a-8c8d-d89b595f8164"
+ }
+ },
+ "payload": {
+ "requestParameters": "{\"usePreload\":true,\"userParams\":[{\"failure\" : \"FAIL\"}]}",
+ "configurationParameters": "[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[9]\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[16]\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[23]\"}]"
+ }
+ },
+ "timeout": 30,
+ "retries": 0,
+ "success": "final_success",
+ "failure": "final_failure",
+ "failure_timeout": "final_failure_timeout",
+ "failure_retries": "final_failure_retries",
+ "failure_exception": "final_failure_exception",
+ "failure_guard": "final_failure_guard"
+ }
+ ]
+ }
+}
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTestTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTestTest.java
index cfa9c49eb..9f313ca39 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTestTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTestTest.java
@@ -334,6 +334,11 @@ public class BaseRuleTestTest {
}
@Test
+ public void testTestVdnsRainyDayCompliant() {
+ checkHttpPolicyCompliantFailure(base::testVdnsRainyDayCompliant);
+ }
+
+ @Test
public void testTestVfwSunnyDayLegacy() {
checkAppcLegacyPolicy("ModifyConfig", base::testVfwSunnyDayLegacy);
}
@@ -491,6 +496,21 @@ public class BaseRuleTestTest {
verify(topics).inject(eq(BaseRuleTest.DCAE_TOPIC), any());
}
+ protected void checkHttpPolicyCompliantFailure(Runnable test) {
+ enqueueClMgt(ControlLoopNotificationType.OPERATION_FAILURE);
+ enqueueClMgt(ControlLoopNotificationType.FINAL_FAILURE);
+
+ test.run();
+
+ assertEquals(1, permitCount);
+ assertEquals(1, finalCount);
+
+ assertTrue(clMgtQueue.isEmpty());
+
+ // initial event
+ verify(topics).inject(eq(BaseRuleTest.DCAE_TOPIC), any());
+ }
+
private void enqueueClMgt(ControlLoopNotificationType type) {
VirtualControlLoopNotification notif = new VirtualControlLoopNotification();
notif.setNotification(type);