aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/app_tests
diff options
context:
space:
mode:
Diffstat (limited to 'ice_validator/app_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
-rw-r--r--ice_validator/app_tests/test_config.py (renamed from ice_validator/app_tests/test_app_config.py)147
-rw-r--r--ice_validator/app_tests/test_data.zipbin0 -> 125 bytes
-rw-r--r--ice_validator/app_tests/test_helpers.py88
-rw-r--r--ice_validator/app_tests/vvp-config.yaml5
26 files changed, 1591 insertions, 11 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"}]
diff --git a/ice_validator/app_tests/test_app_config.py b/ice_validator/app_tests/test_config.py
index a021b53..a41cfbf 100644
--- a/ice_validator/app_tests/test_app_config.py
+++ b/ice_validator/app_tests/test_config.py
@@ -34,19 +34,23 @@
# limitations under the License.
#
# ============LICENSE_END============================================
-#
-#
+import uuid
from io import StringIO
import pytest
import yaml
+from config import Config, get_generator_plugin_names, to_uri
import vvp
+
DEFAULT_CONFIG = """
+namespace: {namespace}
+owner: onap-test
ui:
app-name: VNF Validation Tool
+ requirement-link-url: http://requirement.url.com
categories:
- name: Environment File Compliance. (Required to Onboard)
category: environment_file
@@ -55,14 +59,23 @@ categories:
Required for ASDC onboarding, not needed for manual Openstack testing.
settings:
polling-freqency: 1000
- default-verbosity: Standard
+ env-specs:
+ - tests.test_environment_file_parameters.ENV_PARAMETER_SPEC
+terms:
+ version: 1.0.0
+ path: path/to/terms.txt
+ popup-title: Terms and Conditions
+ popup-link-text: View Terms and Conditions
+ popup-msg-text: Review and Accept the Terms
"""
# noinspection PyShadowingNames
-@pytest.fixture(scope="module")
+@pytest.fixture()
def config():
- return vvp.Config(yaml.safe_load(StringIO(DEFAULT_CONFIG)))
+ unique = str(uuid.uuid4())
+ data = DEFAULT_CONFIG.format(namespace=unique)
+ return Config(yaml.safe_load(StringIO(data)))
def test_app_name(config):
@@ -87,10 +100,6 @@ def test_get_category_when_other(config):
)
-def test_default_verbosity(config):
- assert config.default_verbosity(vvp.ValidatorApp.VERBOSITY_LEVELS) == "Standard (-v)"
-
-
def test_queues(config):
assert config.log_queue.empty(), "Log should start empty"
config.log_file.write("Test")
@@ -102,6 +111,8 @@ def test_queues(config):
MISSING_CATEGORY_FIELD = """
+namespace: org.onap.test
+owner: onap-test
ui:
app-name: VNF Validation Tool
categories:
@@ -116,7 +127,7 @@ settings:
def test_missing_category_fields():
settings = yaml.safe_load(StringIO(MISSING_CATEGORY_FIELD))
with pytest.raises(RuntimeError) as e:
- vvp.Config(settings)
+ Config(settings)
assert "Missing: name" in str(e)
@@ -140,3 +151,119 @@ def test_default_input_format(config):
def test_input_formats(config):
assert "Directory (Uncompressed)" in config.input_formats
assert "ZIP File" in config.input_formats
+
+
+def test_env_specs(config):
+ specs = config.env_specs
+ assert len(specs) == 1
+ assert "ALL" in specs[0]
+
+
+def test_get_generator_plugin_names(config):
+ names = get_generator_plugin_names()
+ assert "VNF-API" in names
+ assert "GR-API" in names
+
+
+def test_preload_formats(config):
+ formats = config.preload_formats
+ assert all(format in formats for format in ("VNF-API", "GR-API"))
+
+
+def test_requirement_link_http(config):
+ assert config.requirement_link_url == "http://requirement.url.com"
+
+
+def test_to_uri_relative_path():
+ assert to_uri("path/").startswith("file://")
+ assert to_uri("path/").endswith("/path")
+
+
+def test_to_uri_relative_http():
+ assert to_uri("http://url.com") == "http://url.com"
+
+
+def test_to_uri_absolute_path():
+ assert to_uri("/path/one").startswith("file:///")
+ assert to_uri("/path/one").endswith("/path/one")
+
+
+def test_requirement_link_path(config):
+ config._config["ui"]["requirement-link-url"] = "path/to/reqs.txt"
+ url = config.requirement_link_url
+ assert url.startswith("file://")
+ assert "path/to/reqs.txt" in url
+
+
+def test_terms_version(config):
+ assert config.terms_version == "1.0.0"
+
+
+def test_terms_popup_title(config):
+ assert config.terms_popup_title == "Terms and Conditions"
+
+
+def test_terms_popup_message(config):
+ assert config.terms_popup_message == "Review and Accept the Terms"
+
+
+def test_terms_link_url_default(config):
+ config._config["terms"]["path"] = None
+ assert config.terms_link_url is None
+
+
+def test_terms_acceptance(config):
+ assert not config.are_terms_accepted
+ config.set_terms_accepted()
+ assert config.are_terms_accepted
+
+
+def test_terms_link_url_path(config):
+ assert config.terms_link_url.startswith("file://")
+ assert config.terms_link_url.endswith("/path/to/terms.txt")
+
+
+def test_terms_link_text(config):
+ assert config.terms_link_text == "View Terms and Conditions"
+
+
+def test_default_halt_on_failure(config):
+ assert config.default_halt_on_failure
+
+
+def test_get_subdir_for_preload(config):
+ assert config.get_subdir_for_preload("VNF-API") == "vnfapi"
+
+
+def test_default_preload_format(config):
+ assert config.default_preload_format in ("VNF-API", "GR-API", "Excel")
+
+
+def test_category_description(config):
+ assert "Checks certain parameters" in config.get_description(
+ "Environment File Compliance. (Required to Onboard)"
+ )
+
+
+def test_get_category_by_name(config):
+ assert (
+ config.get_category("Environment File Compliance. (Required to Onboard)")
+ == "environment_file"
+ )
+
+
+def test_cached_category_setting(config):
+ assert (
+ config.get_category_value("Environment File Compliance. (Required to Onboard)")
+ == 0
+ )
+
+
+def test_disclaimer_text(config):
+ assert config.disclaimer_text == ""
+
+
+def test_requirement_link_text(config):
+ url_text = "Requirement URL"
+ config._config["ui"]["requirement-link-text"] = url_text
+ assert config.requirement_link_text == url_text
diff --git a/ice_validator/app_tests/test_data.zip b/ice_validator/app_tests/test_data.zip
new file mode 100644
index 0000000..2787159
--- /dev/null
+++ b/ice_validator/app_tests/test_data.zip
Binary files differ
diff --git a/ice_validator/app_tests/test_helpers.py b/ice_validator/app_tests/test_helpers.py
new file mode 100644
index 0000000..d90374a
--- /dev/null
+++ b/ice_validator/app_tests/test_helpers.py
@@ -0,0 +1,88 @@
+# -*- 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============================================
+from pathlib import Path
+
+import pytest
+
+from tests.helpers import check, first, unzip, remove
+
+THIS_DIR = Path(__file__).parent
+
+
+def test_check_fail():
+ with pytest.raises(RuntimeError, match="pre-condition failed"):
+ check(False, "pre-condition failed")
+
+
+def test_check_pass():
+ check(True, "pre-condition failed")
+
+
+def test_first_found():
+ result = first(range(1, 10), lambda x: x % 4 == 0)
+ assert result == 4
+
+
+def test_first_not_found():
+ result = first(range(1, 3), lambda x: x % 4 == 0)
+ assert result is None
+
+
+def test_first_custom_default():
+ result = first(range(1, 3), lambda x: x % 4 == 0, default="not found")
+ assert result == "not found"
+
+
+def test_unzip_success(tmpdir):
+ test_zip = THIS_DIR / "test_data.zip"
+ target_dir = tmpdir.join("sub-dir")
+ unzip(test_zip, target_dir)
+ assert "data.txt" in (p.basename for p in target_dir.listdir())
+
+
+def test_unzip_not_found(tmpdir):
+ test_zip = THIS_DIR / "test_data1.zip"
+ with pytest.raises(RuntimeError, match="not a valid zipfile"):
+ unzip(test_zip, tmpdir)
+
+
+def test_remove_with_no_key():
+ assert remove([1, 2, 3, 4], [3]) == [1, 2, 4]
+
+
+def test_remove_with_key():
+ assert remove(["a", "b", "c", "d"], ["A"], lambda s: s.upper()) == ["b", "c", "d"]
diff --git a/ice_validator/app_tests/vvp-config.yaml b/ice_validator/app_tests/vvp-config.yaml
index f80cb6f..512d82d 100644
--- a/ice_validator/app_tests/vvp-config.yaml
+++ b/ice_validator/app_tests/vvp-config.yaml
@@ -36,7 +36,8 @@
# ============LICENSE_END============================================
#
#
-
+namespace: org.onap.test
+owner: onap-test
ui:
app-name: VNF Validation Tool
categories:
@@ -48,3 +49,5 @@ categories:
settings:
polling-freqency: 1000
default-verbosity: Standard
+ env-specs:
+ - tests.test_environment_file_parameters.ENV_PARAMETER_SPEC