From d6f6ebc925506cdf18b903df2cd3cbcef311082d Mon Sep 17 00:00:00 2001 From: rameshiyer27 Date: Mon, 28 Aug 2023 17:32:18 +0100 Subject: Remove pdp statistics implementations from drools-pdp Issue-ID: POLICY-4109 Signed-off-by: zrrmmua Change-Id: I9fd807e4df5392cef680202ad80c7cc269d7b349 --- .../policy/drools/lifecycle/LifecycleFsmTest.java | 59 ---------------------- .../drools/lifecycle/LifecycleFsmUpdateTest.java | 27 ---------- .../server/restful/RestLifecycleManagerTest.java | 1 - 3 files changed, 87 deletions(-) (limited to 'feature-lifecycle/src/test/java/org') diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java index ff8b1042..c08ac9fe 100644 --- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java @@ -189,14 +189,12 @@ public class LifecycleFsmTest { public void testSetGroup() { fsm.setGroup("bar"); assertEquals("bar", fsm.getGroup()); - assertEquals("bar", fsm.getStats().getPdpGroupName()); } @Test public void testSetSubGroup() { fsm.setSubGroup("foo"); assertEquals("foo", fsm.getSubGroup()); - assertEquals("foo", fsm.getStats().getPdpSubGroupName()); } @Test @@ -204,31 +202,6 @@ public class LifecycleFsmTest { assertEquals("foo", fsm.getPdpType()); } - @Test - public void testDeployedPolicyAction() { - fsm.deployedPolicyAction(controllerPolicy); - assertEquals(1, fsm.getStats().getPolicyDeploySuccessCount()); - - fsm.undeployedPolicyAction(controllerPolicy); - assertEquals(1, fsm.getStats().getPolicyDeploySuccessCount()); - assertEquals(1, fsm.getStats().getPolicyUndeploySuccessCount()); - - fsm.resetPoliciesAction(); - assertEquals(0, fsm.getStats().getPolicyUndeployCount()); - assertEquals(0, fsm.getStats().getPolicyUndeploySuccessCount()); - } - - @Test - public void testRestDeployCountsAction() { - deployAllPolicies(); - assertEquals(8, fsm.getStats().getPolicyDeploySuccessCount()); - assertEquals(0, fsm.getStats().getPolicyUndeployCount()); - - fsm.resetPoliciesAction(); - assertEquals(0, fsm.getStats().getPolicyDeploySuccessCount()); - assertEquals(0, fsm.getStats().getPolicyDeployFailCount()); - assertEquals(0, fsm.getStats().getPolicyDeployCount()); - } @Test public void testMergePolicies() { @@ -262,38 +235,6 @@ public class LifecycleFsmTest { fsm.getPolicyIds(List.of(opPolicy, controllerPolicy)).toString()); } - @Test - public void testUpdateCountsAction() { - fsm.resetPoliciesAction(); - - assertDeployUndeployValues(0, 0, 0, 0, 0, 0); - - fsm.updateDeployCountsAction(3L, 2L, 1L); - assertDeployUndeployValues(3, 2, 1, 0, 0, 0); - - fsm.updateUndeployCountsAction(1L, 1L, 0L); - assertDeployUndeployValues(3, 2, 1, 1, 1, 0); - - // shouldn't update values - fsm.updateDeployCountsAction(null, null, null); - fsm.updateUndeployCountsAction(null, null, null); - - assertDeployUndeployValues(3, 2, 1, 1, 1, 0); - fsm.resetPoliciesAction(); - - assertDeployUndeployValues(0, 0, 0, 0, 0, 0); - } - - protected void assertDeployUndeployValues(long deployCount, long deploySuccess, long deployFail, - long undeployCount, long undeploySuccess, long undeployFail) { - assertEquals(deployCount, fsm.getStats().getPolicyDeployCount()); - assertEquals(deploySuccess, fsm.getStats().getPolicyDeploySuccessCount()); - assertEquals(deployFail, fsm.getStats().getPolicyDeployFailCount()); - assertEquals(undeployCount, fsm.getStats().getPolicyUndeployCount()); - assertEquals(undeploySuccess, fsm.getStats().getPolicyUndeploySuccessCount()); - assertEquals(undeployFail, fsm.getStats().getPolicyUndeployFailCount()); - } - protected void deployAllPolicies() { fsm.deployedPolicyAction(controllerPolicy); fsm.deployedPolicyAction(controller2Policy); diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java index 5d56143d..90c0d94c 100644 --- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java @@ -258,7 +258,6 @@ public class LifecycleFsmUpdateTest { assertTrue(fsm.update(getPdpUpdate(List.of(), List.of(artifactPolicy)))); assertEquals(1, PolicyControllerConstants.getFactory().inventory().size()); assertFalse(PolicyControllerConstants.getFactory().get("lifecycle").getDrools().isBrained()); - verifyUndeployStats(5, 5, 0); // Delta: +artifactPolicy // from deltas, all delta updates should be successfully applied @@ -270,7 +269,6 @@ public class LifecycleFsmUpdateTest { // from deltas, all delta updates should be successfully applied assertTrue(fsm.update(getPdpUpdate(List.of(), List.of(controllerPolicy)))); assertEquals(0, PolicyControllerConstants.getFactory().inventory().size()); - verifyUndeployStats(6, 6, 0); // Delta: +controllerPolicy // from deltas, all delta updates should be successfully applied @@ -333,8 +331,6 @@ public class LifecycleFsmUpdateTest { verifyActivePoliciesWithDisables( List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy), List.of(opPolicy.getIdentifier(), op2Policy.getIdentifier())); - verifyDeployStats(17, 16, 1); - verifyUndeployStats(10, 10, 0); // Delta: -opPolicy, -op2Policy, -controller2Policy, -valPolicy, -artifact2Policy, -unvalPolicy // from deltas, -opPolicy and -op2Policy undeploys will fail since there is not controller with that @@ -346,7 +342,6 @@ public class LifecycleFsmUpdateTest { assertEquals(0, PolicyControllerConstants.getFactory().inventory().size()); verifyDeploy(List.of(), 17, 16, 1, 16, 14, 2); - verifyFullStats(33, 30, 3); fsm.shutdown(); } @@ -354,7 +349,6 @@ public class LifecycleFsmUpdateTest { assertEquals(0, fsm.getPoliciesMap().size()); assertEquals("ACTIVE", fsm.state().toString()); assertEquals(0, PolicyControllerConstants.getFactory().inventory().size()); - verifyDeployStats(0, 0, 0); } protected PdpUpdate getPdpUpdate(List policiesToDeploy, List policiesToUndeploy) { @@ -377,8 +371,6 @@ public class LifecycleFsmUpdateTest { private void verifyDeploy(List active, long deployCount, long deploySuccess, long deployFail, long undeployCount, long undeploySuccess, long undeployFail) throws CoderException { verifyActivePolicies(active); - verifyDeployStats(deployCount, deploySuccess, deployFail); - verifyUndeployStats(undeployCount, undeploySuccess, undeployFail); } protected void verifyExists(boolean exists, String controller, List policies) { @@ -533,25 +525,6 @@ public class LifecycleFsmUpdateTest { candidateNativeArtifactPolicies.isEmpty()); } - protected void verifyDeployStats(long count, long success, long fail) { - assertEquals(count, fsm.getStats().getPolicyDeployCount()); - assertEquals(success, fsm.getStats().getPolicyDeploySuccessCount()); - assertEquals(fail, fsm.getStats().getPolicyDeployFailCount()); - } - - protected void verifyUndeployStats(long count, long success, long fail) { - assertEquals(count, fsm.getStats().getPolicyUndeployCount()); - assertEquals(success, fsm.getStats().getPolicyUndeploySuccessCount()); - assertEquals(fail, fsm.getStats().getPolicyUndeployFailCount()); - } - - protected void verifyFullStats(long count, long success, long fail) { - assertEquals(count, fsm.getStats().getPolicyDeployCount() + fsm.getStats().getPolicyUndeployCount()); - assertEquals(success, - fsm.getStats().getPolicyDeploySuccessCount() + fsm.getStats().getPolicyUndeploySuccessCount()); - assertEquals(fail, fsm.getStats().getPolicyDeployFailCount() + fsm.getStats().getPolicyUndeployFailCount()); - } - protected List getNativeArtifactPoliciesBut(List nativePolicies, String controllerName) { return nativePolicies.stream().map(nativePolicy -> { diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java index 7fcf1e5a..85294306 100644 --- a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java @@ -245,7 +245,6 @@ public class RestLifecycleManagerTest { resourceLists("policies", 2); get("policies/example.controller/1.0.0", Status.OK.getStatusCode()); get("policies/example.artifact/1.0.0", Status.OK.getStatusCode()); - get("statistics", Status.OK.getStatusCode()); /* add tosca compliant operational policy */ -- cgit 1.2.3-korg