diff options
author | Straubs, Ralph (rs8887) <rs8887@att.com> | 2020-07-17 10:38:02 -0400 |
---|---|---|
committer | Taka Cho <takamune.cho@att.com> | 2020-08-28 17:03:19 -0400 |
commit | a6d4077e3639a0f3478f0cbf51e06ef46517a10d (patch) | |
tree | 1d34398ef3488d97c1dc6475372a1b8755373a8b /controlloop/common/eventmanager/src/test | |
parent | c75e28d1c1221c37ea4fd1feed9d38c75334f4db (diff) |
Add tdjam-controller
the details is on wiki:
https://wiki.onap.org/display/DW/tdjam+Feature+for+Tosca-Driven+Control+Loops
Fixed some eclipse warnings.
Revised the interaction between a manager and its SerialWorkQueue to
address some threading issues. The original code started processing
the event as soon as the manager was created, WHILE it was still being
added to the map. During junit tests, the event responses came back,
within the same thread, which then attempted to remove the manager from
the map. This resulted in a ConcurrentHashMap exception.
Issue-ID: POLICY-2415
Change-Id: I94a4152637be76e5b2aea2d869afd84dfb413a0e
Signed-off-by: Straubs, Ralph (rs8887) <rs8887@att.com>
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Signed-off-by: Taka Cho <takamune.cho@att.com>
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/test')
-rw-r--r-- | controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java index 1c4030c08..da37e6fc3 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java @@ -118,7 +118,7 @@ public class ControlLoopEventManager2Test { private ControlLoopParams params; private VirtualControlLoopEvent event; private int updateCount; - private ControlLoopEventManager2 mgr; + private ControlLoopEventManager2Drools mgr; /** * Sets up. @@ -180,11 +180,11 @@ public class ControlLoopEventManager2Test { Map<String, String> orig = event.getAai(); event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_IS_CLOSED_LOOP_DISABLED, "true")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + assertThatThrownBy(() -> new ControlLoopEventManager2Drools(params, event, workMem)) .hasMessage("is-closed-loop-disabled is set to true on VServer or VNF"); event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_PROV_STATUS, "inactive")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + assertThatThrownBy(() -> new ControlLoopEventManager2Drools(params, event, workMem)) .hasMessage("prov-status is not ACTIVE on VServer or VNF"); // valid @@ -193,7 +193,7 @@ public class ControlLoopEventManager2Test { // invalid event.setTarget("unknown-target"); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + assertThatThrownBy(() -> new ControlLoopEventManager2Drools(params, event, workMem)) .isInstanceOf(ControlLoopException.class); } @@ -237,8 +237,8 @@ public class ControlLoopEventManager2Test { @Test public void testStartErrors() throws Exception { // wrong jvm - ControlLoopEventManager2 mgr2 = new ControlLoopEventManager2(params, event, workMem); - ControlLoopEventManager2 mgr3 = Serializer.roundTrip(mgr2); + ControlLoopEventManager2Drools mgr2 = new ControlLoopEventManager2Drools(params, event, workMem); + ControlLoopEventManager2Drools mgr3 = Serializer.roundTrip(mgr2); assertThatCode(() -> mgr3.start()).isInstanceOf(IllegalStateException.class) .hasMessage("manager is no longer active"); @@ -317,10 +317,10 @@ public class ControlLoopEventManager2Test { @Test public void testIsActive() throws Exception { - mgr = new ControlLoopEventManager2(params, event, workMem); + mgr = new ControlLoopEventManager2Drools(params, event, workMem); assertTrue(mgr.isActive()); - ControlLoopEventManager2 mgr2 = Serializer.roundTrip(mgr); + ControlLoopEventManager2Drools mgr2 = Serializer.roundTrip(mgr); assertFalse(mgr2.isActive()); } @@ -597,15 +597,15 @@ public class ControlLoopEventManager2Test { Map<String, String> orig = event.getAai(); event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_IS_CLOSED_LOOP_DISABLED, "true")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + assertThatThrownBy(() -> new ControlLoopEventManager2Drools(params, event, workMem)) .isInstanceOf(IllegalStateException.class); event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, "true")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + assertThatThrownBy(() -> new ControlLoopEventManager2Drools(params, event, workMem)) .isInstanceOf(IllegalStateException.class); event.setAai(addAai(orig, ControlLoopEventManager2.PNF_IS_IN_MAINT, "true")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + assertThatThrownBy(() -> new ControlLoopEventManager2Drools(params, event, workMem)) .isInstanceOf(IllegalStateException.class); } @@ -620,17 +620,16 @@ public class ControlLoopEventManager2Test { Map<String, String> orig = event.getAai(); event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_PROV_STATUS, "ACTIVE")); - assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); + assertThatCode(() -> new ControlLoopEventManager2Drools(params, event, workMem)).doesNotThrowAnyException(); event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_PROV_STATUS, "inactive")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + assertThatThrownBy(() -> new ControlLoopEventManager2Drools(params, event, workMem)) .isInstanceOf(IllegalStateException.class); event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_PROV_STATUS, "ACTIVE")); - assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); - + assertThatCode(() -> new ControlLoopEventManager2Drools(params, event, workMem)).doesNotThrowAnyException(); event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_PROV_STATUS, "inactive")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + assertThatThrownBy(() -> new ControlLoopEventManager2Drools(params, event, workMem)) .isInstanceOf(IllegalStateException.class); } @@ -640,15 +639,15 @@ public class ControlLoopEventManager2Test { for (String value : Arrays.asList("yes", "y", "true", "t", "yEs", "trUe")) { event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_IS_CLOSED_LOOP_DISABLED, value)); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + assertThatThrownBy(() -> new ControlLoopEventManager2Drools(params, event, workMem)) .isInstanceOf(IllegalStateException.class); } event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_IS_CLOSED_LOOP_DISABLED, "false")); - assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); + assertThatCode(() -> new ControlLoopEventManager2Drools(params, event, workMem)).doesNotThrowAnyException(); event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_IS_CLOSED_LOOP_DISABLED, "no")); - assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); + assertThatCode(() -> new ControlLoopEventManager2Drools(params, event, workMem)).doesNotThrowAnyException(); } @Test @@ -684,7 +683,7 @@ public class ControlLoopEventManager2Test { @Test public void testGetBlockingExecutor() throws Exception { - mgr = new ControlLoopEventManager2(params, event, workMem); + mgr = new ControlLoopEventManager2Drools(params, event, workMem); assertThatCode(() -> mgr.getBlockingExecutor()).doesNotThrowAnyException(); } @@ -764,7 +763,7 @@ public class ControlLoopEventManager2Test { } - private class MyManager extends ControlLoopEventManager2 { + private class MyManager extends ControlLoopEventManager2Drools { private static final long serialVersionUID = 1L; public MyManager(ControlLoopParams params, VirtualControlLoopEvent event, WorkingMemory workMem) |