summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-kubernetes/src
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2022-03-21 12:38:52 +0000
committerAdheli Tavares <adheli.tavares@est.tech>2022-03-22 13:04:37 +0000
commit0a78930e107a44c3b4119a321c680692154f90f5 (patch)
treeb3cd4d3850d092001e5b3f179ff41bc2eb465ab3 /participant/participant-impl/participant-impl-kubernetes/src
parente5a316e5c8aeaae1ba4aead0a71b6baf2f8cc5c1 (diff)
Clean up unit tests
- use the unified test reference folder - fix some sonar lint issues Issue-ID: POLICY-3945 Change-Id: I33e30332d911f02c32937316bac6d2d331ac6346 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes/src')
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java4
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java18
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidatorTest.java9
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java7
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/ParticipantK8sParametersTest.java6
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ActuatorControllerTest.java18
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java26
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartServiceTest.java6
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/service/ChartStoreTest.java4
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java15
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/TestUtils.java15
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml32
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties24
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml179
14 files changed, 90 insertions, 273 deletions
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 6124060cb..41d9b845d 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
@@ -75,7 +75,7 @@ class AutomationCompositionElementHandlerTest {
private static ToscaServiceTemplate toscaServiceTemplate;
private static final String K8S_AUTOMATION_COMPOSITION_ELEMENT =
"org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement";
- private CommonTestData commonTestData = new CommonTestData();
+ private final CommonTestData commonTestData = new CommonTestData();
@InjectMocks
@Spy
@@ -160,7 +160,7 @@ class AutomationCompositionElementHandlerTest {
}
@Test
- void test_handleStatistics() throws PfModelException {
+ void test_handleStatistics() {
UUID elementId1 = UUID.randomUUID();
automationCompositionElementHandler.getChartMap().put(elementId1, charts.get(0));
when(participantIntermediaryApi.getAutomationCompositionElement(elementId1))
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 d85ab6d9f..f5826bf3b 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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
@@ -23,9 +23,10 @@ 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.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mockStatic;
@@ -89,7 +90,7 @@ class HelmClientTest {
}
@Test
- void test_installChart() throws IOException {
+ void test_installChart() {
mockedClient.when(() -> HelmClient.executeCommand(any()))
.thenReturn("success");
doReturn(new File("/target/tmp/override.yaml")).when(chartStore)
@@ -100,16 +101,14 @@ class HelmClientTest {
chartinfo.setNamespace("");
assertDoesNotThrow(() -> helmClient.installChart(chartinfo));
- mockedClient.when(() -> HelmClient.executeCommand(any()))
- .thenReturn(new String());
+ mockedClient.when(() -> HelmClient.executeCommand(any())).thenReturn("");
assertDoesNotThrow(() -> helmClient.installChart(chartinfo));
}
@Test
- void test_addRepository() throws IOException {
- mockedClient.when(() -> HelmClient.executeCommand(any()))
- .thenReturn(new String());
+ void test_addRepository() {
+ mockedClient.when(() -> HelmClient.executeCommand(any())).thenReturn("");
when(repo.getRepoName()).thenReturn("RepoName");
when(repo.getAddress()).thenReturn("http://localhost:8080");
assertDoesNotThrow(() -> helmClient.addRepository(repo));
@@ -129,7 +128,10 @@ class HelmClientTest {
assertThat(configuredRepo).isEqualTo("nginx-stable");
File tmpFile = new File(tmpPath + charts.get(1).getChartId().getName());
- tmpFile.mkdirs();
+ if (!tmpFile.mkdirs()) {
+ fail("Couldn't create dirs");
+ }
+
doReturn(Path.of(tmpPath)).when(chartStore).getAppPath(charts.get(1).getChartId());
doReturn(null).when(helmClient).verifyConfiguredRepo(charts.get(1));
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 89b077044..fbddf8b28 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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");
@@ -49,24 +49,21 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
class PodStatusValidatorTest {
-
private static final Coder CODER = new StandardCoder();
private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json";
private static List<ChartInfo> charts;
- private static int timeout = 60;
- private static int statusCheckInterval = 30;
-
@InjectMocks
private static PodStatusValidator podStatusValidator;
private static MockedStatic<HelmClient> mockedClient;
-
@BeforeAll
static void init() throws CoderException {
charts = CODER.decode(new File(CHART_INFO_YAML), ChartList.class).getCharts();
mockedClient = mockStatic(HelmClient.class);
+ int timeout = 60;
+ int statusCheckInterval = 30;
podStatusValidator = new PodStatusValidator(charts.get(0), timeout, statusCheckInterval);
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 13f8edc15..7ffd68812 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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");
@@ -21,7 +21,6 @@
package org.onap.policy.clamp.acm.participant.kubernetes.parameters;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -36,7 +35,7 @@ public class CommonTestData {
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());
+ public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
public static final Coder CODER = new StandardCoder();
@@ -147,7 +146,7 @@ public class CommonTestData {
final TopicParameters topicParams = new TopicParameters();
topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
topicParams.setTopicCommInfrastructure("dmaap");
- topicParams.setServers(Arrays.asList("localhost"));
+ topicParams.setServers(List.of("localhost"));
return topicParams;
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 09ea74afe..2e17be06b 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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");
@@ -31,8 +31,8 @@ import org.junit.jupiter.api.Test;
class ParticipantK8sParametersTest {
- private CommonTestData commonTestData = new CommonTestData();
- private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
+ private final CommonTestData commonTestData = new CommonTestData();
+ private final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
@Test
void testParticipantPolicyParameters() {
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 8d05d2bf6..997a227cb 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,13 +32,13 @@ import org.springframework.boot.test.autoconfigure.actuate.metrics.AutoConfigure
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@AutoConfigureMetrics
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@TestPropertySource(locations = {"classpath:application_test.properties"})
+@ActiveProfiles("test")
class ActuatorControllerTest extends CommonActuatorController {
private static final String HEALTH_ENDPOINT = "health";
@@ -54,36 +54,36 @@ class ActuatorControllerTest extends CommonActuatorController {
}
@Test
- void testGetHealth_Unauthorized() throws Exception {
+ void testGetHealth_Unauthorized() {
assertUnauthorizedActGet(HEALTH_ENDPOINT);
}
@Test
- void testGetMetrics_Unauthorized() throws Exception {
+ void testGetMetrics_Unauthorized() {
assertUnauthorizedActGet(METRICS_ENDPOINT);
}
@Test
- void testGetPrometheus_Unauthorized() throws Exception {
+ void testGetPrometheus_Unauthorized() {
assertUnauthorizedActGet(PROMETHEUS_ENDPOINT);
}
@Test
- void testGetHealth() throws Exception {
+ void testGetHealth() {
Invocation.Builder invocationBuilder = super.sendActRequest(HEALTH_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
}
@Test
- void testGetMetrics() throws Exception {
+ void testGetMetrics() {
Invocation.Builder invocationBuilder = super.sendActRequest(METRICS_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
}
@Test
- void testGePrometheus() throws Exception {
+ void testGePrometheus() {
Invocation.Builder invocationBuilder = super.sendActRequest(PROMETHEUS_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 7105c2327..c57684fd7 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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
@@ -70,12 +70,12 @@ class ChartControllerTest {
private static final Coder CODER = new StandardCoder();
private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json";
private static List<ChartInfo> charts;
- private static String RETRIEVE_CHART_URL = "/helm/charts";
- private static String INSTALL_CHART_URL = "/helm/install";
- 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";
+ private static final String RETRIEVE_CHART_URL = "/helm/charts";
+ private static final String INSTALL_CHART_URL = "/helm/install";
+ private static final String UNINSTALL_CHART_URL = "/helm/uninstall/";
+ private static final String ONBOARD_CHART_URL = "/helm/onboard/chart";
+ private static final String DELETE_CHART_URL = "/helm/chart";
+ private static final String CONFIGURE_REPO_URL = "/helm/repo";
@Autowired
private MockMvc mockMvc;
@@ -88,7 +88,7 @@ class ChartControllerTest {
/**
* Read input chart info json.
- * @throws Exception incase of error.
+ * @throws CoderException in case of error.
*/
@BeforeAll
static void setupParams() throws CoderException {
@@ -97,7 +97,6 @@ class ChartControllerTest {
/**
* Mock service layer in Controller.
- * @throws Exception incase of error.
*/
@BeforeEach
void mockServiceClass() {
@@ -110,7 +109,7 @@ class ChartControllerTest {
/**
* Test endpoint for retrieving all charts.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void retrieveAllCharts() throws Exception {
@@ -124,7 +123,7 @@ class ChartControllerTest {
/**
* Test endpoint for installing a chart.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void installChart() throws Exception {
@@ -149,7 +148,7 @@ class ChartControllerTest {
/**
* Test endpoint for uninstalling a chart.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void uninstallChart() throws Exception {
@@ -174,7 +173,7 @@ class ChartControllerTest {
/**
* Test endpoint for chart onboarding.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void onboardChart() throws Exception {
@@ -196,7 +195,7 @@ class ChartControllerTest {
/**
* Test endpoint for deleting a chart.
- * @throws Exception incase of error.
+ * @throws Exception in case of error.
*/
@Test
void deleteChart() throws Exception {
@@ -250,7 +249,6 @@ class ChartControllerTest {
}
-
private String getInstallationJson(String name, String version) {
JSONObject jsonObj = new JSONObject();
jsonObj.put("name", name);
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 4fc045d48..d83d43f20 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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
@@ -23,10 +23,10 @@ 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;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 180861bae..029db9994 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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");
@@ -23,8 +23,8 @@ 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;
-import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.File;
import java.io.IOException;
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 e5a5be9fa..8b716a5fd 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,9 +50,8 @@ public class CommonActuatorController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendActRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendActRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, true);
}
@@ -61,9 +60,8 @@ public class CommonActuatorController {
*
* @param endpoint the target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendNoAuthActRequest(final String endpoint) throws Exception {
+ protected Invocation.Builder sendNoAuthActRequest(final String endpoint) {
return sendFqeRequest(httpPrefix + ACTUATOR_ENDPOINT + endpoint, false);
}
@@ -73,10 +71,8 @@ public class CommonActuatorController {
* @param fullyQualifiedEndpoint the fully qualified target endpoint
* @param includeAuth if authorization header should be included
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth)
- throws Exception {
+ protected Invocation.Builder sendFqeRequest(final String fullyQualifiedEndpoint, boolean includeAuth) {
final Client client = ClientBuilder.newBuilder().build();
client.property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, "true");
@@ -95,9 +91,8 @@ public class CommonActuatorController {
* Assert that GET call to actuator endpoint is Unauthorized.
*
* @param endPoint the endpoint
- * @throws Exception if an error occurs
*/
- protected void assertUnauthorizedActGet(final String endPoint) throws Exception {
+ protected void assertUnauthorizedActGet(final String endPoint) {
Response rawresp = sendNoAuthActRequest(endPoint).buildGet().invoke();
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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 8f4969a9b..c9b616fa0 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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");
@@ -31,17 +31,14 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
public final class TestUtils {
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
- private static final String TOSCA_TEMPLATE_YAML = "src/test/resources/servicetemplates/KubernetesHelm.yaml";
+ private static final String TOSCA_TEMPLATE_YAML = "clamp/acm/test/participant-kubernetes-helm.yaml";
public static ToscaServiceTemplate testAutomationCompositionRead() {
- return testAutomationCompositionYamlSerialization(TOSCA_TEMPLATE_YAML);
+ return testAutomationCompositionYamlSerialization();
}
- private static ToscaServiceTemplate testAutomationCompositionYamlSerialization(
- String automationCompositionFilePath) {
- String automationCompositionString = ResourceUtils.getResourceAsString(automationCompositionFilePath);
- ToscaServiceTemplate serviceTemplate =
- yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
- return serviceTemplate;
+ private static ToscaServiceTemplate testAutomationCompositionYamlSerialization() {
+ String automationCompositionString = ResourceUtils.getResourceAsString(TestUtils.TOSCA_TEMPLATE_YAML);
+ return yamlTranslator.fromYaml(automationCompositionString, ToscaServiceTemplate.class);
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml
new file mode 100644
index 000000000..c54996e79
--- /dev/null
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml
@@ -0,0 +1,32 @@
+server:
+ error:
+ path: /error
+
+participant:
+ name: AutomationCompositionParticipant Kubernetes Test
+ intermediaryParameters:
+ name: Participant parameters
+ description: Participant Description
+ reportingTimeInterval: 120000
+ participantId:
+ name: K8sParticipant0
+ version: 1.0.0
+ participantType:
+ version: 2.3.4
+ name: org.onap.k8s.acm.K8SAutomationCompositionParticipant
+ clampAutomationCompositionTopics:
+ topicSources:
+ -
+ topic: POLICY-ACRUNTIME-PARTICIPANT
+ fetchTimeout: 15000
+ servers:
+ - localhost
+ topicCommInfrastructure: dmaap
+ topicSinks:
+ -
+ topic: POLICY-ACRUNTIME-PARTICIPANT
+ servers:
+ - localhost
+ topicCommInfrastructure: dmaap
+ name: AutomationComposition Topics
+
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
deleted file mode 100644
index 243512166..000000000
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application_test.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-spring.security.user.name=participantUser
-spring.security.user.password=zb!XztG34
-
-server.servlet.context-path=/onap/policy/clamp/acm/k8sparticipant
-server.error.path=/error
-server.http-port=8083
-
-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.acm.K8SAutomationCompositionParticipant
-participant.intermediaryParameters.participantType.version=2.3.4
-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
deleted file mode 100644
index f5eb6233f..000000000
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/servicetemplates/KubernetesHelm.yaml
+++ /dev/null
@@ -1,179 +0,0 @@
-# ============LICENSE_START=======================================================
-# Copyright (C) 2021 Nordix Foundation.
-# ================================================================================
-# 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=========================================================
-tosca_definitions_version: tosca_simple_yaml_1_3
-data_types:
- onap.datatypes.ToscaConceptIdentifier:
- derived_from: tosca.datatypes.Root
- properties:
- name:
- type: string
- required: true
- version:
- type: string
- required: true
-node_types:
- 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.acm.AutomationCompositionElement:
- version: 1.0.1
- derived_from: tosca.nodetypes.Root
- properties:
- provider:
- type: string
- requred: false
- participantType:
- type: onap.datatypes.ToscaConceptIdentifier
- requred: true
- startPhase:
- type: integer
- required: false
- constraints:
- - greater-or-equal: 0
- metadata:
- common: true
- 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:
- provider:
- type: string
- requred: false
- elements:
- type: list
- required: true
- entry_schema:
- type: onap.datatypes.ToscaConceptIdentifier
- org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement:
- version: 1.0.1
- derived_from: org.onap.policy.clamp.acm.AutomationCompositionElement
- properties:
- chart:
- type: string
- required: true
- configs:
- type: list
- required: false
- requirements:
- type: string
- requred: false
- templates:
- type: list
- required: false
- entry_schema:
- values:
- type: string
- requred: true
-topology_template:
- node_templates:
- org.onap.k8s.acm.K8SAutomationCompositionParticipant:
- version: 2.3.4
- type: org.onap.policy.clamp.acm.Participant
- type_version: 1.0.1
- description: Participant for K8S
- properties:
- provider: ONAP
-
- org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement:
- # Chart from any chart repository configured on helm client.
- version: 1.2.3
- type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for the K8S microservice for Hello World
- properties:
- provider: ONAP
- participantType:
- name: org.onap.k8s.acm.K8SAutomationCompositionParticipant
- version: 2.3.4
- startPhase: 2
- uninitializedToPassiveTimeout: 180
- podStatusCheckInterval: 30
- chart:
- chartId:
- name: hello
- version: 0.1.0
- releaseName: helloworld
- namespace: onap
- repository: chartMuseum
-
- org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement:
- # Chart from local file system
- version: 1.2.3
- type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for the K8S microservice for PMSH
- properties:
- provider: ONAP
- participantType:
- name: org.onap.k8s.acm.K8SAutomationCompositionParticipant
- version: 2.3.4
- startPhase: 2
- uninitializedToPassiveTimeout: 180
- podStatusCheckInterval: 30
- chart:
- chartId:
- name: dcae-pmsh
- version: 8.0.0
- namespace: onap
- releaseName: pmshms
- overrideParams:
- global.masterPassword: test
-
- org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement:
- # Chart installation without passing repository name
- version: 1.2.3
- type: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
- type_version: 1.0.0
- description: Automation composition element for the K8S microservice for local chart
- properties:
- provider: ONAP
- participantType:
- name: org.onap.k8s.acm.K8SAutomationCompositionParticipant
- version: 2.3.4
- startPhase: 2
- uninitializedToPassiveTimeout: 180
- podStatusCheckInterval: 30
- chart:
- chartId:
- name: nginx-ingress
- version: 0.9.1
- releaseName: nginxms
- namespace: onap
-
- org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition:
- version: 1.2.3
- type: org.onap.policy.clamp.acm.AutomationComposition
- type_version: 1.0.0
- description: Automation composition for Hello World
- properties:
- provider: ONAP
- elements:
- - name: org.onap.domain.database.HelloWorld_K8SMicroserviceAutomationCompositionElement
- version: 1.2.3
- - name: org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement
- version: 1.2.3
- - name: org.onap.domain.database.Local_K8SMicroserviceAutomationCompositionElement
- version: 1.2.3