summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-kserve/src/test
diff options
context:
space:
mode:
authoraravind.est <aravindhan.a@est.tech>2023-03-06 16:29:58 +0000
committeraravind.est <aravindhan.a@est.tech>2023-03-06 17:00:45 +0000
commit80111fe3c4c1e2e145485c2f2a833bdaabb3a680 (patch)
treee07f5d0c334aec4b56c3bfdcef50f80678a9928c /participant/participant-impl/participant-impl-kserve/src/test
parente297b91468a465cf828f3a95d0e17fdd1ee89887 (diff)
Add log message when kserve setup is unavailable and improve coverage
Add log message when kserve setup is unavailable. Improve code coverage. Issue-ID: POLICY-4525 Signed-off-by: aravind.est <aravindhan.a@est.tech> Change-Id: If92fc38ceb8e3427e4b2c6045d2fd3ffcc106198
Diffstat (limited to 'participant/participant-impl/participant-impl-kserve/src/test')
-rwxr-xr-xparticipant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java21
-rwxr-xr-xparticipant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java2
2 files changed, 20 insertions, 3 deletions
diff --git a/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java b/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java
index d8a896ef8..63ad3ef14 100755
--- a/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/handler/AcElementHandlerTest.java
@@ -20,14 +20,18 @@
package org.onap.policy.clamp.acm.participant.kserve.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.doReturn;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import io.kubernetes.client.openapi.ApiException;
import java.io.IOException;
+import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
@@ -77,7 +81,7 @@ class AcElementHandlerTest {
}
@BeforeEach
- void startMocks() throws KserveException, ExecutionException, InterruptedException, IOException, ApiException {
+ void startMocks() throws ExecutionException, InterruptedException, IOException, ApiException {
doReturn(true).when(kserveClient).deployInferenceService(any(), any());
doReturn(true).when(automationCompositionElementHandler)
.checkInferenceServiceStatus(any(), any(), anyInt(), anyInt());
@@ -100,13 +104,26 @@ class AcElementHandlerTest {
}
@Test
- void test_AutomationCompositionElementUpdate() {
+ void test_AutomationCompositionElementUpdate() throws IOException, ApiException {
var element = commonTestData.getAutomationCompositionElement();
var nodeTemplatesMap = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
assertDoesNotThrow(
() -> automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), element,
nodeTemplatesMap.get(KSERVE_AUTOMATION_COMPOSITION_ELEMENT).getProperties()));
+ assertThat(automationCompositionElementHandler.getConfigRequestMap()).hasSize(1)
+ .containsKey(element.getId());
+
+ doThrow(new ApiException("Error installing the inference service")).when(kserveClient)
+ .deployInferenceService(any(), any());
+
+ var elementId2 = UUID.randomUUID();
+ element.setId(elementId2);
+ assertThrows(KserveException.class,
+ () -> automationCompositionElementHandler.deploy(commonTestData.getAutomationCompositionId(), element,
+ nodeTemplatesMap.get(KSERVE_AUTOMATION_COMPOSITION_ELEMENT).getProperties()));
+
+ assertThat(automationCompositionElementHandler.getConfigRequestMap().containsKey(elementId2)).isFalse();
}
@Test
diff --git a/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java b/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java
index 3ef89a7c1..6f1b8c433 100755
--- a/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java
+++ b/participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/k8s/InferenceServiceValidatorTest.java
@@ -62,7 +62,7 @@ class InferenceServiceValidatorTest {
new InferenceServiceValidator("", namespace, TIMEOUT, STATUS_CHECK_INTERVAL,
kserveClient);
assertThatThrownBy(inferenceServiceValidator::run).isInstanceOf(KserveException.class)
- .hasMessage("Error verifying the status of the inference service. Exiting");
+ .cause().hasMessage("Kserve setup is unavailable for inference service to be deployed");
}
@Test