summaryrefslogtreecommitdiffstats
path: root/tosca2heat/heat-translator/translator/tests
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2017-07-17 17:40:59 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2017-07-17 17:40:59 +0800
commitc7491340551cdd9d757d63b4bbe79132506e386a (patch)
treeae14fd406f3f0ebe415ce69bd9c6d0698af30d1e /tosca2heat/heat-translator/translator/tests
parent859e2826074aa51e0334d4607ccfcde5972e882e (diff)
Synchronize upstream version of 0.9
Synchronize heat-translator wiht upstream versionn of 0.9 JIRA: PARSER-128 Change-Id: I4d2c62a0e81119d5c0305e3ac052415a6d5acee3 Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/heat-translator/translator/tests')
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/autoscaling/tosca_autoscaling.yaml1
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_autoscaling.yaml3
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_cluster_autoscaling.yaml1
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/monitoring/asg_res.yaml10
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/monitoring/hot_monitoring_scaling.yaml53
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/nfv/hot_tosca_nfv_autoscaling.yaml3
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_w_multiple_attachment.yaml96
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/monitoring/tosca_monitoring_scaling.yaml60
-rw-r--r--tosca2heat/heat-translator/translator/tests/data/storage/tosca_multiple_blockstorage_w_multiple_attachment.yaml79
-rw-r--r--tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py41
10 files changed, 342 insertions, 5 deletions
diff --git a/tosca2heat/heat-translator/translator/tests/data/autoscaling/tosca_autoscaling.yaml b/tosca2heat/heat-translator/translator/tests/data/autoscaling/tosca_autoscaling.yaml
index f58d727..d5356be 100644
--- a/tosca2heat/heat-translator/translator/tests/data/autoscaling/tosca_autoscaling.yaml
+++ b/tosca2heat/heat-translator/translator/tests/data/autoscaling/tosca_autoscaling.yaml
@@ -38,3 +38,4 @@ topology_template:
max_instances: 10
default_instances: 3
increment: 1
+ cooldown: 60
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_autoscaling.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_autoscaling.yaml
index 1cd2c03..a83f019 100644
--- a/tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_autoscaling.yaml
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_autoscaling.yaml
@@ -10,6 +10,7 @@ resources:
properties:
min_size: 2
desired_capacity: 3
+ cooldown: 60
resource:
type: asg_res.yaml
max_size: 10
@@ -20,6 +21,7 @@ resources:
get_resource: asg_group
adjustment_type: change_in_capacity
scaling_adjustment: 1
+ cooldown: 60
asg_scale_in:
type: OS::Heat::ScalingPolicy
properties:
@@ -27,6 +29,7 @@ resources:
get_resource: asg_group
adjustment_type: change_in_capacity
scaling_adjustment: -1
+ cooldown: 60
asg_alarm:
type: OS::Aodh::Alarm
properties:
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_cluster_autoscaling.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_cluster_autoscaling.yaml
index ca0fb3a..e0dbb7f 100644
--- a/tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_cluster_autoscaling.yaml
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/autoscaling/hot_cluster_autoscaling.yaml
@@ -12,6 +12,7 @@ resources:
properties:
flavor: m1.medium
image: rhel-6.5-test-image
+ software_config_transport: POLL_SERVER_HEAT
networks:
- network: net0
cluster_scaling_scale_out:
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/monitoring/asg_res.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/monitoring/asg_res.yaml
new file mode 100644
index 0000000..d3415ea
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/monitoring/asg_res.yaml
@@ -0,0 +1,10 @@
+heat_template_version: 2013-05-23
+description: Tacker Scaling template
+resources:
+ my_server_1:
+ type: OS::Nova::Server
+ properties:
+ flavor: m1.medium
+ user_data_format: SOFTWARE_CONFIG
+ software_config_transport: POLL_SERVER_HEAT
+ image: rhel-6.5-test-image
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/monitoring/hot_monitoring_scaling.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/monitoring/hot_monitoring_scaling.yaml
new file mode 100644
index 0000000..85ff54d
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/monitoring/hot_monitoring_scaling.yaml
@@ -0,0 +1,53 @@
+heat_template_version: 2013-05-23
+
+description: >
+ Template for deploying servers based on policies.
+
+parameters: {}
+resources:
+ asg_scale_out:
+ type: OS::Heat::ScalingPolicy
+ properties:
+ auto_scaling_group_id:
+ get_resource: asg_group
+ adjustment_type: change_in_capacity
+ scaling_adjustment: 1
+ cooldown: 60
+ low_cpu_usage:
+ type: OS::Aodh::Alarm
+ properties:
+ meter_name: cpu_util
+ description: utilization less_than 20%
+ evaluation_periods: 1
+ period: 600
+ statistic: avg
+ threshold: 20
+ comparison_operator: gt
+ asg_group:
+ type: OS::Heat::AutoScalingGroup
+ properties:
+ min_size: 2
+ desired_capacity: 3
+ resource:
+ type: asg_res.yaml
+ max_size: 10
+ cooldown: 60
+ asg_scale_in:
+ type: OS::Heat::ScalingPolicy
+ properties:
+ auto_scaling_group_id:
+ get_resource: asg_group
+ adjustment_type: change_in_capacity
+ scaling_adjustment: -1
+ cooldown: 60
+ high_cpu_usage:
+ type: OS::Aodh::Alarm
+ properties:
+ meter_name: cpu_util
+ description: utilization greater_than 60%
+ evaluation_periods: 1
+ period: 600
+ statistic: avg
+ threshold: 60
+ comparison_operator: gt
+outputs: {}
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/nfv/hot_tosca_nfv_autoscaling.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/nfv/hot_tosca_nfv_autoscaling.yaml
index 7d1e2f6..dde597b 100644
--- a/tosca2heat/heat-translator/translator/tests/data/hot_output/nfv/hot_tosca_nfv_autoscaling.yaml
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/nfv/hot_tosca_nfv_autoscaling.yaml
@@ -12,6 +12,7 @@ resources:
get_resource: SP1_group
adjustment_type: change_in_capacity
scaling_adjustment: 1
+ cooldown: 120
SP1_group:
type: OS::Heat::AutoScalingGroup
properties:
@@ -20,6 +21,7 @@ resources:
resource:
type: SP1_res.yaml
max_size: 3
+ cooldown: 120
SP1_scale_in:
type: OS::Heat::ScalingPolicy
properties:
@@ -27,4 +29,5 @@ resources:
get_resource: SP1_group
adjustment_type: change_in_capacity
scaling_adjustment: -1
+ cooldown: 120
outputs: {} \ No newline at end of file
diff --git a/tosca2heat/heat-translator/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_w_multiple_attachment.yaml b/tosca2heat/heat-translator/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_w_multiple_attachment.yaml
new file mode 100644
index 0000000..34f408e
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/hot_output/storage/hot_multiple_blockstorage_w_multiple_attachment.yaml
@@ -0,0 +1,96 @@
+heat_template_version: 2013-05-23
+
+description: >
+ TOSCA simple profile with 1 server attached 2 block storages.
+
+parameters:
+ cpus:
+ type: number
+ description: Number of CPUs for the server.
+ default: 1
+ constraints:
+ - allowed_values:
+ - 1
+ - 2
+ - 4
+ - 8
+ storage_location1:
+ type: string
+ description: Block storage mount point (filesystem path).
+ default: /dev/vdb
+ storage_location2:
+ type: string
+ description: Block storage mount point (filesystem path).
+ default: /dev/vdc
+ storage_size:
+ type: number
+ description: Size of the storage to be created.
+ default: 1
+ storage_snapshot_id:
+ type: string
+ description: Optional identifier for an existing snapshot to use when creating storage.
+ default: ssid
+
+resources:
+ my_server:
+ type: OS::Nova::Server
+ properties:
+ flavor: m1.medium
+ image: fedora-amd64-heat-config
+ software_config_transport: POLL_SERVER_HEAT
+ user_data_format: SOFTWARE_CONFIG
+ depends_on:
+ - my_storage1
+ - my_storage2
+
+ my_storage1:
+ type: OS::Cinder::Volume
+ properties:
+ size:
+ get_param: storage_size
+ snapshot_id:
+ get_param: storage_snapshot_id
+
+ my_storage2:
+ type: OS::Cinder::Volume
+ properties:
+ size:
+ get_param: storage_size
+ snapshot_id:
+ get_param: storage_snapshot_id
+
+ attachesto_1:
+ type: OS::Cinder::VolumeAttachment
+ properties:
+ instance_uuid:
+ get_resource: my_server
+ mountpoint:
+ get_param: storage_location1
+ volume_id:
+ get_resource: my_storage1
+
+ attachesto_2:
+ type: OS::Cinder::VolumeAttachment
+ properties:
+ instance_uuid:
+ get_resource: my_server
+ mountpoint:
+ get_param: storage_location2
+ volume_id:
+ get_resource: my_storage2
+
+outputs:
+ server_ip:
+ description: The private IP address of the applications server.
+ value:
+ get_attr:
+ - my_server
+ - first_address
+ volume_id_1:
+ description: The volume id of the first block storage instance.
+ value:
+ get_resource: my_storage1
+ volume_id_2:
+ description: The volume id of the second block storage instance.
+ value:
+ get_resource: my_storage2
diff --git a/tosca2heat/heat-translator/translator/tests/data/monitoring/tosca_monitoring_scaling.yaml b/tosca2heat/heat-translator/translator/tests/data/monitoring/tosca_monitoring_scaling.yaml
new file mode 100644
index 0000000..0c36236
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/monitoring/tosca_monitoring_scaling.yaml
@@ -0,0 +1,60 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: >
+ Template for deploying servers based on policies.
+
+topology_template:
+ node_templates:
+ my_server_1:
+ type: tosca.nodes.Compute
+ capabilities:
+ host:
+ properties:
+ num_cpus: 2
+ disk_size: 10 GB
+ mem_size: 512 MB
+ os:
+ properties:
+ # host Operating System image properties
+ architecture: x86_64
+ type: Linux
+ distribution: RHEL
+ version: 6.5
+ policies:
+ - asg:
+ type: tosca.policies.Scaling
+ description: Simple node autoscaling
+ targets: [my_server_1]
+ properties:
+ min_instances: 2
+ max_instances: 10
+ default_instances: 3
+ increment: 1
+ cooldown: 60
+
+ - cpu_monitoring:
+ type: tosca.policies.Monitoring
+ description: Simple node monitoring
+ targets: [my_server_1]
+ triggers:
+ high_cpu_usage:
+ description: trigger
+ meter_name: cpu_util
+ condition:
+ constraint: utilization greater_than 60%
+ threshold: 60
+ period: 600
+ evaluations: 1
+ method: average
+ comparison_operator: gt
+
+ low_cpu_usage:
+ description: trigger
+ meter_name: cpu_util
+ condition:
+ constraint: utilization less_than 20%
+ threshold: 20
+ period: 600
+ evaluations: 1
+ method: average
+ comparison_operator: gt \ No newline at end of file
diff --git a/tosca2heat/heat-translator/translator/tests/data/storage/tosca_multiple_blockstorage_w_multiple_attachment.yaml b/tosca2heat/heat-translator/translator/tests/data/storage/tosca_multiple_blockstorage_w_multiple_attachment.yaml
new file mode 100644
index 0000000..7eb7843
--- /dev/null
+++ b/tosca2heat/heat-translator/translator/tests/data/storage/tosca_multiple_blockstorage_w_multiple_attachment.yaml
@@ -0,0 +1,79 @@
+tosca_definitions_version: tosca_simple_yaml_1_0
+
+description: >
+ TOSCA simple profile with 1 server attached 2 block storages.
+
+topology_template:
+ inputs:
+ cpus:
+ type: integer
+ description: Number of CPUs for the server.
+ constraints:
+ - valid_values: [ 1, 2, 4, 8 ]
+ storage_size:
+ type: scalar-unit.size
+ default: 1 GB
+ description: Size of the storage to be created.
+ storage_snapshot_id:
+ type: string
+ description: >
+ Optional identifier for an existing snapshot to use when creating storage.
+ storage_location1:
+ type: string
+ description: >
+ Block storage mount point (filesystem path).
+ storage_location2:
+ type: string
+ description: >
+ Block storage mount point (filesystem path).
+
+ node_templates:
+ my_server:
+ type: tosca.nodes.Compute
+ capabilities:
+ host:
+ properties:
+ disk_size: 10 GB
+ num_cpus: { get_input: cpus }
+ mem_size: 4096 MB
+ os:
+ properties:
+ architecture: x86_64
+ type: Linux
+ distribution: Fedora
+ version: 18.0
+ requirements:
+ - local_storage1:
+ node: my_storage1
+ relationship:
+ type: AttachesTo
+ properties:
+ location: { get_input: storage_location1 }
+ - local_storage2:
+ node: my_storage2
+ relationship:
+ type: AttachesTo
+ properties:
+ location: { get_input: storage_location2 }
+ my_storage1:
+ type: tosca.nodes.BlockStorage
+ properties:
+ size: { get_input: storage_size }
+ snapshot_id: { get_input: storage_snapshot_id }
+
+ my_storage2:
+ type: tosca.nodes.BlockStorage
+ properties:
+ size: { get_input: storage_size }
+ snapshot_id: { get_input: storage_snapshot_id }
+
+ outputs:
+ server_ip:
+ description: The private IP address of the application's server.
+ value: { get_attribute: [my_server, private_address] }
+ volume_id_1:
+ description: The volume id of the first block storage instance.
+ value: { get_attribute: [my_storage1, volume_id] }
+ volume_id_2:
+ description: The volume id of the second block storage instance.
+ value: { get_attribute: [my_storage2, volume_id] }
diff --git a/tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py b/tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py
index 6d0d316..95df72a 100644
--- a/tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py
+++ b/tosca2heat/heat-translator/translator/tests/test_tosca_hot_translation.py
@@ -26,14 +26,15 @@ from translator.tests.base import TestCase
class ToscaHotTranslationTest(TestCase):
- def _test_successful_translation(self, tosca_file, hot_files, params=None):
+ def _test_successful_translation(self, tosca_file, hot_files, params=None,
+ nested_resources=False):
if not params:
params = {}
if not isinstance(hot_files, list):
hot_files = [hot_files]
- diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
- hot_files,
- params)
+ diff =\
+ TranslationUtils.compare_tosca_translation_with_hot(
+ tosca_file, hot_files, params, nested_resources)
self.assertEqual({}, diff, '<difference> : ' +
json.dumps(diff, indent=4, separators=(', ', ': ')))
@@ -191,6 +192,18 @@ class ToscaHotTranslationTest(TestCase):
except Exception:
self._test_successful_translation(tosca_file, hot_file2, params)
+ def test_hot_translate_multiple_blockstorage_w_multiple_attachment(self):
+ tosca_file = '../tests/data/storage/' \
+ 'tosca_multiple_blockstorage_w_multiple_attachment.yaml'
+ hot_file = '../tests/data/hot_output/storage/' \
+ 'hot_multiple_blockstorage_w_multiple_attachment.yaml'
+ params = {'cpus': 1,
+ 'storage_location1': '/dev/vdb',
+ 'storage_location2': '/dev/vdc',
+ 'storage_size': '1 GB',
+ 'storage_snapshot_id': 'ssid'}
+ self._test_successful_translation(tosca_file, hot_file, params)
+
def test_hot_translate_single_object_store(self):
tosca_file = '../tests/data/storage/tosca_single_object_store.yaml'
hot_file = '../tests/data/hot_output/hot_single_object_store.yaml'
@@ -515,6 +528,15 @@ class ToscaHotTranslationTest(TestCase):
params = {}
self._test_successful_translation(tosca_file, hot_files, params)
+ def test_hot_translate_scaling_nested_plate(self):
+ tosca_file = '../tests/data/autoscaling/tosca_autoscaling.yaml'
+ hot_files = [
+ '../tests/data/hot_output/autoscaling/asg_res.yaml'
+ ]
+ params = {}
+ self._test_successful_translation(tosca_file, hot_files, params,
+ nested_resources=True)
+
def test_translate_unsupported_tosca_type(self):
tosca_file = '../tests/data/test_tosca_unsupported_type.yaml'
tosca_tpl = os.path.normpath(os.path.join(
@@ -528,7 +550,7 @@ class ToscaHotTranslationTest(TestCase):
.translate)
self.assertEqual(expected_msg, err.__str__())
- def _translate_nodetemplates(self):
+ def test_hot_translate_cluster_scaling_policy(self):
tosca_file = '../tests/data/autoscaling/tosca_cluster_autoscaling.yaml'
hot_file = '../tests/data/hot_output/autoscaling/' \
'hot_cluster_autoscaling.yaml'
@@ -543,3 +565,12 @@ class ToscaHotTranslationTest(TestCase):
]
params = {}
self._test_successful_translation(tosca_file, hot_files, params)
+
+ def test_hot_translate_mon_scaling_policy(self):
+ tosca_file = '../tests/data/monitoring/tosca_monitoring_scaling.yaml'
+ hot_files = [
+ '../tests/data/hot_output/monitoring/hot_monitoring_scaling.yaml',
+ '../tests/data/hot_output/monitoring/asg_res.yaml',
+ ]
+ params = {}
+ self._test_successful_translation(tosca_file, hot_files, params)