From 4b1c2aaab1c3200076138d8702bc324d78a69fa8 Mon Sep 17 00:00:00 2001 From: mojahidi Date: Mon, 11 Dec 2017 15:24:11 +0530 Subject: Adding Error code in HEAT Validators added error code in NestedResourceValidator and ResourceGroupResourceValidator fixed sonar issues Change-Id: I1705b7103a3b3c42338f97cb4a7a255a6c85e88f Issue-ID: SDC-572 Signed-off-by: mojahidi Signed-off-by: vempo --- .../impl/util/HeatValidationService.java | 334 +++++++++++---------- .../heatresource/NestedResourceValidator.java | 81 +++-- .../ResourceGroupResourceValidator.java | 118 +++++--- .../heatresource/NestedResourceValidatorTest.java | 102 +++++-- .../ResourceGroupResourceValidatorTest.java | 120 +++++--- .../missing_nested_file/input/MANIFEST.json | 17 ++ .../input/hot-nimbus-psm_v1.0.env | 10 + .../input/hot-nimbus-psm_v1.0.yaml | 62 ++++ .../wrong_value_type_assigned/input/MANIFEST.json | 51 ++++ .../input/hot-nimbus-pps_v1.0.env | 11 + .../input/hot-nimbus-pps_v1.0.yaml | 58 ++++ .../input/hot-nimbus-psm_v1.0.env | 10 + .../input/hot-nimbus-psm_v1.0.yaml | 199 ++++++++++++ .../input/nested-pps_v1.0.yaml | 101 +++++++ .../input/nested-psm_v1.0.yaml | 99 ++++++ 15 files changed, 1089 insertions(+), 284 deletions(-) create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/MANIFEST.json create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/hot-nimbus-psm_v1.0.env create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/hot-nimbus-psm_v1.0.yaml create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/MANIFEST.json create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-pps_v1.0.env create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-pps_v1.0.yaml create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-psm_v1.0.env create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-psm_v1.0.yaml create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/nested-pps_v1.0.yaml create mode 100644 openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/nested-psm_v1.0.yaml (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib') diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java index d59d0a8def..90750a48ec 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/util/HeatValidationService.java @@ -1,36 +1,29 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2017 European Support Limited + * * 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.util; import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.sdc.heat.datatypes.model.*; import org.openecomp.sdc.tosca.services.YamlUtil; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; import org.openecomp.core.validation.types.GlobalValidationContext; import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.DefinedHeatParameterTypes; -import org.openecomp.sdc.heat.datatypes.model.Environment; -import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate; -import org.openecomp.sdc.heat.datatypes.model.Parameter; -import org.openecomp.sdc.heat.datatypes.model.Resource; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; @@ -42,45 +35,43 @@ import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.validation.impl.validators.HeatValidator; import java.io.InputStream; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; +import java.util.*; public class HeatValidationService { - private static final Logger logger = (Logger) LoggerFactory.getLogger(HeatValidator.class); + private static final Logger LOGGER = LoggerFactory.getLogger(HeatValidator.class); private static final String NESTED_FILE = "nested file"; - private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + private static final String NO_CONTENT_IN_FILE_MSG = "The file ' %s ' has no content"; + private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage(); + private HeatValidationService(){ + } /** * Check artifacts existence. * - * @param fileName the file name + * @param fileName the file name * @param artifactsNames the artifacts names - * @param globalContext the global context + * @param globalContext the global context */ public static void checkArtifactsExistence(String fileName, Set artifactsNames, GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); artifactsNames - .stream() - .filter(artifactName -> !globalContext.getFileContextMap().containsKey(artifactName)) - .forEach(artifactName -> { - globalContext.addMessage(fileName, - ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(globalContext.getMessageCode(),Messages.MISSING_ARTIFACT.getErrorMessage() - ,artifactName), - LoggerTragetServiceName.VALIDATE_ARTIFACTS_EXISTENCE, - LoggerErrorDescription.MISSING_FILE); - }); - - mdcDataDebugMessage.debugExitMessage("file", fileName); + .stream() + .filter(artifactName -> !globalContext.getFileContextMap().containsKey(artifactName)) + .forEach(artifactName -> + globalContext.addMessage(fileName, + ErrorLevel.ERROR, ErrorMessagesFormatBuilder + .getErrorWithParameters( + globalContext.getMessageCode(), + Messages.MISSING_ARTIFACT.getErrorMessage(), artifactName), + LoggerTragetServiceName.VALIDATE_ARTIFACTS_EXISTENCE, + LoggerErrorDescription.MISSING_FILE)); + + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } /** @@ -109,74 +100,98 @@ public class HeatValidationService { return stringBuilder.toString(); } - /** * Check nested parameters. * - * @param parentFileName the calling nested file name - * @param nestedFileName the nested file name - * @param resourceName the resource name - * @param globalContext the global context - * @param resourceFileProperties the resource file properties + * @param parentFileName the calling nested file name + * @param nestedFileName the nested file name + * @param globalContext the global context + * @param parentParameters parent parameters. + * @param nestedParameters nested parameters. + * @param nestedParametersNames nested parameter names. */ public static void checkNestedParameters(String parentFileName, String nestedFileName, - String resourceName, Resource resource, - Set resourceFileProperties, - Optional indexVarValue, - GlobalValidationContext globalContext) { - + GlobalValidationContext globalContext, + Map parentParameters, + Map nestedParameters, + Set nestedParametersNames) { - mdcDataDebugMessage.debugEntryMessage("file", parentFileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", parentFileName); HeatOrchestrationTemplate parentHeatOrchestrationTemplate; HeatOrchestrationTemplate nestedHeatOrchestrationTemplate; + try { - Optional fileContent = globalContext.getFileContent(nestedFileName); - if (fileContent.isPresent()) { - nestedHeatOrchestrationTemplate = - new YamlUtil().yamlToObject(fileContent.get(), HeatOrchestrationTemplate.class); - } else { - MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, - LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, - ErrorLevel.ERROR.name(), LoggerErrorCode.DATA_ERROR.getErrorCode(), - LoggerErrorDescription.EMPTY_FILE); - throw new Exception("The file '" + nestedFileName + "' has no content"); - } + nestedHeatOrchestrationTemplate = getHeatOrchestrationTemplate(nestedFileName, globalContext); + parentHeatOrchestrationTemplate = getHeatOrchestrationTemplate(parentFileName, globalContext); } catch (Exception exception) { - logger.debug("",exception); - mdcDataDebugMessage.debugExitMessage("file", parentFileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", parentFileName); return; } - try { - Optional fileContent = globalContext.getFileContent(parentFileName); - if (fileContent.isPresent()) { - parentHeatOrchestrationTemplate = - new YamlUtil().yamlToObject(fileContent.get(), HeatOrchestrationTemplate.class); - } else { - MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, - LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, - ErrorLevel.ERROR.name(), LoggerErrorCode.DATA_ERROR.getErrorCode(), - LoggerErrorDescription.EMPTY_FILE); - throw new Exception("The file '" + parentFileName + "' has no content"); - } - } catch (Exception exception) { - logger.debug("",exception); - mdcDataDebugMessage.debugExitMessage("file", parentFileName); - return; + parentParameters.putAll(parentHeatOrchestrationTemplate.getParameters()); + nestedParameters.putAll(nestedHeatOrchestrationTemplate.getParameters()); + if (!nestedParameters.isEmpty()) { + nestedParametersNames.addAll(nestedHeatOrchestrationTemplate.getParameters().keySet()); + } + + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", parentFileName); + } + + private static HeatOrchestrationTemplate getHeatOrchestrationTemplate(String fileName, + GlobalValidationContext globalContext) + throws Exception { + + Optional fileContent = globalContext.getFileContent(fileName); + if (fileContent.isPresent()) { + return new YamlUtil().yamlToObject(fileContent.get(), HeatOrchestrationTemplate.class); + } else { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, + ErrorLevel.ERROR.name(), LoggerErrorCode.DATA_ERROR.getErrorCode(), + LoggerErrorDescription.EMPTY_FILE); + Exception exception = new Exception(String.format(NO_CONTENT_IN_FILE_MSG, fileName)); + LOGGER.error("Error while reading file : " + fileName , exception); + throw exception; } - Map parentParameters = parentHeatOrchestrationTemplate.getParameters(); - Map nestedParameters = nestedHeatOrchestrationTemplate.getParameters(); - Set nestedParametersNames = - nestedParameters == null ? null : nestedHeatOrchestrationTemplate.getParameters().keySet(); + } + + public static void checkNestedParametersNoMissingParameterInNested(String parentFileName, + String nestedFileName, + String resourceName, + Set resourceFileProperties, + GlobalValidationContext globalContext) { + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", parentFileName); + + Map parentParameters = new HashMap<>(); + Map nestedParameters = new HashMap<>(); + Set nestedParametersNames = new HashSet<>(); + checkNestedParameters(parentFileName, nestedFileName, globalContext, parentParameters, + nestedParameters, nestedParametersNames); checkNoMissingParameterInNested(parentFileName, nestedFileName, resourceName, - resourceFileProperties, nestedParametersNames, globalContext); - checkNestedInputValuesAlignWithType(parentFileName, nestedFileName, parentParameters, - nestedParameters, resourceName, resource, indexVarValue, globalContext); + resourceFileProperties, nestedParametersNames, globalContext); - mdcDataDebugMessage.debugExitMessage("file", parentFileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", parentFileName); + } + + public static void checkNestedInputValuesAlignWithType(String parentFileName, + String nestedFileName, + String resourceName, Resource resource, + Optional indexVarValue, + GlobalValidationContext globalContext) { + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", parentFileName); + + Map parentParameters = new HashMap<>(); + Map nestedParameters = new HashMap<>(); + Set nestedParametersNames = new HashSet<>(); + checkNestedParameters(parentFileName, nestedFileName, globalContext, parentParameters, + nestedParameters, nestedParametersNames); + checkNestedInputValuesAlignWithType(parentFileName, nestedFileName, + nestedParameters, resourceName, resource, indexVarValue, globalContext); + + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", parentFileName); } private static void checkNoMissingParameterInNested(String parentFileName, String nestedFileName, @@ -185,54 +200,49 @@ public class HeatValidationService { Set nestedParametersNames, GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage(NESTED_FILE, nestedFileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("nested file", nestedFileName); if (CollectionUtils.isNotEmpty(nestedParametersNames)) { resourceFileProperties - .stream() - .filter(propertyName -> !nestedParametersNames.contains(propertyName)) - .forEach(propertyName -> globalContext - .addMessage(parentFileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages - .MISSING_PARAMETER_IN_NESTED.getErrorMessage(), - nestedFileName, resourceName, propertyName), - LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, - LoggerErrorDescription.MISSING_PARAMETER_IN_NESTED)); + .stream() + .filter(propertyName -> !nestedParametersNames.contains(propertyName)) + .forEach(propertyName -> globalContext + .addMessage(parentFileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder + .getErrorWithParameters( + globalContext.getMessageCode(), + Messages.MISSING_PARAMETER_IN_NESTED.getErrorMessage(), + nestedFileName, resourceName, propertyName), + LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, + LoggerErrorDescription.MISSING_PARAMETER_IN_NESTED)); } - mdcDataDebugMessage.debugExitMessage(NESTED_FILE, nestedFileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage(NESTED_FILE, nestedFileName); } - private static void checkNestedInputValuesAlignWithType(String parentFileName, String nestedFileName, - Map parentParameters, Map nestedParameters, String resourceName, Resource resource, Optional indexVarValue, GlobalValidationContext globalContext) { - - mdcDataDebugMessage.debugEntryMessage(NESTED_FILE, nestedFileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(NESTED_FILE, nestedFileName); Map properties = resource.getProperties(); for (Map.Entry propertyEntry : properties.entrySet()) { String parameterName = propertyEntry.getKey(); Object parameterInputValue = propertyEntry.getValue(); - - if (Objects.nonNull(parameterInputValue)) { - if (parameterInputValue instanceof String) { - if (indexVarValue.isPresent() && indexVarValue.get().equals(parameterInputValue)) { - parameterInputValue = 3; //indexVarValue is actually number value in runtime - } - validateStaticValueForNestedInputParameter(parentFileName, nestedFileName, resourceName, - parameterName, parameterInputValue, nestedParameters.get(parameterName), - globalContext); + if (parameterInputValue instanceof String) { + if (indexVarValue.isPresent() && indexVarValue.get().equals(parameterInputValue)) { + parameterInputValue = 3; //indexVarValue is actually number value in runtime } + validateStaticValueForNestedInputParameter(parentFileName, nestedFileName, resourceName, + parameterName, parameterInputValue, nestedParameters.get(parameterName), + globalContext); } } - mdcDataDebugMessage.debugExitMessage(NESTED_FILE, nestedFileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage(NESTED_FILE, nestedFileName); } private static void validateStaticValueForNestedInputParameter(String parentFileName, @@ -242,25 +252,24 @@ public class HeatValidationService { Object staticValue, Parameter parameterInNested, GlobalValidationContext - globalContext) { - + globalContext) { - mdcDataDebugMessage.debugEntryMessage(NESTED_FILE, nestedFileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(NESTED_FILE, nestedFileName); if (parameterInNested == null) { return; } if (!DefinedHeatParameterTypes - .isValueIsFromGivenType(staticValue, parameterInNested.getType())) { + .isValueIsFromGivenType(staticValue, parameterInNested.getType())) { globalContext.addMessage(parentFileName, ErrorLevel.WARNING, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages - .WRONG_VALUE_TYPE_ASSIGNED_NESTED_INPUT.getErrorMessage(), - resourceName, parameterName, nestedFileName), - LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, - LoggerErrorDescription.WRONG_VALUE_ASSIGNED_NESTED_PARAMETER); + .getErrorWithParameters(globalContext.getMessageCode(), + Messages.WRONG_VALUE_TYPE_ASSIGNED_NESTED_INPUT.getErrorMessage(), + resourceName, parameterName, nestedFileName), + LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, + LoggerErrorDescription.WRONG_VALUE_ASSIGNED_NESTED_PARAMETER); } - mdcDataDebugMessage.debugExitMessage(NESTED_FILE, nestedFileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage(NESTED_FILE, nestedFileName); } @@ -268,58 +277,72 @@ public class HeatValidationService { * Is nested loop exist in file boolean. * * @param callingFileName the calling file name - * @param nestedFileName the nested file name - * @param filesInLoop the files in loop - * @param globalContext the global context + * @param nestedFileName the nested file name + * @param filesInLoop the files in loop + * @param globalContext the global context * @return the boolean */ public static boolean isNestedLoopExistInFile(String callingFileName, String nestedFileName, List filesInLoop, GlobalValidationContext globalContext) { - - mdcDataDebugMessage.debugEntryMessage("file", callingFileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", callingFileName); HeatOrchestrationTemplate nestedHeatOrchestrationTemplate; try { - Optional fileContent = globalContext.getFileContent(nestedFileName); - if (fileContent.isPresent()) { - nestedHeatOrchestrationTemplate = - new YamlUtil().yamlToObject(fileContent.get(), HeatOrchestrationTemplate.class); - } else { - MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, - LoggerTragetServiceName.VALIDATE_NESTING_LOOPS, ErrorLevel.ERROR.name(), - LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.EMPTY_FILE); - throw new Exception("The file '" + nestedFileName + "' has no content"); - } - + nestedHeatOrchestrationTemplate = getNestedHeatOrchestrationTemplate(nestedFileName, + globalContext); } catch (Exception exception) { - logger.debug("",exception); - logger.warn("HEAT Validator will not be executed on file " + nestedFileName - + " due to illegal HEAT format"); + LOGGER.error("Error while reading file : " + nestedFileName, exception); + LOGGER.warn("HEAT Validator will not be executed on file " + nestedFileName + + " due to illegal HEAT format"); - mdcDataDebugMessage.debugExitMessage("file", callingFileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", callingFileName); return false; } filesInLoop.add(nestedFileName); Collection nestedResources = - nestedHeatOrchestrationTemplate.getResources() == null ? null - : nestedHeatOrchestrationTemplate.getResources().values(); + nestedHeatOrchestrationTemplate.getResources() == null ? null + : nestedHeatOrchestrationTemplate.getResources().values(); + boolean isNestedLoopExist = addNestedFilesInLoopAndCheckIfNestedLoopExist(nestedResources, + callingFileName, filesInLoop, globalContext); + + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", callingFileName); + return isNestedLoopExist; + } + private static boolean addNestedFilesInLoopAndCheckIfNestedLoopExist( + Collection nestedResources,String callingFileName, + List filesInLoop, + GlobalValidationContext globalContext){ if (CollectionUtils.isNotEmpty(nestedResources)) { for (Resource resource : nestedResources) { String resourceType = resource.getType(); if (Objects.nonNull(resourceType) && isNestedResource(resourceType)) { - mdcDataDebugMessage.debugExitMessage("file", callingFileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", callingFileName); return resourceType.equals(callingFileName) || !filesInLoop.contains(resourceType) - && isNestedLoopExistInFile(callingFileName, resourceType, filesInLoop, globalContext); + && isNestedLoopExistInFile(callingFileName, resourceType, filesInLoop, globalContext); } } } - - mdcDataDebugMessage.debugExitMessage("file", callingFileName); return false; } + private static HeatOrchestrationTemplate getNestedHeatOrchestrationTemplate( String nestedFileName, + GlobalValidationContext globalContext) throws Exception { + Optional fileContent = globalContext.getFileContent(nestedFileName); + HeatOrchestrationTemplate nestedHeatOrchestrationTemplate; + if (fileContent.isPresent()) { + nestedHeatOrchestrationTemplate = + new YamlUtil().yamlToObject(fileContent.get(), HeatOrchestrationTemplate.class); + } else { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.VALIDATE_NESTING_LOOPS, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.EMPTY_FILE); + throw new Exception(String.format(NO_CONTENT_IN_FILE_MSG, nestedFileName)); + } + + return nestedHeatOrchestrationTemplate; + } public static boolean isNestedResource(String resourceType) { return resourceType.contains(".yaml") || resourceType.contains(".yml"); @@ -328,31 +351,30 @@ public class HeatValidationService { /** * Validate env content environment. * - * @param fileName the file name - * @param envFileName the env file name + * @param fileName the file name + * @param envFileName the env file name * @param globalContext the global context * @return the environment */ public static Environment validateEnvContent(String fileName, String envFileName, GlobalValidationContext globalContext) { + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("env file", envFileName); - mdcDataDebugMessage.debugEntryMessage("env file", envFileName); - - Environment envContent = null; + Environment envContent; try { Optional fileContent = globalContext.getFileContent(envFileName); if (fileContent.isPresent()) { envContent = new YamlUtil().yamlToObject(fileContent.get(), Environment.class); } else { MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, - LoggerTragetServiceName.VALIDATE_ENV_FILE, ErrorLevel.ERROR.name(), - LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.EMPTY_FILE); - throw new Exception("The file '" + envFileName + "' has no content"); + LoggerTragetServiceName.VALIDATE_ENV_FILE, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.EMPTY_FILE); + throw new Exception(String.format(NO_CONTENT_IN_FILE_MSG, envFileName)); } } catch (Exception exception) { - logger.debug("",exception); - mdcDataDebugMessage.debugExitMessage("env file", envFileName); + LOGGER.error("Error while reading env file : " + envFileName, exception); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("env file", envFileName); return null; } return envContent; diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidator.java index aa7b91826c..41897f4563 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidator.java @@ -1,6 +1,23 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * 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. + */ + package org.openecomp.sdc.validation.impl.validators.heatresource; import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.core.validation.ErrorMessageCode; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; import org.openecomp.core.validation.types.GlobalValidationContext; import org.openecomp.sdc.common.errors.Messages; @@ -24,71 +41,83 @@ import java.util.Set; * Created by TALIO on 2/22/2017. */ public class NestedResourceValidator implements ResourceValidator { - private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage(); + private static final ErrorMessageCode ERROR_CODE_HNR1 = new ErrorMessageCode("HNR1"); + private static final ErrorMessageCode ERROR_CODE_HNR2 = new ErrorMessageCode("HNR2"); + private static final ErrorMessageCode ERROR_CODE_HNR3 = new ErrorMessageCode("HNR3"); + private static final ErrorMessageCode ERROR_CODE_HNR4 = new ErrorMessageCode("HNR4"); @Override public void validate(String fileName, Map.Entry resourceEntry, - GlobalValidationContext globalContext, ValidationContext validationContext){ + GlobalValidationContext globalContext, ValidationContext validationContext) { handleNestedResourceType(fileName, resourceEntry.getKey(), resourceEntry.getValue(), - Optional.empty(), globalContext); + Optional.empty(), globalContext); } private static void handleNestedResourceType(String fileName, String resourceName, Resource resource, Optional indexVarValue, GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); validateAllPropertiesMatchNestedParameters(fileName, resourceName, resource, indexVarValue, - globalContext); + globalContext); validateLoopsOfNestingFromFile(fileName, resource.getType(), globalContext); - mdcDataDebugMessage.debugExitMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } public static void validateAllPropertiesMatchNestedParameters(String fileName, - String resourceName, - Resource resource, - Optional indexVarValue, - GlobalValidationContext - globalContext) { + String resourceName, + Resource resource, + Optional indexVarValue, + GlobalValidationContext + globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); String resourceType = resource.getType(); if (globalContext.getFileContextMap().containsKey(resourceType)) { Set propertiesNames = - resource.getProperties() == null ? null : resource.getProperties().keySet(); + resource.getProperties() == null ? null : resource.getProperties().keySet(); if (CollectionUtils.isNotEmpty(propertiesNames)) { + globalContext.setMessageCode(ERROR_CODE_HNR3); + HeatValidationService + .checkNestedParametersNoMissingParameterInNested(fileName, resourceType, resourceName, + propertiesNames, + globalContext); + globalContext.setMessageCode(ERROR_CODE_HNR4); HeatValidationService - .checkNestedParameters(fileName, resourceType, resourceName, resource, propertiesNames, - indexVarValue, globalContext); + .checkNestedInputValuesAlignWithType(fileName, resourceType, resourceName, resource, + indexVarValue, globalContext); } } else { globalContext.addMessage(resourceType, ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.MISSING_NESTED_FILE.getErrorMessage(), resourceType), - LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, - LoggerErrorDescription.MISSING_FILE); + .getErrorWithParameters(ERROR_CODE_HNR1, + Messages.MISSING_NESTED_FILE.getErrorMessage(), + resourceType), + LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, + LoggerErrorDescription.MISSING_FILE); } - mdcDataDebugMessage.debugExitMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } public static void validateLoopsOfNestingFromFile(String fileName, String resourceType, - GlobalValidationContext globalContext) { + GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); List filesInLoop = new ArrayList<>(Collections.singletonList(fileName)); if (HeatValidationService - .isNestedLoopExistInFile(fileName, resourceType, filesInLoop, globalContext)) { + .isNestedLoopExistInFile(fileName, resourceType, filesInLoop, globalContext)) { globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.NESTED_LOOP.getErrorMessage(), - HeatValidationService.drawFilesLoop(filesInLoop)), - LoggerTragetServiceName.VALIDATE_NESTING_LOOPS, LoggerErrorDescription.NESTED_LOOP); + .getErrorWithParameters(ERROR_CODE_HNR2, Messages.NESTED_LOOP.getErrorMessage(), + HeatValidationService.drawFilesLoop(filesInLoop)), + LoggerTragetServiceName.VALIDATE_NESTING_LOOPS, LoggerErrorDescription.NESTED_LOOP); } - mdcDataDebugMessage.debugExitMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidator.java index c94875c9f2..06794923cf 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidator.java @@ -1,6 +1,23 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * 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. + */ + package org.openecomp.sdc.validation.impl.validators.heatresource; import org.apache.commons.collections4.CollectionUtils; +import org.openecomp.core.validation.ErrorMessageCode; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; import org.openecomp.core.validation.types.GlobalValidationContext; import org.openecomp.sdc.common.errors.Messages; @@ -27,7 +44,16 @@ import java.util.Set; * Created by TALIO on 2/22/2017. */ public class ResourceGroupResourceValidator implements ResourceValidator { - private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage(); + + private static final ErrorMessageCode ERROR_CODE_HRR1 = new ErrorMessageCode("HRR1"); + private static final ErrorMessageCode ERROR_CODE_HRR2 = new ErrorMessageCode("HRR2"); + private static final ErrorMessageCode ERROR_CODE_HRR3 = new ErrorMessageCode("HRR3"); + private static final ErrorMessageCode ERROR_CODE_HRR4 = new ErrorMessageCode("HRR4"); + private static final ErrorMessageCode ERROR_CODE_HRR5 = new ErrorMessageCode("HRR5"); + private static final ErrorMessageCode ERROR_CODE_HRR6 = new ErrorMessageCode("HRR6"); + private static final ErrorMessageCode ERROR_CODE_HRR7 = new ErrorMessageCode("HRR7"); + private static final ErrorMessageCode ERROR_CODE_HRR8 = new ErrorMessageCode("HRR8"); @Override public void validate(String fileName, Map.Entry resourceEntry, @@ -39,28 +65,39 @@ public class ResourceGroupResourceValidator implements ResourceValidator { Map.Entry resourceEntry, GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); - + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); + + globalContext.setMessageCode(ERROR_CODE_HRR6); + HeatTreeManagerUtil + .checkResourceTypeValid(fileName, resourceEntry.getKey(), resourceEntry.getValue(), + globalContext); + globalContext.setMessageCode(ERROR_CODE_HRR7); + HeatTreeManagerUtil + .checkResourceGroupTypeValid(fileName, resourceEntry.getKey(), resourceEntry.getValue(), + globalContext); + globalContext.setMessageCode(ERROR_CODE_HRR8); + HeatTreeManagerUtil.checkIfResourceGroupTypeIsNested(fileName, resourceEntry.getKey(), + resourceEntry.getValue(), globalContext); Resource resourceDef = HeatTreeManagerUtil - .getResourceDef(fileName, resourceEntry.getKey(), resourceEntry.getValue(), globalContext); - if (resourceDef != null) { - if (Objects.nonNull(resourceDef.getType()) - && HeatValidationService.isNestedResource(resourceDef.getType())) { + .getResourceDef( resourceEntry.getValue()); + + if (resourceDef != null && Objects.nonNull(resourceDef.getType()) + && HeatValidationService.isNestedResource(resourceDef.getType())) { Optional indexVarValue = - getResourceGroupIndexVarValue(resourceEntry, fileName, globalContext); + getResourceGroupIndexVarValue(resourceEntry, fileName, globalContext); handleNestedResourceType(fileName, resourceEntry.getKey(), resourceDef, indexVarValue, - globalContext); - } + globalContext); + } - mdcDataDebugMessage.debugExitMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } private static Optional getResourceGroupIndexVarValue( - Map.Entry resourceEntry, String fileName, - GlobalValidationContext globalContext) { + Map.Entry resourceEntry, String fileName, + GlobalValidationContext globalContext) { Object indexVar = - resourceEntry.getValue().getProperties().get(HeatConstants.INDEX_PROPERTY_NAME); + resourceEntry.getValue().getProperties().get(HeatConstants.INDEX_PROPERTY_NAME); if (indexVar == null) { return Optional.of(HeatConstants.RESOURCE_GROUP_INDEX_VAR_DEFAULT_VALUE); } @@ -69,9 +106,11 @@ public class ResourceGroupResourceValidator implements ResourceValidator { return Optional.of((String) indexVar); } else { globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.RESOURCE_GROUP_INVALID_INDEX_VAR.getErrorMessage(), - resourceEntry.getKey()), LoggerTragetServiceName.VALIDATE_RESOURCE_GROUP_TYPE, - LoggerErrorDescription.INVALID_INDEX_VAR); + .getErrorWithParameters( + ERROR_CODE_HRR1, Messages.RESOURCE_GROUP_INVALID_INDEX_VAR.getErrorMessage(), + resourceEntry.getKey()), + LoggerTragetServiceName.VALIDATE_RESOURCE_GROUP_TYPE, + LoggerErrorDescription.INVALID_INDEX_VAR); return Optional.empty(); } } @@ -80,13 +119,13 @@ public class ResourceGroupResourceValidator implements ResourceValidator { Resource resource, Optional indexVarValue, GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); validateAllPropertiesMatchNestedParameters(fileName, resourceName, resource, indexVarValue, - globalContext); + globalContext); validateLoopsOfNestingFromFile(fileName, resource.getType(), globalContext); - mdcDataDebugMessage.debugExitMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } private static void validateAllPropertiesMatchNestedParameters(String fileName, @@ -94,43 +133,52 @@ public class ResourceGroupResourceValidator implements ResourceValidator { Resource resource, Optional indexVarValue, GlobalValidationContext - globalContext) { + globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); String resourceType = resource.getType(); if (globalContext.getFileContextMap().containsKey(resourceType)) { Set propertiesNames = - resource.getProperties() == null ? null : resource.getProperties().keySet(); + resource.getProperties() == null ? null : resource.getProperties().keySet(); if (CollectionUtils.isNotEmpty(propertiesNames)) { + globalContext.setMessageCode(ERROR_CODE_HRR4); + HeatValidationService + .checkNestedParametersNoMissingParameterInNested(fileName, resourceType, resourceName, + propertiesNames, + globalContext); + globalContext.setMessageCode(ERROR_CODE_HRR5); HeatValidationService - .checkNestedParameters(fileName, resourceType, resourceName, resource, propertiesNames, - indexVarValue, globalContext); + .checkNestedInputValuesAlignWithType(fileName, resourceType, resourceName, resource, + indexVarValue, globalContext); } } else { globalContext.addMessage(resourceType, ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.MISSING_NESTED_FILE.getErrorMessage(), resourceType), - LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, - LoggerErrorDescription.MISSING_FILE); + .getErrorWithParameters( + ERROR_CODE_HRR2, Messages.MISSING_NESTED_FILE.getErrorMessage(), + resourceType), + LoggerTragetServiceName.VALIDATE_PROPERTIES_MATCH_NESTED_PARAMETERS, + LoggerErrorDescription.MISSING_FILE); } - mdcDataDebugMessage.debugExitMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } private static void validateLoopsOfNestingFromFile(String fileName, String resourceType, GlobalValidationContext globalContext) { - mdcDataDebugMessage.debugEntryMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("file", fileName); List filesInLoop = new ArrayList<>(Collections.singletonList(fileName)); if (HeatValidationService - .isNestedLoopExistInFile(fileName, resourceType, filesInLoop, globalContext)) { + .isNestedLoopExistInFile(fileName, resourceType, filesInLoop, globalContext)) { globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.NESTED_LOOP.getErrorMessage(), - HeatValidationService.drawFilesLoop(filesInLoop)), - LoggerTragetServiceName.VALIDATE_NESTING_LOOPS, LoggerErrorDescription.NESTED_LOOP); + .getErrorWithParameters( + ERROR_CODE_HRR3, Messages.NESTED_LOOP.getErrorMessage(), + HeatValidationService.drawFilesLoop(filesInLoop)), + LoggerTragetServiceName.VALIDATE_NESTING_LOOPS, LoggerErrorDescription.NESTED_LOOP); } - mdcDataDebugMessage.debugExitMessage("file", fileName); + MDC_DATA_DEBUG_MESSAGE.debugExitMessage("file", fileName); } } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java index 96aa631a69..14a23d66d9 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NestedResourceValidatorTest.java @@ -1,70 +1,124 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * 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. + */ + package org.openecomp.sdc.validation.impl.validators.heatresource; +import org.openecomp.core.validation.types.GlobalValidationContext; import org.openecomp.core.validation.types.MessageContainer; +import org.openecomp.sdc.heat.datatypes.model.Resource; import org.openecomp.sdc.validation.impl.validators.HeatResourceValidator; import org.openecomp.sdc.validation.util.ValidationTestUtil; import org.testng.Assert; import org.testng.annotations.Test; -import java.io.IOException; import java.util.Map; +import java.util.Optional; /** * Created by TALIO on 2/28/2017. */ public class NestedResourceValidatorTest { - HeatResourceValidator baseValidator = new HeatResourceValidator(); - NestedResourceValidator resourceValidator = new NestedResourceValidator(); + private final HeatResourceValidator baseValidator = new HeatResourceValidator(); + private final NestedResourceValidator resourceValidator = new NestedResourceValidator(); + private static final String PATH = "/org/openecomp/validation/validators/heat_validator/"; @Test - public void testNoLoopsNesting() throws IOException { + public void testNoLoopsNesting() { + Map messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, null, - "/org/openecomp/validation/validators/heat_validator/no_loops_nesting/negative_test/input"); + resourceValidator, null, + PATH + "no_loops_nesting/negative_test/input"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 4); Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: Nested files loop - [hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: [HNR2]: Nested files loop - [hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml]"); Assert.assertEquals( - messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().size(), 2); + messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().size(), 2); Assert.assertEquals( - messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(0) - .getMessage(), - "ERROR: Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]"); + messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(0) + .getMessage(), + "ERROR: [HNR2]: Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]"); Assert.assertEquals( - messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(1) - .getMessage(), - "ERROR: Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]"); + messages.get("nested-points-to-hot-nimbus-psm.yaml").getErrorMessageList().get(1) + .getMessage(), + "ERROR: [HNR2]: Nested files loop - [nested-points-to-hot-nimbus-psm.yaml -- nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml]"); Assert.assertEquals(messages.get("yaml-point-to-itself.yaml").getErrorMessageList().size(), 1); Assert.assertEquals( - messages.get("yaml-point-to-itself.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: Nested files loop - [yaml-point-to-itself.yaml -- yaml-point-to-itself.yaml]"); + messages.get("yaml-point-to-itself.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: [HNR2]: Nested files loop - [yaml-point-to-itself.yaml -- yaml-point-to-itself.yaml]"); Assert.assertEquals(messages.get("nested-psm_v1.0.yaml").getErrorMessageList().size(), 1); Assert.assertEquals( - messages.get("nested-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: Nested files loop - [nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml]"); + messages.get("nested-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: [HNR2]: Nested files loop - [nested-psm_v1.0.yaml -- nested-points-to-hot-nimbus-psm.yaml -- hot-nimbus-psm_v1.0.yaml -- nested-psm_v1.0.yaml]"); } @Test - public void testPropertiesMatchNestedParameters() throws IOException { + public void testPropertiesMatchNestedParameters() { Map messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, null, - "/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/negative_test/input"); + resourceValidator, null, + PATH + "properties_match_nested_parameters/negative_test/input"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1); Assert.assertEquals( - messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: Referenced parameter not found in nested file - nested-pps_v1.0.yaml, parameter name [server_pcrf_pps_001], Resource ID [parameter_not_existing_in_nested]"); + messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: [HNR3]: Referenced parameter not found in nested file - nested-pps_v1.0.yaml, parameter name [server_pcrf_pps_001], Resource ID [parameter_not_existing_in_nested]"); + } + + @Test + public void testWrongValueTypeAssigned() { + Map messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, null, + PATH + "properties_match_nested_parameters/wrong_value_type_assigned/input"); + + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "WARNING: [HNR4]: Wrong value type assigned to a nested input parameter, nested resource [server_pcrf_pps_001], property name [index_integer], nested file [nested-pps_v1.0.yaml]"); + } + + @Test + public void testMissingNestedFile() { + final Resource resource = new Resource(); + resource.setType("nested-pps_v1.0.yaml"); + + final GlobalValidationContext globalValidationContext = ValidationTestUtil.createGlobalContextFromPath(PATH + "missing_nested_file/input"); + + NestedResourceValidator.validateAllPropertiesMatchNestedParameters(null, null, resource, Optional.empty(), globalValidationContext); + + Map messages = globalValidationContext.getContextMessageContainers(); + Assert.assertNotNull(messages); + Assert.assertEquals(messages.size(), 1); + + Assert.assertEquals(messages.get("nested-pps_v1.0.yaml").getErrorMessageList().size(), 1); + Assert.assertEquals( + messages.get("nested-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: [HNR1]: Missing nested file - nested-pps_v1.0.yaml"); } } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java index 4b255ae967..4948c53cde 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/ResourceGroupResourceValidatorTest.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * 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. + */ + package org.openecomp.sdc.validation.impl.validators.heatresource; import org.openecomp.core.validation.types.MessageContainer; @@ -7,7 +23,6 @@ import org.openecomp.sdc.validation.util.ValidationTestUtil; import org.testng.Assert; import org.testng.annotations.Test; -import java.io.IOException; import java.util.Map; /** @@ -15,92 +30,111 @@ import java.util.Map; */ public class ResourceGroupResourceValidatorTest { - HeatResourceValidator baseValidator = new HeatResourceValidator(); - ResourceGroupResourceValidator resourceValidator = new ResourceGroupResourceValidator(); + private final HeatResourceValidator baseValidator = new HeatResourceValidator(); + private final ResourceGroupResourceValidator resourceValidator = new ResourceGroupResourceValidator(); + private static final String PATH = "/org/openecomp/validation/validators/heat_validator/"; @Test public void testResourceGroupWithInvalidIndexVar() { Map messages = ValidationTestUtil.testValidator(baseValidator, - resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(), - "/org/openecomp/validation/validators/heat_validator/resource_group_invalid_indexvar/negative_test/input"); + resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(), + PATH + "resource_group_invalid_indexvar/negative_test/input"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); - Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 8); + Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 14); + Assert.assertEquals( + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_1], resource_def type [yamlFile.yaml]"); + Assert.assertEquals( + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), + "ERROR: [HRR1]: Wrong value assigned to a ResourceGroup index_var property (functions are not allowed but only strings), Resource ID [resource_with_resources_group_1]"); + Assert.assertEquals( + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(), + "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_2], resource_def type [yamlFile.yaml]"); + Assert.assertEquals( + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(3).getMessage(), + "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_2], property name [index_boolean], nested file [yamlFile.yaml]"); + Assert.assertEquals( + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(4).getMessage(), + "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_3], resource_def type [yamlFile.yaml]"); + Assert.assertEquals( + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(5).getMessage(), + "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_3], property name [index_boolean], nested file [yamlFile.yaml]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: Wrong value assigned to a ResourceGroup index_var property (functions are not allowed but only strings), Resource ID [resource_with_resources_group_1]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(6).getMessage(), + "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_3], property name [index_number], nested file [yamlFile.yaml]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), - "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_2], property name [index_boolean], nested file [yamlFile.yaml]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(7).getMessage(), + "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_4], resource_def type [yamlFile.yaml]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(), - "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_3], property name [index_boolean], nested file [yamlFile.yaml]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(8).getMessage(), + "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_4], property name [index_boolean], nested file [yamlFile.yaml]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(3).getMessage(), - "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_3], property name [index_number], nested file [yamlFile.yaml]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(9).getMessage(), + "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_5], resource_def type [yamlFile.yaml]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(4).getMessage(), - "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_4], property name [index_boolean], nested file [yamlFile.yaml]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(10).getMessage(), + "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_5], property name [index_boolean], nested file [yamlFile.yaml]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(5).getMessage(), - "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_5], property name [index_boolean], nested file [yamlFile.yaml]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(11).getMessage(), + "WARNING: [HRR5]: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_5], property name [index_number], nested file [yamlFile.yaml]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(6).getMessage(), - "WARNING: Wrong value type assigned to a nested input parameter, nested resource [resource_with_resources_group_5], property name [index_number], nested file [yamlFile.yaml]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(12).getMessage(), + "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_6], resource_def type [yamlFile.yaml]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(7).getMessage(), - "ERROR: Wrong value assigned to a ResourceGroup index_var property (functions are not allowed but only strings), Resource ID [resource_with_resources_group_6]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(13).getMessage(), + "ERROR: [HRR1]: Wrong value assigned to a ResourceGroup index_var property (functions are not allowed but only strings), Resource ID [resource_with_resources_group_6]"); } @Test public void testResourceGroupWithInvalidType() { Map messages =ValidationTestUtil.testValidator(baseValidator, - resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(), - "/org/openecomp/validation/validators/heat_validator/resource_group_invalid_type/negative_test/input"); + resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(), + PATH + "resource_group_invalid_type/negative_test/input"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 1); Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 3); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), - "WARNING: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_1], resource_def type [{get_param=pcrf_vnf_id}]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "WARNING: [HRR7]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_1], resource_def type [{get_param=pcrf_vnf_id}]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), - "WARNING: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_2], resource_def type [OS::Nova::Server]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), + "WARNING: [HRR6]: A resource has an invalid or unsupported type - null, Resource ID [resource_with_resources_group_3]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(), - "WARNING: A resource has an invalid or unsupported type - null, Resource ID [resource_with_resources_group_3]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(2).getMessage(), + "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group_4], resource_def type [yamlFile.yaml]"); } @Test - public void testResourcesGroupWithNested() throws IOException { + public void testResourcesGroupWithNested() { Map messages =ValidationTestUtil.testValidator(baseValidator, - resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(), - "/org/openecomp/validation/validators/heat_validator/resources_group_with_nested/negative_test/input"); + resourceValidator, HeatResourcesTypes.RESOURCE_GROUP_RESOURCE_TYPE.getHeatResource(), + PATH + "resources_group_with_nested/negative_test/input"); Assert.assertNotNull(messages); - Assert.assertEquals(messages.size(), 3); + Assert.assertEquals(messages.size(), 4); Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 2); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: Referenced parameter not found in nested file - nested-from-resources-group.yaml, parameter name [resource_with_resources_group], Resource ID [property_not_in_nested]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(), + "WARNING: [HRR8]: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_with_resources_group], resource_def type [nested-from-resources-group.yaml]"); Assert.assertEquals( - messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), - "WARNING: OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, Resource ID [resource_without_resources_group], resource_def type [OS::Nova::Server]"); + messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(1).getMessage(), + "ERROR: [HRR4]: Referenced parameter not found in nested file - nested-from-resources-group.yaml, parameter name [resource_with_resources_group], Resource ID [property_not_in_nested]"); - Assert.assertEquals(messages.get("nested-pps_v1.0.yaml").getErrorMessageList().size(), 1); + Assert.assertEquals(messages.get("nested-pps_v1.0.yaml").getErrorMessageList().size(), 2); Assert.assertEquals( - messages.get("nested-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: Nested files loop - [nested-pps_v1.0.yaml -- nested-from-resources-group.yaml -- hot-nimbus-pps_v1.0.yaml -- nested-pps_v1.0.yaml]"); + messages.get("nested-pps_v1.0.yaml").getErrorMessageList().get(1).getMessage(), + "ERROR: [HRR3]: Nested files loop - [nested-pps_v1.0.yaml -- nested-from-resources-group.yaml -- hot-nimbus-pps_v1.0.yaml -- nested-pps_v1.0.yaml]"); Assert.assertEquals(messages.get("nested-not-exist.yaml").getErrorMessageList().size(), 1); Assert.assertEquals( - messages.get("nested-not-exist.yaml").getErrorMessageList().get(0).getMessage(), - "ERROR: Missing nested file - nested-not-exist.yaml"); + messages.get("nested-not-exist.yaml").getErrorMessageList().get(0).getMessage(), + "ERROR: [HRR2]: Missing nested file - nested-not-exist.yaml"); } } diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/MANIFEST.json new file mode 100644 index 0000000000..dd26e5ac45 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/MANIFEST.json @@ -0,0 +1,17 @@ +{ + "name": "hot-mog", + "description": "HOT template to create hot mog server", + "version": "2013-05-23", + "data": [ + { + "file": "hot-nimbus-psm_v1.0.yaml", + "type": "HEAT", + "data": [ + { + "file": "hot-nimbus-psm_v1.0.env", + "type": "HEAT_ENV" + } + ] + } + ] +} \ 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/heat_validator/missing_nested_file/input/hot-nimbus-psm_v1.0.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/hot-nimbus-psm_v1.0.env new file mode 100644 index 0000000000..f24e4763c6 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/hot-nimbus-psm_v1.0.env @@ -0,0 +1,10 @@ +parameters: + pcrf_psm_server_names: ZRDM1PCRF01PSM001,ZRDM1PCRF01PSM002,ZRDM1PCRF01PSM003,ZRDM1PCRF01PSM004,ZRDM1PCRF01PSM005,ZRDM1PCRF01PSM006,ZRDM1PCRF01PSM007,ZRDM1PCRF01PSM008,ZRDM1PCRF01PSM009,ZRDM1PCRF01PSM010,ZRDM1PCRF01PSM011,ZRDM1PCRF01PSM012 + pcrf_psm_image_name: PCRF_8.995-ATTM1.0.3.qcow2 + pcrf_psm_flavor_name: lc.4xlarge4 + availabilityzone_name: nova + pcrf_cps_net_name: Mobisupport-25193-I-INT1_int_pcrf_net_0 + pcrf_cps_net_ips: 172.26.16.63,172.26.16.64,172.26.16.65,172.26.16.66,172.26.16.67,172.26.16.68,172.26.16.69,172.26.16.70,172.26.16.71,172.26.16.72,172.26.16.73,172.26.16.74 + pcrf_cps_net_mask: 255.255.255.0 + pcrf_security_group_name: nimbus_security_group + pcrf_vnf_id: 730797234b4a40aa99335157b02871cd diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/hot-nimbus-psm_v1.0.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/hot-nimbus-psm_v1.0.yaml new file mode 100644 index 0000000000..e5298fe389 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/missing_nested_file/input/hot-nimbus-psm_v1.0.yaml @@ -0,0 +1,62 @@ +heat_template_version: 2013-05-23 + +description: heat template that creates PCRF Session Manager stack + +parameters: + pcrf_psm_server_names: + type: comma_delimited_list + label: PCRF SM server names + description: name of the PCRF SM instance + pcrf_psm_image_name: + type: string + label: PCRF SM image name + description: PCRF SM image name + pcrf_psm_flavor_name: + type: string + label: PCRF SM flavor name + description: flavor name of PCRF SM instance + availabilityzone_name: + type: string + label: availabilityzone name + description: availabilityzone name + pcrf_cps_net_name: + type: string + label: CPS network name + description: CPS network name + pcrf_cps_net_ips: + type: comma_delimited_list + label: CPS network ips + description: CPS network ips + pcrf_cps_net_mask: + type: string + label: CPS network mask + description: CPS network mask + pcrf_security_group_name: + type: string + label: security group name + description: the name of security group + pcrf_vnf_id: + type: string + label: PCRF VNF Id + description: PCRF VNF Id + vnf_id: + type: string + +resources: + nova_server_1: + type: OS::Nova::Server + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 0] } + image: { get_param: pcrf_psm_image_name } + flavor: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + networks: + - port: { get_resource: oam1_int_port } + fixed_ip: 10.0.0.0 + floating_ip: 10.0.0.1 + network: 100_1000_0011 + port_extra_properties: {admin_state_up: true , allowed_address_pairs: 10} + subnet: 10.0.0.2 + - port: { get_resource: oam1_mgmt_port } + metadata: + vnf_id: { get_param: vnf_id } \ 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/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/MANIFEST.json new file mode 100644 index 0000000000..fe7d8bdf5a --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/MANIFEST.json @@ -0,0 +1,51 @@ +{ + "name": "hot-mog", + "description": "HOT template to create hot mog server", + "version": "2013-05-23", + "data": [ + { + "file": "hot-nimbus-pps_v1.0.yaml", + "type": "HEAT", + "data": [ + { + "file": "hot-nimbus-pps_v1.0.env", + "type": "HEAT_ENV" + } + ] + }, + { + "file": "hot-nimbus-psm_v1.0.yaml", + "type": "HEAT", + "data": [ + { + "file": "hot-nimbus-psm_v1.0.env", + "type": "HEAT_ENV" + } + ] + }, + { + "file": "nested-pps_v1.0.yaml", + "type": "HEAT" + }, + { + "file": "nested-psm_v1.0.yaml", + "type": "HEAT" + }, + { + "file": "mount_iso_script.sh", + "type": "SHELL" + }, + { + "file": "cloud-nimbus.sh", + "type": "SHELL" + }, + { + "file": "nimbus-ethernet", + "type": "OTHER" + }, + { + "file": "nimbus-ethernet-gw", + "type": "OTHER" + } + ] +} \ 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/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-pps_v1.0.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-pps_v1.0.env new file mode 100644 index 0000000000..340be2b815 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-pps_v1.0.env @@ -0,0 +1,11 @@ +parameters: + pcrf_pps_server_names: ZRDM1PCRF01PPS001,ZRDM1PCRF01PPS002,ZRDM1PCRF01PPS003,ZRDM1PCRF01PPS004,ZRDM1PCRF01PPS005,ZRDM1PCRF01PPS006 + pcrf_pps_image_name: PCRF_8.995-ATTM1.0.3.qcow2 + pcrf_pps_flavor_name: lc.3xlarge + availabilityzone_name: nova + pcrf_cps_net_name: Mobisupport-25193-I-INT1_int_pcrf_net_0 + pcrf_cps_net_ips: 172.26.16.7,172.26.16.8,172.26.16.9,172.26.16.10,172.26.16.11,172.26.16.12 + pcrf_cps_net_mask: 255.255.255.0 + pcrf_security_group_name: nimbus_security_group + pcrf_vnf_id: 730797234b4a40aa99335157b02871cd + diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-pps_v1.0.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-pps_v1.0.yaml new file mode 100644 index 0000000000..2fe32fa078 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-pps_v1.0.yaml @@ -0,0 +1,58 @@ +heat_template_version: 2013-05-23 + +description: heat template that creates PCRF Policy Server stack + +parameters: + pcrf_pps_server_names: + type: comma_delimited_list + label: PCRF PS server names + description: PCRF PS server names + pcrf_pps_image_name: + type: string + label: PCRF PS image name + description: PCRF PS image name + pcrf_pps_flavor_name: + type: string + label: PCRF PS flavor name + description: flavor name of PCRF PS instance + availabilityzone_name: + type: string + label: availabilityzone name + description: availabilityzone name + pcrf_cps_net_name: + type: string + label: CPS network name + description: CPS network name + pcrf_cps_net_ips: + type: comma_delimited_list + label: CPS network ips + description: CPS network ips + pcrf_cps_net_mask: + type: string + label: CPS network mask + description: CPS network mask + pcrf_security_group_name: + type: string + label: security group name + description: the name of security group + pcrf_vnf_id: + type: string + label: PCRF VNF Id + description: PCRF VNF Id + index_integer: + type: integer + +resources: + server_pcrf_pps_001: + type: nested-pps_v1.0.yaml + properties: + pcrf_pps_server_name: { get_param: [pcrf_pps_server_names, 0] } + pcrf_pps_image_name: { get_param: pcrf_pps_image_name } + pcrf_pps_flavor_name: { get_param: pcrf_pps_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 0] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + index_integer: "TEST_ME" diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-psm_v1.0.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-psm_v1.0.env new file mode 100644 index 0000000000..f24e4763c6 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-psm_v1.0.env @@ -0,0 +1,10 @@ +parameters: + pcrf_psm_server_names: ZRDM1PCRF01PSM001,ZRDM1PCRF01PSM002,ZRDM1PCRF01PSM003,ZRDM1PCRF01PSM004,ZRDM1PCRF01PSM005,ZRDM1PCRF01PSM006,ZRDM1PCRF01PSM007,ZRDM1PCRF01PSM008,ZRDM1PCRF01PSM009,ZRDM1PCRF01PSM010,ZRDM1PCRF01PSM011,ZRDM1PCRF01PSM012 + pcrf_psm_image_name: PCRF_8.995-ATTM1.0.3.qcow2 + pcrf_psm_flavor_name: lc.4xlarge4 + availabilityzone_name: nova + pcrf_cps_net_name: Mobisupport-25193-I-INT1_int_pcrf_net_0 + pcrf_cps_net_ips: 172.26.16.63,172.26.16.64,172.26.16.65,172.26.16.66,172.26.16.67,172.26.16.68,172.26.16.69,172.26.16.70,172.26.16.71,172.26.16.72,172.26.16.73,172.26.16.74 + pcrf_cps_net_mask: 255.255.255.0 + pcrf_security_group_name: nimbus_security_group + pcrf_vnf_id: 730797234b4a40aa99335157b02871cd diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-psm_v1.0.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-psm_v1.0.yaml new file mode 100644 index 0000000000..c2d7b05ead --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/hot-nimbus-psm_v1.0.yaml @@ -0,0 +1,199 @@ +heat_template_version: 2013-05-23 + +description: heat template that creates PCRF Session Manager stack + +parameters: + pcrf_psm_server_names: + type: comma_delimited_list + label: PCRF SM server names + description: name of the PCRF SM instance + pcrf_psm_image_name: + type: string + label: PCRF SM image name + description: PCRF SM image name + pcrf_psm_flavor_name: + type: string + label: PCRF SM flavor name + description: flavor name of PCRF SM instance + availabilityzone_name: + type: string + label: availabilityzone name + description: availabilityzone name + pcrf_cps_net_name: + type: string + label: CPS network name + description: CPS network name + pcrf_cps_net_ips: + type: comma_delimited_list + label: CPS network ips + description: CPS network ips + pcrf_cps_net_mask: + type: string + label: CPS network mask + description: CPS network mask + pcrf_security_group_name: + type: string + label: security group name + description: the name of security group + pcrf_vnf_id: + type: string + label: PCRF VNF Id + description: PCRF VNF Id + +resources: + server_pcrf_psm_001: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 0] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 0] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_002: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 1] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 1] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_003: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 2] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 2] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_004: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 3] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 3] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_005: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 4] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 4] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_006: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 5] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 5] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_007: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 6] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 6] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_008: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 7] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 7] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_009: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 8] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 8] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_010: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 9] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 9] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_011: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 10] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 10] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_psm_012: + type: nested-psm_v1.0.yaml + properties: + pcrf_psm_server_name: { get_param: [pcrf_psm_server_names, 11] } + pcrf_psm_image_name: { get_param: pcrf_psm_image_name } + pcrf_psm_flavor_name: { get_param: pcrf_psm_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 11] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/nested-pps_v1.0.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/nested-pps_v1.0.yaml new file mode 100644 index 0000000000..6b7d84635d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/nested-pps_v1.0.yaml @@ -0,0 +1,101 @@ +heat_template_version: 2013-05-23 + +description: heat template that creates PCRF Policy Server stack + +parameters: + pcrf_pps_server_name: + type: string + label: PCRF PS server name + description: PCRF PS server name + pcrf_pps_image_name: + type: string + label: PCRF PS image name + description: PCRF PS image name + pcrf_pps_flavor_name: + type: string + label: PCRF PS flavor name + description: flavor name of PCRF PS instance + availabilityzone_name: + type: string + label: availabilityzone name + description: availabilityzone name + pcrf_cps_net_name: + type: string + label: CPS network name + description: CPS network name + pcrf_cps_net_ip: + type: string + label: CPS network ip + description: CPS network ip + pcrf_cps_net_mask: + type: string + label: CPS network mask + description: CPS network mask + pcrf_security_group_name: + type: string + label: security group name + description: the name of security group + pcrf_vnf_id: + type: string + label: PCRF VNF Id + description: PCRF VNF Id + index_integer: + type: integer + +resources: + script_init: + type: OS::Heat::SoftwareConfig + properties: + group: ungrouped + config: + str_replace: + template: { get_file: cloud-nimbus.sh } + params: + $vm_name: { get_param: pcrf_pps_server_name } + network: + type: OS::Heat::CloudConfig + properties: + cloud_config: + write_files: + - path: /etc/sysconfig/network-scripts/ifcfg-eth0 + permissions: "0644" + content: + str_replace: + template: { get_file: nimbus-ethernet } + params: + $dev: eth0 + $ip: { get_param: pcrf_cps_net_ip } + $netmask: { get_param: pcrf_cps_net_mask } + runcmd: + - ifdown eth0 && ifup eth0 + + pcrf_server_init: + type: OS::Heat::MultipartMime + properties: + parts: + - config: { get_resource: network} + - config: { get_resource: script_init} + + pcrf_server_pps: + type: OS::Nova::Server + properties: + config_drive: "True" + name: { get_param: pcrf_pps_server_name } + image: { get_param: pcrf_pps_image_name } + flavor: { get_param: pcrf_pps_flavor_name } + availability_zone: { get_param: availabilityzone_name } + networks: + - port: { get_resource: pcrf_pps_port_0} + user_data_format: RAW + user_data: + get_resource: pcrf_server_init + metadata: + vnf_id: {get_param: pcrf_vnf_id} + + pcrf_pps_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: pcrf_cps_net_name } + fixed_ips: + - ip_address: { get_param: pcrf_cps_net_ip } + security_groups: [{ get_param: pcrf_security_group_name }] diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/nested-psm_v1.0.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/nested-psm_v1.0.yaml new file mode 100644 index 0000000000..c86aa34713 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/properties_match_nested_parameters/wrong_value_type_assigned/input/nested-psm_v1.0.yaml @@ -0,0 +1,99 @@ +heat_template_version: 2013-05-23 + +description: heat template that creates PCRF Session Manager stack + +parameters: + pcrf_psm_server_name: + type: string + label: PCRF SM server name + description: PCRF SM server name + pcrf_psm_image_name: + type: string + label: image name + description: PCRF SM image name + pcrf_psm_flavor_name: + type: string + label: PCRF SM flavor name + description: flavor name of PCRF SM instance + availabilityzone_name: + type: string + label: availabilityzone name + description: availabilityzone name + pcrf_cps_net_name: + type: string + label: CPS network name + description: CPS network name + pcrf_cps_net_ip: + type: string + label: CPS network ip + description: CPS network ip + pcrf_cps_net_mask: + type: string + label: CPS network mask + description: CPS network mask + pcrf_security_group_name: + type: string + label: security group name + description: the name of security group + pcrf_vnf_id: + type: string + label: PCRF VNF Id + description: PCRF VNF Id + +resources: + network: + type: OS::Heat::CloudConfig + properties: + cloud_config: + write_files: + - path: /etc/sysconfig/network-scripts/ifcfg-eth0 + permissions: "0644" + content: + str_replace: + template: { get_file: nimbus-ethernet } + params: + $dev: eth0 + $ip: { get_param: pcrf_cps_net_ip } + $netmask: { get_param: pcrf_cps_net_mask } + runcmd: + - ifdown eth0 && ifup eth0 + script_init: + type: OS::Heat::SoftwareConfig + properties: + group: ungrouped + config: + str_replace: + template: { get_file: cloud-nimbus.sh } + params: + $vm_name: { get_param: pcrf_psm_server_name } + pcrf_server_init: + type: OS::Heat::MultipartMime + properties: + parts: + - config: { get_resource: network} + - config: { get_resource: script_init} + + pcrf_server_psm: + type: OS::Nova::Server + properties: + config_drive: "True" + name: { get_param: pcrf_psm_server_name } + image: { get_param: pcrf_psm_image_name } + flavor: { get_param: pcrf_psm_flavor_name } + availability_zone: { get_param: availabilityzone_name } + networks: + - port: { get_resource: psm01_port_0} + user_data_format: RAW + user_data: + get_resource: pcrf_server_init + metadata: + vnf_id: {get_param: pcrf_vnf_id} + #scheduler_hints: {group: { get_resource: servergroup_nimbus }} + + psm01_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: pcrf_cps_net_name } + fixed_ips: + - ip_address: { get_param: pcrf_cps_net_ip } + security_groups: [{ get_param: pcrf_security_group_name }] \ No newline at end of file -- cgit 1.2.3-korg