X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vvp%2Fvalidation-scripts.git;a=blobdiff_plain;f=ice_validator%2Ftests%2Ftest_port_resource_ids.py;h=076c4796934414f93bbcdd6768b875687ecc7f12;hp=78a6751e36a0a0acc6d90210e0a0db7693c1fc60;hb=60d5ad7d00eadd6395eca186e6fa76a43df3c6cf;hpb=cc21b8b08b6dbcec577bfb26ff397ac899da8002 diff --git a/ice_validator/tests/test_port_resource_ids.py b/ice_validator/tests/test_port_resource_ids.py index 78a6751..076c479 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 # @@ -39,13 +39,27 @@ # import re + import pytest -import yaml +from tests import cached_yaml as yaml + +from .helpers import validates +from .utils.network_roles import get_network_role_from_port, \ + get_network_type_from_port, \ + property_uses_get_resource 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 +@validates('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 @@ -60,10 +74,8 @@ def test_port_resource_ids(heat_template): if "resources" not in yml: pytest.skip("No resources specified in the heat template") - port_patterns = { - 'internal': re.compile(r'(.+?)_\d+_int_(.+?)_\d+_port'), - 'external': re.compile(r'(.+?)_\d+_(.+?)_\d+_port'), - } + port_patterns = {'internal': re.compile(r'(.+?)_\d+_int_(.+?)_port_\d+'), + 'external': re.compile(r'(.+?)_\d+_(.+?)_port_\d+')} resources = yml['resources'] invalid_ports = [] @@ -108,9 +120,12 @@ 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: + if property_uses_get_resource(v, "network"): + continue network_role = get_network_role_from_port(port_resource) if not network_role: continue @@ -120,10 +135,8 @@ def test_port_resource_ids(heat_template): if not network_type: continue - prepend = "" - if network_type == 'internal': - prepend = "int_" - has_network_role = prepend+network_role+"_" in port_id + if port_patterns[network_type].match(port_id): + has_network_role = True else: # match the assumed naming convention for ports # if the specified port is provided via get_param