aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authorAdam Wudzinski <adam.wudzinski@nokia.com>2021-01-15 17:38:30 +0100
committerAdam Wudzinski <adam.wudzinski@nokia.com>2021-01-18 16:58:27 +0100
commitf3b0ef4dc7cc21b273ea160781b5170b2d105e1a (patch)
tree04550aed49f28b599d2702a519ad7d51a855aac8 /openecomp-be/lib
parentbd5a1006210092f9ac5c48352cc94f6264e961ef (diff)
Map VSP PM_DICTIONARY Type to VF PM_DICTIONARY Type
File defined in ZIP VSP package as PM_DICTIONARY will be now mapped to PM_DICTIONARY type in VF. Also PmDictionaryValidator is run on files with PM_DICTIONARY type in ZIP Manifest file, instead of file naming convention. Issue-ID: SDC-3390 Signed-off-by: Adam Wudzinski <adam.wudzinski@nokia.com> Change-Id: I2e21353b9e80b6bb68c4c6d408ad1ffa33314e7b
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java21
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java68
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java43
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtilsTest.java34
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java46
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/global_context_util/MANIFEST.json22
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/MANIFEST.json22
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/health_base_node.env6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/health_base_node.yaml65
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/pmdict.yaml (renamed from openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_pm_dictionary.yaml)0
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/MANIFEST.json22
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/health_base_node.env6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/health_base_node.yaml65
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/pmdict.yaml105
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_pm_dictionary.yaml230
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/MANIFEST.json21
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/health_base_node.env6
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/health_base_node.yaml64
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/pmdict.yaml101
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java50
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java75
26 files changed, 809 insertions, 323 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java
index c49062acc0..c4215c9783 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtils.java
@@ -23,16 +23,6 @@ import java.util.Set;
class FileExtensionUtils {
- private static final Set<String> VALID_PM_DICTIONARY_EXTENSIONS = Set.of(
- "pmdict.yml",
- "pmdict.yaml",
- "pm_dict.yml",
- "pm_dict.yaml",
- "pmdictionary.yml",
- "pmdictionary.yaml",
- "pm_dictionary.yml",
- "pm_dictionary.yaml"
- );
private static final Set<String> VALID_YAML_EXTENSIONS = Set.of(
".yaml",
".yml",
@@ -40,16 +30,9 @@ class FileExtensionUtils {
);
static boolean isYaml(String fileName) {
- return isValidExt(fileName, VALID_YAML_EXTENSIONS);
- }
-
- static boolean isPmDictionary(String fileName) {
- return isValidExt(fileName, VALID_PM_DICTIONARY_EXTENSIONS);
- }
-
- private static boolean isValidExt(String fileName, Set<String> validExtensions) {
String fileNameLower = fileName.toLowerCase();
- return validExtensions.stream()
+ return FileExtensionUtils.VALID_YAML_EXTENSIONS.stream()
.anyMatch(fileNameLower::endsWith);
}
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java
new file mode 100644
index 0000000000..4467bd1311
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtil.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdc.validation.impl.validators;
+
+import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
+import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
+import org.openecomp.sdc.validation.util.ValidationUtil;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+class GlobalContextUtil {
+
+ private GlobalContextUtil() {}
+
+ static Set<String> findPmDictionaryFiles(GlobalValidationContext globalContext) {
+ if (isManifestMissing(globalContext)) {
+ return Set.of();
+ }
+
+ Map<String, FileData.Type> filesWithTypes = readAllFilesWithTypes(globalContext);
+ return filterPmDictionaryFiles(filesWithTypes);
+ }
+
+ private static boolean isManifestMissing(GlobalValidationContext globalContext) {
+ return globalContext.getFileContent("MANIFEST.json")
+ .isEmpty();
+ }
+
+ private static Set<String> filterPmDictionaryFiles(Map<String, FileData.Type> filesWithTypes) {
+ return filesWithTypes.entrySet().stream()
+ .filter(isPmDictionaryType())
+ .map(Map.Entry::getKey)
+ .collect(Collectors.toSet());
+ }
+
+ private static Map<String, FileData.Type> readAllFilesWithTypes(GlobalValidationContext globalContext) {
+ ManifestContent manifestContent = ValidationUtil.validateManifest(globalContext);
+ return ManifestUtil.getFileTypeMap(manifestContent);
+ }
+
+ private static Predicate<Map.Entry<String, FileData.Type>> isPmDictionaryType() {
+ return entry -> entry.getValue()
+ .equals(FileData.Type.PM_DICTIONARY);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java
index f5338c5d3b..05021fdf4f 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -22,8 +22,6 @@ package org.openecomp.sdc.validation.impl.validators;
import io.vavr.control.Option;
import io.vavr.control.Try;
-import java.io.InputStream;
-import java.util.List;
import org.onap.validation.yaml.YamlContentValidator;
import org.onap.validation.yaml.error.YamlDocumentValidationError;
import org.openecomp.core.validation.ErrorMessageCode;
@@ -32,16 +30,25 @@ import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.validation.Validator;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Set;
+
public class PmDictionaryValidator implements Validator {
private static final ErrorMessageCode PM_DICT_ERROR_CODE = new ErrorMessageCode("PM_DICT");
@Override
public void validate(GlobalValidationContext globalContext) {
- globalContext.getFiles().stream()
- .filter(FileExtensionUtils::isPmDictionary)
- .map(fileName -> new ValidationHelper(globalContext, fileName))
- .forEach(ValidationHelper::validate);
+ Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
+ validatePmDictionaryFiles(globalContext, pmDictionaryFiles);
+ }
+
+
+ private void validatePmDictionaryFiles(GlobalValidationContext globalContext, Set<String> pmDictionaryFiles) {
+ pmDictionaryFiles.stream()
+ .map(fileName -> new ValidationHelper(globalContext, fileName))
+ .forEach(ValidationHelper::validate);
}
private static class ValidationHelper {
@@ -56,35 +63,35 @@ public class PmDictionaryValidator implements Validator {
public void validate() {
Option.ofOptional(globalContext.getFileContent(fileName))
- .peek(this::validateFileContent)
- .onEmpty(() -> addErrorToContext(formatMessage("File is empty")));
+ .peek(this::validateFileContent)
+ .onEmpty(() -> addErrorToContext(formatMessage("File is empty")));
}
private void validateFileContent(InputStream inputStream) {
Try.of(inputStream::readAllBytes)
- .mapTry(fileContent -> new YamlContentValidator().validate(fileContent))
- .onSuccess(this::reportValidationErrorsIfPresent)
- .onFailure(e -> addErrorToContext(formatMessage(e.getMessage())));
+ .mapTry(fileContent -> new YamlContentValidator().validate(fileContent))
+ .onSuccess(this::reportValidationErrorsIfPresent)
+ .onFailure(e -> addErrorToContext(formatMessage(e.getMessage())));
}
private void reportValidationErrorsIfPresent(List<YamlDocumentValidationError> validationErrors) {
validationErrors.stream()
- .map(this::prepareValidationMessage)
- .forEach(this::addErrorToContext);
+ .map(this::prepareValidationMessage)
+ .forEach(this::addErrorToContext);
}
private String prepareValidationMessage(YamlDocumentValidationError error) {
final String errorMessage = String.format("Document Number: %s, Path: %s, Problem: %s",
- error.getYamlDocumentNumber(),
- error.getPath(),
- error.getMessage()
+ error.getYamlDocumentNumber(),
+ error.getPath(),
+ error.getMessage()
);
return formatMessage(errorMessage);
}
private String formatMessage(String message) {
return ErrorMessagesFormatBuilder
- .getErrorWithParameters(PM_DICT_ERROR_CODE, message);
+ .getErrorWithParameters(PM_DICT_ERROR_CODE, message);
}
private void addErrorToContext(String message) {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
index 4196ad2929..b11ff5e341 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/YamlValidator.java
@@ -1,6 +1,6 @@
/*
* Copyright © 2016-2017 European Support Limited
- * Copyright © 2020 Nokia
+ * Copyright © 2020-2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import java.io.InputStream;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
public class YamlValidator implements Validator {
private static final ErrorMessageCode ERROR_CODE_YML_1 = new ErrorMessageCode("YML1");
@@ -37,9 +38,11 @@ public class YamlValidator implements Validator {
@Override
public void validate(GlobalValidationContext globalContext) {
+ Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
+
Collection<String> files = globalContext.files(
(fileName, globalValidationContext) -> FileExtensionUtils.isYaml(fileName)
- && !FileExtensionUtils.isPmDictionary(fileName));
+ && !pmDictionaryFiles.contains(fileName));
files.forEach(fileName -> validate(fileName, globalContext));
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtilsTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtilsTest.java
index 53a2cfa650..73b3112339 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtilsTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/FileExtensionUtilsTest.java
@@ -39,22 +39,6 @@ class FileExtensionUtilsTest {
".properties"
);
- private static final Set<String> VALID_PM_DICTIONARY_EXTENSIONS = Set.of(
- "pmdict.yml",
- "pmdict.yaml",
- "pm_dict.yml",
- "pm_dict.yaml",
- "pmdictionary.yml",
- "pmdictionary.yaml",
- "pm_dictionary.yml",
- "pm_dictionary.yaml"
- );
- private static final Set<String> INVALID_PM_DICTIONARY_EXTENSIONS = Set.of(
- "pmdict.txt",
- "pmdict.java",
- "pm.yml"
- );
-
private static final Set<String> TEST_FILE_PREFIXES = Set.of(
"test",
"test_file"
@@ -76,22 +60,6 @@ class FileExtensionUtilsTest {
assertTrue(allInvalidFilesNotMatched);
}
- @Test
- void shouldMatchProperPmDictionaryExtensions() {
- final boolean allValidFilesMatched = constructTestFilenamesWithExtensions(VALID_PM_DICTIONARY_EXTENSIONS)
- .allMatch(FileExtensionUtils::isPmDictionary);
-
- assertTrue(allValidFilesMatched);
- }
-
- @Test
- void shouldNotMatchImproperPmDictionaryExtensions() {
- final boolean allInvalidFilesNotMatched = constructTestFilenamesWithExtensions(INVALID_PM_DICTIONARY_EXTENSIONS)
- .noneMatch(FileExtensionUtils::isPmDictionary);
-
- assertTrue(allInvalidFilesNotMatched);
- }
-
private Stream<String> constructTestFilenamesWithExtensions(Set<String> extensions) {
return extensions.stream()
.flatMap(ext -> prepareFilenamesWithExtension(ext).stream());
@@ -108,4 +76,4 @@ class FileExtensionUtilsTest {
return TEST_FILE_PREFIXES.stream()
.map(prefix -> prefix + extension);
}
-} \ No newline at end of file
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java
new file mode 100644
index 0000000000..5856b3f322
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/GlobalContextUtilTest.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.openecomp.sdc.validation.impl.validators;
+
+import org.junit.jupiter.api.Test;
+import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class GlobalContextUtilTest {
+ private static final String TEST_MANIFEST_PATH = "/org/openecomp/validation/validators/global_context_util/";
+
+ @Test
+ void shouldReturnOnlyFilesWithPmDictionaryType() {
+ // given
+ GlobalValidationContext globalContext = ValidationTestUtil.createGlobalContextFromPath(TEST_MANIFEST_PATH);
+
+ // when
+ Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
+
+ // then
+ assertEquals(1, pmDictionaryFiles.size());
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java
index d841694a23..b510eeb26a 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/PmDictionaryValidatorTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -31,30 +31,48 @@ import org.openecomp.sdc.validation.util.ValidationTestUtil;
public class PmDictionaryValidatorTest {
private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/pm_dictionary_validator";
- private static final String VALID_PM_DICTIONARY_YAML = "valid_pm_dictionary.yaml";
- private static final String INVALID_PM_DICTIONARY_YAML = "invalid_pm_dictionary.yaml";
+ private static final String VALID_PM_DICTIONARY_PACKAGE_PATH = "valid_file/";
+ private static final String INVALID_PM_DICTIONARY_PACKAGE_PATH = "invalid_file/";
+ private static final String WRONG_PM_DICTIONARY_TYPE_PACKAGE_PATH = "wrong_file_type/";
+ private static final String PM_DICTIONARY_FILE_NAME = "pmdict.yaml";
+
@Test
- public void shouldNotReturnErrorsWhenValidPmDict() {
+ void shouldNotReturnErrorsWhenValidPmDict() {
+ // when
Map<String, MessageContainer> messages = runValidation(
- RESOURCE_PATH + "/" + VALID_PM_DICTIONARY_YAML);
+ RESOURCE_PATH + "/" + VALID_PM_DICTIONARY_PACKAGE_PATH);
+ // then
assertNotNull(messages);
assertEquals(0, messages.size());
}
@Test
- public void shouldReturnErrorsWhenInvalidPmDict() {
+ void shouldReturnErrorsWhenInvalidPmDict() {
+ // when
+ Map<String, MessageContainer> messages = runValidation(
+ RESOURCE_PATH + "/" + INVALID_PM_DICTIONARY_PACKAGE_PATH);
+
+ // then
+ assertNotNull(messages);
+ assertNotNull(messages.get(PM_DICTIONARY_FILE_NAME));
+ assertEquals(4, messages.get(PM_DICTIONARY_FILE_NAME).getErrorMessageList().size());
+ }
+
+ @Test
+ void shouldNotReturnErrorsWhenInvalidPmDictButWrongPmDictionaryTypeInManifest() {
+ // when
Map<String, MessageContainer> messages = runValidation(
- RESOURCE_PATH + "/" + INVALID_PM_DICTIONARY_YAML);
+ RESOURCE_PATH + "/" + WRONG_PM_DICTIONARY_TYPE_PACKAGE_PATH);
+ // then
assertNotNull(messages);
- assertNotNull(messages.get(INVALID_PM_DICTIONARY_YAML));
- assertEquals(4, messages.get(INVALID_PM_DICTIONARY_YAML).getErrorMessageList().size());
+ assertEquals(0, messages.size());
}
private Map<String, MessageContainer> runValidation(String path) {
PmDictionaryValidator validator = new PmDictionaryValidator();
return ValidationTestUtil.testValidator(validator, path);
}
-} \ No newline at end of file
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/global_context_util/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/global_context_util/MANIFEST.json
new file mode 100644
index 0000000000..c803a36143
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/global_context_util/MANIFEST.json
@@ -0,0 +1,22 @@
+{
+ "name": "Health VNF",
+ "description": "Health VNF onboarding package.",
+ "data": [
+ {
+ "file": "health_base_node.yaml",
+ "type": "HEAT",
+ "isBase": "true",
+ "data": [
+ {
+ "file": "health_base_node.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ },
+ {
+ "file": "pmdict.yaml",
+ "type": "PM_DICTIONARY"
+ }
+ ]
+}
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/MANIFEST.json
new file mode 100644
index 0000000000..c803a36143
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/MANIFEST.json
@@ -0,0 +1,22 @@
+{
+ "name": "Health VNF",
+ "description": "Health VNF onboarding package.",
+ "data": [
+ {
+ "file": "health_base_node.yaml",
+ "type": "HEAT",
+ "isBase": "true",
+ "data": [
+ {
+ "file": "health_base_node.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ },
+ {
+ "file": "pmdict.yaml",
+ "type": "PM_DICTIONARY"
+ }
+ ]
+}
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/health_base_node.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/health_base_node.env
new file mode 100644
index 0000000000..5207a59da2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/health_base_node.env
@@ -0,0 +1,6 @@
+parameters:
+ health_node_name_0: health_app_vm
+ health_node_image_name: ubuntu-java
+ health_node_flavor_name: aa.001-0002
+ key_name: galix_key
+ private_net_id: onap-wro
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/health_base_node.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/health_base_node.yaml
new file mode 100644
index 0000000000..42762dcc25
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/health_base_node.yaml
@@ -0,0 +1,65 @@
+heat_template_version: '2013-05-23'
+
+description: Heat template that deploys PnP PNF simulator
+
+parameters:
+ health_node_name_0:
+ type: string
+ label: Node name
+ description: Name of the node
+ # Flavors of each node
+ health_node_flavor_name:
+ type: string
+ label: Flavor
+ description: Type of instance (flavor) to be used for health node
+ # Images of each node
+ health_node_image_name:
+ type: string
+ label: Image name
+ description: OpenStack VM image to be used for node
+ # Others
+ private_net_id:
+ type: string
+ label: Private network name or ID
+ description: Private network
+ key_name:
+ type: string
+ label: Key pair name
+ description: Public/Private key pair name
+ vnf_id:
+ type: string
+ label: VNF ID
+ description: The VNF ID is provided by ONAP
+ vnf_name:
+ type: string
+ description: Unique name for this VNF instance
+ vf_module_id:
+ type: string
+ label: module ID
+ description: The Module ID is provided by ONAP
+ vf_module_name:
+ type: string
+ description: Unique name for VNF Module instance
+ dcae_collector_ip_0:
+ type: string
+
+resources:
+ health_node:
+ type: OS::Nova::Server
+ properties:
+ name: { get_param: health_node_name_0 }
+ key_name: { get_param: key_name }
+ image: { get_param: health_node_image_name }
+ flavor: { get_param: health_node_flavor_name }
+ networks:
+ - network: { get_param: private_net_id }
+ metadata:
+ vnf_name: { get_param: vnf_name }
+ vnf_id: { get_param: vnf_id }
+ vf_module_name: { get_param: vf_module_name }
+ vf_module_id: { get_param: vf_module_id }
+
+outputs:
+ oam_management_v4_address:
+ value: {get_attr: [health_node, networks, { get_param: private_net_id }, 0]}
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_pm_dictionary.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/pmdict.yaml
index cfeb497eeb..cfeb497eeb 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_pm_dictionary.yaml
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/invalid_file/pmdict.yaml
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/MANIFEST.json
new file mode 100644
index 0000000000..c803a36143
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/MANIFEST.json
@@ -0,0 +1,22 @@
+{
+ "name": "Health VNF",
+ "description": "Health VNF onboarding package.",
+ "data": [
+ {
+ "file": "health_base_node.yaml",
+ "type": "HEAT",
+ "isBase": "true",
+ "data": [
+ {
+ "file": "health_base_node.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ },
+ {
+ "file": "pmdict.yaml",
+ "type": "PM_DICTIONARY"
+ }
+ ]
+}
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/health_base_node.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/health_base_node.env
new file mode 100644
index 0000000000..5207a59da2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/health_base_node.env
@@ -0,0 +1,6 @@
+parameters:
+ health_node_name_0: health_app_vm
+ health_node_image_name: ubuntu-java
+ health_node_flavor_name: aa.001-0002
+ key_name: galix_key
+ private_net_id: onap-wro
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/health_base_node.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/health_base_node.yaml
new file mode 100644
index 0000000000..74e5051e98
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/health_base_node.yaml
@@ -0,0 +1,65 @@
+heat_template_version: '2013-05-23'
+
+description: Heat template that deploys PnP PNF simulator
+
+parameters:
+ health_node_name_0:
+ type: string
+ label: Node name
+ description: Name of the node
+ # Flavors of each node
+ health_node_flavor_name:
+ type: string
+ label: Flavor
+ description: Type of instance (flavor) to be used for health node
+ # Images of each node
+ health_node_image_name:
+ type: string
+ label: Image name
+ description: OpenStack VM image to be used for node
+ # Others
+ private_net_id:
+ type: string
+ label: Private network name or ID
+ description: Private network
+ key_name:
+ type: string
+ label: Key pair name
+ description: Public/Private key pair name
+ vnf_id:
+ type: string
+ label: VNF ID
+ description: The VNF ID is provided by ONAP
+ vnf_name:
+ type: string
+ description: Unique name for this VNF instance
+ vf_module_id:
+ type: string
+ label: module ID
+ description: The Module ID is provided by ONAP
+ vf_module_name:
+ type: string
+ description: Unique name for VNF Module instance
+ dcae_collector_ip_0:
+ type: string
+
+resources:
+ health_node:
+ type: OS::Nova::Server
+ properties:
+ name: { get_param: health_node_name_0 }
+ key_name: { get_param: key_name }
+ image: { get_param: health_node_image_name }
+ flavor: { get_param: health_node_flavor_name }
+ networks:
+ - network: { get_param: private_net_id }
+ metadata:
+ vnf_name: { get_param: vnf_name }
+ vnf_id: { get_param: vnf_id }
+ vf_module_name: { get_param: vf_module_name }
+ vf_module_id: { get_param: vf_module_id }
+
+outputs:
+ oam_management_v4_address:
+ value: {get_attr: [health_node, networks, { get_param: private_net_id }, 0]}
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/pmdict.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/pmdict.yaml
new file mode 100644
index 0000000000..b033e99c3f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_file/pmdict.yaml
@@ -0,0 +1,105 @@
+---
+# PM Dictionary Schema
+pmMetaData: { presence: required, structure: {
+ pmHeader: { presence: required, structure: {
+ pmDefVsn: { presence: required, comment: “Version of the PM Dictionary artifact that contains this measurement. Vendor defined.”},
+ pmDefSchemaVsn: { presence: required, comment: “PM Dictionary schema version from the VES Event Registration specification.”},
+ nfType: { presence: required, comment: “NF type to whom this measurement applies. This should match the nfName-vendor string used in the fileReady or perf3gpp eventName.”}
+ } } ,
+ pmFields: { presence: required, structure: {
+ measType: { presence: required, comment: “Measurement name used in PM file, in 3GPP format where specified, else vendor defined. Names for 3GPP-defined 4G measurements are specified in 3GPP TS 32.425 item e). Names for 3GPP-defined 5G measurements are specified in 3GPP TS 28.552 item e). Vendor defined names are preceded with VS.”},
+ iMeasType: { presence: required, comment: “Vendor defined integer identifier for the measType, used for efficiency in GPB. Must be combined with measInfoId to identify a specific measurement.”},
+ measDescription: { presence: required, comment: “Text description of the purpose of the measurement, what information does the measurement provide.”},
+ measCondition: { presence: required, comment: “Text description of the condition that causes the measurement to be updated.”},
+ measResultType: { presence: required, value: [integer], comment: “Data type of the measurement result.”},
+ measResultRange: { presence: optional, comment: “Range of the measurement result. Only necessary when the range is smaller than the full range of the data type.”},
+ measResultUnits: { presence: required, value: [seconds, minutes, nanoseconds, microseconds, dB, number, kilobytes, bytes, ethernetFrames, packets, users], comment: “Units of measure of the measurement result.”},
+ measObjClass: { presence: required, comment: “Object class of the measurement.”},
+ measCollectionMethod: { presence: required, value: [CC, SI, DER, Gauge, Average], comment: “Measurement collection method of the measurement. CC, SI, DER and Gauge are as defined in 3GPP. Average contains the average value of the measurement during the granularity period.”},
+ measLastChange: { presence: required, comment: “Version of the PM Dictionary artifact the last time this measurement was added, modified or deleted.”},
+ measChangeType: { presence: required, value: [added, modified, deleted], comment: “Indicates the type of change that occurred during the measLastChange.”},
+ measInfoId: { presence: required, comment: “Name for a group of related measurements, in 3GPP format where specified, else vendor defined. Family names for 3GPP-defined 4G measurements are specified in 3GPP TS 32.425 Section 3.1. Family names for 3GPP-defined 5G measurements are specified in 3GPP TS 28.552 Section 3.4.”},
+ iMeasInfoId: { presence: required, comment: “Vendor defined integer identifier for the measInfoId, used for efficiency in GPB.”},
+ measFamily: { presence: required, comment: “Abbreviation for a family of measurements, in 3GPP format where specified, else vendor defined.”},
+ measAdditionalFields: { presence: required, comment: “This section contains vendor specific measurement fields.”, structure: {
+ measAggregationLevels: { presence: required, value: [NRBTS, NRCellCU, NRCellDU, IPNO, IPSEC, ETHIF], comment: “A list of one or more aggregations levels that Nokia recommends for this measurement. For example, if the value is NRBTS NRCellCU, then Nokia recommends that this measurement be aggregated on the 5G BTS level and the 5G CU Cell level.”},
+ measTriggerType: { presence: optional, value: [Event, Sample], comment: “Indicates whether this measurement is triggered by an event or is sampled.”}
+ } }
+ } }
+} }
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2204
+ iMeasType: 1
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when X2AP: SgNB Modification Required message is sent to MeNB with the SCG Change Indication set as PSCellChange."
+ measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change attempts."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G18A_1807_003
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChAttempt
+ measAdditionalFields:
+ vendorField1: X
+ vendorField2: B
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2204
+ iMeasType: 2
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when the TDCoverall timer has elapsed before gNB receives the X2AP: SgNB Modification Confirm message."
+ measDescription: "This measurement the number of intra gNB intra frequency PSCell change failures due to TDCoverall timer expiry."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G18A_1807_003
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChFailTdcExp
+ measAdditionalFields:
+ vendorField1: Y
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2206
+ iMeasType: 1
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when MeNB replies to X2AP: SgNB Modification Required message with the X2AP: SgNB Modification Refuse message."
+ measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change failures due to MeNB refusal."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G19_1906_002
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChFailMenbRef
+ measAdditionalFields:
+ vendorField1: Z
+ vendorField2: A
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+...
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_pm_dictionary.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_pm_dictionary.yaml
deleted file mode 100644
index 1caab5fc73..0000000000
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/valid_pm_dictionary.yaml
+++ /dev/null
@@ -1,230 +0,0 @@
----
-# PM Dictionary schema specifying and describing the meta information
-# used to define perf3gpp measurements in the PM Dictionary
-pmMetaData:
- presence: required
- structure:
- pmHeader:
- presence: required
- structure:
- nfType:
- presence: required
- comment: NF type; should match the nfName-vendor string used in the fileReady
- or perf3gpp eventName
- pmDefSchemaVsn:
- presence: required
- value: 2.0
- comment: PM Dictionary Schema Version from the VES Event Registration specification
- pmDefVsn:
- presence: required
- comment: vendor-defined PM Dictionary version
- pmFields:
- presence: required
- structure:
- iMeasInfoId:
- presence: required
- comment: vendor-defined integer measurement group identifier
- iMeasType:
- presence: required
- comment: vendor-defined integer identifier for the measType; must be combined
- with measInfoId to identify a specific measurement.
- measChangeType:
- presence: required
- value:
- - added
- - modified
- - deleted
- comment: indicates the type of change that occurred during measLastChange
- measCollectionMethod:
- presence: required
- value:
- - CC
- - SI
- - DER
- - Gauge
- - Average
- comment: the measurement collection method; CC, SI, DER and Gauge are as
- defined in 3GPP; average contains the average value of the measurement
- during the granularity period
- measCondition:
- presence: required
- comment: description of the condition causing the measurement
- measDescription:
- presence: required
- comment: description of the measurement information and purpose
- measFamily:
- presence: required
- comment: abbreviation for a family of measurements, in 3GPP format, or vendor
- defined
- measInfoId:
- presence: required
- comment: name for a group of related measurements in 3GPP format or vendor
- defined
- measLastChange:
- presence: required
- comment: version of the PM Dictionary the last time this measurement was
- added, modified or deleted
- measObjClass:
- presence: required
- value:
- - NGBTS
- - NGCELL
- - IPNO
- - IPSEC
- - ETHIF
- comment: measurement object class
- measResultRange:
- presence: optional
- comment: range of the measurement result; only necessary when the range
- is smaller than the full range of the data type
- measResultType:
- presence: required
- value:
- - float
- - uint32
- - uint64
- comment: data type of the measurement result
- measResultUnits:
- presence: required
- value:
- - seconds
- - minutes
- - nanoseconds
- - microseconds
- - dB
- - number
- - kilobytes
- - bytes
- - ethernetFrames
- - packets
- - users
- comment: units of measure for the measurement result
- measType:
- presence: required
- comment: measurement name in 3GPP or vendor-specific format; vendor specific
- names are preceded with VS
- measAdditionalFields:
- presence: required
- comment: vendor-specific PM Dictionary fields
- structure:
- vendorField1:
- presence: required
- value:
- - X
- - Y
- - Z
- comment: vendor field 1 description
- vendorField2:
- presence: optional
- value:
- - A
- - B
- comment: vendor field 2 description.
-...
-# PM Dictionary perf3gpp measurements for the gnb-Nokia NF (bracket style yaml)
----
-pmMetaData:
- pmHeader:
- nfType: gnb-Nokia
- pmDefSchemaVsn: 2.0
- pmDefVsn: 5G19_1906_002
- pmFields:
- iMeasInfoId: 2204
- iMeasType: 1
- measCollectionMethod: CC
- measCondition: "This measurement is updated when X2AP: SgNB Modification Required message is sent to MeNB
- with the SCG Change Indication set as PSCellChange."
- measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change attempts."
- measFamily: NINFC
- measInfoId: "NR Intra Frequency PSCell Change"
- measLastChange: 5G18A_1807_003
- measObjClass: NGCELL
- measResultRange: 0-4096
- measResultType: float
- measChangeType: added
- measResultUnits: number
- measType: VS.NINFC.IntraFrPscelChAttempt
- measAdditionalFields:
- vendorField1: X
- vendorField2: B
-...
----
-pmMetaData:
- pmHeader:
- nfType: gnb-Nokia
- pmDefSchemaVsn: 2.0
- pmDefVsn: 5G19_1906_002
- pmFields:
- iMeasInfoId: 2204
- iMeasType: 2
- measCollectionMethod: CC
- measCondition: "This measurement is updated when the TDCoverall timer has elapsed before gNB receives the X2AP: SgNB Modification Confirm message."
- measDescription: "This measurement the number of intra gNB intra frequency PSCell change failures due to TDCoverall timer expiry."
- measFamily: NINFC
- measInfoId: "NR Intra Frequency PSCell Change"
- measLastChange: 5G18A_1807_003
- measObjClass: NGCELL
- measResultRange: 0-4096
- measResultType: float
- measChangeType: added
- measResultUnits: number
- measType: VS.NINFC.IntraFrPscelChFailTdcExp
- measAdditionalFields:
- vendorField1:
- - Y
- - X
-...
----
-pmMetaData:
- pmHeader:
- nfType: gnb-Nokia
- pmDefSchemaVsn: 2.0
- pmDefVsn: 5G19_1906_002
- pmFields:
- iMeasInfoId: 2206
- iMeasType: 1
- measCondition: "This measurement is updated when MeNB replies to X2AP: SgNB Modification Required message with the X2AP: SgNB Modification Refuse message."
- measCollectionMethod: CC
- measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change failures due to MeNB refusal."
- measFamily: NINFC
- measInfoId: "NR Intra Frequency PSCell Change"
- measLastChange: 5G19_1906_002
- measObjClass: NGCELL
- measResultRange: 0-4096
- measResultType: float
- measChangeType: added
- measResultUnits: number
- measType: VS.NINFC.IntraFrPscelChFailMenbRef
- measAdditionalFields:
- vendorField1:
- - X
- - Y
- vendorField2: A
-...
----
-pmMetaData:
- pmHeader:
- nfType: gnb-Nokia
- pmDefSchemaVsn: 2.0
- pmDefVsn: 5G19_1906_002
- pmFields:
- iMeasInfoId: 2206
- iMeasType: 1
- measCondition: "This measurement is updated when MeNB replies to X2AP: SgNB Modification Required message with the X2AP: SgNB Modification Refuse message."
- measCollectionMethod: CC
- measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change failures due to MeNB refusal."
- measFamily: NINFC
- measInfoId: "NR Intra Frequency PSCell Change"
- measLastChange: 5G19_1906_002
- measObjClass: NGCELL
- measResultRange: 0-4096
- measResultType: float
- measChangeType: added
- measResultUnits: number
- measType: VS.NINFC.IntraFrPscelChFailMenbRef
- measAdditionalFields:
- vendorField1:
- - X
- - Z
- vendorField2: A
-...
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/MANIFEST.json
new file mode 100644
index 0000000000..a1feefdf5f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/MANIFEST.json
@@ -0,0 +1,21 @@
+{
+ "name": "Health VNF",
+ "description": "Health VNF onboarding package.",
+ "data": [
+ {
+ "file": "health_base_node.yaml",
+ "type": "HEAT",
+ "isBase": "true",
+ "data": [
+ {
+ "file": "health_base_node.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ },
+ {
+ "file": "pmdict.yaml",
+ "type": "OTHER"
+ }
+ ]
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/health_base_node.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/health_base_node.env
new file mode 100644
index 0000000000..5207a59da2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/health_base_node.env
@@ -0,0 +1,6 @@
+parameters:
+ health_node_name_0: health_app_vm
+ health_node_image_name: ubuntu-java
+ health_node_flavor_name: aa.001-0002
+ key_name: galix_key
+ private_net_id: onap-wro
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/health_base_node.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/health_base_node.yaml
new file mode 100644
index 0000000000..ba69e9c6cc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/health_base_node.yaml
@@ -0,0 +1,64 @@
+heat_template_version: '2013-05-23'
+
+description: Heat template that deploys PnP PNF simulator
+
+parameters:
+ health_node_name_0:
+ type: string
+ label: Node name
+ description: Name of the node
+ # Flavors of each node
+ health_node_flavor_name:
+ type: string
+ label: Flavor
+ description: Type of instance (flavor) to be used for health node
+ # Images of each node
+ health_node_image_name:
+ type: string
+ label: Image name
+ description: OpenStack VM image to be used for node
+ # Others
+ private_net_id:
+ type: string
+ label: Private network name or ID
+ description: Private network
+ key_name:
+ type: string
+ label: Key pair name
+ description: Public/Private key pair name
+ vnf_id:
+ type: string
+ label: VNF ID
+ description: The VNF ID is provided by ONAP
+ vnf_name:
+ type: string
+ description: Unique name for this VNF instance
+ vf_module_id:
+ type: string
+ label: module ID
+ description: The Module ID is provided by ONAP
+ vf_module_name:
+ type: string
+ description: Unique name for VNF Module instance
+ dcae_collector_ip_0:
+ type: string
+
+resources:
+ health_node:
+ type: OS::Nova::Server
+ properties:
+ name: { get_param: health_node_name_0 }
+ key_name: { get_param: key_name }
+ image: { get_param: health_node_image_name }
+ flavor: { get_param: health_node_flavor_name }
+ networks:
+ - network: { get_param: private_net_id }
+ metadata:
+ vnf_name: { get_param: vnf_name }
+ vnf_id: { get_param: vnf_id }
+ vf_module_name: { get_param: vf_module_name }
+ vf_module_id: { get_param: vf_module_id }
+
+outputs:
+ oam_management_v4_address:
+ value: {get_attr: [health_node, networks, { get_param: private_net_id }, 0]}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/pmdict.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/pmdict.yaml
new file mode 100644
index 0000000000..e8a4df8a47
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/pm_dictionary_validator/wrong_file_type/pmdict.yaml
@@ -0,0 +1,101 @@
+---
+# PM Dictionary Schema
+pmMetaData: { presence: required, structure: {
+ pmHeader: { presence: required, structure: {
+ pmDefVsn: { presence: required, comment: “Version of the PM Dictionary artifact that contains this measurement. Vendor defined.”},
+ pmDefSchemaVsn: { presence: required, comment: “PM Dictionary schema version from the VES Event Registration specification.”},
+ nfType: { presence: required, comment: “NF type to whom this measurement applies. This should match the nfName-vendor string used in the fileReady or perf3gpp eventName.”}
+ } } ,
+ pmFields: { presence: required, structure: {
+ measType: { presence: required, comment: “Measurement name used in PM file, in 3GPP format where specified, else vendor defined. Names for 3GPP-defined 4G measurements are specified in 3GPP TS 32.425 item e). Names for 3GPP-defined 5G measurements are specified in 3GPP TS 28.552 item e). Vendor defined names are preceded with VS.”},
+ iMeasType: { presence: required, comment: “Vendor defined integer identifier for the measType, used for efficiency in GPB. Must be combined with measInfoId to identify a specific measurement.”},
+ measDescription: { presence: required, comment: “Text description of the purpose of the measurement, what information does the measurement provide.”},
+ measCondition: { presence: required, comment: “Text description of the condition that causes the measurement to be updated.”},
+ measResultType: { presence: required, value: [integer], comment: “Data type of the measurement result.”},
+ measResultRange: { presence: optional, comment: “Range of the measurement result. Only necessary when the range is smaller than the full range of the data type.”},
+ measResultUnits: { presence: required, value: [seconds, minutes, nanoseconds, microseconds, dB, number, kilobytes, bytes, ethernetFrames, packets, users], comment: “Units of measure of the measurement result.”},
+ measObjClass: { presence: required, comment: “Object class of the measurement.”},
+ measCollectionMethod: { presence: required, value: [CC, SI, DER, Gauge, Average], comment: “Measurement collection method of the measurement. CC, SI, DER and Gauge are as defined in 3GPP. Average contains the average value of the measurement during the granularity period.”},
+ measLastChange: { presence: required, comment: “Version of the PM Dictionary artifact the last time this measurement was added, modified or deleted.”},
+ measChangeType: { presence: required, value: [added, modified, deleted], comment: “Indicates the type of change that occurred during the measLastChange.”},
+ measInfoId: { presence: required, comment: “Name for a group of related measurements, in 3GPP format where specified, else vendor defined. Family names for 3GPP-defined 4G measurements are specified in 3GPP TS 32.425 Section 3.1. Family names for 3GPP-defined 5G measurements are specified in 3GPP TS 28.552 Section 3.4.”},
+ iMeasInfoId: { presence: required, comment: “Vendor defined integer identifier for the measInfoId, used for efficiency in GPB.”},
+ measFamily: { presence: required, comment: “Abbreviation for a family of measurements, in 3GPP format where specified, else vendor defined.”},
+ measAdditionalFields: { presence: required, comment: “This section contains vendor specific measurement fields.”, structure: {
+ measAggregationLevels: { presence: required, value: [NRBTS, NRCellCU, NRCellDU, IPNO, IPSEC, ETHIF], comment: “A list of one or more aggregations levels that Nokia recommends for this measurement. For example, if the value is NRBTS NRCellCU, then Nokia recommends that this measurement be aggregated on the 5G BTS level and the 5G CU Cell level.”},
+ measTriggerType: { presence: optional, value: [Event, Sample], comment: “Indicates whether this measurement is triggered by an event or is sampled.”}
+ } }
+ } }
+} }
+---
+pmMetaData:
+ pmFields:
+ iMeasInfoId: 2204
+ iMeasType: 1
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when X2AP: SgNB Modification Required message is sent to MeNB with the SCG Change Indication set as PSCellChange."
+ measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change attempts."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G18A_1807_003
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChAttempt
+ measAdditionalFields:
+ vendorField1: X
+ vendorField2: B
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2204
+ iMeasType: 2
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when the TDCoverall timer has elapsed before gNB receives the X2AP: SgNB Modification Confirm message."
+ measDescription: "This measurement the number of intra gNB intra frequency PSCell change failures due to TDCoverall timer expiry."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G18A_1807_003
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChFailTdcExp
+ measAdditionalFields:
+ vendorField1: Y
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2206
+ iMeasType: 1
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when MeNB replies to X2AP: SgNB Modification Required message with the X2AP: SgNB Modification Refuse message."
+ measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change failures due to MeNB refusal."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G19_1906_002
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChFailMenbRef
+ measAdditionalFields:
+ vendorField1: Z
+ vendorField2: A
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+...
+
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
index 578b120256..d33533a7d0 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
@@ -12,6 +12,8 @@
* 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.
+ *
+ * Modifications copyright (c) 2021 Nokia
*/
package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule;
@@ -80,6 +82,8 @@ public interface CandidateService {
String createManifest(VspDetails vspDetails, FilesDataStructure structure);
+ String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest);
+
Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure);
void updateValidationData(String vspId, Version version, ValidationStructureList validationData);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java
index fd70d20c22..90490e7153 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/ManifestCreator.java
@@ -3,6 +3,7 @@
* SDC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications copyright (c) 2021 Nokia
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +32,8 @@ import java.util.Optional;
public interface ManifestCreator {
Optional<ManifestContent> createManifest(VspDetails vspDetails, FilesDataStructure filesDataStructure);
+ Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, ManifestContent existingManifest);
+
Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler
fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
index 8bae5e8193..7c11fb65ab 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2016-2018 European Support Limited
+ * Modifications copyright (c) 2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -363,6 +364,13 @@ public class CandidateServiceImpl implements CandidateService {
}
@Override
+ public String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest) {
+ return JsonUtil.object2Json(manifestCreator.createManifestFromExisting(vspDetails, structure, existingManifest)
+ .orElseThrow(() -> new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withMessage(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()).build())));
+ }
+
+ @Override
public Optional<ManifestContent> createManifest(VspDetails vspDetails,
FileContentHandler fileContentHandler,
AnalyzedZipHeatFiles analyzedZipHeatFiles) {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
index 3f061b059c..54cc1fbf1c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImpl.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2016-2017 European Support Limited
+ * Modifications copyright (c) 2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,10 +55,56 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
addModulesToManifestFileDataList(filesDataStructure, fileDataList);
addNestedToManifest(filesDataStructure, fileDataList);
addArtifactsToManifestFileDataList(filesDataStructure, fileDataList);
+
+ ManifestContent manifestContent = createManifest(vspDetails, fileDataList);
+ return Optional.of(manifestContent);
+ }
+
+ @Override
+ public Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, ManifestContent existingManifest) {
+ if (Objects.isNull(filesDataStructure)) {
+ return Optional.empty();
+ }
+
+ List<FileData> fileDataList = new ArrayList<>();
+ addModulesToManifestFileDataList(filesDataStructure, fileDataList);
+ addNestedToManifest(filesDataStructure, fileDataList);
+ addArtifactsToManifestFileDataList(filesDataStructure, fileDataList, existingManifest);
+
ManifestContent manifestContent = createManifest(vspDetails, fileDataList);
return Optional.of(manifestContent);
}
+ private void addArtifactsToManifestFileDataList(FilesDataStructure filesDataStructure, List<FileData> fileDataList, ManifestContent existingManifest) {
+ Collection<String> forArtifacts = CollectionUtils
+ .union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned());
+ if (CollectionUtils.isNotEmpty(forArtifacts)) {
+ for (String artifact : forArtifacts) {
+ if (isCloudSpecificArtifact(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact));
+ } else if (isControllerBlueprintArchive(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact));
+ } else if (isHelm(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact));
+ } else if (isPmDictionary(artifact, existingManifest)) {
+ fileDataList.add(createBaseFileData(FileData.Type.PM_DICTIONARY, artifact));
+ }
+ else {
+ fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
+ }
+ }
+ }
+ }
+
+ private boolean isPmDictionary(String artifact, ManifestContent existingManifest) {
+ return existingManifest.getData()
+ .stream()
+ .filter(fileData -> fileData.getType()
+ .equals(FileData.Type.PM_DICTIONARY))
+ .map(FileData::getFile)
+ .anyMatch(pmDictionaryFile -> pmDictionaryFile.equals(artifact));
+ }
+
private void addNestedToManifest(
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
if (CollectionUtils.isNotEmpty(filesDataStructure.getNested())) {
@@ -172,8 +219,7 @@ public class ManifestCreatorNamingConventionImpl implements ManifestCreator {
fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact));
} else if (isHelm(artifact)) {
fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact));
- }
- else {
+ } else {
fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java
index 1a9bc2aa4c..2cea0f73e3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/ManifestCreatorNamingConventionImplTest.java
@@ -3,13 +3,14 @@
* SDC
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications copyright (c) 2021 Nokia
* ================================================================================
* 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.
@@ -20,15 +21,18 @@
package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import java.util.Optional;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNamingConventionImpl {
@@ -37,13 +41,66 @@ public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNami
private static final String ARTIFACT_3 = "cloudtech_aws_configtemplate.zip";
private static final String ARTIFACT_4 = "k8s_charts.zip";
private static final String ARTIFACT_5 = "cloudtech_openstack_configtemplate.zip";
+ private static final String PMDICT_YAML = "pmdict.yaml";
+
@Test
- public void testIsCloudSpecificArtifact() {
+ void testIsCloudSpecificArtifact() {
assertTrue(isCloudSpecificArtifact(ARTIFACT_1));
assertTrue(isCloudSpecificArtifact(ARTIFACT_2));
assertTrue(isCloudSpecificArtifact(ARTIFACT_3));
assertFalse(isCloudSpecificArtifact(ARTIFACT_4));
assertFalse(isCloudSpecificArtifact(ARTIFACT_5));
}
+
+ @Test
+ void shouldMapPmDictionaryTypeFromExistingManifestToPmDictionaryTypeInNewManifest() {
+ // given
+ VspDetails vspDetails = new VspDetails();
+ FilesDataStructure fileDataStructure = new FilesDataStructure();
+ fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
+ ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.PM_DICTIONARY);
+
+ // when
+ Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
+ .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest);
+
+ // then
+ assertTrue(newManifest.isPresent());
+ assertTrue(newManifest.get()
+ .getData()
+ .stream()
+ .allMatch(fd -> fd.getType().equals(FileData.Type.PM_DICTIONARY) &&
+ fd.getFile().equals(PMDICT_YAML)));
+ }
+
+ @Test
+ void shouldMapPmDictionaryWithOtherTypeFromExistingManifestToOtherTypeInNewManifest() {
+ // given
+ VspDetails vspDetails = new VspDetails();
+ FilesDataStructure fileDataStructure = new FilesDataStructure();
+ fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
+ ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.OTHER);
+
+ // when
+ Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
+ .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest);
+
+ // then
+ assertTrue(newManifest.isPresent());
+ assertTrue(newManifest.get()
+ .getData()
+ .stream()
+ .allMatch(fd -> fd.getType().equals(FileData.Type.OTHER) &&
+ fd.getFile().equals(PMDICT_YAML)));
+ }
+
+ private ManifestContent prepareManifestWithPmDictFileWithType(FileData.Type fileType) {
+ ManifestContent existingManifest = new ManifestContent();
+ FileData fileData = new FileData();
+ fileData.setFile(PMDICT_YAML);
+ fileData.setType(fileType);
+ existingManifest.setData(List.of(fileData));
+ return existingManifest;
+ }
}