summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Hansen <tony@att.com>2021-10-27 19:20:36 +0000
committerGerrit Code Review <gerrit@onap.org>2021-10-27 19:20:36 +0000
commitc6f1b58aae6ecddeb4d2a615e017c625c7e29bfa (patch)
tree964fc26ae0dfa876d081871f00ce1d33b505e503
parent9e930892d28fc4a3378fad8f942c9f91cffe4698 (diff)
parentf98abd8de6b9457a7edcd3457e664bd9200de2bf (diff)
Merge "Add cmpv2Certificate flag, removed hyphens from config under postgres and enhanced Readme file"
-rw-r--r--mod2/helm-generator/Changelog.md6
-rw-r--r--mod2/helm-generator/README.md16
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/AddOnsManager.java81
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartBuilder.java2
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartGenerator.java11
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java14
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/main/resources/component-spec-schema.json6
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/AddOnsManagerTest.java77
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartBuilderTest.java2
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartGeneratorTest.java8
-rw-r--r--mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java27
11 files changed, 219 insertions, 31 deletions
diff --git a/mod2/helm-generator/Changelog.md b/mod2/helm-generator/Changelog.md
index 130e224..63e3e6c 100644
--- a/mod2/helm-generator/Changelog.md
+++ b/mod2/helm-generator/Changelog.md
@@ -5,8 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
-## [1.0.2]- 2021-10-13
+## [1.0.2]- 2021-10-27
* [DCAEGEN2-2936] Convert streams_publishes and streams_subscribes json strings under applicationConfig to map
+* [DCAEGEN2-2948] Spec schema changes: Change Cluster to ClusterIP, make policy-id as required field
+* [DCAEGEN2-2949] Add useCmpv2Certificates: true and include certificate.yaml (add-on)
+* [DCAEGEN2-2950] Remove hyphens from a component name under postgres-config section
+* [DCAEGEN2-2951] Enhance Readme file: add environment variables info
## [1.0.1]- 2021-10-04
diff --git a/mod2/helm-generator/README.md b/mod2/helm-generator/README.md
index 6304ebb..d797410 100644
--- a/mod2/helm-generator/README.md
+++ b/mod2/helm-generator/README.md
@@ -1,11 +1,19 @@
## Instructions for running helm chart generator
-version: 1.0.0-SNAPSHOT
+version: 1.0.2-SNAPSHOT
1. Must have helm installed.
2. Run `mvn clean package` to build and package the code.
-3. Run main class `HelmChartGeneratorApplication` with parameters added to configuration properties, set in the following order:
+3. Discover helmchartgenerator-cli-<version>.jar under helmchartgenerator-cli/target
+
+4. Override the default values for Chart Museum APIs for chart distribution by setting the following ENV variables:
+ CHARTMUSEUM_BASEURL -> Base URL along with a port of Chart Museum (e.g "http://chartmuseum:8080")
+ (Note: the port is only needed if it's not the standard 80 for http or 443 for https.)
+ CHARTMUSEUM_AUTH_BASIC_USERNAME -> Username for basic auth
+ CHARTMUSEUM_AUTH_BASIC_PASSWORD -> Password for basic auth
+
+5. Run the jar with these parameters set in the following order:
1. Spec file location
2. Chart directory location
3. Output directory location
@@ -17,4 +25,6 @@ version: 1.0.0-SNAPSHOT
Test files currently included in project:
- Spec file: `helm-chart-generator\src\test\input\specs\ves.json`
- - Charts Directory: `helm-chart-generator\src\test\input\blueprint` \ No newline at end of file
+ - Charts Directory: `helm-chart-generator\src\test\input\blueprint`
+
+ gi \ No newline at end of file
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/AddOnsManager.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/AddOnsManager.java
new file mode 100644
index 0000000..3aff2f0
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/AddOnsManager.java
@@ -0,0 +1,81 @@
+/*
+ * # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T 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.dcaegen2.platform.helmchartgenerator.chartbuilder;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FileUtils;
+import org.onap.dcaegen2.platform.helmchartgenerator.Utils;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.base.ComponentSpec;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.TlsInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * manages addOn template files
+ */
+@Slf4j
+@Component
+public class AddOnsManager {
+
+ public AddOnsManager(Utils utils) {
+ this.utils = utils;
+ }
+
+ @Autowired
+ private Utils utils;
+
+ /**
+ * include addons template files based on parameters in componentSpec file
+ * @param specFileLocation spec file location
+ * @param chart chart directory
+ * @param chartTemplateLocation chart template location
+ */
+ public void includeAddons(String specFileLocation, File chart, String chartTemplateLocation) {
+ if(externalTlsExists(specFileLocation)){
+ includeCertificateYamlAddOn(chart, chartTemplateLocation);
+ }
+ }
+
+ private void includeCertificateYamlAddOn(File chart, String chartTemplateLocation) {
+ Path certificateYaml = Paths.get(chartTemplateLocation, "addons/templates/certificates.yaml");
+ if(!Files.exists(certificateYaml)) {
+ throw new RuntimeException("certificates.yaml not found under templates directory in addons");
+ }
+ try {
+ File templates = new File(chart, "templates");
+ FileUtils.copyFileToDirectory(certificateYaml.toFile(), templates);
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ throw new RuntimeException("could not add certificates.yaml to templates directory");
+ }
+ }
+
+ private boolean externalTlsExists(String specFileLocation) {
+ ComponentSpec cs = utils.deserializeJsonFileToModel(specFileLocation, ComponentSpec.class);
+ TlsInfo tlsInfo = cs.getAuxilary().getTlsInfo();
+ return tlsInfo != null && tlsInfo.getUseExternalTls() != null && tlsInfo.getUseExternalTls();
+ }
+}
+
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartBuilder.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartBuilder.java
index 21f5dae..677466b 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartBuilder.java
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartBuilder.java
@@ -69,6 +69,6 @@ public class ChartBuilder {
public File build(String specFileLocation, String chartTemplateLocation, String outputLocation, String specSchemaLocation ) throws Exception {
validator.validateChartTemplateStructure(chartTemplateLocation);
ChartInfo chartInfo = specParser.extractChartInfo(specFileLocation, chartTemplateLocation, specSchemaLocation);
- return chartGenerator.generate(chartTemplateLocation, chartInfo, outputLocation);
+ return chartGenerator.generate(chartTemplateLocation, chartInfo, outputLocation, specFileLocation);
}
}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartGenerator.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartGenerator.java
index be02d68..c884e47 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartGenerator.java
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ChartGenerator.java
@@ -43,16 +43,21 @@ public class ChartGenerator {
@Autowired
private Utils utils;
+ @Autowired
+ private AddOnsManager addOnsManager;
+
/**
* Constructor for ChartGenerator
* @param helmClient HelmClient implementation
* @param merger KeyValueMerger implementation
* @param utils
+ * @param addOnsManager
*/
- public ChartGenerator(HelmClient helmClient, KeyValueMerger merger, Utils utils) {
+ public ChartGenerator(HelmClient helmClient, KeyValueMerger merger, Utils utils, AddOnsManager addOnsManager) {
this.helmClient = helmClient;
this.merger = merger;
this.utils = utils;
+ this.addOnsManager = addOnsManager;
}
/**
@@ -60,10 +65,12 @@ public class ChartGenerator {
* @param chartBlueprintLocation location of the base helm chart template
* @param chartInfo chartInfo object with key-values parsed from the specfile.
* @param outputLocation location to store the helm chart
+ * @param specFileLocation
* @return generated helm chart tgz file
*/
- public File generate(String chartBlueprintLocation, ChartInfo chartInfo, String outputLocation) {
+ public File generate(String chartBlueprintLocation, ChartInfo chartInfo, String outputLocation, String specFileLocation) {
File newChartDir = utils.cloneFileToTempLocation(chartBlueprintLocation + "/base");
+ addOnsManager.includeAddons(specFileLocation, newChartDir, chartBlueprintLocation);
merger.mergeValuesToChart(chartInfo, newChartDir);
helmClient.lint(newChartDir);
final File chartLocation = helmClient.packageChart(newChartDir, outputLocation);
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java
index 9a9f8f1..82d70c8 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/chartbuilder/ComponentSpecParser.java
@@ -243,7 +243,8 @@ public class ComponentSpecParser {
Map<String, Object> keystore = new LinkedHashMap<>();
Map<String, Object> passwordsSecretRef = new LinkedHashMap<>();
TlsInfo tlsInfo = cs.getAuxilary().getTlsInfo();
- String componentName = getComponentNameWithOmitFirstWord(cs);
+ String componentName = getComponentNameWithOmitFirstWordAndTrimHyphens(cs);
+ outerValues.put("useCmpv2Certificates", false);
if(externalTlsExists(tlsInfo)) {
String mountPath = tlsInfo.getCertDirectory();
if(tlsInfo.getUseExternalTls() != null && tlsInfo.getUseExternalTls()) {
@@ -260,15 +261,16 @@ public class ComponentSpecParser {
utils.putIfNotNull(certificate,"dnsNames", List.of(cs.getSelf().getName()));
certificate.put("keystore", keystore);
outerValues.put("certificates", List.of(certificate));
+ outerValues.put("useCmpv2Certificates", true);
}
}
- private String getComponentNameWithOmitFirstWord(ComponentSpec cs) {
- return cs.getSelf().getName().substring(cs.getSelf().getName().indexOf("-") + 1);
+ private String getComponentNameWithOmitFirstWordAndTrimHyphens(ComponentSpec cs) {
+ return cs.getSelf().getName().substring(cs.getSelf().getName().indexOf("-") + 1).replaceAll("-","");
}
private boolean externalTlsExists(TlsInfo tlsInfo) {
- return tlsInfo != null && tlsInfo.getUseExternalTls() != null && tlsInfo.getUseExternalTls().equals(true);
+ return tlsInfo != null && tlsInfo.getUseExternalTls() != null && tlsInfo.getUseExternalTls();
}
private void checkCertificateYamlExists(String chartTemplateLocation) {
@@ -301,7 +303,7 @@ public class ComponentSpecParser {
private void populatePostgresSection(Map<String, Object> outerValues, ComponentSpec cs) {
if(cs.getAuxilary().getDatabases() != null) {
String componentFullName = cs.getSelf().getName();
- String component = getComponentNameWithOmitFirstWord(cs);
+ String component = getComponentNameWithOmitFirstWordAndTrimHyphens(cs);
Map<String, Object> postgres = new LinkedHashMap<>();
Map<String, Object> service = new LinkedHashMap<>();
Map<String, Object> container = new LinkedHashMap<>();
@@ -332,7 +334,7 @@ public class ComponentSpecParser {
private void populateSecretsSection(Map<String, Object> outerValues, ComponentSpec cs) {
if(cs.getAuxilary().getDatabases() != null) {
- String component = getComponentNameWithOmitFirstWord(cs);
+ String component = getComponentNameWithOmitFirstWordAndTrimHyphens(cs);
List<Object> secrets = new ArrayList<>();
Map<String, Object> secret = new LinkedHashMap<>();
secret.put("uid", "pg-user-creds");
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/resources/component-spec-schema.json b/mod2/helm-generator/helmchartgenerator-core/src/main/resources/component-spec-schema.json
index ddea3f0..30bbb38 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/main/resources/component-spec-schema.json
+++ b/mod2/helm-generator/helmchartgenerator-core/src/main/resources/component-spec-schema.json
@@ -148,7 +148,7 @@
}
},
"required": [
- "node_label",
+ "policy_id",
"policy_model_id"
]
}
@@ -904,7 +904,7 @@
"type": "string",
"enum": [
"NodePort",
- "Cluster"
+ "ClusterIP"
]
},
"name": {
@@ -1159,4 +1159,4 @@
]
}
}
-} \ No newline at end of file
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/AddOnsManagerTest.java b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/AddOnsManagerTest.java
new file mode 100644
index 0000000..d7c697b
--- /dev/null
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/AddOnsManagerTest.java
@@ -0,0 +1,77 @@
+/** # ============LICENSE_START=======================================================
+ * # Copyright (c) 2021 AT&T 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.dcaegen2.platform.helmchartgenerator;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.AddOnsManager;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.base.Auxilary;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.base.ComponentSpec;
+import org.onap.dcaegen2.platform.helmchartgenerator.models.componentspec.common.TlsInfo;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class AddOnsManagerTest {
+
+ private AddOnsManager manager;
+
+ @Mock
+ private Utils utils;
+
+ @BeforeEach
+ void setUp() {
+ manager = new AddOnsManager(utils);
+ }
+
+ @Test
+ void testIncludeCertificationYamlAddOn() throws Exception {
+ final String specFileLocation = "src/test/input/specs/ves.json";
+ when(utils.deserializeJsonFileToModel(specFileLocation, ComponentSpec.class)).thenReturn(getMockCs());
+ manager.includeAddons(specFileLocation,
+ new File("src/test/dcae-ves-collector"),
+ "src/test/input/blueprint");
+ Assertions.assertTrue(Files.exists(Path.of("src/test/dcae-ves-collector/templates/certificates.yaml")));
+ }
+
+ private ComponentSpec getMockCs() {
+ ComponentSpec cs = new ComponentSpec();
+ Auxilary auxilary = new Auxilary();
+ TlsInfo tlsInfo = new TlsInfo();
+ tlsInfo.setUseExternalTls(true);
+ tlsInfo.setUseTls(true);
+ auxilary.setTlsInfo(tlsInfo);
+ cs.setAuxilary(auxilary);
+ return cs;
+ }
+
+ @AfterEach
+ void tearDown() throws Exception{
+ FileUtils.deleteDirectory(new File("src/test/dcae-ves-collector"));
+ }
+}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartBuilderTest.java b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartBuilderTest.java
index dd19382..b9ad2cb 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartBuilderTest.java
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartBuilderTest.java
@@ -48,7 +48,7 @@ class ChartBuilderTest {
builder.build("someSpec", "someChartLocation", "someOutputLocation", "someSpecSchemaLocation");
Mockito.verify(specParser, Mockito.times(1)).extractChartInfo(any(), any(), any());
- Mockito.verify(chartGenerator, Mockito.times(1)).generate(any(), any(), any());
+ Mockito.verify(chartGenerator, Mockito.times(1)).generate(any(), any(), any(), any());
Mockito.verify(validator, Mockito.times(1)).validateChartTemplateStructure(any());
}
}
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartGeneratorTest.java b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartGeneratorTest.java
index 1c2c9bc..65fafc2 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartGeneratorTest.java
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ChartGeneratorTest.java
@@ -24,6 +24,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
+import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.AddOnsManager;
import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.ChartGenerator;
import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.HelmClient;
import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.KeyValueMerger;
@@ -43,12 +44,15 @@ class ChartGeneratorTest {
@Mock
private Utils utils;
+ @Mock
+ private AddOnsManager addOnsManager;
+
@Test
void testChartGenerationSteps() throws Exception{
- ChartGenerator chartGenerator = new ChartGenerator(helmClient, kvMerger, utils);
+ ChartGenerator chartGenerator = new ChartGenerator(helmClient, kvMerger, utils, addOnsManager);
Mockito.when(utils.cloneFileToTempLocation(any())).thenReturn(any());
- chartGenerator.generate("src/test/input/blueprint", new ChartInfo(), "src/test/output");
+ chartGenerator.generate("src/test/input/blueprint", new ChartInfo(), "src/test/output", "specFileLocation");
Mockito.verify(kvMerger, Mockito.times(1)).mergeValuesToChart(any(), any());
Mockito.verify(helmClient, Mockito.times(1)).lint(any());
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java
index f29ea1b..8b26d25 100644
--- a/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java
+++ b/mod2/helm-generator/helmchartgenerator-core/src/test/java/org/onap/dcaegen2/platform/helmchartgenerator/ComponentSpecParserTest.java
@@ -19,6 +19,7 @@
package org.onap.dcaegen2.platform.helmchartgenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -33,6 +34,7 @@ import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith({MockitoExtension.class})
class ComponentSpecParserTest {
@@ -78,7 +80,8 @@ class ComponentSpecParserTest {
assertThat(outerKv.get("image")).isEqualTo("nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest");
assertThat(outerKv.get("logDirectory")).isEqualTo("/opt/app/VESCollector/logs/");
assertThat(outerKv.get("certDirectory")).isEqualTo("/opt/app/dcae-certificate/");
- assertThat(outerKv.get("tlsServer")).isEqualTo(true);
+ assertTrue((Boolean) outerKv.get("tlsServer"));
+ assertTrue((Boolean) outerKv.get("useCmpv2Certificates"));
}
private void assertMetadata(ChartInfo chartInfo) {
@@ -119,16 +122,16 @@ class ComponentSpecParserTest {
}
assertThat(service.get("type")).isEqualTo("NodePort");
assertThat(service.get("name")).isEqualTo("dcae-ves-collector");
- assertThat(service.get("has_internal_only_ports")).isEqualTo(true);
+ assertTrue((Boolean) service.get("has_internal_only_ports"));
assertThat(ports.get(0).get("name")).isEqualTo("http");
assertThat(ports.get(0).get("port")).isEqualTo(8443);
assertThat(ports.get(0).get("plain_port")).isEqualTo(8080);
assertThat(ports.get(0).get("port_protocol")).isEqualTo("http");
assertThat(ports.get(0).get("nodePort")).isEqualTo(17);
- assertThat(ports.get(0).get("useNodePortExt")).isEqualTo(true);
+ assertTrue((Boolean) ports.get(0).get("useNodePortExt"));
assertThat(ports.get(1).get("name")).isEqualTo("metrics");
assertThat(ports.get(1).get("port")).isEqualTo(4444);
- assertThat(ports.get(1).get("internal_only")).isEqualTo(true);
+ assertTrue((Boolean) ports.get(1).get("internal_only"));
}
private void assertPolicyInfo(ChartInfo chartInfo) {
@@ -143,9 +146,9 @@ class ComponentSpecParserTest {
assertThat(certificate.get("commonName")).isEqualTo("dcae-ves-collector");
assertThat(((List) certificate.get("dnsNames")).get(0)).isEqualTo("dcae-ves-collector");
assertThat(((List) ((Map<String, Map>) certificate.get("keystore")).get("outputType")).get(0)).isEqualTo("jks");
- assertThat((((Map<String, Map>) certificate.get("keystore")).get("passwordSecretRef")).get("name")).isEqualTo("ves-collector-cmpv2-keystore-password");
+ assertThat((((Map<String, Map>) certificate.get("keystore")).get("passwordSecretRef")).get("name")).isEqualTo("vescollector-cmpv2-keystore-password");
assertThat((((Map<String, Map>) certificate.get("keystore")).get("passwordSecretRef")).get("key")).isEqualTo("password");
- assertThat((((Map<String, Map>) certificate.get("keystore")).get("passwordSecretRef")).get("create")).isEqualTo(true);
+ assertTrue((Boolean) (((Map<String, Map>) certificate.get("keystore")).get("passwordSecretRef")).get("create"));
}
private void assertConfigMap(ChartInfo chartInfo) {
@@ -155,7 +158,7 @@ class ComponentSpecParserTest {
assertThat(volume_one.get("name")).isEqualTo("dcae-external-repo-configmap-schema-map");
assertThat(volume_one.get("type")).isEqualTo("configMap");
assertThat(volume_one.get("mountPath")).isEqualTo("/opt/app/VESCollector/etc/externalRepo/");
- assertThat(volume_one.get("optional")).isEqualTo(true);
+ assertTrue((Boolean) volume_one.get("optional"));
}
private void assertPostgres(ChartInfo chartInfo) {
@@ -168,18 +171,18 @@ class ComponentSpecParserTest {
assertThat(((Map<String, Object>) ((Map<String, Object>) postgres.get("container")).get("name")).get("replica")).isEqualTo("dcae-ves-collector-pg-replica");
assertThat(((Map<String, Object>) postgres.get("persistence")).get("mountSubPath")).isEqualTo("dcae-ves-collector/data");
assertThat(((Map<String, Object>) postgres.get("persistence")).get("mountInitPath")).isEqualTo("dcae-ves-collector");
- assertThat(((Map<String, Object>) postgres.get("config")).get("pgUserName")).isEqualTo("ves-collector");
- assertThat(((Map<String, Object>) postgres.get("config")).get("pgDatabase")).isEqualTo("ves-collector");
- assertThat(((Map<String, Object>) postgres.get("config")).get("pgUserExternalSecret")).isEqualTo("{{ include \"common.release\" . }}-ves-collector-pg-user-creds");
+ assertThat(((Map<String, Object>) postgres.get("config")).get("pgUserName")).isEqualTo("vescollector");
+ assertThat(((Map<String, Object>) postgres.get("config")).get("pgDatabase")).isEqualTo("vescollector");
+ assertThat(((Map<String, Object>) postgres.get("config")).get("pgUserExternalSecret")).isEqualTo("{{ include \"common.release\" . }}-vescollector-pg-user-creds");
}
private void assertSecrets(ChartInfo chartInfo) {
List<Object> secrets = (List<Object>) chartInfo.getValues().get("secrets");
Map<String, Object> secret1 = (Map<String, Object>) secrets.get(0);
assertThat(secret1.get("uid")).isEqualTo("pg-user-creds");
- assertThat(secret1.get("name")).isEqualTo("{{ include \"common.release\" . }}-ves-collector-pg-user-creds");
+ assertThat(secret1.get("name")).isEqualTo("{{ include \"common.release\" . }}-vescollector-pg-user-creds");
assertThat(secret1.get("type")).isEqualTo("basicAuth");
- assertThat(secret1.get("externalSecret")).isEqualTo("{{ ternary \"\" (tpl (default \"\" .Values.postgres.config.pgUserExternalSecret) .) (hasSuffix \"ves-collector-pg-user-creds\" .Values.postgres.config.pgUserExternalSecret) }}");
+ assertThat(secret1.get("externalSecret")).isEqualTo("{{ ternary \"\" (tpl (default \"\" .Values.postgres.config.pgUserExternalSecret) .) (hasSuffix \"vescollector-pg-user-creds\" .Values.postgres.config.pgUserExternalSecret) }}");
assertThat(secret1.get("login")).isEqualTo("{{ .Values.postgres.config.pgUserName }}");
assertThat(secret1.get("password")).isEqualTo("{{ .Values.postgres.config.pgUserPassword }}");
assertThat(secret1.get("passwordPolicy")).isEqualTo("generate");