summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-kubernetes/src
diff options
context:
space:
mode:
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/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java14
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java3
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java5
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java18
4 files changed, 34 insertions, 6 deletions
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java
index e1e9195eb..3f2113d98 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java
@@ -20,9 +20,9 @@
package org.onap.policy.clamp.controlloop.participant.kubernetes.handler;
-
import java.io.IOException;
import java.lang.invoke.MethodHandles;
+import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
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;
@@ -51,7 +52,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
/**
* This class handles implementation of controlLoopElement updates.
*/
@@ -170,10 +170,16 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
* Overridden method.
*
* @param controlLoopElementId controlLoopElement id
- * @throws PfModelException incase of error
+ * @throws PfModelException in case of error
*/
@Override
public synchronized void handleStatistics(UUID controlLoopElementId) throws PfModelException {
- // TODO Implement statistics functionality
+ var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
+ if (clElement != null) {
+ var clElementStatistics = new ClElementStatistics();
+ clElementStatistics.setControlLoopState(clElement.getState());
+ clElementStatistics.setTimeStamp(Instant.now());
+ intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics);
+ }
}
}
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/controlloop/participant/kubernetes/helm/HelmClient.java
index 1c405539b..31fa62f1f 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/controlloop/participant/kubernetes/helm/HelmClient.java
@@ -47,6 +47,7 @@ public class HelmClient {
private ChartStore chartStore;
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final String PATH_DELIMITER = "/";
/**
* Install a chart.
@@ -100,7 +101,7 @@ public class HelmClient {
}
var localHelmChartDir = chartStore.getAppPath(chart.getChartId()).toString();
logger.info("Chart not found in helm repositories, verifying local repo {} ", localHelmChartDir);
- if (verifyLocalHelmRepo(new File(localHelmChartDir + "/" + chart.getChartId().getName()))) {
+ if (verifyLocalHelmRepo(new File(localHelmChartDir + PATH_DELIMITER + chart.getChartId().getName()))) {
repository = localHelmChartDir;
}
return repository;
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/controlloop/participant/kubernetes/helm/HelmClientTest.java
index 79a37f8e6..41b1fbeb5 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/controlloop/participant/kubernetes/helm/HelmClientTest.java
@@ -89,7 +89,10 @@ class HelmClientTest {
.thenReturn("success");
doReturn(new File("/target/tmp/override.yaml")).when(chartStore)
.getOverrideFile(any());
- assertDoesNotThrow(() -> helmClient.installChart(charts.get(0)));
+ var chartinfo = charts.get(0);
+ assertDoesNotThrow(() -> helmClient.installChart(chartinfo));
+ chartinfo.setNamespace("");
+ assertDoesNotThrow(() -> helmClient.installChart(chartinfo));
}
@Test
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/controlloop/participant/kubernetes/rest/ChartControllerTest.java
index bbb57c320..2af2a0171 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/controlloop/participant/kubernetes/rest/ChartControllerTest.java
@@ -73,6 +73,7 @@ class ChartControllerTest {
private static String UNINSTALL_CHART_URL = "/helm/uninstall/";
private static String ONBOARD_CHART_URL = "/helm/onboard/chart";
private static String DELETE_CHART_URL = "/helm/chart";
+ private static String CONFIGURE_REPO_URL = "/helm/repo";
@Autowired
private MockMvc mockMvc;
@@ -217,6 +218,23 @@ class ChartControllerTest {
}
+ /**
+ * Test endpoint for configuring a helm repository.
+ * @throws Exception in case of error.
+ */
+ @Test
+ void testConfigureRepo() throws Exception {
+ RequestBuilder requestBuilder;
+
+ requestBuilder = MockMvcRequestBuilders.post(CONFIGURE_REPO_URL).accept(MediaType.APPLICATION_JSON_VALUE)
+ .content(getInstallationJson(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion()))
+ .contentType(MediaType.APPLICATION_JSON_VALUE);
+
+ mockMvc.perform(requestBuilder).andExpect(status().isCreated());
+
+ }
+
+
private String getInstallationJson(String name, String version) {
JSONObject jsonObj = new JSONObject();
jsonObj.put("name", name);