X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vvp%2Fvalidation-scripts.git;a=blobdiff_plain;f=ice_validator%2Ftests%2Ftest_software_config_resource_id.py;fp=ice_validator%2Ftests%2Ffixtures%2Ftest_nova_servers_index%2Ffail%2Ffail2.yaml;h=d15ed9db8d8257c4407e723fbf34fcc41bda3416;hp=3d02a12b82169466ca98aa80bd6eb6752dcab760;hb=1f4df7c7ad27b23773ad9cdbe4db1632ce388cf1;hpb=ca9085f0f77d442d3741a8c754e65cc45b6a318d diff --git a/ice_validator/tests/fixtures/test_nova_servers_index/fail/fail2.yaml b/ice_validator/tests/test_software_config_resource_id.py similarity index 60% rename from ice_validator/tests/fixtures/test_nova_servers_index/fail/fail2.yaml rename to ice_validator/tests/test_software_config_resource_id.py index 3d02a12..d15ed9d 100644 --- a/ice_validator/tests/fixtures/test_nova_servers_index/fail/fail2.yaml +++ b/ice_validator/tests/test_software_config_resource_id.py @@ -38,42 +38,47 @@ # ECOMP is a trademark and service mark of AT&T Intellectual Property. # -# VERSION = '1.0.0' - ---- +""" resources: - vm_type_a_server_0: - type: OS::Nova::Server - properties: - name: { get_param: [vm_type_a_names, 0] } - flavor: { get_param: vm_type_a_flavor_name} - image: { get_param: vm_type_a_image_name} +{vm-type}_{vm-type_index}_{network-role}_port_{port-index}: +""" + +import pytest - vm_type_a_sErver_0: - type: OS::Nova::Server - properties: - name: { get_param: [vm_type_a_names, 0] } - flavor: { get_param: vm_type_a_flavor_name} - image: { get_param: vm_type_a_image_name} +from .structures import Heat +from .helpers import validates - vm_type_a_server_1: - type: OS::Nova::Server - properties: - name: { get_param: [vm_type_a_names, 1] } - flavor: { get_param: vm_type_a_flavor_name} - image: { get_param: vm_type_a_image_name} +VERSION = "1.1.0" - vm_type_b_server_0: - type: OS::Nova::Server - properties: - name: { get_param: vm_type_b_name_0 } - flavor: { get_param: vm_type_b_flavor_name} - image: { get_param: vm_type_b_image_name} +# pylint: disable=invalid-name - vm_type_b_server_1: - type: OS::Nova::Server - properties: - name: { get_param: vm_type_b_name_1 } - flavor: { get_param: vm_type_b_flavor_name} - image: { get_param: vm_type_b_image_name} +@validates("R-08975") +def test_software_config_vm_type(heat_template): + """ + A VNF's Heat Orchestration Template's Resource OS::Heat::SoftwareConfig + Resource ID **MUST** contain the {vm-type}. + """ + heat = Heat(filepath=heat_template) + software_configs = heat.get_resource_by_type("OS::Heat::SoftwareConfig") + if not software_configs: + pytest.skip("No SoftwareConfig resources found") + vm_types = sorted( + list( + set( + x + for x in [ + heat.get_vm_type(rid, resource=r) + for rid, r in heat.resources.items() + ] + if x + ) + ) + ) + if not vm_types: + pytest.skip("No vm_types found") + bad = [] + for rid in software_configs: + if not any(heat.part_is_in_name(part=v, name=rid) for v in vm_types): + bad.append("%s vm-type not in %s" % (rid, vm_types)) + assert not bad, "; ".join(bad)