aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/app_tests/preload_tests
diff options
context:
space:
mode:
authorLovett, Trevor <trevor.lovett@att.com>2019-08-27 12:40:36 -0500
committerLovett, Trevor (tl2972) <tl2972@att.com>2019-08-27 16:02:47 -0500
commit84db7f8f65cd0ec77f09cfde365599df9890ce6c (patch)
treeeadedec4cb5f0db131442a6e594a5b8c61ee50cf /ice_validator/app_tests/preload_tests
parentb1df832ae5ddaac6344b7ccf3f1f32a0bcfbdd67 (diff)
[VVP] Generated completed preload from env files
User can supply an optional directory containing .env files and/or CSAR VSP which can be used to generate populated preloads in the requested format. The nested directories can be used to create sub-environments that inherit their settings from the parent directories. Optionally, values can be specified in a defaults.yaml and they will be used if that value is not defined in the .env file. This is useful if the parameter name and value will be the same in all modules. Issue-ID: VVP-278 Change-Id: Icd9846c63463537793db908be8ce5dba13c4bda3 Signed-off-by: Lovett, Trevor <trevor.lovett@att.com>
Diffstat (limited to 'ice_validator/app_tests/preload_tests')
-rw-r--r--ice_validator/app_tests/preload_tests/__init__.py0
-rw-r--r--ice_validator/app_tests/preload_tests/preload_envs/base.env3
-rw-r--r--ice_validator/app_tests/preload_tests/preload_envs/defaults.yaml1
-rw-r--r--ice_validator/app_tests/preload_tests/preload_envs/env_one/base.env2
-rw-r--r--ice_validator/app_tests/preload_tests/preload_envs/env_one/env_one_a/base.env2
-rw-r--r--ice_validator/app_tests/preload_tests/preload_envs/env_three/defaults.yaml2
-rw-r--r--ice_validator/app_tests/preload_tests/preload_envs/env_three/service_Starkmultimodule243550_csar.csarbin0 -> 80814 bytes
-rw-r--r--ice_validator/app_tests/preload_tests/preload_envs/env_two/base.env2
-rw-r--r--ice_validator/app_tests/preload_tests/preload_envs/incremental.env2
-rw-r--r--ice_validator/app_tests/preload_tests/preload_envs/test.csarbin0 -> 117854 bytes
-rw-r--r--ice_validator/app_tests/preload_tests/sample_env/base.env39
-rw-r--r--ice_validator/app_tests/preload_tests/sample_heat/base.env15
-rw-r--r--ice_validator/app_tests/preload_tests/sample_heat/base.yaml376
-rw-r--r--ice_validator/app_tests/preload_tests/sample_heat/base_volume.env2
-rw-r--r--ice_validator/app_tests/preload_tests/sample_heat/base_volume.yaml47
-rw-r--r--ice_validator/app_tests/preload_tests/sample_heat/incremental.env11
-rw-r--r--ice_validator/app_tests/preload_tests/sample_heat/incremental.yaml156
-rw-r--r--ice_validator/app_tests/preload_tests/sample_heat/nested_svc.yaml84
-rw-r--r--ice_validator/app_tests/preload_tests/sample_heat/user.data0
-rw-r--r--ice_validator/app_tests/preload_tests/test_environment.py180
-rw-r--r--ice_validator/app_tests/preload_tests/test_grapi.py243
-rw-r--r--ice_validator/app_tests/preload_tests/test_vnfapi.py195
22 files changed, 1362 insertions, 0 deletions
diff --git a/ice_validator/app_tests/preload_tests/__init__.py b/ice_validator/app_tests/preload_tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/__init__.py
diff --git a/ice_validator/app_tests/preload_tests/preload_envs/base.env b/ice_validator/app_tests/preload_tests/preload_envs/base.env
new file mode 100644
index 0000000..9d38e4f
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/preload_envs/base.env
@@ -0,0 +1,3 @@
+parameters:
+ common: "ABC"
+ my_ip: default
diff --git a/ice_validator/app_tests/preload_tests/preload_envs/defaults.yaml b/ice_validator/app_tests/preload_tests/preload_envs/defaults.yaml
new file mode 100644
index 0000000..f4b1b59
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/preload_envs/defaults.yaml
@@ -0,0 +1 @@
+availability_zone_0: az0
diff --git a/ice_validator/app_tests/preload_tests/preload_envs/env_one/base.env b/ice_validator/app_tests/preload_tests/preload_envs/env_one/base.env
new file mode 100644
index 0000000..4135914
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/preload_envs/env_one/base.env
@@ -0,0 +1,2 @@
+parameters:
+ my_ip: 192.168.0.1
diff --git a/ice_validator/app_tests/preload_tests/preload_envs/env_one/env_one_a/base.env b/ice_validator/app_tests/preload_tests/preload_envs/env_one/env_one_a/base.env
new file mode 100644
index 0000000..d799d77
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/preload_envs/env_one/env_one_a/base.env
@@ -0,0 +1,2 @@
+parameters:
+ my_ip: 192.168.0.13
diff --git a/ice_validator/app_tests/preload_tests/preload_envs/env_three/defaults.yaml b/ice_validator/app_tests/preload_tests/preload_envs/env_three/defaults.yaml
new file mode 100644
index 0000000..5476931
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/preload_envs/env_three/defaults.yaml
@@ -0,0 +1,2 @@
+availability_zone_0: az0-b
+custom_env_3: default
diff --git a/ice_validator/app_tests/preload_tests/preload_envs/env_three/service_Starkmultimodule243550_csar.csar b/ice_validator/app_tests/preload_tests/preload_envs/env_three/service_Starkmultimodule243550_csar.csar
new file mode 100644
index 0000000..64ce556
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/preload_envs/env_three/service_Starkmultimodule243550_csar.csar
Binary files differ
diff --git a/ice_validator/app_tests/preload_tests/preload_envs/env_two/base.env b/ice_validator/app_tests/preload_tests/preload_envs/env_two/base.env
new file mode 100644
index 0000000..616e178
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/preload_envs/env_two/base.env
@@ -0,0 +1,2 @@
+parameters:
+ my_ip: 192.168.0.2
diff --git a/ice_validator/app_tests/preload_tests/preload_envs/incremental.env b/ice_validator/app_tests/preload_tests/preload_envs/incremental.env
new file mode 100644
index 0000000..97db79f
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/preload_envs/incremental.env
@@ -0,0 +1,2 @@
+parameters:
+ inc_property: "global"
diff --git a/ice_validator/app_tests/preload_tests/preload_envs/test.csar b/ice_validator/app_tests/preload_tests/preload_envs/test.csar
new file mode 100644
index 0000000..d23a746
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/preload_envs/test.csar
Binary files differ
diff --git a/ice_validator/app_tests/preload_tests/sample_env/base.env b/ice_validator/app_tests/preload_tests/sample_env/base.env
new file mode 100644
index 0000000..0650c68
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/sample_env/base.env
@@ -0,0 +1,39 @@
+# -*- 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============================================
+parameters:
+ availability_zone_0: az0
+ availability_zone_1: az1
diff --git a/ice_validator/app_tests/preload_tests/sample_heat/base.env b/ice_validator/app_tests/preload_tests/sample_heat/base.env
new file mode 100644
index 0000000..3784ea0
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/sample_heat/base.env
@@ -0,0 +1,15 @@
+parameters:
+
+ db_image_name: db_image
+
+ db_flavor_name: db_flavor
+
+ lb_image_name: lb_image
+
+ lb_flavor_name: lb_flavor
+
+ svc_image_name: svc_image
+
+ svc_flavor_name: svc_flavor
+
+ svc_count: 3 \ No newline at end of file
diff --git a/ice_validator/app_tests/preload_tests/sample_heat/base.yaml b/ice_validator/app_tests/preload_tests/sample_heat/base.yaml
new file mode 100644
index 0000000..327d2ee
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/sample_heat/base.yaml
@@ -0,0 +1,376 @@
+heat_template_version: 2015-04-30
+
+description: Base Module of Sample VNF
+
+parameters:
+
+ # ONAP Assigned Parameters
+ workload_context:
+ type: string
+ description: Unique ID for this VNF instance
+
+ environment_context:
+ type: string
+ description: Unique ID for this VNF instance
+
+ vnf_id:
+ type: string
+ description: Unique ID for this VNF instance
+
+ vf_module_id:
+ type: string
+ description: Unique ID for this VNF module instance
+
+ vf_module_index:
+ type: number
+ description: Index of this VF Module
+
+ vnf_name:
+ type: string
+ description: Unique name for this VNF instance
+
+
+ # Availability Zones
+ availability_zone_0:
+ type: string
+ description: Primary Availability Zone
+
+ availability_zone_1:
+ type: string
+ description: Secondary Availability Zone
+
+
+ # External Networks
+ oam_net_id:
+ type: string
+ description: Operations, Administration, and Management Network
+
+ oam_subnet_id:
+ type: string
+ description: Subnet for OAM Network
+
+ ha_net_id:
+ type: string
+ description: High Availability Network
+
+ ctrl_net_id:
+ type: string
+ description: Control Plane network
+
+ ctrl_subnet_id:
+ type: string
+ description: Subnet for High Availability Network
+
+
+ # Server Inputs: Database
+ db_name_0:
+ type: string
+ description: Primary DB Server Name
+
+ db_name_1:
+ type: string
+ description: Secondary DB
+
+ db_image_name:
+ type: string
+ description: Database VM Image Name
+
+ db_flavor_name:
+ type: string
+ description: Database VM Flavor Name
+
+ db_ha_floating_v6_ip:
+ type: string
+ description: Database Floating IPv6 Address for HA
+
+ db_ha_floating_ip:
+ type: string
+ description: Database Floating IPv4 Address for HA
+
+ db_oam_ip_0:
+ type: string
+ description: Fixed IPv4 Address for OAM
+
+ db_oam_ip_1:
+ type: string
+ description: Fixed IPv4 Address for OAM
+
+ db_vol0_id:
+ type: string
+ description: Volume ID for DB in AZ 0
+
+ db_vol1_id:
+ type: string
+ description: Volume ID for DB in AZ 1
+
+
+ # Server Inputs: Loadbalancer
+ lb_name_0:
+ type: string
+ description: Load Balancer Name
+
+ lb_image_name:
+ type: string
+ description: Loadbalancer VM Image
+
+ lb_flavor_name:
+ type: string
+ description: Loadbalancer VM Flavor
+
+ lb_ha_floating_ip:
+ type: string
+ description: Floating HA IP for LB
+
+
+ lb_ha_floating_v6_ip:
+ type: string
+ description: Floating HA IP for LB
+
+
+ # Server Inputs: Webservice Controller Plane Interface (mgmt)
+ mgmt_name_0:
+ type: string
+ description: List of Management VM Names
+
+ mgmt_image_name:
+ type: string
+ description: Management VM Image
+
+ mgmt_flavor_name:
+ type: string
+ description: Management VM Flavor
+
+ mgmt_ctrl_ip_0:
+ type: string
+ description: IP to web service for control plane
+
+ mgmt_ctrl_v6_ip_0:
+ type: string
+ description: IP to web service for control plane
+
+
+ # Server Inputs: Services
+ svc_names:
+ type: comma_delimited_list
+ description: Service VM Names
+
+ svc_image_name:
+ type: string
+ description: Service VM Image
+
+ svc_flavor_name:
+ type: string
+ description: Service VM Flavor
+
+ svc_count:
+ type: number
+ description: Number of instances of Service to create
+
+resources:
+
+ int_private_network:
+ type: OS::Neutron::Net
+
+ int_private_subnet:
+ type: OS::Neutron::Subnet
+ properties:
+ name:
+ str_replace:
+ template: $VNF_NAME-private_subnet
+ params:
+ $VNF_NAME: { get_param: vnf_name }
+ network: { get_resource: int_private_network }
+
+ db_server_0:
+ type: OS::Nova::Server
+ properties:
+ image: { get_param: db_image_name }
+ flavor: { get_param: db_flavor_name }
+ name: { get_param: db_name_0 }
+ metadata:
+ vnf_id: { get_param: vnf_id }
+ vf_module_id: { get_param: vf_module_id }
+ vf_module_index: { get_param: vf_module_index }
+ vnf_name: { get_param: vnf_name }
+ workload_context: { get_param: workload_context }
+ environment_context: { get_param: environment_context }
+ networks:
+ - port: { get_resource: db_0_int_private_port_0 }
+ - port: { get_resource: db_0_ha_port_0 }
+ - port: { get_resource: db_0_oam_port_0 }
+ user_data: { get_file: user.data }
+ availability_zone: { get_param: availability_zone_0 }
+
+ db_server_1:
+ type: OS::Nova::Server
+ properties:
+ image: { get_param: db_image_name }
+ flavor: { get_param: db_flavor_name }
+ name: { get_param: db_name_1 }
+ metadata:
+ vnf_id: { get_param: vnf_id}
+ vf_module_id: { get_param: vf_module_id }
+ vnf_name: { get_param: vnf_name }
+ workload_context: { get_param: workload_context }
+ environment_context: { get_param: environment_context }
+ networks:
+ - port: {get_resource: db_1_int_private_port_0}
+ - port: {get_resource: db_1_ha_port_0}
+ - port: { get_resource: db_1_oam_port_0 }
+ availability_zone: { get_param: availability_zone_1 }
+
+ db_0_oam_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_param: oam_net_id }
+ fixed_ips:
+ - subnet_id: { get_param: oam_subnet_id }
+ ip_address: { get_param: db_oam_ip_0 }
+
+ db_0_ha_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_param: ha_net_id }
+ allowed_address_pairs:
+ - ip_address: {get_param: db_ha_floating_ip }
+ - ip_address: {get_param: db_ha_floating_v6_ip }
+
+ db_0_int_private_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_resource: int_private_network }
+ fixed_ips:
+ - subnet_id: { get_resource: int_private_subnet }
+
+ db_1_oam_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_param: oam_net_id }
+ fixed_ips:
+ - subnet_id: { get_param: oam_subnet_id }
+ ip_address: { get_param: db_oam_ip_1 }
+
+ db_1_ha_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_param: ha_net_id }
+ allowed_address_pairs:
+ - ip_address: {get_param: db_ha_floating_ip }
+ - ip_address: {get_param: db_ha_floating_v6_ip }
+
+ db_1_int_private_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_resource: int_private_network }
+ fixed_ips:
+ - subnet_id: { get_resource: int_private_subnet }
+
+
+ db_volume_attachment_0:
+ type: OS::Cinder::VolumeAttachment
+ properties:
+ volume_id: { get_param: db_vol0_id }
+ server: { get_resource: db_server_0 }
+
+ db_volume_attachment_1:
+ type: OS::Cinder::VolumeAttachment
+ properties:
+ volume_id: { get_param: db_vol1_id }
+ server: { get_resource: db_server_1 }
+
+ mgmt_server_0:
+ type: OS::Nova::Server
+ properties:
+ image: { get_param: mgmt_image_name }
+ flavor: { get_param: mgmt_flavor_name }
+ name: { get_param: mgmt_name_0 }
+ metadata:
+ vnf_id: { get_param: vnf_id }
+ vf_module_id: { get_param: vf_module_id }
+ vf_module_index: { get_param: vf_module_index }
+ vnf_name: { get_param: vnf_name }
+ workload_context: { get_param: workload_context }
+ environment_context: { get_param: environment_context }
+ networks:
+ - port: { get_resource: mgmt_0_int_private_port_0 }
+ - port: { get_resource: mgmt_0_ctrl_port_0 }
+ user_data: { get_file: user.data }
+ availability_zone: { get_param: availability_zone_0 }
+
+ mgmt_0_int_private_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_resource: int_private_network }
+ fixed_ips:
+ - subnet_id: { get_resource: int_private_subnet }
+
+ mgmt_0_ctrl_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_param: ctrl_net_id }
+ fixed_ips:
+ - subnet: { get_param: ctrl_subnet_id }
+ - ip_address: { get_param: mgmt_ctrl_ip_0 }
+ - ip_address: { get_param: mgmt_ctrl_v6_ip_0}
+
+ lb_server_0:
+ type: OS::Nova::Server
+ properties:
+ image: { get_param: lb_image_name }
+ flavor: { get_param: lb_flavor_name }
+ name: { get_param: lb_name_0 }
+ metadata:
+ vnf_id: { get_param: vnf_id }
+ vf_module_id: { get_param: vf_module_id }
+ vf_module_index: { get_param: vf_module_index }
+ vnf_name: { get_param: vnf_name }
+ workload_context: { get_param: workload_context }
+ environment_context: { get_param: environment_context }
+ networks:
+ - port: { get_resource: lb_0_int_private_port_0 }
+ - port: { get_resource: lb_0_ha_port_0 }
+ user_data: { get_file: user.data }
+ availability_zone: { get_param: availability_zone_0 }
+
+ lb_0_ha_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_param: ha_net_id }
+ allowed_address_pairs:
+ - ip_address: {get_param: lb_ha_floating_ip }
+ - ip_address: {get_param: lb_ha_floating_v6_ip }
+
+ lb_0_int_private_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_resource: int_private_network }
+ fixed_ips:
+ - subnet_id: { get_resource: int_private_subnet }
+
+ svc_resource_group_0:
+ type: OS::Heat::ResourceGroup
+ properties:
+ count: { get_param: svc_count }
+ resource_def:
+ type: nested_svc.yaml
+ properties:
+ workload_context: {get_param: workload_context}
+ environment_context: {get_param: environment_context}
+ vnf_id: {get_param: vnf_id}
+ vf_module_id: {get_param: vf_module_id}
+ vnf_name: {get_param: vnf_name}
+ availability_zone_0: {get_param: availability_zone_0}
+ svc_names: {get_param: svc_names}
+ svc_image_name: {get_param: svc_image_name}
+ svc_flavor_name: {get_param: svc_flavor_name}
+ index: "%index%"
+ int_private_net_id: {get_resource: int_private_network}
+ int_private_subnet_id: {get_resource: int_private_subnet}
+
+outputs:
+
+ int_private_subnet_id:
+ value: { get_resource: int_private_subnet }
+
+ int_private_net_id:
+ value: { get_resource: int_private_network }
diff --git a/ice_validator/app_tests/preload_tests/sample_heat/base_volume.env b/ice_validator/app_tests/preload_tests/sample_heat/base_volume.env
new file mode 100644
index 0000000..a6468ad
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/sample_heat/base_volume.env
@@ -0,0 +1,2 @@
+parameters:
+ volume_size: 10 \ No newline at end of file
diff --git a/ice_validator/app_tests/preload_tests/sample_heat/base_volume.yaml b/ice_validator/app_tests/preload_tests/sample_heat/base_volume.yaml
new file mode 100644
index 0000000..4d47766
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/sample_heat/base_volume.yaml
@@ -0,0 +1,47 @@
+heat_template_version: '2013-05-23'
+
+description: nsadkfl
+
+parameters:
+
+ vnf_name:
+ type: string
+ label: VF name
+ description: Unique name for this VF instance.
+
+ volume_size:
+ type: number
+ description: Size in GB
+ constraints:
+ - range: { min: 100, max: 400 }
+
+resources:
+
+ db_vol0:
+ type: OS::Cinder::Volume
+ properties:
+ name:
+ str_replace:
+ template: VNF_NAME_db_vol0
+ params:
+ VNF_NAME: {get_param: vnf_name}
+ volume_type: "solidfire"
+ volume_size: { get_param: volume_size }
+
+ db_vol1:
+ type: OS::Cinder::Volume
+ properties:
+ name:
+ str_replace:
+ template: VNF_NAME_db_vol1
+ params:
+ VNF_NAME: {get_param: vnf_name}
+ volume_type: "solidfire"
+ volume_size: { get_param: volume_size }
+
+outputs:
+ db_vol0_id:
+ value: { get_resource: db_vol0 }
+
+ db_vol1_id:
+ value: { get_resource: db_vol1 }
diff --git a/ice_validator/app_tests/preload_tests/sample_heat/incremental.env b/ice_validator/app_tests/preload_tests/sample_heat/incremental.env
new file mode 100644
index 0000000..f6ff1a0
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/sample_heat/incremental.env
@@ -0,0 +1,11 @@
+parameters:
+
+ lb_image_name: lb_image
+
+ lb_flavor_name: lb_flavor
+
+ svc_image_name: svc_image
+
+ svc_flavor_name: svc_flavor
+
+ svc_count: 3 \ No newline at end of file
diff --git a/ice_validator/app_tests/preload_tests/sample_heat/incremental.yaml b/ice_validator/app_tests/preload_tests/sample_heat/incremental.yaml
new file mode 100644
index 0000000..1460149
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/sample_heat/incremental.yaml
@@ -0,0 +1,156 @@
+heat_template_version: 2015-04-30
+
+description: Base Module of Sample VNF
+
+parameters:
+
+ # ONAP Assigned Parameters
+ workload_context:
+ type: string
+ description: Unique ID for this VNF instance
+
+ environment_context:
+ type: string
+ description: Unique ID for this VNF instance
+
+ vnf_id:
+ type: string
+ description: Unique ID for this VNF instance
+
+ vf_module_id:
+ type: string
+ description: Unique ID for this VNF module instance
+
+ vf_module_index:
+ type: number
+ description: Index of this VF Module
+
+ vnf_name:
+ type: string
+ description: Unique name for this VNF instance
+
+
+ # Availability Zones
+ availability_zone_0:
+ type: string
+ description: Primary Availability Zone
+
+
+ # External Networks
+ ha_net_id:
+ type: string
+ description: High Availability Network
+
+ int_private_net_id:
+ type: string
+ description: Private network
+
+ int_private_subnet_id:
+ type: string
+ description: Private network subnet
+
+ # Server Inputs: Loadbalancer
+ lb_names:
+ type: comma_delimited_list
+ description: Load Balancer Names
+
+ lb_image_name:
+ type: string
+ description: Loadbalancer VM Image
+
+ lb_flavor_name:
+ type: string
+ description: Loadbalancer VM Flavor
+
+ lb_ha_floating_ip:
+ type: string
+ description: Floating HA IP for LB
+
+ lb_ha_floating_v6_ip:
+ type: string
+ description: Floating HA IP for LB
+
+ # Server Inputs: Services
+ svc_0_names:
+ type: comma_delimited_list
+ description: Service VM Names
+
+ svc_1_names:
+ type: comma_delimited_list
+ description: Service VM Names
+
+ svc_2_names:
+ type: comma_delimited_list
+ description: Service VM Names
+
+ svc_image_name:
+ type: string
+ description: Service VM Image
+
+ svc_flavor_name:
+ type: string
+ description: Service VM Flavor
+
+ svc_count:
+ type: number
+ description: Number of instances of Service to create
+
+resources:
+
+
+ lb_server_1:
+ type: OS::Nova::Server
+ properties:
+ image: { get_param: lb_image_name }
+ flavor: { get_param: lb_flavor_name }
+ name: { get_param: [lb_names, {get_param: vf_module_index}] }
+ metadata:
+ vnf_id: { get_param: vnf_id }
+ vf_module_id: { get_param: vf_module_id }
+ vf_module_index: { get_param: vf_module_index }
+ vnf_name: { get_param: vnf_name }
+ workload_context: { get_param: workload_context }
+ environment_context: { get_param: environment_context }
+ networks:
+ - port: { get_resource: lb_1_int_private_port_0 }
+ - port: { get_resource: lb_1_ha_port_0 }
+ user_data: { get_file: user.data }
+ availability_zone: { get_param: availability_zone_0 }
+
+ lb_1_ha_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_param: ha_net_id }
+ allowed_address_pairs:
+ - ip_address: {get_param: lb_ha_floating_ip }
+ - ip_address: {get_param: lb_ha_floating_v6_ip }
+
+ lb_1_int_private_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_param: int_private_net_id }
+ fixed_ips:
+ - subnet_id: { get_param: int_private_subnet_id }
+
+ svc_resource_group_1:
+ type: OS::Heat::ResourceGroup
+ properties:
+ count: { get_param: svc_count }
+ resource_def:
+ type: nested_svc.yaml
+ properties:
+ workload_context: {get_param: workload_context}
+ environment_context: {get_param: environment_context}
+ vnf_id: {get_param: vnf_id}
+ vf_module_id: {get_param: vf_module_id}
+ vnf_name: {get_param: vnf_name}
+ availability_zone_0: {get_param: availability_zone_0}
+ svc_names:
+ - {get_param: [svc_0_names, {get_param: vf_module_index}]}
+ - {get_param: [svc_1_names, {get_param: vf_module_index}]}
+ - {get_param: [svc_2_names, {get_param: vf_module_index}]}
+ svc_image_name: {get_param: svc_image_name}
+ svc_flavor_name: {get_param: svc_flavor_name}
+ int_private_net_id: {get_param: int_private_net_id}
+ int_private_subnet_id: {get_param: int_private_subnet_id}
+ index: "%index%"
diff --git a/ice_validator/app_tests/preload_tests/sample_heat/nested_svc.yaml b/ice_validator/app_tests/preload_tests/sample_heat/nested_svc.yaml
new file mode 100644
index 0000000..2de4656
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/sample_heat/nested_svc.yaml
@@ -0,0 +1,84 @@
+heat_template_version: 2015-04-30
+
+description: Base Module of Sample VNF
+
+parameters:
+
+ # ONAP Assigned Parameters
+ workload_context:
+ type: string
+ description: Unique ID for this VNF instance
+
+ environment_context:
+ type: string
+ description: Unique ID for this VNF instance
+
+ vnf_id:
+ type: string
+ description: Unique ID for this VNF instance
+
+ vf_module_id:
+ type: string
+ description: Unique ID for this VNF module instance
+
+
+ vnf_name:
+ type: string
+ description: Unique name for this VNF instance
+
+
+ # Availability Zones
+ availability_zone_0:
+ type: string
+ description: Primary Availability Zone
+
+
+ # Server Inputs: Services
+ svc_names:
+ type: comma_delimited_list
+ description: Service VM Names
+
+ svc_image_name:
+ type: string
+ description: Service VM Image
+
+ svc_flavor_name:
+ type: string
+ description: Service VM Flavor
+
+ index:
+ type: number
+ description: Number of services to create
+
+ int_private_net_id:
+ type: string
+ description: Network ID of internal private network
+
+ int_private_subnet_id:
+ type: string
+ description: Subnet ID of internal private network
+
+resources:
+
+ svc_server_0:
+ type: OS::Nova::Server
+ properties:
+ image: { get_param: svc_image_name }
+ flavor: { get_param: svc_flavor_name }
+ name: { get_param: [svc_names, {get_param: index}] }
+ metadata:
+ vnf_id: { get_param: vnf_id }
+ vf_module_id: { get_param: vf_module_id }
+ vnf_name: { get_param: vnf_name }
+ workload_context: { get_param: workload_context }
+ environment_context: { get_param: environment_context }
+ networks:
+ - port: {get_resource: svc_0_int_private_port_0}
+ availability_zone: { get_param: availability_zone_0 }
+
+ svc_0_int_private_port_0:
+ type: OS::Neutron::Port
+ properties:
+ network: { get_param: int_private_net_id }
+ fixed_ips:
+ - subnet: { get_param: int_private_subnet_id }
diff --git a/ice_validator/app_tests/preload_tests/sample_heat/user.data b/ice_validator/app_tests/preload_tests/sample_heat/user.data
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/sample_heat/user.data
diff --git a/ice_validator/app_tests/preload_tests/test_environment.py b/ice_validator/app_tests/preload_tests/test_environment.py
new file mode 100644
index 0000000..b627b4b
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/test_environment.py
@@ -0,0 +1,180 @@
+# -*- 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============================================
+from pathlib import Path
+
+import pytest
+
+from preload.environment import CloudServiceArchive, PreloadEnvironment
+
+THIS_DIR = Path(__file__).parent
+PRELOAD_ENV_DIR = THIS_DIR / "preload_envs"
+
+
+@pytest.fixture(scope="session")
+def csar():
+ return CloudServiceArchive(PRELOAD_ENV_DIR / "test.csar")
+
+
+@pytest.fixture(scope="session")
+def env():
+ return PreloadEnvironment(PRELOAD_ENV_DIR)
+
+
+def test_csar_service_name(csar):
+ assert csar.service_name == "stark_vccf_svc"
+
+
+def test_csar_str_and_repr(csar):
+ assert str(csar) == "CSAR (path=test.csar, name=stark_vccf_svc)"
+ assert repr(csar) == "CSAR (path=test.csar, name=stark_vccf_svc)"
+
+
+def test_csar_vf_module_model_name(csar):
+ assert (
+ csar.get_vf_module_model_name("base_vIECCF")
+ == "StarkVccfVf..base_vIECCF..module-0"
+ )
+
+
+def test_csar_get_vf_module_resource_name(csar):
+ assert csar.get_vf_module_resource_name("base_vIECCF") == "stark_vccf_vf"
+
+
+def test_csar_get_vf_module_resource_name_not_found(csar):
+ assert csar.get_vf_module_resource_name("unknown") is None
+
+
+def test_preload_environment_global_csar(env):
+ assert env.csar.service_name == "stark_vccf_svc"
+
+
+def test_preload_environment_nest_env_csar_inherit(env):
+ env_two = env.get_environment("env_two")
+ assert env_two.csar.service_name == "stark_vccf_svc"
+
+
+def test_preload_environment_nest_env_csar_override(env):
+ sub_env = env.get_environment("env_three")
+ assert sub_env.csar.service_name == "StarkMultiModule2_43550"
+
+
+def test_preload_environment_environments(env):
+ names = {e.name for e in env.environments}
+ assert names == {"env_two", "env_three", "env_one_a"}
+
+
+def test_preload_environment_environments_nested(env):
+ env_one = env.get_environment("env_one")
+ names = {e.name for e in env_one.environments}
+ assert names == {"env_one_a"}
+
+
+def test_preload_environment_get_module_global_base(env):
+ module = env.get_module("base")
+ assert module["my_ip"] == "default"
+
+
+def test_preload_environment_get_module_global_not_found(env):
+ module = env.get_module("unknown")
+ assert module == {}
+
+
+def test_preload_environment_get_module_sub_env(env):
+ env_two = env.get_environment("env_two")
+ module = env_two.get_module("base")
+ assert module["my_ip"] == "192.168.0.2"
+ assert module["common"] == "ABC"
+
+
+def test_preload_environment_module_names(env):
+ expected = {"base.env", "incremental.env"}
+ assert env.module_names == expected
+ # check a nested env with inherits all modules
+ assert env.get_environment("env_three").module_names == expected
+
+
+def test_preload_environment_modules(env):
+ modules = env.modules
+ assert isinstance(modules, dict)
+ assert modules.keys() == {"base.env", "incremental.env"}
+ assert all(isinstance(val, dict) for val in modules.values())
+
+
+def test_preload_environment_is_base(env):
+ assert env.is_base
+ assert not env.get_environment("env_one").is_base
+
+
+def test_preload_environment_is_leaf(env):
+ assert not env.is_leaf
+ assert env.get_environment("env_two").is_leaf
+ assert not env.get_environment("env_one").is_leaf
+ assert env.get_environment("env_one_a").is_leaf
+
+
+def test_preload_environment_str_repr(env):
+ assert str(env) == "PreloadEnvironment(name=preload_envs)"
+ assert repr(env) == "PreloadEnvironment(name=preload_envs)"
+
+
+def test_preload_environment_defaults(env):
+ expected = {"availability_zone_0": "az0"}
+ assert env.defaults == expected
+ assert env.get_environment("env_one_a").defaults == expected
+
+
+def test_preload_environment_defaults_merging_and_override(env):
+ assert env.get_environment("env_three").defaults == {
+ "availability_zone_0": "az0-b",
+ "custom_env_3": "default",
+ }
+
+
+def test_preload_environment_defaults_in_module_env(env):
+ mod = env.get_environment("env_three").get_module("base")
+ assert mod == {
+ "availability_zone_0": "az0-b",
+ "common": "ABC",
+ "custom_env_3": "default",
+ "my_ip": "default",
+ }
+ mod = env.get_environment("env_one").get_module("base")
+ assert mod == {
+ "availability_zone_0": "az0",
+ "common": "ABC",
+ "my_ip": "192.168.0.1",
+ }
diff --git a/ice_validator/app_tests/preload_tests/test_grapi.py b/ice_validator/app_tests/preload_tests/test_grapi.py
new file mode 100644
index 0000000..7b56440
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/test_grapi.py
@@ -0,0 +1,243 @@
+# -*- 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============================================
+import json
+import tempfile
+from pathlib import Path
+from shutil import rmtree
+
+import pytest
+
+from preload.environment import PreloadEnvironment
+from preload.model import Vnf, get_heat_templates
+from preload_grapi import GrApiPreloadGenerator
+from tests.helpers import first
+
+THIS_DIR = Path(__file__).parent
+SAMPLE_HEAT_DIR = THIS_DIR / "sample_heat"
+
+
+def load_json(path):
+ with path.open("r") as f:
+ return json.load(f)
+
+
+def load_module(base_dir, name):
+ path = Path(str(base_dir / "grapi" / name))
+ assert path.exists(), "{} does not exist".format(path)
+ return load_json(path)
+
+
+@pytest.fixture(scope="session")
+def session_dir(request):
+ # Temporary directory that gets deleted at the session
+ # pytest tmpdir doesn't support a non-function scoped temporary directory
+ session_dir = Path(tempfile.mkdtemp())
+ request.addfinalizer(lambda: rmtree(session_dir))
+ return session_dir
+
+
+@pytest.fixture(scope="session")
+def preload(pytestconfig, session_dir):
+ # Generate the preloads for testing
+ def fake_getoption(opt, default=None):
+ return [SAMPLE_HEAT_DIR.as_posix()] if opt == "template_dir" else None
+
+ pytestconfig.getoption = fake_getoption
+ templates = get_heat_templates(pytestconfig)
+ env = PreloadEnvironment(THIS_DIR / "sample_env")
+ vnf = Vnf(templates)
+ generator = GrApiPreloadGenerator(vnf, session_dir, env)
+ generator.generate()
+ return session_dir
+
+
+@pytest.fixture(scope="session")
+def base(preload):
+ return load_module(preload, "base.json")
+
+
+@pytest.fixture(scope="session")
+def incremental(preload):
+ return load_module(preload, "incremental.json")
+
+
+def test_base_fields(base):
+ data = base["input"]["preload-vf-module-topology-information"][
+ "vnf-topology-identifier-structure"
+ ]
+ assert data["vnf-name"] == "VALUE FOR: vnf_name"
+ assert "<Service Name>/<VF Instance Name>" in data["vnf-type"]
+
+
+def test_base_azs(base):
+ az = base["input"]["preload-vf-module-topology-information"][
+ "vnf-resource-assignments"
+ ]["availability-zones"]["availability-zone"]
+ assert isinstance(az, list)
+ assert len(az) == 2
+ assert az[0] == "VALUE FOR: availability_zone_0"
+
+
+def test_base_networks(base):
+ nets = base["input"]["preload-vf-module-topology-information"][
+ "vnf-resource-assignments"
+ ]["vnf-networks"]["vnf-network"]
+ assert isinstance(nets, list)
+ assert len(nets) == 3
+ oam = first(nets, lambda n: n["network-role"] == "oam")
+ assert oam == {
+ "network-role": "oam",
+ "network-name": "VALUE FOR: network name of oam_net_id",
+ "subnets-data": {"subnet-data": [{"subnet-id": "VALUE FOR: oam_subnet_id"}]},
+ }
+
+
+def test_base_vm_types(base):
+ vms = base["input"]["preload-vf-module-topology-information"]["vf-module-topology"][
+ "vf-module-assignments"
+ ]["vms"]["vm"]
+ vm_types = {vm["vm-type"] for vm in vms}
+ assert vm_types == {"db", "svc", "mgmt", "lb"}
+ db = first(vms, lambda v: v["vm-type"] == "db")
+ assert db == {
+ "vm-type": "db",
+ "vm-count": 2,
+ "vm-names": {"vm-name": ["VALUE FOR: db_name_0", "VALUE FOR: db_name_1"]},
+ "vm-networks": {
+ "vm-network": [
+ {
+ "network-role": "oam",
+ "network-information-items": {
+ "network-information-item": [
+ {
+ "ip-version": "4",
+ "use-dhcp": "N",
+ "ip-count": 2,
+ "network-ips": {
+ "network-ip": [
+ "VALUE FOR: db_oam_ip_0",
+ "VALUE FOR: db_oam_ip_1",
+ ]
+ },
+ },
+ {
+ "ip-version": "6",
+ "use-dhcp": "N",
+ "ip-count": 0,
+ "network-ips": {"network-ip": []},
+ },
+ ]
+ },
+ "mac-addresses": {"mac-address": []},
+ "floating-ips": {"floating-ip-v4": [], "floating-ip-v6": []},
+ "interface-route-prefixes": {"interface-route-prefix": []},
+ },
+ {
+ "network-role": "ha",
+ "network-information-items": {
+ "network-information-item": [
+ {
+ "ip-version": "4",
+ "use-dhcp": "N",
+ "ip-count": 0,
+ "network-ips": {"network-ip": []},
+ },
+ {
+ "ip-version": "6",
+ "use-dhcp": "N",
+ "ip-count": 0,
+ "network-ips": {"network-ip": []},
+ },
+ ]
+ },
+ "mac-addresses": {"mac-address": []},
+ "floating-ips": {
+ "floating-ip-v4": ["VALUE FOR: db_ha_floating_ip"],
+ "floating-ip-v6": ["VALUE FOR: db_ha_floating_v6_ip"],
+ },
+ "interface-route-prefixes": {"interface-route-prefix": []},
+ },
+ ]
+ },
+ }
+
+
+def test_base_general(base):
+ general = base["input"]["preload-vf-module-topology-information"][
+ "vf-module-topology"
+ ]["vf-module-topology-identifier"]
+ assert (
+ general["vf-module-type"] == "VALUE FOR: <vfModuleModelName> from CSAR or SDC"
+ )
+ assert general["vf-module-name"] == "VALUE FOR: vf_module_name"
+
+
+def test_base_parameters(base):
+ params = base["input"]["preload-vf-module-topology-information"][
+ "vf-module-topology"
+ ]["vf-module-parameters"]["param"]
+ assert params == [
+ {"name": "svc_image_name", "value": "svc_image"},
+ {"name": "svc_flavor_name", "value": "svc_flavor"},
+ ]
+
+
+def test_incremental(incremental):
+ az = incremental["input"]["preload-vf-module-topology-information"][
+ "vnf-resource-assignments"
+ ]["availability-zones"]["availability-zone"]
+ assert isinstance(az, list)
+ assert len(az) == 1
+ assert az[0] == "VALUE FOR: availability_zone_0"
+
+
+def test_incremental_networks(incremental):
+ nets = incremental["input"]["preload-vf-module-topology-information"][
+ "vnf-resource-assignments"
+ ]["vnf-networks"]["vnf-network"]
+ assert isinstance(nets, list)
+ assert len(nets) == 1
+ assert nets[0]["network-role"] == "ha"
+
+
+def test_preload_env_population(preload):
+ base_path = THIS_DIR / "sample_env/preloads/grapi/base.json"
+ data = load_json(base_path)
+ azs = data["input"]["preload-vf-module-topology-information"][
+ "vnf-resource-assignments"
+ ]["availability-zones"]["availability-zone"]
+ assert azs == ["az0", "az1"]
diff --git a/ice_validator/app_tests/preload_tests/test_vnfapi.py b/ice_validator/app_tests/preload_tests/test_vnfapi.py
new file mode 100644
index 0000000..5732335
--- /dev/null
+++ b/ice_validator/app_tests/preload_tests/test_vnfapi.py
@@ -0,0 +1,195 @@
+# -*- 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============================================
+import tempfile
+from pathlib import Path
+from shutil import rmtree
+
+import pytest
+
+from app_tests.preload_tests.test_grapi import load_json
+from preload.environment import PreloadEnvironment
+from preload.model import Vnf, get_heat_templates
+from preload_vnfapi import VnfApiPreloadGenerator
+from tests.helpers import load_yaml, first
+
+THIS_DIR = Path(__file__).parent
+SAMPLE_HEAT_DIR = THIS_DIR / "sample_heat"
+
+
+def load_module(base_dir, name):
+ path = Path(str(base_dir / "vnfapi" / name))
+ assert path.exists(), "{} does not exist".format(path)
+ return load_yaml(str(path))
+
+
+@pytest.fixture(scope="session")
+def session_dir(request):
+ # Temporary directory that gets deleted at the session
+ # pytest tmpdir doesn't support a non-function scoped temporary directory
+ session_dir = Path(tempfile.mkdtemp())
+ request.addfinalizer(lambda: rmtree(session_dir))
+ return session_dir
+
+
+@pytest.fixture(scope="session")
+def preload(pytestconfig, session_dir):
+ # Generate the preloads for testing
+ def fake_getoption(opt, default=None):
+ return [SAMPLE_HEAT_DIR.as_posix()] if opt == "template_dir" else None
+
+ pytestconfig.getoption = fake_getoption
+ templates = get_heat_templates(pytestconfig)
+ vnf = Vnf(templates)
+ preload_env = PreloadEnvironment(THIS_DIR / "sample_env")
+ generator = VnfApiPreloadGenerator(vnf, session_dir, preload_env)
+ generator.generate()
+ return session_dir
+
+
+@pytest.fixture(scope="session")
+def base(preload):
+ return load_module(preload, "base.json")
+
+
+@pytest.fixture(scope="session")
+def incremental(preload):
+ return load_module(preload, "incremental.json")
+
+
+def test_base_azs(base):
+ az = base["input"]["vnf-topology-information"]["vnf-assignments"][
+ "availability-zones"
+ ]
+ assert az == [
+ {"availability-zone": "VALUE FOR: availability_zone_0"},
+ {"availability-zone": "VALUE FOR: availability_zone_1"},
+ ]
+
+
+def test_base_networks(base):
+ nets = base["input"]["vnf-topology-information"]["vnf-assignments"]["vnf-networks"]
+ assert nets == [
+ {
+ "network-role": "oam",
+ "network-name": "VALUE FOR: network name for oam_net_id",
+ "subnet-id": "oam_subnet_id",
+ },
+ {"network-role": "ha", "network-name": "VALUE FOR: network name for ha_net_id"},
+ {
+ "network-role": "ctrl",
+ "network-name": "VALUE FOR: network name for ctrl_net_id",
+ "subnet-id": "ctrl_subnet_id",
+ },
+ ]
+
+
+def test_base_vm_types(base):
+ vms = base["input"]["vnf-topology-information"]["vnf-assignments"]["vnf-vms"]
+ vm_types = {vm["vm-type"] for vm in vms}
+ assert vm_types == {"db", "svc", "mgmt", "lb"}
+ db = first(vms, lambda v: v["vm-type"] == "db")
+ assert db == {
+ "vm-type": "db",
+ "vm-count": 2,
+ "vm-names": {"vm-name": ["VALUE FOR: db_name_0", "VALUE FOR: db_name_1"]},
+ "vm-networks": [
+ {
+ "network-role": "oam",
+ "network-role-tag": "oam",
+ "ip-count": 2,
+ "ip-count-ipv6": 0,
+ "floating-ip": "",
+ "floating-ip-v6": "",
+ "network-ips": [
+ {"ip-address": "VALUE FOR: db_oam_ip_0"},
+ {"ip-address": "VALUE FOR: db_oam_ip_1"},
+ ],
+ "network-ips-v6": [],
+ "network-macs": [],
+ "interface-route-prefixes": [],
+ "use-dhcp": "N",
+ },
+ {
+ "network-role": "ha",
+ "network-role-tag": "ha",
+ "ip-count": 0,
+ "ip-count-ipv6": 0,
+ "floating-ip": "VALUE FOR: db_ha_floating_ip",
+ "floating-ip-v6": "VALUE FOR: db_ha_floating_v6_ip",
+ "network-ips": [],
+ "network-ips-v6": [],
+ "network-macs": [],
+ "interface-route-prefixes": [],
+ "use-dhcp": "N",
+ },
+ ],
+ }
+
+
+def test_base_parameters(base):
+ params = base["input"]["vnf-topology-information"]["vnf-parameters"]
+ assert params == [
+ {"vnf-parameter-name": "svc_image_name", "vnf-parameter-value": "svc_image"},
+ {"vnf-parameter-name": "svc_flavor_name", "vnf-parameter-value": "svc_flavor"},
+ ]
+
+
+def test_incremental(incremental):
+ az = incremental["input"]["vnf-topology-information"]["vnf-assignments"][
+ "availability-zones"
+ ]
+ assert isinstance(az, list)
+ assert len(az) == 1
+ assert az[0] == {"availability-zone": "VALUE FOR: availability_zone_0"}
+
+
+def test_incremental_networks(incremental):
+ nets = incremental["input"]["vnf-topology-information"]["vnf-assignments"][
+ "vnf-networks"
+ ]
+ assert isinstance(nets, list)
+ assert len(nets) == 1
+ assert nets[0]["network-role"] == "ha"
+
+
+def test_preload_env_population(preload):
+ base_path = THIS_DIR / "sample_env/preloads/vnfapi/base.json"
+ data = load_json(base_path)
+ azs = data["input"]["vnf-topology-information"]["vnf-assignments"][
+ "availability-zones"
+ ]
+ assert azs == [{"availability-zone": "az0"}, {"availability-zone": "az1"}]