diff options
author | 2018-03-24 00:04:37 +0800 | |
---|---|---|
committer | 2018-04-12 10:35:13 +0800 | |
commit | 1210f741d01f26609b687e6680e5180fb1be5efe (patch) | |
tree | b087864f78a67021471fbcb911154d1e0ec400a2 | |
parent | cd02d1f9b64957a63ad4b16bac639116975edb22 (diff) |
Fix aria validation error in import case2.0.0-ONAPbeijing2.0.0-ONAP
Previously, we assume all the yaml files in the csar package are located
under definition directory. This is not always true according to
SOL-004. We need to change the way how we call aria to validate the vnfd
content within the csar pacakge.
Also added the unit test for vnfsdk_pkgtools/validator.
Issue-ID: VNFSDK-231
Change-Id: Ia112b21b3bbf64ab980dd4e98aab0e87131f28e0
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
-rw-r--r-- | tests/resources/test_import.csar | bin | 0 -> 1074 bytes | |||
-rw-r--r-- | tests/validator/test_aria_validator.py | 27 | ||||
-rw-r--r-- | vnfsdk_pkgtools/validator/aria_validator.py | 9 |
3 files changed, 32 insertions, 4 deletions
diff --git a/tests/resources/test_import.csar b/tests/resources/test_import.csar Binary files differnew file mode 100644 index 0000000..90bb629 --- /dev/null +++ b/tests/resources/test_import.csar diff --git a/tests/validator/test_aria_validator.py b/tests/validator/test_aria_validator.py new file mode 100644 index 0000000..8ae5eab --- /dev/null +++ b/tests/validator/test_aria_validator.py @@ -0,0 +1,27 @@ +# Copyright (c) 2018 Intel Corp. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +import logging +import os + +from vnfsdk_pkgtools.packager import csar +from vnfsdk_pkgtools.validator import aria_validator + +CSAR_PATH = 'tests/resources/test_import.csar' + +def test_validate(tmpdir): + reader = csar._CSARReader(CSAR_PATH, str(tmpdir.mkdir('validate')), logging) + validator = aria_validator.AriaValidator() + validator.validate(reader) diff --git a/vnfsdk_pkgtools/validator/aria_validator.py b/vnfsdk_pkgtools/validator/aria_validator.py index 83d7dfe..b4b947c 100644 --- a/vnfsdk_pkgtools/validator/aria_validator.py +++ b/vnfsdk_pkgtools/validator/aria_validator.py @@ -15,7 +15,7 @@ import os -from aria.parser.loading import LiteralLocation +from aria.parser.loading import UriLocation from aria.parser.consumption import ( ConsumptionContext, ConsumerChain, @@ -31,9 +31,10 @@ from vnfsdk_pkgtools import validator class AriaValidator(validator.ValidatorBase): def validate(self, reader): context = ConsumptionContext() - context.loading.prefixes += [os.path.join(reader.destination, 'definitions')] - context.presentation.location = LiteralLocation(reader.entry_definitions_yaml) - print reader.entry_definitions_yaml + service_template_path = os.path.join(reader.destination, + reader.entry_definitions) + context.presentation.location = UriLocation(service_template_path) + print(reader.entry_definitions_yaml) chain = ConsumerChain(context, (Read, Validate, ServiceTemplate, ServiceInstance)) chain.consume() if context.validation.dump_issues(): |