diff options
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes/src')
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/Application.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java) | 12 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantConfig.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java) | 2 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java) | 18 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SecurityConfig.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SecurityConfig.java) | 2 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SpringFoxConfig.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SpringFoxConfig.java) | 4 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java) | 14 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/exception/ServiceException.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/exception/ServiceException.java) | 2 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java) | 105 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClient.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java) | 10 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidator.java) | 12 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartInfo.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartInfo.java) | 2 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartList.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartList.java) | 2 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/HelmRepository.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/HelmRepository.java) | 2 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/InstallationInfo.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/InstallationInfo.java) | 2 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParameters.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java) | 6 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartService.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java) | 10 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStore.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java) | 8 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml | 16 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java | 182 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java) | 12 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidatorTest.java) | 22 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java) | 14 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParametersTest.java) | 6 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ActuatorControllerTest.java) | 4 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java) | 12 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java) | 10 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStoreTest.java) | 10 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/CommonActuatorController.java) | 4 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java (renamed from participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/TestUtils.java) | 16 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java | 180 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties | 22 | ||||
-rw-r--r-- | participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml | 58 |
32 files changed, 393 insertions, 388 deletions
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/Application.java index 5d9d203fe..6908b2760 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/Application.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/Application.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes; +package org.onap.policy.clamp.acm.participant.kubernetes; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -29,10 +29,14 @@ import org.springframework.context.annotation.ComponentScan; * Starter. * */ +// @formatter:off @SpringBootApplication -@ComponentScan({"org.onap.policy.clamp.controlloop.participant.kubernetes", - "org.onap.policy.clamp.controlloop.participant.intermediary"}) -@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.kubernetes.parameters") +@ComponentScan({ + "org.onap.policy.clamp.acm.participant.kubernetes", + "org.onap.policy.clamp.acm.participant.intermediary" +}) +@ConfigurationPropertiesScan("org.onap.policy.clamp.acm.participant.kubernetes.parameters") +//@formatter:on public class Application { /** * Main class. diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantConfig.java index 54627d557..428819be9 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantConfig.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantConfig.java @@ -18,7 +18,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations; +package org.onap.policy.clamp.acm.participant.kubernetes.configurations; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java index bfbed66b7..878b43f48 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/ParticipantIntermediaryConfig.java @@ -18,10 +18,10 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations; +package org.onap.policy.clamp.acm.participant.kubernetes.configurations; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.kubernetes.handler.ControlLoopElementHandler; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.kubernetes.handler.AutomationCompositionElementHandler; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; @@ -29,15 +29,15 @@ import org.springframework.context.annotation.Configuration; public class ParticipantIntermediaryConfig { /** - * Register ControlLoopElementListener. + * Register AutomationCompositionElementListener. * * @param intermediaryApi the ParticipantIntermediaryApi - * @param clElementHandler the ControlLoop Element Handler + * @param acElementHandler the AutomationComposition Element Handler */ @Autowired - public void registerControlLoopElementListener(ParticipantIntermediaryApi intermediaryApi, - ControlLoopElementHandler clElementHandler) { - intermediaryApi.registerControlLoopElementListener(clElementHandler); - clElementHandler.setIntermediaryApi(intermediaryApi); + public void registerAutomationCompositionElementListener(ParticipantIntermediaryApi intermediaryApi, + AutomationCompositionElementHandler acElementHandler) { + intermediaryApi.registerAutomationCompositionElementListener(acElementHandler); + acElementHandler.setIntermediaryApi(intermediaryApi); } } diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SecurityConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SecurityConfig.java index 6b4fb0a75..da5762b43 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SecurityConfig.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SecurityConfig.java @@ -16,7 +16,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations; +package org.onap.policy.clamp.acm.participant.kubernetes.configurations; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SpringFoxConfig.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SpringFoxConfig.java index 09a497705..cfa98bd65 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/configurations/SpringFoxConfig.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/configurations/SpringFoxConfig.java @@ -18,9 +18,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.configurations; +package org.onap.policy.clamp.acm.participant.kubernetes.configurations; -import org.onap.policy.clamp.controlloop.participant.kubernetes.controller.ChartController; +import org.onap.policy.clamp.acm.participant.kubernetes.controller.ChartController; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.PathSelectors; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java index e2ccda4d5..19ab4bbab 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/controller/ChartController.java @@ -16,7 +16,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.controller; +package org.onap.policy.clamp.acm.participant.kubernetes.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -24,12 +24,12 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import java.io.IOException; import java.util.ArrayList; -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.models.HelmRepository; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.InstallationInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartService; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.models.HelmRepository; +import org.onap.policy.clamp.acm.participant.kubernetes.models.InstallationInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.springframework.beans.factory.annotation.Autowired; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/exception/ServiceException.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/exception/ServiceException.java index 9a825cf75..6414f2fa9 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/exception/ServiceException.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/exception/ServiceException.java @@ -16,7 +16,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.exception; +package org.onap.policy.clamp.acm.participant.kubernetes.exception; public class ServiceException extends Exception { 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/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java index a8a746254..753608686 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/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.handler; +package org.onap.policy.clamp.acm.participant.kubernetes.handler; import java.io.IOException; import java.lang.invoke.MethodHandles; @@ -34,17 +34,17 @@ import java.util.concurrent.Future; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.helm.PodStatusValidator; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartService; +import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.helm.PodStatusValidator; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService; +import org.onap.policy.clamp.models.acm.concepts.AcElementStatistics; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -57,10 +57,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** - * This class handles implementation of controlLoopElement updates. + * This class handles implementation of automationCompositionElement updates. */ @Component -public class ControlLoopElementHandler implements ControlLoopElementListener { +public class AutomationCompositionElementHandler implements AutomationCompositionElementListener { private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); @@ -76,7 +76,7 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { @Setter private ParticipantIntermediaryApi intermediaryApi; - // Map of CLElement Id and installed Helm charts + // Map of acElement Id and installed Helm charts @Getter(AccessLevel.PACKAGE) private final Map<UUID, ChartInfo> chartMap = new HashMap<>(); @@ -87,26 +87,27 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { } /** - * Callback method to handle a control loop element state change. + * Callback method to handle a automation composition element state change. * - * @param controlLoopElementId the ID of the control loop element - * @param currentState the current state of the control loop element - * @param newState the state to which the control loop element is changing to + * @param automationCompositionElementId the ID of the automation composition element + * @param currentState the current state of the automation composition element + * @param newState the state to which the automation composition element is changing to */ @Override - public synchronized void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId, - UUID controlLoopElementId, ControlLoopState currentState, ControlLoopOrderedState newState) { + public synchronized void automationCompositionElementStateChange(ToscaConceptIdentifier automationCompositionId, + UUID automationCompositionElementId, AutomationCompositionState currentState, + AutomationCompositionOrderedState newState) { switch (newState) { case UNINITIALISED: - ChartInfo chart = chartMap.get(controlLoopElementId); + ChartInfo chart = chartMap.get(automationCompositionElementId); if (chart != null) { LOGGER.info("Helm deployment to be deleted {} ", chart.getReleaseName()); try { chartService.uninstallChart(chart); - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.UNINITIALISED, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); - chartMap.remove(controlLoopElementId); + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.UNINITIALISED, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); + chartMap.remove(automationCompositionElementId); podStatusMap.remove(chart.getReleaseName()); } catch (ServiceException se) { LOGGER.warn("Deletion of Helm deployment failed", se); @@ -114,14 +115,14 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { } break; case PASSIVE: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.PASSIVE, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); break; case RUNNING: - intermediaryApi.updateControlLoopElementState(controlLoopId, - controlLoopElementId, newState, ControlLoopState.RUNNING, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); + intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, + automationCompositionElementId, newState, AutomationCompositionState.RUNNING, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); break; default: LOGGER.warn("Cannot transition from state {} to state {}", currentState, newState); @@ -129,29 +130,27 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { } } - /** - * Callback method to handle an update on a control loop element. + * Callback method to handle an update on a automation composition element. * - * @param element the information on the control loop element + * @param element the information on the automation composition element * @param nodeTemplate toscaNodeTemplate * @throws PfModelException in case of an exception */ @Override - public synchronized void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, - ControlLoopElement element, ToscaNodeTemplate nodeTemplate) throws PfModelException { + public synchronized void automationCompositionElementUpdate(ToscaConceptIdentifier automationCompositionId, + AutomationCompositionElement element, ToscaNodeTemplate nodeTemplate) throws PfModelException { @SuppressWarnings("unchecked") - Map<String, Object> chartData = - (Map<String, Object>) nodeTemplate.getProperties().get("chart"); + Map<String, Object> chartData = (Map<String, Object>) nodeTemplate.getProperties().get("chart"); LOGGER.info("Installation request received for the Helm Chart {} ", chartData); try { - var chartInfo = CODER.convert(chartData, ChartInfo.class); + var chartInfo = CODER.convert(chartData, ChartInfo.class); chartService.installChart(chartInfo); chartMap.put(element.getId(), chartInfo); var config = CODER.convert(nodeTemplate.getProperties(), ThreadConfig.class); - checkPodStatus(controlLoopId, element.getId(), chartInfo, config.uninitializedToPassiveTimeout, + checkPodStatus(automationCompositionId, element.getId(), chartInfo, config.uninitializedToPassiveTimeout, config.podStatusCheckInterval); } catch (ServiceException | CoderException | IOException | ExecutionException @@ -162,6 +161,7 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { /** * Invoke a new thread to check the status of deployed pods. + * * @param chart ChartInfo */ public void checkPodStatus(ToscaConceptIdentifier controlLoopId, UUID elementId, @@ -171,26 +171,27 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { podStatusCheckInterval), "Done"); if (!result.get().isEmpty()) { LOGGER.info("Pod Status Validator Completed: {}", result.isDone()); - intermediaryApi.updateControlLoopElementState(controlLoopId, elementId, - ControlLoopOrderedState.PASSIVE, ControlLoopState.PASSIVE, - ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); + intermediaryApi.updateAutomationCompositionElementState(controlLoopId, elementId, + AutomationCompositionOrderedState.PASSIVE, AutomationCompositionState.PASSIVE, + ParticipantMessageType.AUTOMATION_COMPOSITION_STATE_CHANGE); } } /** * Overridden method. * - * @param controlLoopElementId controlLoopElement id + * @param automationCompositionElementId automationCompositionElement id * @throws PfModelException in case of error */ @Override - public synchronized void handleStatistics(UUID controlLoopElementId) throws PfModelException { - var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId); - if (clElement != null) { - var clElementStatistics = new ClElementStatistics(); - clElementStatistics.setControlLoopState(clElement.getState()); - clElementStatistics.setTimeStamp(Instant.now()); - intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics); + public synchronized void handleStatistics(UUID automationCompositionElementId) throws PfModelException { + var acElement = intermediaryApi.getAutomationCompositionElement(automationCompositionElementId); + if (acElement != null) { + var acElementStatistics = new AcElementStatistics(); + acElementStatistics.setState(acElement.getState()); + acElementStatistics.setTimeStamp(Instant.now()); + intermediaryApi.updateAutomationCompositionElementStatistics(automationCompositionElementId, + acElementStatistics); } } } diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClient.java index 6133c7ebd..87199688e 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClient.java @@ -18,7 +18,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.helm; +package org.onap.policy.clamp.acm.participant.kubernetes.helm; import java.io.File; import java.io.IOException; @@ -28,10 +28,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import org.apache.commons.io.IOUtils; -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.HelmRepository; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartStore; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.HelmRepository; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidator.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java index d55fd6658..f8b08a6be 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidator.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java @@ -16,7 +16,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.helm; +package org.onap.policy.clamp.acm.participant.kubernetes.helm; import java.io.BufferedReader; import java.io.IOException; @@ -27,9 +27,9 @@ import java.util.HashMap; import java.util.Map; import lombok.SneakyThrows; import org.apache.commons.io.IOUtils; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.handler.ControlLoopElementHandler; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.handler.AutomationCompositionElementHandler; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,12 +77,12 @@ public class PodStatusValidator implements Runnable { if (! isVerified) { logger.info("Waiting for the pods to be active for the chart {}", chart.getChartId().getName()); podStatusMap.forEach((key, value) -> logger.info("Pod: {} , state: {}", key, value)); - ControlLoopElementHandler.getPodStatusMap().put(chart.getReleaseName(), podStatusMap); + AutomationCompositionElementHandler.getPodStatusMap().put(chart.getReleaseName(), podStatusMap); // Recheck status of pods in specific intervals. Thread.sleep(statusCheckInterval * 1000L); } else { logger.info("All pods are in running state for the helm chart {}", chart.getChartId().getName()); - ControlLoopElementHandler.getPodStatusMap().put(chart.getReleaseName(), podStatusMap); + AutomationCompositionElementHandler.getPodStatusMap().put(chart.getReleaseName(), podStatusMap); } } catch (ServiceException | IOException e) { throw new ServiceException("Error verifying the status of the pod. Exiting", e); diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartInfo.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartInfo.java index 5cbc203ec..b925e782d 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartInfo.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartInfo.java @@ -16,7 +16,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.models; +package org.onap.policy.clamp.acm.participant.kubernetes.models; import java.util.Map; import lombok.Data; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartList.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartList.java index 7f46bbde5..951bdaa1b 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/ChartList.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/ChartList.java @@ -16,7 +16,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.models; +package org.onap.policy.clamp.acm.participant.kubernetes.models; import java.util.List; import lombok.Builder; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/HelmRepository.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/HelmRepository.java index a495c7b5c..2e25e42a6 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/HelmRepository.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/HelmRepository.java @@ -16,7 +16,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.models; +package org.onap.policy.clamp.acm.participant.kubernetes.models; import lombok.Builder; import lombok.Data; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/InstallationInfo.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/InstallationInfo.java index b21e93a01..6ef6865cb 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/models/InstallationInfo.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/models/InstallationInfo.java @@ -16,7 +16,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.models; +package org.onap.policy.clamp.acm.participant.kubernetes.models; import lombok.Getter; import org.immutables.gson.Gson; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParameters.java index 3b2b3732b..b95756ec5 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParameters.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParameters.java @@ -18,15 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.parameters; +package org.onap.policy.clamp.acm.participant.kubernetes.parameters; import javax.validation.Valid; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantIntermediaryParameters; -import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantIntermediaryParameters; +import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartService.java index a07fca596..344d161b7 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartService.java @@ -16,15 +16,15 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.service; +package org.onap.policy.clamp.acm.participant.kubernetes.service; import java.io.IOException; import java.lang.invoke.MethodHandles; import java.util.Collection; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.helm.HelmClient; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo; -import org.onap.policy.clamp.controlloop.participant.kubernetes.models.HelmRepository; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.helm.HelmClient; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.HelmRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStore.java index ed53d0352..52c1b1f04 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStore.java @@ -18,7 +18,7 @@ * ========================LICENSE_END=================================== */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.service; +package org.onap.policy.clamp.acm.participant.kubernetes.service; import java.io.File; import java.io.FileOutputStream; @@ -37,9 +37,9 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import lombok.AccessLevel; import lombok.Getter; -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.parameters.ParticipantK8sParameters; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.parameters.ParticipantK8sParameters; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml index b266fe337..3be0fb2c0 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml @@ -13,22 +13,22 @@ participant: reportingTimeIntervalMs: 120000 description: Participant Description participantId: - name: K8sParticipant0 - version: 1.0.0 + name: org.onap.policy.clamp.acm.KubernetesParticipant + version: 2.3.4 participantType: - name: org.onap.k8s.controlloop.K8sControlLoopParticipant + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant version: 2.3.4 - clampControlLoopTopics: + clampAutomationCompositionTopics: topicSources: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:localhost} topicCommInfrastructure: dmaap fetchTimeout: 15000 topicSinks: - - topic: POLICY-CLRUNTIME-PARTICIPANT + topic: POLICY-ACRUNTIME-PARTICIPANT servers: - ${topicServer:localhost} topicCommInfrastructure: dmaap @@ -41,7 +41,7 @@ management: server: port: 8083 servlet: - context-path: /onap/k8sparticipant + context-path: /onap/policy/clamp/acm/k8sparticipant logging: # Configuration of logging @@ -50,7 +50,7 @@ logging: org.springframework: ERROR org.springframework.data: ERROR org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR - org.onap.policy.clamp.controlloop.participant.kubernetes: INFO + org.onap.policy.clamp.acm.participant.kubernetes: INFO file: name: /var/log/onap/policy/clamp/application.log diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java new file mode 100644 index 000000000..dc74afc1a --- /dev/null +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.acm.participant.kubernetes.handler; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.parameters.CommonTestData; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService; +import org.onap.policy.clamp.acm.participant.kubernetes.utils.TestUtils; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +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.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class AutomationCompositionElementHandlerTest { + + private static final Coder CODER = new StandardCoder(); + private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; + private static final String KEY_NAME = + "org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement"; + private static List<ChartInfo> charts; + private static ToscaServiceTemplate toscaServiceTemplate; + private static final String K8S_AUTOMATION_COMPOSITION_ELEMENT = + "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement"; + private CommonTestData commonTestData = new CommonTestData(); + + @InjectMocks + @Spy + private AutomationCompositionElementHandler automationCompositionElementHandler = + new AutomationCompositionElementHandler(); + + @Mock + private ChartService chartService; + + @Mock + private ParticipantIntermediaryApi participantIntermediaryApi; + + @Mock + private ExecutorService executor; + @Mock + private Future<String> result; + + @BeforeAll + static void init() throws CoderException { + charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); + toscaServiceTemplate = TestUtils.testAutomationCompositionRead(); + } + + @Test + void test_AutomationCompositionElementStateChange() throws ServiceException { + UUID automationCompositionElementId1 = UUID.randomUUID(); + UUID automationCompositionElementId2 = UUID.randomUUID(); + + automationCompositionElementHandler.getChartMap().put(automationCompositionElementId1, charts.get(0)); + automationCompositionElementHandler.getChartMap().put(automationCompositionElementId2, charts.get(1)); + + doNothing().when(chartService).uninstallChart(charts.get(0)); + + automationCompositionElementHandler.automationCompositionElementStateChange( + commonTestData.getAutomationCompositionId(), automationCompositionElementId1, + AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.UNINITIALISED); + + doThrow(new ServiceException("Error uninstalling the chart")).when(chartService).uninstallChart(charts.get(0)); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( + commonTestData.getAutomationCompositionId(), automationCompositionElementId1, + AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.PASSIVE)); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( + commonTestData.getAutomationCompositionId(), automationCompositionElementId1, + AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.UNINITIALISED)); + + assertDoesNotThrow(() -> automationCompositionElementHandler.automationCompositionElementStateChange( + commonTestData.getAutomationCompositionId(), automationCompositionElementId1, + AutomationCompositionState.PASSIVE, AutomationCompositionOrderedState.RUNNING)); + + } + + @Test + void test_AutomationCompositionElementUpdate() throws PfModelException, IOException, ServiceException, + ExecutionException, InterruptedException { + doNothing().when(automationCompositionElementHandler).checkPodStatus(any(), any(), any(), anyInt(), anyInt()); + UUID elementId1 = UUID.randomUUID(); + AutomationCompositionElement element = new AutomationCompositionElement(); + element.setId(elementId1); + element.setDefinition(new ToscaConceptIdentifier(KEY_NAME, "1.0.1")); + element.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + + Map<String, ToscaNodeTemplate> nodeTemplatesMap = + toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + automationCompositionElementHandler.automationCompositionElementUpdate( + commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT)); + + assertThat(automationCompositionElementHandler.getChartMap()).hasSize(1).containsKey(elementId1); + + doThrow(new ServiceException("Error installing the chart")).when(chartService).installChart(Mockito.any()); + + UUID elementId2 = UUID.randomUUID(); + element.setId(elementId2); + automationCompositionElementHandler.automationCompositionElementUpdate( + commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT)); + + assertThat(automationCompositionElementHandler.getChartMap().containsKey(elementId2)).isFalse(); + } + + @Test + void test_handleStatistics() throws PfModelException { + UUID elementId1 = UUID.randomUUID(); + automationCompositionElementHandler.getChartMap().put(elementId1, charts.get(0)); + when(participantIntermediaryApi.getAutomationCompositionElement(elementId1)) + .thenReturn(new AutomationCompositionElement()); + assertDoesNotThrow(() -> automationCompositionElementHandler.handleStatistics(elementId1)); + } + + @Test + void test_checkPodStatus() throws ExecutionException, InterruptedException { + doReturn(result).when(executor).submit(any(Runnable.class), any()); + doReturn("Done").when(result).get(); + doReturn(true).when(result).isDone(); + var chartInfo = charts.get(0); + ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); + AutomationCompositionElement element = new AutomationCompositionElement(); + assertDoesNotThrow( + () -> automationCompositionElementHandler.checkPodStatus(controlLoopId, element.getId(), chartInfo, + 1, 1)); + } +} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java index 335dbcb21..7f1943c97 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.helm; +package org.onap.policy.clamp.acm.participant.kubernetes.helm; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -44,11 +44,11 @@ import org.mockito.Mock; import org.mockito.MockedStatic; import org.mockito.Mockito; import org.mockito.Spy; -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.models.HelmRepository; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartStore; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.models.HelmRepository; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartStore; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidatorTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java index 18c32d474..89b077044 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidatorTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java @@ -19,9 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.helm; - - +package org.onap.policy.clamp.acm.participant.kubernetes.helm; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -39,10 +37,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.MockedStatic; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.handler.ControlLoopElementHandler; -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.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.handler.AutomationCompositionElementHandler; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -74,7 +72,7 @@ class PodStatusValidatorTest { @AfterEach void clearPodStatusMap() { - ControlLoopElementHandler.getPodStatusMap().clear(); + AutomationCompositionElementHandler.getPodStatusMap().clear(); } @AfterAll @@ -89,9 +87,9 @@ class PodStatusValidatorTest { mockedClient.when(() -> HelmClient.executeCommand(any())) .thenReturn(runningPod); assertDoesNotThrow(() -> podStatusValidator.run()); - assertThat(ControlLoopElementHandler.getPodStatusMap()).hasSize(1); - assertThat(ControlLoopElementHandler.getPodStatusMap()).containsKey(charts.get(0).getReleaseName()); - assertThat(ControlLoopElementHandler.getPodStatusMap()) + assertThat(AutomationCompositionElementHandler.getPodStatusMap()).hasSize(1); + assertThat(AutomationCompositionElementHandler.getPodStatusMap()).containsKey(charts.get(0).getReleaseName()); + assertThat(AutomationCompositionElementHandler.getPodStatusMap()) .containsValue(Map.of("HelloWorld-54777df9f8-qpzqr", "Running")); } @@ -103,7 +101,7 @@ class PodStatusValidatorTest { .thenReturn(invalidPod); assertThatThrownBy(() -> podStatusValidator.run()) .isInstanceOf(ServiceException.class).hasMessage("Error verifying the status of the pod. Exiting"); - assertThat(ControlLoopElementHandler.getPodStatusMap()).isEmpty(); + assertThat(AutomationCompositionElementHandler.getPodStatusMap()).isEmpty(); } } 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/acm/participant/kubernetes/parameters/CommonTestData.java index f6ec401b8..13f8edc15 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/acm/participant/kubernetes/parameters/CommonTestData.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.parameters; +package org.onap.policy.clamp.acm.participant.kubernetes.parameters; import java.util.Arrays; import java.util.List; @@ -33,7 +33,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; public class CommonTestData { - public static final String PARTICIPANT_GROUP_NAME = "ControlLoopParticipantGroup"; + public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup"; public static final String DESCRIPTION = "Participant description"; public static final long TIME_INTERVAL = 2000; public static final List<TopicParameters> TOPIC_PARAMS = Arrays.asList(getTopicParams()); @@ -104,7 +104,7 @@ public class CommonTestData { map.put("description", DESCRIPTION); map.put("participantId", getParticipantId()); map.put("participantType", getParticipantId()); - map.put("clampControlLoopTopics", getTopicParametersMap(false)); + map.put("clampAutomationCompositionTopics", getTopicParametersMap(false)); } return map; @@ -145,17 +145,17 @@ public class CommonTestData { */ public static TopicParameters getTopicParams() { final TopicParameters topicParams = new TopicParameters(); - topicParams.setTopic("POLICY-CLRUNTIME-PARTICIPANT"); + topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT"); topicParams.setTopicCommInfrastructure("dmaap"); topicParams.setServers(Arrays.asList("localhost")); return topicParams; } /** - * Get controlloop id. - * @return ToscaConceptIdentifier controlLoopId + * Get automation composition id. + * @return ToscaConceptIdentifier automationCompositionId */ - public ToscaConceptIdentifier getControlLoopId() { + public ToscaConceptIdentifier getAutomationCompositionId() { return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0"); } } diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParametersTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java index f22fc711e..09ea74afe 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParametersTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.parameters; +package org.onap.policy.clamp.acm.participant.kubernetes.parameters; import static org.assertj.core.api.Assertions.assertThat; @@ -43,14 +43,14 @@ class ParticipantK8sParametersTest { @Test void testParticipantK8sParameters_NullTopicSinks() { final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); - participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSinks(null); + participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSinks(null); assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); } @Test void testParticipantK8sParameters_NullTopicSources() { final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters(); - participantParameters.getIntermediaryParameters().getClampControlLoopTopics().setTopicSources(null); + participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSources(null); assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty(); } diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ActuatorControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java index 1442e9f1f..8d05d2bf6 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ActuatorControllerTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.rest; +package org.onap.policy.clamp.acm.participant.kubernetes.rest; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -27,7 +27,7 @@ import javax.ws.rs.core.Response; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.participant.kubernetes.utils.CommonActuatorController; +import org.onap.policy.clamp.acm.participant.kubernetes.utils.CommonActuatorController; import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigureMetrics; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java index 8048b19ce..73c5c98a1 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.rest; +package org.onap.policy.clamp.acm.participant.kubernetes.rest; import static org.hamcrest.CoreMatchers.is; import static org.mockito.Mockito.doNothing; @@ -38,11 +38,11 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.onap.policy.clamp.controlloop.participant.kubernetes.controller.ChartController; -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.ParticipantK8sParameters; -import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartService; +import org.onap.policy.clamp.acm.participant.kubernetes.controller.ChartController; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.parameters.ParticipantK8sParameters; +import org.onap.policy.clamp.acm.participant.kubernetes.service.ChartService; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java index f1c8d19df..f5b6093d3 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.service; +package org.onap.policy.clamp.acm.participant.kubernetes.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -42,10 +42,10 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException; -import org.onap.policy.clamp.controlloop.participant.kubernetes.helm.HelmClient; -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.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.helm.HelmClient; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStoreTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java index 54f1cc528..180861bae 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStoreTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.service; +package org.onap.policy.clamp.acm.participant.kubernetes.service; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -40,10 +40,10 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -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.ParticipantK8sParameters; +import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo; +import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartList; +import org.onap.policy.clamp.acm.participant.kubernetes.parameters.ParticipantK8sParameters; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/CommonActuatorController.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java index 35ffbb5e9..e5a5be9fa 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/CommonActuatorController.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.utils; +package org.onap.policy.clamp.acm.participant.kubernetes.utils; import static org.junit.Assert.assertEquals; @@ -40,7 +40,7 @@ import org.onap.policy.common.utils.network.NetworkUtil; public class CommonActuatorController { public static final String SELF = NetworkUtil.getHostname(); - public static final String CONTEXT_PATH = "onap/k8sparticipant"; + public static final String CONTEXT_PATH = "onap/policy/clamp/acm/k8sparticipant"; public static final String ACTUATOR_ENDPOINT = CONTEXT_PATH + "/actuator/"; private static String httpPrefix; diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/TestUtils.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java index af514f8aa..8f4969a9b 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/TestUtils.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.participant.kubernetes.utils; +package org.onap.policy.clamp.acm.participant.kubernetes.utils; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -33,15 +33,15 @@ public final class TestUtils { private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator(); private static final String TOSCA_TEMPLATE_YAML = "src/test/resources/servicetemplates/KubernetesHelm.yaml"; - - public static ToscaServiceTemplate testControlLoopRead() { - return testControlLoopYamlSerialization(TOSCA_TEMPLATE_YAML); + public static ToscaServiceTemplate testAutomationCompositionRead() { + return testAutomationCompositionYamlSerialization(TOSCA_TEMPLATE_YAML); } - - private static ToscaServiceTemplate testControlLoopYamlSerialization(String controlLoopFilePath) { - String controlLoopString = ResourceUtils.getResourceAsString(controlLoopFilePath); - ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(controlLoopString, ToscaServiceTemplate.class); + private static ToscaServiceTemplate testAutomationCompositionYamlSerialization( + String automationCompositionFilePath) { + String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath); + ToscaServiceTemplate serviceTemplate = + yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class); return serviceTemplate; } } 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 deleted file mode 100644 index 805404b90..000000000 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java +++ /dev/null @@ -1,180 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. - * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.participant.kubernetes.handler; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; -import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; -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; -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.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.springframework.test.context.junit.jupiter.SpringExtension; - - -@ExtendWith(SpringExtension.class) -class ControlLoopElementHandlerTest { - - private static final Coder CODER = new StandardCoder(); - private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json"; - private static final String KEY_NAME = "org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement"; - private static List<ChartInfo> charts; - 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 - private ControlLoopElementHandler controlLoopElementHandler = new ControlLoopElementHandler(); - - @Mock - private ChartService chartService; - - @Mock - private ParticipantIntermediaryApi participantIntermediaryApi; - - @Mock - private ExecutorService executor; - - @Mock - private Future<String> result; - - @BeforeAll - static void init() throws CoderException { - charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts(); - toscaServiceTemplate = TestUtils.testControlLoopRead(); - } - - - @Test - void test_ControlLoopElementStateChange() throws ServiceException { - UUID controlLoopElementId1 = UUID.randomUUID(); - UUID controlLoopElementId2 = UUID.randomUUID(); - - controlLoopElementHandler.getChartMap().put(controlLoopElementId1, charts.get(0)); - controlLoopElementHandler.getChartMap().put(controlLoopElementId2, charts.get(1)); - - doNothing().when(chartService).uninstallChart(charts.get(0)); - - 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(commonTestData.getControlLoopId(), controlLoopElementId1, - ControlLoopState.PASSIVE, ControlLoopOrderedState.PASSIVE)); - - assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(commonTestData.getControlLoopId(), controlLoopElementId1, - ControlLoopState.PASSIVE, ControlLoopOrderedState.UNINITIALISED)); - - assertDoesNotThrow(() -> controlLoopElementHandler - .controlLoopElementStateChange(commonTestData.getControlLoopId(), controlLoopElementId1, - ControlLoopState.PASSIVE, ControlLoopOrderedState.RUNNING)); - - } - - @Test - void test_ControlLoopElementUpdate() throws PfModelException, IOException, ServiceException, - ExecutionException, InterruptedException { - doNothing().when(controlLoopElementHandler).checkPodStatus(any(), any(), any(), anyInt(), anyInt()); - UUID elementId1 = UUID.randomUUID(); - ControlLoopElement element = new ControlLoopElement(); - element.setId(elementId1); - element.setDefinition(new ToscaConceptIdentifier(KEY_NAME, "1.0.1")); - element.setOrderedState(ControlLoopOrderedState.PASSIVE); - - Map<String, ToscaNodeTemplate> nodeTemplatesMap = - toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - controlLoopElementHandler.controlLoopElementUpdate(commonTestData.getControlLoopId(), element, - nodeTemplatesMap.get(K8S_CONTROL_LOOP_ELEMENT)); - - assertThat(controlLoopElementHandler.getChartMap()).hasSize(1).containsKey(elementId1); - - doThrow(new ServiceException("Error installing the chart")).when(chartService) - .installChart(Mockito.any()); - - UUID elementId2 = UUID.randomUUID(); - element.setId(elementId2); - controlLoopElementHandler.controlLoopElementUpdate(commonTestData.getControlLoopId(), element, - nodeTemplatesMap.get(K8S_CONTROL_LOOP_ELEMENT)); - - assertThat(controlLoopElementHandler.getChartMap().containsKey(elementId2)).isFalse(); - } - - @Test - void test_handleStatistics() throws PfModelException { - UUID elementId1 = UUID.randomUUID(); - controlLoopElementHandler.getChartMap().put(elementId1, charts.get(0)); - when(participantIntermediaryApi.getControlLoopElement(elementId1)).thenReturn(new ControlLoopElement()); - assertDoesNotThrow(() -> controlLoopElementHandler.handleStatistics(elementId1)); - } - - @Test - void test_checkPodStatus() throws ExecutionException, InterruptedException { - doReturn(result).when(executor).submit(any(Runnable.class), any()); - doReturn("Done").when(result).get(); - doReturn(true).when(result).isDone(); - var chartInfo = charts.get(0); - ToscaConceptIdentifier controlLoopId = new ToscaConceptIdentifier(); - ControlLoopElement element = new ControlLoopElement(); - assertDoesNotThrow(() -> controlLoopElementHandler.checkPodStatus(controlLoopId, element.getId(), chartInfo, - 1, 1)); - } -} diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties index b5b209fd1..243512166 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties @@ -1,24 +1,24 @@ spring.security.user.name=participantUser spring.security.user.password=zb!XztG34 -server.servlet.context-path=/onap/k8sparticipant +server.servlet.context-path=/onap/policy/clamp/acm/k8sparticipant server.error.path=/error server.http-port=8083 -participant.name=ControlLoopParticipant Kubernetes Test +participant.name=AutomationCompositionParticipant Kubernetes Test participant.intermediaryParameters.name=Participant parameters participant.intermediaryParameters.reportingTimeInterval=120000 participant.intermediaryParameters.description=Participant Description participant.intermediaryParameters.participantId.name=K8sParticipant0 participant.intermediaryParameters.participantId.version=1.0.0 -participant.intermediaryParameters.participantType.name=org.onap.k8s.controlloop.K8SControlLoopParticipant +participant.intermediaryParameters.participantType.name=org.onap.k8s.acm.K8SAutomationCompositionParticipant participant.intermediaryParameters.participantType.version=2.3.4 -participant.intermediaryParameters.clampControlLoopTopics.name=ControlLoop Topics -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].topicCommInfrastructure=dmaap -participant.intermediaryParameters.clampControlLoopTopics.topicSources[0].fetchTimeout=15000 -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topic=POLICY-CLRUNTIME-PARTICIPANT -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].servers[0]=localhost -participant.intermediaryParameters.clampControlLoopTopics.topicSinks[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.name=AutomationComposition Topics +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].topicCommInfrastructure=dmaap +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSources[0].fetchTimeout=15000 +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topic=POLICY-ACRUNTIME-PARTICIPANT +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].servers[0]=localhost +participant.intermediaryParameters.clampAutomationCompositionTopics.topicSinks[0].topicCommInfrastructure=dmaap management.endpoints.web.exposure.include=health,metrics,prometheus diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml index 7d594019a..f5eb6233f 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml @@ -27,14 +27,14 @@ data_types: type: string required: true node_types: - org.onap.policy.clamp.controlloop.Participant: + org.onap.policy.clamp.acm.Participant: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: provider: type: string requred: false - org.onap.policy.clamp.controlloop.ControlLoopElement: + org.onap.policy.clamp.acm.AutomationCompositionElement: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: @@ -51,11 +51,11 @@ node_types: - greater-or-equal: 0 metadata: common: true - description: A value indicating the start phase in which this control loop element will be started, the - first start phase is zero. Control Loop Elements are started in their start_phase order and stopped - in reverse start phase order. Control Loop Elements with the same start phase are started and - stopped simultaneously - org.onap.policy.clamp.controlloop.ControlLoop: + description: A value indicating the start phase in which this automation composition element will be started, + the first start phase is zero. Automation Composition Elements are started in their start_phase + order and stopped in reverse start phase order. Automation Composition Elements with the same start + phase are started and stopped simultaneously + org.onap.policy.clamp.acm.AutomationComposition: version: 1.0.1 derived_from: tosca.nodetypes.Root properties: @@ -67,9 +67,9 @@ node_types: required: true entry_schema: type: onap.datatypes.ToscaConceptIdentifier - org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement: + org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement: version: 1.0.1 - derived_from: org.onap.policy.clamp.controlloop.ControlLoopElement + derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement properties: chart: type: string @@ -89,24 +89,24 @@ node_types: requred: true topology_template: node_templates: - org.onap.k8s.controlloop.K8SControlLoopParticipant: + org.onap.k8s.acm.K8SAutomationCompositionParticipant: version: 2.3.4 - type: org.onap.policy.clamp.controlloop.Participant + type: org.onap.policy.clamp.acm.Participant type_version: 1.0.1 description: Participant for K8S properties: provider: ONAP - org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement: + org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement: # Chart from any chart repository configured on helm client. version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement + type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement type_version: 1.0.0 - description: Control loop element for the K8S microservice for Hello World + description: Automation composition element for the K8S microservice for Hello World properties: provider: ONAP participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant version: 2.3.4 startPhase: 2 uninitializedToPassiveTimeout: 180 @@ -119,16 +119,16 @@ topology_template: namespace: onap repository: chartMuseum - org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement: + org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement: # Chart from local file system version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement + type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement type_version: 1.0.0 - description: Control loop element for the K8S microservice for PMSH + description: Automation composition element for the K8S microservice for PMSH properties: provider: ONAP participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant version: 2.3.4 startPhase: 2 uninitializedToPassiveTimeout: 180 @@ -142,16 +142,16 @@ topology_template: overrideParams: global.masterPassword: test - org.onap.domain.database.Local_K8SMicroserviceControlLoopElement: + org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement: # Chart installation without passing repository name version: 1.2.3 - type: org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement + type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement type_version: 1.0.0 - description: Control loop element for the K8S microservice for local chart + description: Automation composition element for the K8S microservice for local chart properties: provider: ONAP participantType: - name: org.onap.k8s.controlloop.K8SControlLoopParticipant + name: org.onap.k8s.acm.K8SAutomationCompositionParticipant version: 2.3.4 startPhase: 2 uninitializedToPassiveTimeout: 180 @@ -163,17 +163,17 @@ topology_template: releaseName: nginxms namespace: onap - org.onap.domain.sample.GenericK8s_ControlLoopDefinition: + org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition: version: 1.2.3 - type: org.onap.policy.clamp.controlloop.ControlLoop + type: org.onap.policy.clamp.acm.AutomationComposition type_version: 1.0.0 - description: Control loop for Hello World + description: Automation composition for Hello World properties: provider: ONAP elements: - - name: org.onap.domain.database.HelloWorld_K8SMicroserviceControlLoopElement + - name: org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement version: 1.2.3 - - name: org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement + - name: org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement version: 1.2.3 - - name: org.onap.domain.database.Local_K8SMicroserviceControlLoopElement + - name: org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement version: 1.2.3 |