diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2020-01-17 14:48:07 -0600 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2020-01-17 15:18:56 -0600 |
commit | db4f17f190e542ecdffc8ad0b41c9421a275bf09 (patch) | |
tree | 3aac6e6a134959d48b452eb0ac8ee3e7eaa70804 /controlloop/common/controller-usecases/src/test/java | |
parent | c579d2fab3240ff39b906ff4629fe071b54b8473 (diff) |
DCAE Onset flood prevention
Issue-ID: POLICY-2323
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: I08cd55b442ccce3e0eaaa63c1ebd4422c1e0a0d5
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'controlloop/common/controller-usecases/src/test/java')
-rw-r--r-- | controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java | 27 |
1 files changed, 24 insertions, 3 deletions
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); @@ -120,6 +122,25 @@ public class VcpeTest extends UsecasesBase { } /** + * 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. */ @Before |