Add new automated OSTF test
It will check work of wait condition and wait handle Heat resources. For this test, enough the creation of a working stack Change-Id: I47c65cf7ebf34299d9ef47da6ed815c85b7834f3 Closes-Bug: #1514495
This commit is contained in:
parent
f02be2b6fa
commit
33a4de7046
|
@ -0,0 +1,70 @@
|
|||
heat_template_version: 2013-05-23
|
||||
|
||||
description: >
|
||||
HOT template to demonstrate usage of the Heat native waitcondition resources
|
||||
This is expected to work with any image containing curl and something which
|
||||
runs the raw user-data script, e.g cirros or some image containing cloud-init
|
||||
parameters:
|
||||
key_name:
|
||||
type: string
|
||||
description: Name of keypair to assign to server
|
||||
image:
|
||||
type: string
|
||||
description: Name of image to use for server
|
||||
flavor:
|
||||
type: string
|
||||
description: Flavor to use for server
|
||||
default: m1.tiny
|
||||
timeout:
|
||||
type: number
|
||||
description: Timeout for WaitCondition, depends on your image and environment
|
||||
default: 600
|
||||
net:
|
||||
description: Name of net to use for server
|
||||
type: string
|
||||
|
||||
resources:
|
||||
wait_condition:
|
||||
type: OS::Heat::WaitCondition
|
||||
properties:
|
||||
handle: {get_resource: wait_handle}
|
||||
# Note, count of 5 vs 6 is due to duplicate signal ID 5 sent below
|
||||
count: 5
|
||||
timeout: {get_param: timeout}
|
||||
|
||||
wait_handle:
|
||||
type: OS::Heat::WaitConditionHandle
|
||||
|
||||
instance:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
image: {get_param: image}
|
||||
flavor: {get_param: flavor}
|
||||
key_name: {get_param: key_name}
|
||||
networks:
|
||||
- network: {get_param: net}
|
||||
user_data_format: RAW
|
||||
user_data:
|
||||
str_replace:
|
||||
template: |
|
||||
#!/bin/sh
|
||||
# Below are some examples of the various ways signals
|
||||
# can be sent to the Handle resource
|
||||
# Simple success signal
|
||||
wc_notify --data-binary '{"status": "SUCCESS"}'
|
||||
# Or you optionally can specify any of the additional fields
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "reason": "signal2"}'
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "reason": "signal3", "data": "data3"}'
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "reason": "signal4", "data": "data4"}'
|
||||
# If you require control of the ID, you can pass it.
|
||||
# The ID should be unique, unless you intend for duplicate
|
||||
# signals to overrite each other. The following two calls
|
||||
# do the exact same thing, and will be treated as one signal
|
||||
# (You can prove this by changing count above to 7)
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "id": "5"}'
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "id": "5"}'
|
||||
# Example of sending a failure signal, optionally
|
||||
# reason, id, and data can be specified as above
|
||||
# wc_notify --data-binary '{"status": "FAILURE"}'
|
||||
params:
|
||||
wc_notify: { get_attr: ['wait_handle', 'curl_cli'] }
|
|
@ -0,0 +1,66 @@
|
|||
heat_template_version: 2013-05-23
|
||||
|
||||
description: >
|
||||
HOT template to demonstrate usage of the Heat native waitcondition resources
|
||||
This is expected to work with any image containing curl and something which
|
||||
runs the raw user-data script, e.g cirros or some image containing cloud-init
|
||||
|
||||
parameters:
|
||||
key_name:
|
||||
type: string
|
||||
description: Name of keypair to assign to server
|
||||
image:
|
||||
type: string
|
||||
description: Name of image to use for server
|
||||
flavor:
|
||||
type: string
|
||||
description: Flavor to use for server
|
||||
default: m1.tiny
|
||||
timeout:
|
||||
type: number
|
||||
description: Timeout for WaitCondition, depends on your image and environment
|
||||
default: 600
|
||||
|
||||
resources:
|
||||
wait_condition:
|
||||
type: OS::Heat::WaitCondition
|
||||
properties:
|
||||
handle: {get_resource: wait_handle}
|
||||
# Note, count of 5 vs 6 is due to duplicate signal ID 5 sent below
|
||||
count: 5
|
||||
timeout: {get_param: timeout}
|
||||
|
||||
wait_handle:
|
||||
type: OS::Heat::WaitConditionHandle
|
||||
|
||||
instance:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
image: {get_param: image}
|
||||
flavor: {get_param: flavor}
|
||||
key_name: {get_param: key_name}
|
||||
user_data_format: RAW
|
||||
user_data:
|
||||
str_replace:
|
||||
template: |
|
||||
#!/bin/sh
|
||||
# Below are some examples of the various ways signals
|
||||
# can be sent to the Handle resource
|
||||
# Simple success signal
|
||||
wc_notify --data-binary '{"status": "SUCCESS"}'
|
||||
# Or you optionally can specify any of the additional fields
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "reason": "signal2"}'
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "reason": "signal3", "data": "data3"}'
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "reason": "signal4", "data": "data4"}'
|
||||
# If you require control of the ID, you can pass it.
|
||||
# The ID should be unique, unless you intend for duplicate
|
||||
# signals to overrite each other. The following two calls
|
||||
# do the exact same thing, and will be treated as one signal
|
||||
# (You can prove this by changing count above to 7)
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "id": "5"}'
|
||||
wc_notify --data-binary '{"status": "SUCCESS", "id": "5"}'
|
||||
# Example of sending a failure signal, optionally
|
||||
# reason, id, and data can be specified as above
|
||||
# wc_notify --data-binary '{"status": "FAILURE"}'
|
||||
params:
|
||||
wc_notify: { get_attr: ['wait_handle', 'curl_cli'] }
|
|
@ -813,3 +813,94 @@ class HeatSmokeTests(heatmanager.HeatBaseTest):
|
|||
'verifying if the instance was rolled back',
|
||||
len(instances) == 0
|
||||
)
|
||||
|
||||
def test_wait_condition(self):
|
||||
"""Check creation of stack with Wait Condition/Handle resources
|
||||
Target component: Heat
|
||||
|
||||
Scenario:
|
||||
1. Create test flavor.
|
||||
2. Create a keypair.
|
||||
3. Save generated private key to file on Controller node.
|
||||
4. Create a stack using template.
|
||||
5. Wait for the stack status to change to 'CREATE_COMPLETE'.
|
||||
6. Delete the file with private key.
|
||||
7. Delete the stack.
|
||||
8. Wait for the stack to be deleted.
|
||||
|
||||
Duration: 820 s.
|
||||
Available since release: 2015.1.0-8.0
|
||||
"""
|
||||
|
||||
self.check_image_exists()
|
||||
|
||||
# creation of test flavor
|
||||
heat_flavor = self.verify(
|
||||
50, self.create_flavor,
|
||||
1, 'Test flavor can not be created.',
|
||||
'flavor creation'
|
||||
)
|
||||
|
||||
# creation of test keypair
|
||||
keypair = self.verify(
|
||||
10, self._create_keypair,
|
||||
2, 'Keypair can not be created.',
|
||||
'keypair creation',
|
||||
self.compute_client
|
||||
)
|
||||
path_to_key = self.verify(
|
||||
10, self.save_key_to_file,
|
||||
3, 'Private key can not be saved to file.',
|
||||
'saving private key to the file',
|
||||
keypair.private_key
|
||||
)
|
||||
|
||||
# definition of stack parameters
|
||||
parameters = {
|
||||
'key_name': keypair.name,
|
||||
'flavor': heat_flavor.name,
|
||||
'image': self.config.compute.image_name,
|
||||
}
|
||||
|
||||
if 'neutron' in self.config.network.network_provider:
|
||||
parameters['net'], _ = self.create_network_resources()
|
||||
template = self.load_template('heat_wait_condition_neutron.yaml')
|
||||
else:
|
||||
template = self.load_template('heat_wait_condition_nova.yaml')
|
||||
|
||||
# creation of stack
|
||||
fail_msg = 'Stack was not created properly.'
|
||||
stack = self.verify(
|
||||
20, self.create_stack,
|
||||
4, fail_msg,
|
||||
'stack creation',
|
||||
template, parameters=parameters
|
||||
)
|
||||
self.verify(
|
||||
600, self.wait_for_stack_status,
|
||||
5, fail_msg,
|
||||
'stack status becoming "CREATE_COMPLETE"',
|
||||
stack.id, 'CREATE_COMPLETE', 600, 15
|
||||
)
|
||||
|
||||
# deletion of file with keypair from vm
|
||||
self.verify(
|
||||
10, self.delete_key_file,
|
||||
6, 'The file with private key can not be deleted.',
|
||||
'deleting the file with private key',
|
||||
path_to_key
|
||||
)
|
||||
|
||||
# deletion of stack
|
||||
self.verify(
|
||||
20, self.heat_client.stacks.delete,
|
||||
7, 'Can not delete stack.',
|
||||
'deleting stack',
|
||||
stack.id
|
||||
)
|
||||
self.verify(
|
||||
100, self.wait_for_stack_deleted,
|
||||
8, 'Can not delete stack.',
|
||||
'deleting stack',
|
||||
stack.id
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue