diff options
author | 2018-08-22 11:13:45 -0500 | |
---|---|---|
committer | 2018-08-22 12:52:32 -0500 | |
commit | f5edc06be0d8bedeb0904b348ba5e3e67c74f186 (patch) | |
tree | 5fba01ca97aebe14f4b7004551bc58c17a858169 /ice_validator/tests/test_port_resource_ids.py | |
parent | 1af0d577ab6d8c431ae1322657c50efd5e0a1a93 (diff) |
[VVP] Added new three new reports
Resolves VVP-81 by introducing three new reports to the validation
script output.
Each report is written to the output directory under ice_validator.
* mapping_errors.csv - each row represents an issue where a test is
mapped to a requirement that does not exist
in the requirement.json file
* traceability.csv - Shows a mapping between all test cases and
requirements. Rows will also be shown
where a requirement does not have a tests, and
where tests are not mapped to a requirement
* report.{html|csv|xlsx} - Formatted error report that shows each
failure that was detected and maps it to
a the file name, requirement(s) violated if
known, possible resolution steps, error
message, and raw output from pytest. The
report can be written in html, csv, or Excel
format
Other minor changes:
* Replaced smart quotes with regular quotes to resolve issues with py3
* Updated copyright of modified files
* Fixed Flake-8 errors
Issue-ID: VVP-81
Change-Id: I659836cb20262ae44652c03639281a817dd051ae
Signed-off-by: Lovett, Trevor (tl2972) <tl2972@att.com>
Diffstat (limited to 'ice_validator/tests/test_port_resource_ids.py')
-rw-r--r-- | ice_validator/tests/test_port_resource_ids.py | 80 |
1 files changed, 42 insertions, 38 deletions
diff --git a/ice_validator/tests/test_port_resource_ids.py b/ice_validator/tests/test_port_resource_ids.py index a6f7093..511af35 100644 --- a/ice_validator/tests/test_port_resource_ids.py +++ b/ice_validator/tests/test_port_resource_ids.py @@ -2,11 +2,11 @@ # ============LICENSE_START======================================================= # org.onap.vvp/validation-scripts # =================================================================== -# Copyright © 2017 AT&T Intellectual Property. All rights reserved. +# Copyright © 2018 AT&T Intellectual Property. All rights reserved. # =================================================================== # # Unless otherwise specified, all software contained herein is licensed -# under the Apache License, Version 2.0 (the “License”); +# under the Apache License, Version 2.0 (the "License"); # you may not use this software except in compliance with the License. # You may obtain a copy of the License at # @@ -21,7 +21,7 @@ # # # Unless otherwise specified, all documentation contained herein is licensed -# under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +# under the Creative Commons License, Attribution 4.0 Intl. (the "License"); # you may not use this documentation except in compliance with the License. # You may obtain a copy of the License at # @@ -43,29 +43,33 @@ import pytest import yaml from .helpers import validates from .utils.vm_types import get_vm_type_for_nova_server -from .utils.network_roles import get_network_role_from_port,\ - get_network_type_from_port,\ - property_uses_get_resource - - -@validates('R-29865', - 'R-69014', - 'R-05201', - 'R-68936', - 'R-32025', - 'R-11168', - 'R-84322', - 'R-96983', - 'R-26506', - 'R-20453', - 'R-26351') +from .utils.network_roles import ( + get_network_role_from_port, + get_network_type_from_port, + property_uses_get_resource, +) + + +@validates( + "R-29865", + "R-69014", + "R-05201", + "R-68936", + "R-32025", + "R-11168", + "R-84322", + "R-96983", + "R-26506", + "R-20453", + "R-26351", +) def test_port_resource_ids(heat_template): - ''' + """ Check that all resource ids for ports follow the right naming convention to include the {vm_type} of the nova server it is associated to and also contains the {network_role} of the network it is associated with - ''' + """ with open(heat_template) as fh: yml = yaml.load(fh) @@ -74,22 +78,22 @@ def test_port_resource_ids(heat_template): pytest.skip("No resources specified in the heat template") port_patterns = { - 'internal': re.compile(r'(.+?)_\d+_int_(.+?)_port_\d+'), - 'external': re.compile(r'(.+?)_\d+_(.+?)_port_\d+'), - } - resources = yml['resources'] + "internal": re.compile(r"(.+?)_\d+_int_(.+?)_port_\d+"), + "external": re.compile(r"(.+?)_\d+_(.+?)_port_\d+"), + } + resources = yml["resources"] invalid_ports = [] for k, v in resources.items(): if not isinstance(v, dict): continue - if 'type' not in v: + if "type" not in v: continue - if v['type'] not in 'OS::Nova::Server': + if v["type"] not in "OS::Nova::Server": continue - if 'properties' not in v: + if "properties" not in v: continue - if 'networks' not in v['properties']: + if "networks" not in v["properties"]: continue has_vm_type = False @@ -102,18 +106,18 @@ def test_port_resource_ids(heat_template): vm_type = vm_type.lower() # get all ports associated with the nova server - properties = v['properties'] - for v2 in properties['networks']: + properties = v["properties"] + for v2 in properties["networks"]: for k3, v3 in v2.items(): - if k3 != 'port': + if k3 != "port": continue if not isinstance(v3, dict): continue - if 'get_param' in v3: + if "get_param" in v3: continue - elif 'get_resource' in v3: - port_id = v3['get_resource'] + elif "get_resource" in v3: + port_id = v3["get_resource"] if not resources[port_id]: continue port_resource = resources[port_id] @@ -121,7 +125,7 @@ def test_port_resource_ids(heat_template): else: continue - has_vm_type = vm_type+"_" in port_id + has_vm_type = vm_type + "_" in port_id has_network_role = False if port_resource: @@ -141,9 +145,9 @@ def test_port_resource_ids(heat_template): else: # match the assumed naming convention for ports # if the specified port is provided via get_param - network_type = 'external' + network_type = "external" if "int_" in port_id: - network_type = 'internal' + network_type = "internal" if port_patterns[network_type].match(port_id): has_network_role = True |