From 5c71b5a62f4208030b3c3cd18b3f42398a0a86e5 Mon Sep 17 00:00:00 2001 From: jhh Date: Mon, 24 Aug 2020 20:04:52 -0500 Subject: block status operations until controllers ready Status messages to the PAP won't be send until all mandatory resources specified in the lifecycle.pdp.policytypes property are functional. Issue-ID: POLICY-2669 Signed-off-by: jhh Change-Id: Ia9d4c678fcfbdb232059d0827235845ee11f1201 Signed-off-by: jhh --- .../lifecycle/LifecycleStateActivePoliciesTest.java | 18 ++++++++++++++++++ .../drools/lifecycle/LifecycleStateActiveTest.java | 8 ++++---- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'feature-lifecycle/src/test/java/org/onap') diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java index 49e439d9..2b0e65bf 100644 --- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java @@ -23,6 +23,7 @@ package org.onap.policy.drools.lifecycle; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -32,6 +33,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; @@ -82,6 +84,22 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest controllerSupport.getController().start(); } + @Test + public void testMandatoryPolicyTypes() { + assertEquals(Set.of("onap.policies.native.drools.Artifact", "onap.policies.native.drools.Controller"), + fsm.getMandatoryPolicyTypes()); + assertEquals(fsm.getMandatoryPolicyTypes(), fsm.getCurrentPolicyTypes()); + assertTrue(fsm.isMandatoryPolicyTypesCompliant()); + assertTrue(fsm.status()); + + fsm.mandatoryPolicyTypes.add("blah"); + assertEquals(Set.of("onap.policies.native.drools.Artifact", "onap.policies.native.drools.Controller", "blah"), + fsm.getMandatoryPolicyTypes()); + assertNotEquals(fsm.getMandatoryPolicyTypes(), fsm.getCurrentPolicyTypes()); + assertFalse(fsm.isMandatoryPolicyTypesCompliant()); + assertFalse(fsm.status()); + } + @Test public void testUpdatePolicies() throws IOException, CoderException { assertEquals(2, fsm.policyTypesMap.size()); diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java index e8a9c825..39a3a939 100644 --- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java @@ -205,7 +205,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest { ToscaPolicy toscaPolicyRestartV1 = getExamplesPolicy("policies/vCPE.policy.operational.input.tosca.json", "operational.restart"); toscaPolicyRestartV1.getProperties().put("controllerName", "lifecycle"); - update.setPolicies(Arrays.asList(toscaPolicyRestartV1)); + update.setPolicies(Collections.singletonList(toscaPolicyRestartV1)); int qlength = fsm.client.getSink().getRecentEvents().length; @@ -260,7 +260,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest { // redeploy operational.restart policy - update.setPolicies(Arrays.asList(toscaPolicyRestartV1)); + update.setPolicies(Collections.singletonList(toscaPolicyRestartV1)); assertTrue(fsm.update(update)); assertEquals(qlength + 4, fsm.client.getSink().getRecentEvents().length); assertEquals(3, fsm.policyTypesMap.size()); @@ -279,7 +279,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest { getExamplesPolicy("policies/vCPE.policy.operational.input.tosca.json", "operational.restart"); toscaPolicyRestartV2.setVersion("2.0.0"); toscaPolicyRestartV2.getProperties().put("controllerName", "lifecycle"); - update.setPolicies(Arrays.asList(toscaPolicyRestartV2)); + update.setPolicies(Collections.singletonList(toscaPolicyRestartV2)); assertTrue(fsm.update(update)); assertEquals(qlength + 5, fsm.client.getSink().getRecentEvents().length); assertEquals(3, fsm.policyTypesMap.size()); @@ -327,7 +327,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest { String badIntegerPolicy = Files.readString(Paths.get(POLICY_COMPLIANT_VCPE_BAD_INTEGER_JSON), StandardCharsets.UTF_8); ToscaPolicy toscaPolicyRestartBad = new StandardCoder().decode(badIntegerPolicy, ToscaPolicy.class); - update.setPolicies(Arrays.asList(toscaPolicyRestartBad)); + update.setPolicies(Collections.singletonList(toscaPolicyRestartBad)); assertFalse(fsm.update(update)); assertTrue(controllerSupport.getController().getDrools().delete(ToscaPolicy.class)); -- cgit 1.2.3-korg