summaryrefslogtreecommitdiffstats
path: root/mod/bpgenerator
diff options
context:
space:
mode:
Diffstat (limited to 'mod/bpgenerator')
-rw-r--r--mod/bpgenerator/common/pom.xml4
-rw-r--r--mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java5
-rw-r--r--mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java3
-rw-r--r--mod/bpgenerator/onap-executable/pom.xml6
-rw-r--r--mod/bpgenerator/onap/pom.xml6
-rw-r--r--mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java12
-rw-r--r--mod/bpgenerator/onap/src/main/resources/bpgen.properties7
-rw-r--r--mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java175
-rw-r--r--mod/bpgenerator/pom.xml2
-rw-r--r--mod/bpgenerator/version.properties2
10 files changed, 202 insertions, 20 deletions
diff --git a/mod/bpgenerator/common/pom.xml b/mod/bpgenerator/common/pom.xml
index 09c9757..ae4f716 100644
--- a/mod/bpgenerator/common/pom.xml
+++ b/mod/bpgenerator/common/pom.xml
@@ -29,7 +29,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>blueprint-generator-common</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>1.7.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Common</name>
@@ -39,7 +39,7 @@
<parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>blueprint-generator</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>1.7.3-SNAPSHOT</version>
</parent>
diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java
index fbd0527..e08b28d 100644
--- a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java
+++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java
@@ -4,8 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
- * * ================================================================================
- * * Modifications Copyright (c) 2021 Nokia
+ * * Copyright (c) 2021 Nokia. 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.
@@ -51,8 +50,6 @@ public class Constants {
public static final String EMPTY_VALUE = "";
public static final String DCAE_NODES_CONTAINERIZED_SERVICE_COMPONENT_USING_DMAAP =
"dcae.nodes.ContainerizedServiceComponentUsingDmaap";
- public static final String MEMORY_LIMIT_128Mi = "128Mi";
- public static final String CPU_LIMIT_250m = "250m";
public static final String CPU_LIMIT = "cpu_limit";
public static final String MEMORY_LIMIT = "memory_limit";
public static final String CPU_REQUEST = "cpu_request";
diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java
index 0526f48..a84afb6 100644
--- a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java
+++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java
@@ -178,7 +178,7 @@ public class BlueprintHelperService {
* <p>
* Default input type: "string".
*
- * @param inputType Input type, supported: "boolean", "integer"
+ * @param inputType Input type, supported: "boolean", "integer", "number"
* @param defaultValue Default value of Type
* @return
*/
@@ -187,6 +187,7 @@ public class BlueprintHelperService {
case "boolean":
return createBooleanInput(defaultValue);
case "integer":
+ case "number":
return createIntegerInput(defaultValue);
default:
return createStringInput(defaultValue);
diff --git a/mod/bpgenerator/onap-executable/pom.xml b/mod/bpgenerator/onap-executable/pom.xml
index ae20547..d1376c3 100644
--- a/mod/bpgenerator/onap-executable/pom.xml
+++ b/mod/bpgenerator/onap-executable/pom.xml
@@ -22,12 +22,12 @@ limitations under the License.
<parent>
<artifactId>blueprint-generator</artifactId>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>1.7.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blueprint-generator-onap-executable</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>1.7.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>OnapExecutable</name>
@@ -37,7 +37,7 @@ limitations under the License.
<dependency>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>blueprint-generator-onap</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>1.7.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
diff --git a/mod/bpgenerator/onap/pom.xml b/mod/bpgenerator/onap/pom.xml
index dc91f39..ccf24b6 100644
--- a/mod/bpgenerator/onap/pom.xml
+++ b/mod/bpgenerator/onap/pom.xml
@@ -29,7 +29,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>blueprint-generator-onap</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>1.7.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Onap</name>
@@ -40,14 +40,14 @@
<parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>blueprint-generator</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>1.7.3-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>blueprint-generator-common</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>1.7.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java
index a3a9c97..ab33bfa 100644
--- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java
+++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * Copyright (c) 2021 Nokia. 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.
@@ -28,6 +29,7 @@ import org.onap.blueprintgenerator.model.common.GetInput;
import org.onap.blueprintgenerator.model.common.ResourceConfig;
import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@@ -46,6 +48,12 @@ public class ResourceConfigService {
@Autowired
private BlueprintHelperService blueprintHelperService;
+ @Value("${resources.cpuLimit}")
+ private String defaultCpuLimit;
+
+ @Value("${resources.memoryLimit}")
+ private String defaultMemoryLimit;
+
/**
* Creates Resouce Config for properties
*
@@ -59,10 +67,10 @@ public class ResourceConfigService {
ResourceConfig resourceConfig = new ResourceConfig();
LinkedHashMap<String, Object> memoryLimit =
- blueprintHelperService.createStringInput(Constants.MEMORY_LIMIT_128Mi);
+ blueprintHelperService.createStringInput(defaultMemoryLimit);
LinkedHashMap<String, Object> cpuLimit =
- blueprintHelperService.createStringInput(Constants.CPU_LIMIT_250m);
+ blueprintHelperService.createStringInput(defaultCpuLimit);
name = blueprintHelperService.getNamePrefix(name);
diff --git a/mod/bpgenerator/onap/src/main/resources/bpgen.properties b/mod/bpgenerator/onap/src/main/resources/bpgen.properties
index 69a3ad6..5bc0ab0 100644
--- a/mod/bpgenerator/onap/src/main/resources/bpgen.properties
+++ b/mod/bpgenerator/onap/src/main/resources/bpgen.properties
@@ -4,7 +4,7 @@
# * org.onap.dcae
# * ================================================================================
# * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
-# * Copyright (c) 2020 Nokia. All rights reserved.
+# * Copyright (c) 2020-2021 Nokia. 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.
@@ -23,10 +23,11 @@
#
imports.onap.types=https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml
-imports.onap.K8s.plugintypes=plugin:k8splugin?version=3.4.2
+imports.onap.K8s.plugintypes=plugin:k8splugin?version=>=3.5.1,<4.0.0
imports.onap.K8s.dcaepolicyplugin=plugin:dcaepolicyplugin?version=2.4.0
imports.dmaap.dmaapplugin=plugin:dmaap?version=1.5.0
import.Postgres=plugin:pgaas?version=1.3.0
import.Clamp=plugin:clamppolicyplugin?version=1.1.0
-
+resources.cpuLimit=${BP_RESOURCES_CPU_LIMIT:250m}
+resources.memoryLimit=${BP_RESOURCES_MEMORY_LIMIT:128Mi}
diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java
new file mode 100644
index 0000000..61f9353
--- /dev/null
+++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java
@@ -0,0 +1,175 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2021 Nokia 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.
+ * * ============LICENSE_END=========================================================
+ *
+ *
+ */
+
+package org.onap.blueprintgenerator.service.common;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.blueprintgenerator.model.common.Appconfig;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.onap.blueprintgenerator.model.componentspec.common.Parameters;
+import org.onap.blueprintgenerator.service.InfoService;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.onap.blueprintgenerator.service.common.kafka.KafkaStreamService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {AppConfigService.class, BlueprintHelperService.class, DmaapService.class,
+ InfoService.class, StreamService.class, KafkaStreamService.class},
+ initializers = ConfigFileApplicationContextInitializer.class)
+public class AppConfigServiceTest {
+
+ private static final String TEST_PARAMETER_NAME = "testParameter";
+ private static final String INPUTS = "inputs";
+ private static final String TYPE = "type";
+ private static final String DEFAULT = "default";
+
+ private static final String PARAMETERS_TYPE_STRING = "string";
+ private static final String PARAMETERS_TYPE_INTEGER = "integer";
+ private static final String PARAMETERS_TYPE_BOOLEAN = "boolean";
+ private static final String PARAMETERS_TYPE_NUMBER = "number";
+
+ private static final String STRING_INPUT_TYPE = "string";
+ private static final String INTEGER_INPUT_TYPE = "integer";
+ private static final String BOOLEAN_INPUT_TYPE = "boolean";
+ private static final String UNKNOWN_TYPE = "test_unknown_type";
+
+ private static final boolean BOOLEAN_TEST_VALUE = true;
+ private static final String TEST_STRING_VALUE = "testValue";
+ private static final String APP_CONFIG = "appconfig";
+
+ @Autowired
+ private AppConfigService appConfigService;
+
+ private OnapComponentSpec componentSpec;
+
+ @Before
+ public void setUp() {
+ componentSpec = Mockito.mock(OnapComponentSpec.class);
+ }
+
+ @Test
+ public void shouldCreateStringInputForStringParameter() {
+
+ mockParameters(PARAMETERS_TYPE_STRING, TEST_STRING_VALUE);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(STRING_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(TEST_STRING_VALUE, createdParameters.get(DEFAULT));
+ }
+
+ @Test
+ public void shouldCreateStringInputForUnknownParameter() {
+
+ mockParameters(UNKNOWN_TYPE, TEST_STRING_VALUE);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(STRING_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(TEST_STRING_VALUE, createdParameters.get(DEFAULT));
+ }
+
+ @Test
+ public void shouldCreateBooleanInputForBooleanParameter() {
+
+ mockParameters(PARAMETERS_TYPE_BOOLEAN, BOOLEAN_TEST_VALUE);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(BOOLEAN_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(BOOLEAN_TEST_VALUE, createdParameters.get(DEFAULT));
+ }
+
+ @Test
+ public void shouldCreateIntegerInputForIntegerParameter() {
+
+ mockParameters(PARAMETERS_TYPE_INTEGER, 123);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(INTEGER_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(123, createdParameters.get(DEFAULT));
+ }
+
+ @Test
+ public void shouldCreateIntegerInputForNumberParameter() {
+
+ mockParameters(PARAMETERS_TYPE_NUMBER, 123);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(INTEGER_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(123, createdParameters.get(DEFAULT));
+ }
+
+ private void assertAppConfigContainsParameterWithCorrectInputName(Map<String, Object> appConfig) {
+ Appconfig appConfigModel = (Appconfig) appConfig.get(APP_CONFIG);
+ Object bpInputName = ((GetInput) appConfigModel.getParams().get(TEST_PARAMETER_NAME)).getBpInputName();
+ assertEquals(bpInputName, TEST_PARAMETER_NAME);
+ }
+
+ private void mockParameters(String type, Object value) {
+ Parameters testParameter = new Parameters();
+ testParameter.setName(TEST_PARAMETER_NAME);
+ testParameter.setType(type);
+ testParameter.setSourced_at_deployment(true);
+ testParameter.setValue(value);
+ Parameters[] parametersArray = new Parameters[1];
+ parametersArray[0] = testParameter;
+ when(componentSpec.getParameters()).thenReturn(parametersArray);
+ }
+}
diff --git a/mod/bpgenerator/pom.xml b/mod/bpgenerator/pom.xml
index 540d3e2..dd157d9 100644
--- a/mod/bpgenerator/pom.xml
+++ b/mod/bpgenerator/pom.xml
@@ -30,7 +30,7 @@
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>blueprint-generator</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>1.7.3-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
diff --git a/mod/bpgenerator/version.properties b/mod/bpgenerator/version.properties
index 75acd49..c3c1ab1 100644
--- a/mod/bpgenerator/version.properties
+++ b/mod/bpgenerator/version.properties
@@ -1,6 +1,6 @@
major=1
minor=7
-patch=2
+patch=3
base_version=${major}.${minor}.${patch}
release_version=${base_version}
snapshot_version=${base_version}-SNAPSHOT