From db4f17f190e542ecdffc8ad0b41c9421a275bf09 Mon Sep 17 00:00:00 2001 From: jhh Date: Fri, 17 Jan 2020 14:48:07 -0600 Subject: DCAE Onset flood prevention Issue-ID: POLICY-2323 Signed-off-by: jhh Change-Id: I08cd55b442ccce3e0eaaa63c1ebd4422c1e0a0d5 Signed-off-by: jhh --- .../src/main/resources/META-INF/kmodule.xml | 6 ++--- .../java/org/onap/policy/controlloop/VcpeTest.java | 27 +++++++++++++++++++--- .../config/usecases-controller.properties | 7 +++--- .../src/test/resources/vcpe/vcpe.onset.1.json | 16 +++++++++++++ .../src/test/resources/vcpe/vcpe.onset.2.json | 16 +++++++++++++ .../src/test/resources/vcpe/vcpe.onset.3.json | 17 ++++++++++++++ .../src/test/resources/vcpe/vcpe.onset.json | 16 ------------- 7 files changed, 80 insertions(+), 25 deletions(-) create mode 100644 controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.1.json create mode 100644 controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.2.json create mode 100644 controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.3.json delete mode 100644 controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.json (limited to 'controlloop/common/controller-usecases') diff --git a/controlloop/common/controller-usecases/src/main/resources/META-INF/kmodule.xml b/controlloop/common/controller-usecases/src/main/resources/META-INF/kmodule.xml index 9ca418668..4fe7da112 100644 --- a/controlloop/common/controller-usecases/src/main/resources/META-INF/kmodule.xml +++ b/controlloop/common/controller-usecases/src/main/resources/META-INF/kmodule.xml @@ -1,9 +1,9 @@ - + diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java index b5aae715b..8690f1a0a 100644 --- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java +++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,9 @@ public class VcpeTest extends UsecasesBase { * VCPE Use case Messages. */ private static final String APPC_SUCCESS = "src/test/resources/vcpe/vcpe.appc.success.json"; - private static final String ONSET = "src/test/resources/vcpe/vcpe.onset.json"; + private static final String ONSET_1 = "src/test/resources/vcpe/vcpe.onset.1.json"; + private static final String ONSET_2 = "src/test/resources/vcpe/vcpe.onset.2.json"; + private static final String ONSET_3 = "src/test/resources/vcpe/vcpe.onset.3.json"; /* * Topic trackers used by the VCPE use case. @@ -88,7 +90,7 @@ public class VcpeTest extends UsecasesBase { public void sunnyDay() throws IOException { /* Inject an ONSET event over the DCAE topic */ - injectOnTopic(DCAE_TOPIC, Paths.get(ONSET)); + injectOnTopic(DCAE_TOPIC, Paths.get(ONSET_1)); /* Wait to acquire a LOCK and a PDP-X PERMIT */ waitForLockAndPermit(policy, policyClMgt); @@ -119,6 +121,25 @@ public class VcpeTest extends UsecasesBase { waitForFinalSuccess(policy, policyClMgt); } + /** + * An ONSET flood prevention test that injects a few ONSETs at once. + * It attempts to simulate the flooding behavior of the DCAE TCA microservice. + * TCA could blast tenths or hundreds of ONSETs within sub-second intervals. + */ + @Test + public void onsetFloodPrevention() throws IOException { + injectOnTopic(DCAE_TOPIC, Paths.get(ONSET_1)); + injectOnTopic(DCAE_TOPIC, Paths.get(ONSET_2)); + injectOnTopic(DCAE_TOPIC, Paths.get(ONSET_3)); + + assertEquals(1, usecases.getDrools().facts(USECASES, VirtualControlLoopEvent.class).stream().count()); + assertEquals(1, usecases.getDrools().facts(USECASES, CanonicalOnset.class).stream().count()); + assertEquals(usecases.getDrools().facts(USECASES, CanonicalOnset.class).get(0), + usecases.getDrools().facts(USECASES, VirtualControlLoopEvent.class).get(0)); + + sunnyDay(); + } + /** * Observe Topics. */ diff --git a/controlloop/common/controller-usecases/src/test/resources/config/usecases-controller.properties b/controlloop/common/controller-usecases/src/test/resources/config/usecases-controller.properties index 07a97b9b4..483b13ad7 100644 --- a/controlloop/common/controller-usecases/src/test/resources/config/usecases-controller.properties +++ b/controlloop/common/controller-usecases/src/test/resources/config/usecases-controller.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP # ================================================================================ -# Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. +# Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,8 +26,9 @@ rules.version=1.0.0 noop.source.topics=DCAE_TOPIC,APPC-CL,APPC-LCM-WRITE,SDNR-CL-RSP,POLICY-CL-MGT,APPC-LCM-READ,SDNR-CL,DCAE_CL_RSP -noop.source.topics.DCAE_TOPIC.events=org.onap.policy.controlloop.VirtualControlLoopEvent -noop.source.topics.DCAE_TOPIC.events.org.onap.policy.controlloop.VirtualControlLoopEvent.filter=[?($.closedLoopEventStatus)] +noop.source.topics.DCAE_TOPIC.events=org.onap.policy.controlloop.CanonicalOnset,org.onap.policy.controlloop.CanonicalAbated +noop.source.topics.DCAE_TOPIC.events.org.onap.policy.controlloop.CanonicalOnset.filter=[?($.closedLoopEventStatus == 'ONSET')] +noop.source.topics.DCAE_TOPIC.events.org.onap.policy.controlloop.CanonicalAbated.filter=[?($.closedLoopEventStatus == 'ABATED')] noop.source.topics.DCAE_TOPIC.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gson noop.source.topics.APPC-CL.events=org.onap.policy.appc.Response,org.onap.policy.appc.Request diff --git a/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.1.json b/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.1.json new file mode 100644 index 000000000..d08ee47cd --- /dev/null +++ b/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.1.json @@ -0,0 +1,16 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "closedLoopAlarmStart": 1463679805324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" + }, + "from": "DCAE", + "version": "1.0.2" +} \ No newline at end of file diff --git a/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.2.json b/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.2.json new file mode 100644 index 000000000..b8c76514e --- /dev/null +++ b/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.2.json @@ -0,0 +1,16 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "closedLoopAlarmStart": 1463679805324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "8cf3cd05-1218-4224-931b-601494ffe55b", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" + }, + "from": "DCAE", + "version": "1.0.2" +} \ No newline at end of file diff --git a/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.3.json b/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.3.json new file mode 100644 index 000000000..40f29b3cf --- /dev/null +++ b/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.3.json @@ -0,0 +1,17 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "closedLoopAlarmStart": 1570722876324905, + "closedLoopAlarmEnd": 1570722876324999, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "8cf3cd05-1218-4224-931b-601494ffe55b", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" + }, + "from": "DCAE", + "version": "1.0.2" +} \ No newline at end of file diff --git a/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.json b/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.json deleted file mode 100644 index d08ee47cd..000000000 --- a/controlloop/common/controller-usecases/src/test/resources/vcpe/vcpe.onset.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", - "closedLoopAlarmStart": 1463679805324, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ONSET", - "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "vserver.is-closed-loop-disabled": "false", - "vserver.prov-status": "ACTIVE", - "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" - }, - "from": "DCAE", - "version": "1.0.2" -} \ No newline at end of file -- cgit 1.2.3-korg