diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-06-14 14:10:58 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2024-06-17 09:04:18 +0000 |
commit | ca2ee94054c580827fcfc7f07c9db641301d6b9a (patch) | |
tree | 837edef253934aa10a09ecafa5819035b9ca0097 /participant/participant-impl/participant-impl-policy | |
parent | b52e095b34ee7c576f7ee83df05e2a09366a8c8a (diff) |
Remove restarting implementation from participants
Remove restarting implementation from participants and
Remove local Map from a1pms and kserve participants.
Issue-ID: POLICY-5046
Change-Id: I9cc2a33d603751c60007475414b45ca54f0aac25
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-policy')
3 files changed, 12 insertions, 83 deletions
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java index d66ab3154..ae906e1ef 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java @@ -35,9 +35,7 @@ import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient; import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient; import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy; import org.onap.policy.clamp.models.acm.concepts.DeployState; -import org.onap.policy.clamp.models.acm.concepts.LockState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; -import org.onap.policy.clamp.models.acm.utils.AcmUtils; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.pdp.concepts.DeploymentSubGroup; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -221,26 +219,4 @@ public class AutomationCompositionElementHandler extends AcElementListenerV1 { return policyList; } - - @Override - public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element, - Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException { - if (DeployState.DEPLOYING.equals(deployState)) { - deploy(automationCompositionId, element, properties); - return; - } - if (DeployState.UNDEPLOYING.equals(deployState) || DeployState.DEPLOYED.equals(deployState) - || DeployState.UPDATING.equals(deployState)) { - var automationCompositionDefinition = element.getToscaServiceTemplateFragment(); - serviceTemplateMap.put(element.getId(), automationCompositionDefinition); - } - if (DeployState.UNDEPLOYING.equals(deployState)) { - undeploy(automationCompositionId, element.getId()); - return; - } - deployState = AcmUtils.deployCompleted(deployState); - lockState = AcmUtils.lockCompleted(deployState, lockState); - intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState, - lockState, StateChangeResult.NO_ERROR, "Restarted"); - } } diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java index af6a401f2..013cb3432 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandlerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -136,7 +136,7 @@ class AutomationCompositionElementHandlerTest { } @Test - void testDeployPapException() throws PfModelException { + void testDeployPapException() { var api = mock(PolicyApiHttpClient.class); doReturn(Response.ok().build()).when(api).createPolicyType(any()); doReturn(Response.ok().build()).when(api).createPolicy(any()); @@ -220,55 +220,6 @@ class AutomationCompositionElementHandlerTest { } @Test - void testHandleRestartComposition() throws PfModelException { - var intermediaryApi = mock(ParticipantIntermediaryApi.class); - var automationCompositionElementHandler = - new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), - mock(PolicyPapHttpClient.class), intermediaryApi); - - var compositionId = UUID.randomUUID(); - automationCompositionElementHandler.handleRestartComposition(compositionId, List.of(), AcTypeState.PRIMED); - - verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, - StateChangeResult.NO_ERROR, "Restarted"); - } - - @Test - void testHandleRestartInstanceDeploying() throws PfModelException { - // Mock success scenario for policy creation and deployment - var api = mock(PolicyApiHttpClient.class); - doReturn(Response.ok().build()).when(api).createPolicyType(any()); - doReturn(Response.ok().build()).when(api).createPolicy(any()); - - var pap = mock(PolicyPapHttpClient.class); - doReturn(Response.accepted().build()).when(pap).handlePolicyDeployOrUndeploy(any(), any(), any()); - - var intermediaryApi = mock(ParticipantIntermediaryApi.class); - var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi); - var element = getTestingAcElement(); - - handler.handleRestartInstance(AC_ID, element, Map.of(), DeployState.DEPLOYING, LockState.NONE); - verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, - DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); - - handler.handleRestartInstance(AC_ID, element, Map.of(), DeployState.UNDEPLOYING, LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, - DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed"); - } - - @Test - void testHandleRestartInstanceDeployed() throws PfModelException { - var api = mock(PolicyApiHttpClient.class); - var pap = mock(PolicyPapHttpClient.class); - var intermediaryApi = mock(ParticipantIntermediaryApi.class); - var handler = new AutomationCompositionElementHandler(api, pap, intermediaryApi); - var element = getTestingAcElement(); - handler.handleRestartInstance(AC_ID, element, Map.of(), DeployState.DEPLOYED, LockState.LOCKED); - verify(intermediaryApi).updateAutomationCompositionElementState(AC_ID, automationCompositionElementId, - DeployState.DEPLOYED, LockState.LOCKED, StateChangeResult.NO_ERROR, "Restarted"); - } - - @Test void testMigrate() throws Exception { var intermediaryApi = mock(ParticipantIntermediaryApi.class); var handler = new AutomationCompositionElementHandler(mock(PolicyApiHttpClient.class), diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java index b3fe2d3a5..3672e5903 100644 --- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java +++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/rest/ActuatorControllerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ package org.onap.policy.clamp.acm.participant.policy.main.rest; import static org.junit.jupiter.api.Assertions.assertEquals; -import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.core.Response; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -71,21 +70,24 @@ class ActuatorControllerTest extends CommonActuatorController { @Test void testGetHealth() { var invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + try (var rawresp = invocationBuilder.buildGet().invoke()) { + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } } @Test void testGetMetrics() { var invocationBuilder = super.sendActRequest(METRICS_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + try (var rawresp = invocationBuilder.buildGet().invoke()) { + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } } @Test void testGePrometheus() { var invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT); - var rawresp = invocationBuilder.buildGet().invoke(); - assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + try (var rawresp = invocationBuilder.buildGet().invoke()) { + assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus()); + } } } |