diff options
author | stark, steven <steven.stark@att.com> | 2019-04-19 16:17:58 -0700 |
---|---|---|
committer | stark, steven <steven.stark@att.com> | 2019-04-22 16:07:01 -0700 |
commit | 684ad537becece9df772b04d0d8226bcb7c30ca4 (patch) | |
tree | 1046d067fbde6209009c4247ad73453ac290672e /ice_validator/tests | |
parent | ac35c043b29a6c65a0c9ce932aa12e1f406ff44c (diff) |
[VVP] updating nested parameter test
R-708564 was updated in RTD to target explicit parameters
Change-Id: If860903ae13b76543c43f3e805b8aa03e9e2019d
Issue-ID: VVP-197
Signed-off-by: stark, steven <steven.stark@att.com>
Diffstat (limited to 'ice_validator/tests')
16 files changed, 962 insertions, 389 deletions
diff --git a/ice_validator/tests/fixtures/test_nested_parameters/fail/base_stark.env b/ice_validator/tests/fixtures/test_nested_parameters/fail/base_stark.env new file mode 100755 index 0000000..ae1e68b --- /dev/null +++ b/ice_validator/tests/fixtures/test_nested_parameters/fail/base_stark.env @@ -0,0 +1,16 @@ +parameters: + flavor: "ns.c2r2d30.n1" + starkimage_name: "Ubuntu 14.04 for KVM VMs with ATT Supported Tools - NO PP" + vm_role: "vm_role" + stark_count: 3 + starkint_mummy_ips: [0.0.0.0] + #dummy_net_id: + #dummy_subnet_id: + #environment_context: + #stark_dummy_ips: + #stark_names: + #vf_module_id: + #vf_module_name: + #vnf_id: + #vnf_name: + #workload_context: diff --git a/ice_validator/tests/fixtures/test_nested_parameters/fail/base_stark.yaml b/ice_validator/tests/fixtures/test_nested_parameters/fail/base_stark.yaml new file mode 100755 index 0000000..dfe53b3 --- /dev/null +++ b/ice_validator/tests/fixtures/test_nested_parameters/fail/base_stark.yaml @@ -0,0 +1,139 @@ +heat_template_version: 2015-04-30 + +description: | + this is a test template + +parameters: + + stark_volumes: + description: nfsadnfkl + type: json + + vnfname: + label: VNF name + description: this name will also be used on VM server and other resources. + type: string + + vnfid: + label: VNF ID + description: 'This ID will be passed as metadata on all Nova Servers, Cinder Volumes, and any other resource that supports metadata' + type: string + + vfmodule_id: + type: string + description: Unique ID for this VF Module instance + + vfmodule_index: + type: string + description: Unique ID for this VF Module instance + + vfmodule_name: + type: string + description: Unique name for this VF Module instance + + vmrole: + type: string + description: role tagged to VM + + flavor: + label: VMs flavor + description: The JSON map containing the nova Flavors to be used for the VM Servers + type: string + + starkimage_name: + type: string + description: "stark image name" + + names: + type: comma_delimited_list + description: VM name for STARK VM 1 + + workloadcontext: + type: string + description: Workload Context for this VNF instance + + environmentcontext: + type: string + description: Environment Context for this VNF instance + + dummynet_id: + type: string + description: nsdaljfnsak + + dummysubnet_id: + type: string + description: nsdaljfnsak + + iplist: + type: comma_delimited_list + description: dsnafljsadnlfks + + stark_count: + type: number + description: njsdlf + + starkdummy_floating_ip: + type: string + description: nfalsd + + starkint_mummy_ips: + type: comma_delimited_list + description: nfdsa + + oamnet_fqdn: + type: string + description: ndfsakl + + oam2net_fqdn: + type: string + description: nfkldas + + instanceip_address: + type: string + description: nfsakdl + + my_contrailip: + type: string + description: nlfdsa + +resources: + + int_mummy_network: + type: OS::Neutron::Net + + int_mummy_subnet: + type: OS::Neutron::Subnet + properties: + network: { get_resource: int_mummy_network } + + stark_RG: + type: OS::Heat::ResourceGroup + properties: + count: { get_param: stark_count } + resource_def: + type: stark_nested.yaml + properties: + index: '%index%' + dummy_net_id: { get_param: dummynet_id } + dummy_subnet_id: { get_param: dummysubnet_id } + stark_dummy_ips: { get_param: iplist } + vnf_name: { get_param: vnfname } + vnf_id: { get_param: vnfid } + vf_module_id: { get_param: vfmodule_id } + vf_module_index: { get_param: vfmodule_index } + vf_module_name: { get_param: vfmodule_name } + vm_role: { get_param: vmrole } + stark_flavor_name: { get_param: flavor } + stark_image_name: { get_param: starkimage_name } + stark_names: { get_param: names } + workload_context: { get_param: workloadcontext } + environment_context: { get_param: environmentcontext } + stark_volumes: { get_param: stark_volumes } + stark_dummy_floating_ip: { get_param: starkdummy_floating_ip } + int_mummy_net_id: { get_resource: int_mummy_network } + int_mummy_subnet_id: { get_resource: int_mummy_subnet } + stark_int_mummy_ips: { get_param: starkint_mummy_ips } + oam_net_fqdn: { get_param: oamnet_fqdn } + oam2_net_fqdn: { get_param: oam2net_fqdn } + instance_ip_address: { get_param: instanceip_address } + mycontrailip: { get_param: my_contrailip } diff --git a/ice_validator/tests/fixtures/test_nested_parameters/fail/heat_template.yaml b/ice_validator/tests/fixtures/test_nested_parameters/fail/heat_template.yaml deleted file mode 100644 index db70d14..0000000 --- a/ice_validator/tests/fixtures/test_nested_parameters/fail/heat_template.yaml +++ /dev/null @@ -1,89 +0,0 @@ -# -*- coding: utf8 -*- -# ============LICENSE_START==================================================== -# org.onap.vvp/validation-scripts -# =================================================================== -# Copyright © 2017 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"); -# you may not use this software 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. -# -# -# -# Unless otherwise specified, all documentation contained herein is licensed -# 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 -# -# https://creativecommons.org/licenses/by/4.0/ -# -# Unless required by applicable law or agreed to in writing, documentation -# 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============================================ -# -# - -# VERSION = '1.0.0' - ---- -description: base - -parameters: - vm_type_volume_name_0: - type: string - vm_type_volume_size_0: - type: number - vm_role: - type: string - vnf_id: - type: string - vf_module_id: - type: string - vnf_name: - type: string - vf_module_name: - type: string - vf_module_index: - type: string - environment_context: - type: string - workload_context: - type: string - -resources: - server_0: - type: nested_template_1.yaml - properties: - name: { get_param: server_name_0 } - vm_1role: { get_param: vm_role } - vnf_1id: { get_param: vnf_id } - vf_module_1id: { get_param: vf_module_id } - vnf_1name: { get_param: vnf_name } - vf_module_1name: { get_param: vf_module_name } - vf_module_1index: { get_param: vf_module_index } - environment_cont1ext: { get_param: environment_context } - workload_cont1ext: { get_param: workload_context } - - my_resource_group_1: - type: OS::Heat::ResourceGroup - properties: - count: 5 - resource_def: { type: nested_template_bad.yaml } - -outputs: - vm_type_volume_id_0: - value: {get_resource: vm_type_volume_0} diff --git a/ice_validator/tests/fixtures/test_nested_parameters/fail/nested_template_bad.yaml b/ice_validator/tests/fixtures/test_nested_parameters/fail/nested_template_bad.yaml deleted file mode 100644 index 068afb8..0000000 --- a/ice_validator/tests/fixtures/test_nested_parameters/fail/nested_template_bad.yaml +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf8 -*- -# ============LICENSE_START==================================================== -# org.onap.vvp/validation-scripts -# =================================================================== -# Copyright © 2017 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"); -# you may not use this software 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. -# -# -# -# Unless otherwise specified, all documentation contained herein is licensed -# 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 -# -# https://creativecommons.org/licenses/by/4.0/ -# -# Unless required by applicable law or agreed to in writing, documentation -# 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============================================ -# -# - -# VERSION = '1.0.0' - ---- -heat_template_version: 2013-05-23 - -resources: - volume: - type: OS::Cinder::Volume - properties: - size: 1 - - volume_attachment: - type: OS::Cinder::VolumeAttachment - properties: - volume_id: { get_resource: volume } - instance_uuid: { get_resource: instance } - - instance: - type: OS::Nova::Server - properties: - image: myimage - flavor: m1.small - -parameters: - admin_volume_size_0: - type: number - description: Size of the volume to be created. - constraints: - - range: { min: 1, max: 1024 } - description: nested templates MAY NOT have constraints. - diff --git a/ice_validator/tests/fixtures/test_nested_parameters/fail/stark_nested.yaml b/ice_validator/tests/fixtures/test_nested_parameters/fail/stark_nested.yaml new file mode 100755 index 0000000..e6b328a --- /dev/null +++ b/ice_validator/tests/fixtures/test_nested_parameters/fail/stark_nested.yaml @@ -0,0 +1,175 @@ +heat_template_version: 2015-04-30 + +description: | + stark nested template + +parameters: + + stark_volumes: + type: comma_delimited_list + description: ndjsfka + + index: + type: number + description: nsadlf + + dummy_net_id: + type: string + description: nsdaljfnsak + + dummy_subnet_id: + type: string + description: nsdaljfnsak + + stark_dummy_ips: + type: comma_delimited_list + description: dsnafljsadnlfks + + vnf_name: + label: VNF name + description: this name will also be used on VM server and other resources. + type: string + + vnf_id: + label: VNF ID + description: 'This ID will be passed as metadata on all Nova Servers, Cinder Volumes, and any other resource that supports metadata' + type: string + + vf_module_id: + type: string + description: Unique ID for this VF Module instance + + vf_module_index: + type: string + description: Unique ID for this VF Module instance + + vf_module_name: + type: string + description: Unique name for this VF Module instance + + vm_role: + type: string + description: role tagged to VM + + stark_flavor_name: + label: VMs flavor + description: The JSON map containing the nova Flavors to be used for the VM Servers + type: string + + stark_image_name: + type: string + description: "stark image name" + + stark_names: + type: comma_delimited_list + description: VM name for stark VM 1 + + workload_context: + type: string + description: Workload Context for this VNF instance + + environment_context: + type: string + description: Environment Context for this VNF instance + + stark_dummy_floating_ip: + type: string + description: Test floating IP test + + int_mummy_net_id: + type: string + description: Test floating IP test + + int_mummy_subnet_id: + type: string + description: Test floating IP test + + stark_int_mummy_ips: + type: comma_delimited_list + description: Test floating IP test + + oam_net_fqdn: + type: string + description: nsdaklfnsaklfsdl + + oam2_net_fqdn: + type: string + description: ndjfls + + instance_ip_address: + type: string + description: nsdlfkn + + mycontrailip: + type: string + description: njsaf + +resources: + + fw_0_oam_protected_vmi_0_IP_0: + type: OS::ContrailV2::InstanceIp + properties: + instance_ip_address: { get_param: instance_ip_address } + + fw_0_oam_vmi_0: + type: OS::ContrailV2::VirtualMachineInterface + properties: + virtual_network_refs: + - get_param: oam_net_fqdn + - get_param: oam2_net_fqdn + virtual_machine_interface_allowed_address_pairs: + { + virtual_machine_interface_allowed_address_pairs_allowed_address_pair: + [{ + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip: + { + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix: { get_param: mycontrailip }, + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix_len: "fasdfas", + }, + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_mac: "test123", + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_address_mode: "asdfasdf", + }], + } + + stark_0_dummy_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: dummy_net_id } + fixed_ips: + - subnet: { get_param: dummy_subnet_id } + ip_address: { get_param: [stark_dummy_ips, { get_param: index }] } + allowed_address_pairs: + - ip_address: { get_param: stark_dummy_floating_ip } + + stark_0_int_mummy_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: int_mummy_net_id } + fixed_ips: + - subnet: { get_param: int_mummy_subnet_id } + ip_address: { get_param: [stark_int_mummy_ips, { get_param: index }] } + + stark_server_0: + type: OS::Nova::Server + properties: + name: { get_param: [stark_names, { get_param: index }] } + image: { get_param: stark_image_name} + flavor: { get_param: stark_flavor_name } + networks: + - port: { get_resource: stark_0_dummy_port_0 } + - port: { get_resource: stark_0_int_mummy_port_0 } + metadata: + vnf_id: {get_param: vnf_id} + vnf_name: {get_param: vnf_name} + vf_module_id: {get_param: vf_module_id} + vf_module_index: {get_param: vf_module_index} + vf_module_name: {get_param: vf_module_name} + vm_role: {get_param: vm_role} + workload_context: {get_param: workload_context } + environment_context: {get_param: environment_context } + + stark_volume_attachment_0: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: {get_resource: stark_server_0 } + volume_id: {get_param: [stark_volumes, { get_param: index }] } diff --git a/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark.env b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark.env new file mode 100755 index 0000000..f3868fd --- /dev/null +++ b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark.env @@ -0,0 +1,16 @@ +parameters: + stark_flavor_name: "ns.c2r2d30.n1" + stark_image_name: "Ubuntu 14.04 for KVM VMs with ATT Supported Tools - NO PP" + vm_role: "vm_role" + stark_count: 3 + stark_int_mummy_ips: [0.0.0.0] + #dummy_net_id: + #dummy_subnet_id: + #environment_context: + #stark_dummy_ips: + #stark_names: + #vf_module_id: + #vf_module_name: + #vnf_id: + #vnf_name: + #workload_context: diff --git a/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark.yaml b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark.yaml new file mode 100755 index 0000000..0f82c0b --- /dev/null +++ b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark.yaml @@ -0,0 +1,134 @@ +heat_template_version: 2015-04-30 + +description: | + this is a test template + +parameters: + + stark_volumes: + description: nfsadnfkl + type: json + + vnf_name: + label: VNF name + description: this name will also be used on VM server and other resources. + type: string + + vnf_id: + label: VNF ID + description: 'This ID will be passed as metadata on all Nova Servers, Cinder Volumes, and any other resource that supports metadata' + type: string + + vf_module_id: + type: string + description: Unique ID for this VF Module instance + + vf_module_name: + type: string + description: Unique name for this VF Module instance + + vm_role: + type: string + description: role tagged to VM + + stark_flavor_name: + label: VMs flavor + description: The JSON map containing the nova Flavors to be used for the VM Servers + type: string + + stark_image_name: + type: string + description: "stark image name" + + stark_names: + type: comma_delimited_list + description: VM name for STARK VM 1 + + workload_context: + type: string + description: Workload Context for this VNF instance + + environment_context: + type: string + description: Environment Context for this VNF instance + + dummy_net_id: + type: string + description: nsdaljfnsak + + dummy_subnet_id: + type: string + description: nsdaljfnsak + + stark_dummy_ips: + type: comma_delimited_list + description: dsnafljsadnlfks + + stark_count: + type: number + description: njsdlf + + stark_dummy_floating_ip: + type: string + description: nfalsd + + stark_int_mummy_ips: + type: comma_delimited_list + description: nfdsa + + oam_net_fqdn: + type: string + description: ndfsakl + + oam2_net_fqdn: + type: string + description: nfkldas + + instance_ip_address: + type: string + description: nfsakdl + + mycontrailip: + type: string + description: nlfdsa + +resources: + + int_mummy_network: + type: OS::Neutron::Net + + int_mummy_subnet: + type: OS::Neutron::Subnet + properties: + network: { get_resource: int_mummy_network } + + stark_RG: + type: OS::Heat::ResourceGroup + properties: + count: { get_param: stark_count } + resource_def: + type: stark_nested.yaml + properties: + index: '%index%' + dummy_net_id: { get_param: dummy_net_id } + dummy_subnet_id: { get_param: dummy_subnet_id } + stark_dummy_ips: { get_param: stark_dummy_ips } + vnf_name: { get_param: vnf_name } + vnf_id: { get_param: vnf_id } + vf_module_id: { get_param: vf_module_id } + vf_module_name: { get_param: vf_module_name } + vm_role: { get_param: vm_role } + stark_flavor_name: { get_param: stark_flavor_name } + stark_image_name: { get_param: stark_image_name } + stark_names: { get_param: stark_names } + workload_context: { get_param: workload_context } + environment_context: { get_param: environment_context } + stark_volumes: { get_param: stark_volumes } + stark_dummy_floating_ip: { get_param: stark_dummy_floating_ip } + int_mummy_net_id: { get_resource: int_mummy_network } + int_mummy_subnet_id: { get_resource: int_mummy_subnet } + stark_int_mummy_ips: { get_param: stark_int_mummy_ips } + oam_net_fqdn: { get_param: oam_net_fqdn } + oam2_net_fqdn: { get_param: oam2_net_fqdn } + instance_ip_address: { get_param: instance_ip_address } + mycontrailip: { get_param: mycontrailip } diff --git a/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark_nested_volume.yaml b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark_nested_volume.yaml new file mode 100755 index 0000000..23a23fe --- /dev/null +++ b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark_nested_volume.yaml @@ -0,0 +1,49 @@ +heat_template_version: 2014-10-16 + +description: > + this is a test + +parameters: + + vnf_name: + type: string + label: VF name + description: Unique name for this VF instance. + + vf_module_id: + type: string + label: VF module id + description: VF module id + + vf_module_name: + type: string + label: VF module name + description: Unique name for this VF module instance. + + stark_volume_size: + type: number + label: stark cinder volume size + description: Size of the Cinder volume. Measured in gigabytes. + +resources: + + stark_volume_0: + type: OS::Cinder::Volume + properties: + name: + str_replace: + template: VNF_NAME_volume_0 + params: + VNF_NAME: {get_param: vnf_name} + metadata: + vnf_name: {get_param: vnf_name} + vf_module_id: { get_param: vf_module_id } + vf_module_name: { get_param: vf_module_name } + size: { get_param: stark_volume_size } + +outputs: + + stark_volume_0: + value: {get_resource: stark_volume_0} + description: test + diff --git a/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark_volume.env b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark_volume.env new file mode 100755 index 0000000..1df1e99 --- /dev/null +++ b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark_volume.env @@ -0,0 +1,4 @@ +parameters: + + stark_volume_size: 1 + count: 2
\ No newline at end of file diff --git a/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark_volume.yaml b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark_volume.yaml new file mode 100755 index 0000000..0273569 --- /dev/null +++ b/ice_validator/tests/fixtures/test_nested_parameters/pass/base_stark_volume.yaml @@ -0,0 +1,51 @@ +heat_template_version: 2014-10-16 + +description: > + this is a test + +parameters: + + count: + type: string + description: nsdkfla + + vnf_name: + type: string + label: VF name + description: Unique name for this VF instance. + + vf_module_id: + type: string + label: VF module id + description: VF module id + + vf_module_name: + type: string + label: VF module name + description: Unique name for this VF module instance. + + stark_volume_size: + type: number + label: stark cinder volume size + description: Size of the Cinder volume. Measured in gigabytes. + +resources: + + stark_volume_RG: + type: OS::Heat::ResourceGroup + properties: + count: { get_param: count } + resource_def: + type: base_stark_nested_volume.yaml + properties: + vnf_name: {get_param: vnf_name} + vf_module_id: { get_param: vf_module_id } + vf_module_name: { get_param: vf_module_name } + stark_volume_size: { get_param: stark_volume_size } + +outputs: + + stark_volumes: + value: { get_attr: [stark_volume_RG, stark_volume_0] } + description: test + diff --git a/ice_validator/tests/fixtures/test_nested_parameters/pass/heat_template.yaml b/ice_validator/tests/fixtures/test_nested_parameters/pass/heat_template.yaml deleted file mode 100644 index 0d4755b..0000000 --- a/ice_validator/tests/fixtures/test_nested_parameters/pass/heat_template.yaml +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf8 -*- -# ============LICENSE_START==================================================== -# org.onap.vvp/validation-scripts -# =================================================================== -# Copyright © 2019 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"); -# you may not use this software 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. -# -# -# -# Unless otherwise specified, all documentation contained herein is licensed -# 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 -# -# https://creativecommons.org/licenses/by/4.0/ -# -# Unless required by applicable law or agreed to in writing, documentation -# 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============================================ -# -# - -# VERSION = '1.0.0' - ---- -description: base - -parameters: - vm_type_volume_name_0: - type: string - vm_type_volume_size_0: - type: number - -resources: - server_0: - type: nested_template_1.yaml - properties: - name: { get_param: name } - my_resource_group_1: - type: OS::Heat::ResourceGroup - properties: - count: 5 - resource_def: { type: nested_template_good.yaml } - -outputs: - vm_type_volume_id_0: - value: {get_resource: vm_type_volume_0} diff --git a/ice_validator/tests/fixtures/test_nested_parameters/pass/nested_template_1.yaml b/ice_validator/tests/fixtures/test_nested_parameters/pass/nested_template_1.yaml deleted file mode 100644 index 5b626a2..0000000 --- a/ice_validator/tests/fixtures/test_nested_parameters/pass/nested_template_1.yaml +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf8 -*- -# ============LICENSE_START==================================================== -# org.onap.vvp/validation-scripts -# =================================================================== -# Copyright © 2017 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"); -# you may not use this software 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. -# -# -# -# Unless otherwise specified, all documentation contained herein is licensed -# 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 -# -# https://creativecommons.org/licenses/by/4.0/ -# -# Unless required by applicable law or agreed to in writing, documentation -# 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============================================ -# -# - -# VERSION = '1.0.0' - ---- -heat_template_version: 2013-05-23 - -resources: - volume: - type: OS::Cinder::Volume - properties: - size: 1 - - volume_attachment: - type: OS::Cinder::VolumeAttachment - properties: - volume_id: { get_resource: volume } - instance_uuid: { get_resource: instance } - - instance: - type: OS::Nova::Server - properties: - image: myimage - flavor: m1.small diff --git a/ice_validator/tests/fixtures/test_nested_parameters/pass/nested_template_good.yaml b/ice_validator/tests/fixtures/test_nested_parameters/pass/nested_template_good.yaml deleted file mode 100644 index 5b626a2..0000000 --- a/ice_validator/tests/fixtures/test_nested_parameters/pass/nested_template_good.yaml +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf8 -*- -# ============LICENSE_START==================================================== -# org.onap.vvp/validation-scripts -# =================================================================== -# Copyright © 2017 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"); -# you may not use this software 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. -# -# -# -# Unless otherwise specified, all documentation contained herein is licensed -# 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 -# -# https://creativecommons.org/licenses/by/4.0/ -# -# Unless required by applicable law or agreed to in writing, documentation -# 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============================================ -# -# - -# VERSION = '1.0.0' - ---- -heat_template_version: 2013-05-23 - -resources: - volume: - type: OS::Cinder::Volume - properties: - size: 1 - - volume_attachment: - type: OS::Cinder::VolumeAttachment - properties: - volume_id: { get_resource: volume } - instance_uuid: { get_resource: instance } - - instance: - type: OS::Nova::Server - properties: - image: myimage - flavor: m1.small diff --git a/ice_validator/tests/fixtures/test_nested_parameters/pass/stark_nested.yaml b/ice_validator/tests/fixtures/test_nested_parameters/pass/stark_nested.yaml new file mode 100755 index 0000000..b2ca936 --- /dev/null +++ b/ice_validator/tests/fixtures/test_nested_parameters/pass/stark_nested.yaml @@ -0,0 +1,170 @@ +heat_template_version: 2015-04-30 + +description: | + stark nested template + +parameters: + + stark_volumes: + type: comma_delimited_list + description: ndjsfka + + index: + type: number + description: nsadlf + + dummy_net_id: + type: string + description: nsdaljfnsak + + dummy_subnet_id: + type: string + description: nsdaljfnsak + + stark_dummy_ips: + type: comma_delimited_list + description: dsnafljsadnlfks + + vnf_name: + label: VNF name + description: this name will also be used on VM server and other resources. + type: string + + vnf_id: + label: VNF ID + description: 'This ID will be passed as metadata on all Nova Servers, Cinder Volumes, and any other resource that supports metadata' + type: string + + vf_module_id: + type: string + description: Unique ID for this VF Module instance + + vf_module_name: + type: string + description: Unique name for this VF Module instance + + vm_role: + type: string + description: role tagged to VM + + stark_flavor_name: + label: VMs flavor + description: The JSON map containing the nova Flavors to be used for the VM Servers + type: string + + stark_image_name: + type: string + description: "stark image name" + + stark_names: + type: comma_delimited_list + description: VM name for stark VM 1 + + workload_context: + type: string + description: Workload Context for this VNF instance + + environment_context: + type: string + description: Environment Context for this VNF instance + + stark_dummy_floating_ip: + type: string + description: Test floating IP test + + int_mummy_net_id: + type: string + description: Test floating IP test + + int_mummy_subnet_id: + type: string + description: Test floating IP test + + stark_int_mummy_ips: + type: comma_delimited_list + description: Test floating IP test + + oam_net_fqdn: + type: string + description: nsdaklfnsaklfsdl + + oam2_net_fqdn: + type: string + description: ndjfls + + instance_ip_address: + type: string + description: nsdlfkn + + mycontrailip: + type: string + description: njsaf + +resources: + + fw_0_oam_protected_vmi_0_IP_0: + type: OS::ContrailV2::InstanceIp + properties: + instance_ip_address: { get_param: instance_ip_address } + + fw_0_oam_vmi_0: + type: OS::ContrailV2::VirtualMachineInterface + properties: + virtual_network_refs: + - get_param: oam_net_fqdn + - get_param: oam2_net_fqdn + virtual_machine_interface_allowed_address_pairs: + { + virtual_machine_interface_allowed_address_pairs_allowed_address_pair: + [{ + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip: + { + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix: { get_param: mycontrailip }, + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix_len: "fasdfas", + }, + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_mac: "test123", + virtual_machine_interface_allowed_address_pairs_allowed_address_pair_address_mode: "asdfasdf", + }], + } + + stark_0_dummy_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: dummy_net_id } + fixed_ips: + - subnet: { get_param: dummy_subnet_id } + ip_address: { get_param: [stark_dummy_ips, { get_param: index }] } + allowed_address_pairs: + - ip_address: { get_param: stark_dummy_floating_ip } + + stark_0_int_mummy_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: int_mummy_net_id } + fixed_ips: + - subnet: { get_param: int_mummy_subnet_id } + ip_address: { get_param: [stark_int_mummy_ips, { get_param: index }] } + + stark_server_0: + type: OS::Nova::Server + properties: + name: { get_param: [stark_names, { get_param: index }] } + image: { get_param: stark_image_name} + flavor: { get_param: stark_flavor_name } + networks: + - port: { get_resource: stark_0_dummy_port_0 } + - port: { get_resource: stark_0_int_mummy_port_0 } + metadata: + vnf_id: {get_param: vnf_id} + vnf_name: {get_param: vnf_name} + vf_module_id: {get_param: vf_module_id} + vf_module_name: {get_param: vf_module_name} + vm_role: {get_param: vm_role} + workload_context: {get_param: workload_context } + environment_context: {get_param: environment_context } + + stark_volume_attachment_0: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: {get_resource: stark_server_0 } + volume_id: {get_param: [stark_volumes, { get_param: index }] } diff --git a/ice_validator/tests/helpers.py b/ice_validator/tests/helpers.py index 5744945..afa8672 100644 --- a/ice_validator/tests/helpers.py +++ b/ice_validator/tests/helpers.py @@ -307,3 +307,20 @@ def parameter_type_to_heat_type(parameter): parameter_type = None return parameter_type + + +def prop_iterator(resource, *props): + terminators = ["get_resource", "get_attr", "str_replace"] + if "properties" in resource: + resource = resource.get("properties") + props = list(props) + + if isinstance(resource, dict) and "get_param" in resource: + yield resource.get("get_param") + else: + prop = resource.get(props.pop(0)) + if isinstance(prop, list): + for x in prop: + yield from prop_iterator(x, *props) + elif isinstance(prop, dict) and not any(x for x in terminators if x in prop): + yield from prop_iterator(prop, *props) diff --git a/ice_validator/tests/test_nested_parameters.py b/ice_validator/tests/test_nested_parameters.py index 12b5768..2622044 100644 --- a/ice_validator/tests/test_nested_parameters.py +++ b/ice_validator/tests/test_nested_parameters.py @@ -42,13 +42,20 @@ import pytest from tests import cached_yaml as yaml from tests.structures import Resource -from .helpers import validates -from .utils.nested_iterables import is_pseudo_param +from .helpers import validates, prop_iterator +import os VERSION = "1.0.0" -def check_nested_parameter_doesnt_change(yaml_file): +def check_nested_parameter_doesnt_change(yaml_file, nresource_type, *nprops): + """ + yaml_file: input heat template + nresource_type: target resource type to look for in nested file + nprops: list of props to dig through to get to parameter + """ + base_dir, _ = os.path.split(yaml_file) + invalid_parameters = [] with open(yaml_file) as fh: yml = yaml.load(fh) @@ -57,22 +64,6 @@ def check_nested_parameter_doesnt_change(yaml_file): if "resources" not in yml: pytest.skip("No resources specified in the heat template") - invalid_parameters = [] - """ - checking if property: { get_param: parameter }, then property == parameter - - resource_id: - type: nested.yaml - properties: - property: { get_param: parameter } - - resource_id: - type: OS::Heat::ResourceGroup - properties: - resource_def: - properties: - property: { get_param: parameter } - """ for resource_id, resource in yml.get("resources", {}).items(): resource_type = resource.get("type") if resource_type and ( @@ -89,32 +80,188 @@ def check_nested_parameter_doesnt_change(yaml_file): r = Resource(resource_id=resource_id, resource=resource) properties = r.get_nested_properties() - for k1, v1 in properties.items(): - if isinstance(v1, dict) and "get_param" in v1: - parameter = v1.get("get_param") - if isinstance(parameter, list): - parameter = parameter[0] - - if is_pseudo_param(parameter): - continue - - if k1 != parameter: - invalid_parameters.append( - { - "resource": r.resource_id, - "nested parameter": k1, - "parameter": parameter, - "file": yaml_file, - } - ) - - assert ( - not invalid_parameters - ), "Invalid parameter name change detected in nested template {}".format( - invalid_parameters + resources = r.get_nested_yaml(base_dir).get("resources", {}) + for nrid, nresource_dict in resources.items(): # iterate through nested file until found target r type + + if ( + nresource_dict.get("type") + and nresource_dict.get("type") != nresource_type + ): + continue + + for nparam in prop_iterator(nresource_dict, *nprops): # get iterator of all target parameters + if nparam: # iterator yields None if parameter isn't found + for k1, v1 in properties.items(): # found nparam, now comparing to parent template + if isinstance(v1, dict) and "get_param" in v1: + parameter = v1.get("get_param") + # k1: nested resource parameter definition + # parameter: parent parameter name + # nparam: nested parameter name + + # resolve list params like [param, { get_param: index }] + if isinstance(nparam, list): + nparam = nparam[0] + if isinstance(parameter, list): + parameter = parameter[0] + + if k1 != nparam: # we only care about the parameter we found in nested template + continue + + if k1 != parameter: + msg = ( + "{} property {} cannot change when passed into " + "a nested template. Nested parameter change detected in " + "resource {}: parent parameter = {}, nested parameter = {}".format( + nresource_type, + nprops, + resource_id, + parameter, + nparam, + ) + ) + invalid_parameters.append(msg) + + assert not invalid_parameters, "\n".join(invalid_parameters) + + +# @validates("R-708564") +# def test_parameter_name_doesnt_change_in_nested_template(yaml_file): +# check_nested_parameter_doesnt_change(yaml_file) + +@validates("R-708564") +def test_server_name_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change(heat_template, "OS::Nova::Server", "name") + + +@validates("R-708564") +def test_server_image_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change(heat_template, "OS::Nova::Server", "image") + + +@validates("R-708564") +def test_server_flavor_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change(heat_template, "OS::Nova::Server", "flavor") + + +@validates("R-708564") +def test_server_metadata_vnf_id_parameter_name_doesnt_change_in_nested_template( + heat_template +): + check_nested_parameter_doesnt_change( + heat_template, "OS::Nova::Server", "metadata", "vnf_id" + ) + + +@validates("R-708564") +def test_server_metadata_vf_module_id_parameter_name_doesnt_change_in_nested_template( + heat_template +): + check_nested_parameter_doesnt_change( + heat_template, "OS::Nova::Server", "metadata", "vf_module_id" + ) + + +@validates("R-708564") +def test_server_metadata_vnf_name_parameter_name_doesnt_change_in_nested_template( + heat_template +): + check_nested_parameter_doesnt_change( + heat_template, "OS::Nova::Server", "metadata", "vnf_name" + ) + + +@validates("R-708564") +def test_server_metadata_vf_module_name_parameter_name_doesnt_change_in_nested_template( + heat_template +): + check_nested_parameter_doesnt_change( + heat_template, "OS::Nova::Server", "metadata", "vf_module_name" + ) + + +@validates("R-708564") +def test_server_metadata_vm_role_parameter_name_doesnt_change_in_nested_template( + heat_template +): + check_nested_parameter_doesnt_change( + heat_template, "OS::Nova::Server", "metadata", "vm_role" + ) + + +@validates("R-708564") +def test_server_metadata_vf_module_index_parameter_name_doesnt_change_in_nested_template( + heat_template +): + check_nested_parameter_doesnt_change( + heat_template, "OS::Nova::Server", "metadata", "vf_module_index" + ) + + +@validates("R-708564") +def test_server_metadata_workload_context_parameter_name_doesnt_change_in_nested_template( + heat_template +): + check_nested_parameter_doesnt_change( + heat_template, "OS::Nova::Server", "metadata", "workload_context" + ) + + +@validates("R-708564") +def test_server_metadata_environment_context_parameter_name_doesnt_change_in_nested_template( + heat_template +): + check_nested_parameter_doesnt_change( + heat_template, "OS::Nova::Server", "metadata", "environment_context" ) @validates("R-708564") -def test_parameter_name_doesnt_change_in_nested_template(yaml_file): - check_nested_parameter_doesnt_change(yaml_file) +def test_port_network_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change(heat_template, "OS::Neutron::Port", "network") + + +@validates("R-708564") +def test_port_fip_ip_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change( + heat_template, "OS::Neutron::Port", "fixed_ips", "ip_address" + ) + + +@validates("R-708564") +def test_port_fip_subnet_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change( + heat_template, "OS::Neutron::Port", "fixed_ips", "subnet" + ) + + +@validates("R-708564") +def test_port_aap_ip_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change( + heat_template, "OS::Neutron::Port", "allowed_address_pairs", "ip_address" + ) + + +@validates("R-708564") +def test_vmi_net_ref_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change( + heat_template, "OS::ContrailV2::VirtualMachineInterface", "virtual_network_refs" + ) + + +@validates("R-708564") +def test_vmi_aap_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change( + heat_template, + "OS::ContrailV2::VirtualMachineInterface", + "virtual_machine_interface_allowed_address_pairs", + "virtual_machine_interface_allowed_address_pairs_allowed_address_pair", + "virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip", + "virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix" + ) + + +@validates("R-708564") +def test_iip_instance_ip_parameter_name_doesnt_change_in_nested_template(heat_template): + check_nested_parameter_doesnt_change( + heat_template, "OS::ContrailV2::InstanceIp", "instance_ip_address" + ) |