From 567a8fd97c6b434f430d38c2d4af5a95b7cdb711 Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Thu, 22 Jun 2023 16:15:11 +0100 Subject: Remove Thread support in kubernetes participant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due the Thread support in Intermediary, Thread support in kubernetes participant could be removed. Issue-ID: POLICY-4741 Change-Id: Ia55697808c541991f99cc7630f25188937e15779 Signed-off-by: FrancescoFioraEst --- .../AutomationCompositionElementHandlerTest.java | 48 +++++++++++----------- .../kubernetes/helm/PodStatusValidatorTest.java | 5 +-- 2 files changed, 26 insertions(+), 27 deletions(-) (limited to 'participant/participant-impl/participant-impl-kubernetes/src/test') 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 index d9702abc5..6b24c0f8a 100644 --- 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 @@ -23,6 +23,7 @@ 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.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.doNothing; @@ -68,17 +69,17 @@ 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"; + "org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement"; private static List charts; private static ToscaServiceTemplate toscaServiceTemplate; private static final String K8S_AUTOMATION_COMPOSITION_ELEMENT = - "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement"; + "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement"; private final CommonTestData commonTestData = new CommonTestData(); @InjectMocks @Spy private AutomationCompositionElementHandler automationCompositionElementHandler = - new AutomationCompositionElementHandler(); + new AutomationCompositionElementHandler(); @Mock private ChartService chartService; @@ -107,19 +108,18 @@ class AutomationCompositionElementHandlerTest { doNothing().when(chartService).uninstallChart(charts.get(0)); - automationCompositionElementHandler.undeploy( - commonTestData.getAutomationCompositionId(), automationCompositionElementId1); + automationCompositionElementHandler.undeploy(commonTestData.getAutomationCompositionId(), + automationCompositionElementId1); doThrow(new ServiceException("Error uninstalling the chart")).when(chartService).uninstallChart(charts.get(0)); - assertDoesNotThrow(() -> automationCompositionElementHandler.undeploy( - commonTestData.getAutomationCompositionId(), automationCompositionElementId1)); + assertDoesNotThrow(() -> automationCompositionElementHandler + .undeploy(commonTestData.getAutomationCompositionId(), automationCompositionElementId1)); } @Test - void test_AutomationCompositionElementUpdate() throws PfModelException, IOException, ServiceException, - ExecutionException, InterruptedException { - doReturn(true).when(chartService).installChart(any()); + void test_AutomationCompositionElementUpdate() + throws PfModelException, IOException, ServiceException, ExecutionException, InterruptedException { doNothing().when(automationCompositionElementHandler).checkPodStatus(any(), any(), any(), anyInt(), anyInt()); var elementId1 = UUID.randomUUID(); var element = new AcElementDeploy(); @@ -127,11 +127,15 @@ class AutomationCompositionElementHandlerTest { element.setDefinition(new ToscaConceptIdentifier(KEY_NAME, "1.0.1")); element.setOrderedState(DeployOrder.DEPLOY); - var nodeTemplatesMap = - toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); - automationCompositionElementHandler.deploy( - commonTestData.getAutomationCompositionId(), element, - nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties()); + var nodeTemplatesMap = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates(); + + doReturn(false).when(chartService).installChart(any()); + assertDoesNotThrow(() -> automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), + element, nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties())); + + doReturn(true).when(chartService).installChart(any()); + automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties()); assertThat(automationCompositionElementHandler.getChartMap()).hasSize(1).containsKey(elementId1); @@ -139,24 +143,20 @@ class AutomationCompositionElementHandlerTest { var elementId2 = UUID.randomUUID(); element.setId(elementId2); - automationCompositionElementHandler.deploy( - commonTestData.getAutomationCompositionId(), element, - nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties()); + assertThrows(PfModelException.class, + () -> automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), element, + nodeTemplatesMap.get(K8S_AUTOMATION_COMPOSITION_ELEMENT).getProperties())); assertThat(automationCompositionElementHandler.getChartMap().containsKey(elementId2)).isFalse(); } @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); var automationCompositionId = UUID.randomUUID(); var element = new AutomationCompositionElement(); - assertDoesNotThrow( - () -> automationCompositionElementHandler.checkPodStatus(automationCompositionId, - element.getId(), chartInfo, 1, 1)); + assertThrows(ServiceException.class, () -> automationCompositionElementHandler + .checkPodStatus(automationCompositionId, element.getId(), chartInfo, 1, 1)); } @Test diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 6cec6056d..91aff830f 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 @@ -22,8 +22,8 @@ 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; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; @@ -92,8 +92,7 @@ class PodStatusValidatorTest { void test_InvalidPodState() throws ServiceException { String invalidPod = "NAME\tREADY\tSTATUS\tRESTARTS\tAGE\nhellofromdocker-54777df9f8-qpzqr\t1/1\tInit\t0\t9h"; doReturn(invalidPod).when(client).executeCommand(any()); - assertThatThrownBy(() -> podStatusValidator.run()) - .isInstanceOf(ServiceException.class).hasMessage("Error verifying the status of the pod. Exiting"); + assertThrows(ServiceException.class, () -> podStatusValidator.run()); assertThat(AutomationCompositionElementHandler.getPodStatusMap()).isEmpty(); } -- cgit 1.2.3-korg