diff options
author | Liam Fallon <liam.fallon@est.tech> | 2021-09-08 09:00:36 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-09-08 09:00:36 +0000 |
commit | 22b02a0536c4cad7fb6d1a838df197415682fef2 (patch) | |
tree | 936b7454011a17f8d20fc26a281996b5b0a19b23 /participant/participant-impl/participant-impl-kubernetes/src | |
parent | b35be71f283c75d937619651ef086047349e93f4 (diff) | |
parent | 1df4475d60d9c6d46087f8284dd2e0697d59c071 (diff) |
Merge "Fix parsing of type heirarchy for nodetypes"
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes/src')
3 files changed, 32 insertions, 17 deletions
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java index da0ef134a..a12fdcaac 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java @@ -44,6 +44,7 @@ import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -87,8 +88,8 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { * @param newState the state to which the control loop element is changing to */ @Override - public synchronized void controlLoopElementStateChange(UUID controlLoopElementId, ControlLoopState currentState, - ControlLoopOrderedState newState) { + public synchronized void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId, + UUID controlLoopElementId, ControlLoopState currentState, ControlLoopOrderedState newState) { switch (newState) { case UNINITIALISED: ChartInfo chart = chartMap.get(controlLoopElementId); @@ -96,8 +97,9 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { LOGGER.info("Helm deployment to be deleted {} ", chart.getReleaseName()); try { chartService.uninstallChart(chart); - intermediaryApi.updateControlLoopElementState(controlLoopElementId, newState, - ControlLoopState.UNINITIALISED, ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); + intermediaryApi.updateControlLoopElementState(controlLoopId, + controlLoopElementId, newState, ControlLoopState.UNINITIALISED, + ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); chartMap.remove(controlLoopElementId); podStatusMap.remove(chart.getReleaseName()); } catch (ServiceException se) { @@ -106,11 +108,13 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { } break; case PASSIVE: - intermediaryApi.updateControlLoopElementState(controlLoopElementId, newState, ControlLoopState.PASSIVE, + intermediaryApi.updateControlLoopElementState(controlLoopId, + controlLoopElementId, newState, ControlLoopState.PASSIVE, ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); break; case RUNNING: - intermediaryApi.updateControlLoopElementState(controlLoopElementId, newState, ControlLoopState.RUNNING, + intermediaryApi.updateControlLoopElementState(controlLoopId, + controlLoopElementId, newState, ControlLoopState.RUNNING, ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); break; default: @@ -128,8 +132,8 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { * @throws PfModelException in case of an exception */ @Override - public synchronized void controlLoopElementUpdate(ControlLoopElement element, - ToscaNodeTemplate nodeTemplate) throws PfModelException { + public synchronized void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, + ControlLoopElement element, ToscaNodeTemplate nodeTemplate) throws PfModelException { @SuppressWarnings("unchecked") Map<String, Object> chartData = (Map<String, Object>) nodeTemplate.getProperties().get("chart"); diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java index 2d4439a45..1f8e76952 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java @@ -47,6 +47,7 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.api.Participan import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.controlloop.participant.kubernetes.parameters.CommonTestData; import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartService; import org.onap.policy.clamp.controlloop.participant.kubernetes.utils.TestUtils; import org.onap.policy.common.utils.coder.Coder; @@ -69,7 +70,7 @@ class ControlLoopElementHandlerTest { private static ToscaServiceTemplate toscaServiceTemplate; private static final String K8S_CONTROL_LOOP_ELEMENT = "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement"; - + private CommonTestData commonTestData = new CommonTestData(); @InjectMocks @Spy @@ -98,19 +99,19 @@ class ControlLoopElementHandlerTest { doNothing().when(chartService).uninstallChart(charts.get(0)); - controlLoopElementHandler.controlLoopElementStateChange(controlLoopElementId1, ControlLoopState.PASSIVE, - ControlLoopOrderedState.UNINITIALISED); + controlLoopElementHandler.controlLoopElementStateChange(commonTestData.getControlLoopId(), + controlLoopElementId1, ControlLoopState.PASSIVE, ControlLoopOrderedState.UNINITIALISED); doThrow(new ServiceException("Error uninstalling the chart")).when(chartService) .uninstallChart(charts.get(0)); assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(controlLoopElementId1, ControlLoopState.PASSIVE, - ControlLoopOrderedState.UNINITIALISED)); + .controlLoopElementStateChange(commonTestData.getControlLoopId(), controlLoopElementId1, + ControlLoopState.PASSIVE, ControlLoopOrderedState.UNINITIALISED)); assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(controlLoopElementId1, ControlLoopState.PASSIVE, - ControlLoopOrderedState.RUNNING)); + .controlLoopElementStateChange(commonTestData.getControlLoopId(), controlLoopElementId1, + ControlLoopState.PASSIVE, ControlLoopOrderedState.RUNNING)); } @@ -125,7 +126,8 @@ class ControlLoopElementHandlerTest { Map<String, ToscaNodeTemplate> nodeTemplatesMap = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - controlLoopElementHandler.controlLoopElementUpdate(element, nodeTemplatesMap.get(K8S_CONTROL_LOOP_ELEMENT)); + controlLoopElementHandler.controlLoopElementUpdate(commonTestData.getControlLoopId(), element, + nodeTemplatesMap.get(K8S_CONTROL_LOOP_ELEMENT)); assertThat(controlLoopElementHandler.getChartMap()).hasSize(1).containsKey(elementId1); @@ -134,7 +136,8 @@ class ControlLoopElementHandlerTest { UUID elementId2 = UUID.randomUUID(); element.setId(elementId2); - controlLoopElementHandler.controlLoopElementUpdate(element, nodeTemplatesMap.get(K8S_CONTROL_LOOP_ELEMENT)); + controlLoopElementHandler.controlLoopElementUpdate(commonTestData.getControlLoopId(), element, + nodeTemplatesMap.get(K8S_CONTROL_LOOP_ELEMENT)); assertThat(controlLoopElementHandler.getChartMap().containsKey(elementId2)).isFalse(); } diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java index 98c086205..f6ec401b8 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java @@ -150,4 +150,12 @@ public class CommonTestData { topicParams.setServers(Arrays.asList("localhost")); return topicParams; } + + /** + * Get controlloop id. + * @return ToscaConceptIdentifier controlLoopId + */ + public ToscaConceptIdentifier getControlLoopId() { + return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); + } } |