Heat¶
Heat conftest¶
Contains fixtures specific for heat.
-
stepler.heat.conftest.create_stack(stack_steps)[source]¶ Fixture to create heat stack with options.
Can be called several times during test. All created stacks will be deleted at teardown.
Parameters: stack_steps (obj) – initialized heat stack steps Returns: function to create heat stack Return type: function
-
stepler.heat.conftest.empty_stack(create_stack, read_heat_template)[source]¶ Function fixture to create empty heat stack.
Parameters: - create_stack (function) – fixture to create stack
- read_heat_template (function) – fixture to read template
Returns: created stack
Return type: obj
-
stepler.heat.conftest.get_template_path()[source]¶ Callable session function fixture to get template path.
Can be called several times during a test.
Returns: function to get template path Return type: function
-
stepler.heat.conftest.heat_client(session)[source]¶ Function fixture to get heat client.
Parameters: session (object) – authenticated keystone session Returns: instantiated heat client Return type: heatclient.Client
-
stepler.heat.conftest.heat_resource_steps(heat_client)[source]¶ Function fixture to get heat resource steps.
Parameters: heat_client (object) – initialized heat client Returns: initialized heat resource steps Return type: stepler.heat.steps.ResourceSteps
-
stepler.heat.conftest.heat_resource_type_steps(heat_client)[source]¶ Function fixture to get heat resource types steps.
Parameters: heat_client (object) – initialized heat client Returns: - initialized heat resource types
- steps
Return type: stepler.heat.steps.ResourceTypeSteps
-
stepler.heat.conftest.read_heat_template(get_template_path)[source]¶ Session fixture to read template from stepler/heat/templates folder.
Can be called several times during a test.
Returns: function to read template Return type: function
-
stepler.heat.conftest.stack_steps(heat_client)[source]¶ Function fixture to get heat stack steps.
Parameters: heat_client (object) – initialized heat client Returns: initialized heat stack steps Return type: stepler.heat.steps.StackSteps
Heat steps¶
Contains steps specific for heat.
-
class
stepler.heat.steps.StackSteps(client)[source]¶ Heat stack steps.
-
check_output_list(output_list)[source]¶ Step to check stack attributes in format: output_key - description.
Parameters: output_list (dict) – stack output list Raises: AssertionError– if check failed
-
check_output_show(stack, output_key, expected_attr_values=None, timeout=0)[source]¶ Step to check stack attributes.
Parameters: - stack (obj) – stack object
- output_key (str) – the name of a stack output
- expected_attr_values (dict|None) – expected attribute values If None, only check that elements of output_show are not empty
- timeout (int) – seconds to wait a result of check
Raises: TimeoutExpired– if check failed after timeout
-
check_presence(stack, must_present=True, timeout=0)[source]¶ Check-step to check heat stack presence.
Parameters: - stack (obj|str) – heat stack object or id
- must_present (bool) – flag to check is stack present or absent
- timeout (int) – seconds to wait a result of check
Raises: TimeoutExpired– if check failed after timeout
-
check_stack_status(stack, status, transit_statuses=(), timeout=0)[source]¶ Verify step to check stack’s stack_status property.
Parameters: - stack (obj) – heat stack to check its status
- status (str) – expected stack status
- transit_statuses (iterable) – allowed transit statuses
- timeout (int) – seconds to wait a result of check
Raises: TimeoutExpired– if check was failed after timeout
-
check_status(stack, status, transit_statuses=(), timeout=0)[source]¶ Verify step to check stack’s status property.
Parameters: - stack (obj) – heat stack to check its status
- status (str) – expected stack status
- transit_statuses (iterable) – allowed transit statuses
- timeout (int) – seconds to wait a result of check
Raises: TimeoutExpired|AssertionError– if check failed after timeout
-
create(name, template, parameters=None, files=None, check=True)[source]¶ Step to create stack.
Parameters: - name (str) – name of stack
- template (str) – yaml template content for create stack from
- parameters (dict|None) – parameters for template
- files (dict|None) – in case if template uses file as reference e.g: “type: volume_with_attachment.yaml”
- check (bool) – flag whether check step or not
Returns: heat stack
Return type: object
-
delete(stack, check=True)[source]¶ Step to delete stack.
Parameters: - stack (obj) – stack to delete
- check (bool) – flag whether to check step or not
Raises: TimeoutExpired– if check failed after timeout
-
get_events_list(stack, check=True)[source]¶ Step to get stack’s events list.
Parameters: - stack (obj) – heat stack
- check (bool, optional) – flag whether check step or not
Raises: AssertionError– if events list is emptyReturns: stack’s events list
Return type:
-
get_output(stack, output_key, check=True)[source]¶ Step to get stack output by output_key.
Parameters: - stack (obj) – stack object
- output_key (str) – output key
- check (bool) – flag whether check step or not
Returns: stack output
Return type: dict
Raises: AssertionError– if output is none or empty
-
get_stack_output_list(stack, check=True)[source]¶ Step to get output list.
Parameters: - stack (obj) – stack object
- check (bool) – flag whether check step or not
Returns: stack output list
Return type: Raises: AssertionError– if check failed
-
get_stack_output_show(stack, output_key, check=True)[source]¶ Step to get output show.
Parameters: - stack (obj) – stack object
- output_key (str) – the name of a stack output
- check (bool) – flag whether check step or not
Returns: stack output
Return type: dict
Raises: AssertionError– if check failed
-
get_stack_template(stack, check=True)[source]¶ Step to get stack’s template.
Parameters: - stack (obj) – heat stack
- check (bool, optional) – flag whether check step or not
Raises: AssertionError– if stack’s template is emptyReturns: stack’s template
Return type: dict
-
get_stacks(check=True)[source]¶ Step to retrieve stacks from heat.
Parameters: check (bool) – flag whether to check step or not Returns: stacks list Return type: list
-
suspend(stack, check=True)[source]¶ Step to suspend stack.
Parameters: - stack (obj) – heat stack
- check (bool, optional) – flag whether check step or not
Raises: AssertionError– if stack’s stack_status is not config.STACK_STATUS_SUSPEND_COMPLETE after suspending
-
update_stack(stack, template=None, parameters=None, check=True)[source]¶ Step to update stack.
Parameters: - stack (obj) – stack object
- template (str, optional) – stack template on which to perform the operation. Default is None.
- parameters (dict, optional) – stack parameters to update
- check (bool) – flag whether check step or not
Raises: TimeoutExpired– if check failed after timeout
-
-
class
stepler.heat.steps.ResourceSteps(client)[source]¶ Heat resource steps
-
check_that_resource_id_changed(physical_resource_id, stack, resource_name)[source]¶ Step to check that after stack updating physical_resource_id was changed.
Parameters: - physical_resource_id (str) – resource id before updating
- stack (object) – heat stack
- resource_name (str) – name of the resource
Raises: AssertionError– if physical_resource_id wasn’t changed
-
Heat tests¶
Heat stack tests¶
-
stepler.heat.tests.test_stack.test_check_output_show_during_stack_creation(create_stack, read_heat_template, stack_steps)[source]¶ Scenario: Check stack output show during stack creation.
Steps:
- Read template from file
- Launch creation stack with template
- Get output show
- Check that output contains expected attribute values
Teardown:
- Delete stack
-
stepler.heat.tests.test_stack.test_create_stack_with_aws(net_subnet_router, read_heat_template, public_network, create_stack, port_steps)[source]¶ Scenario: Create stack with AWS resources.
Setup:
- Create network
- Create subnet
- Create router
- Set router default gateway to public network
- Add router interface to created network
Steps:
- Read AWS template from file
- Create stack with template with parameters:
- internal_network, internal_subnet, external_network
- Check stack reach “COMPLETE” status
Teardown:
- Delete stack
- Delete router
- Delete subnet
- Delete network
-
stepler.heat.tests.test_stack.test_create_stack_with_docker(keypair, flavor, net_subnet_router, ubuntu_xenial_image, read_heat_template, public_network, create_stack, stack_steps)[source]¶ Scenario: Create stack with Docker.
Setup:
- Create network
- Create subnet
- Create router
- Set router default gateway to public network
- Add router interface to created network
Steps:
- Read docker host template from file
- Create stack with template with parameters: key, flavor, image, public_net, int_network_id
- Check stack reach “COMPLETE” status
- Get created server floating_ip
- Read docker_containers template
- Create stack with template with docker_endpoint parameter
- Check stack reach “COMPLETE” status
Teardown:
- Delete stacks
- Delete router
- Delete subnet
- Delete network
-
stepler.heat.tests.test_stack.test_create_stack_with_heat_resources(read_heat_template, create_stack)[source]¶ Scenario: Create stack with heat resources.
Steps:
- Read Heat resources template from file
- Create stack with template
- Check stack reach “COMPLETE” status
Teardown:
- Delete stack
-
stepler.heat.tests.test_stack.test_create_stack_with_neutron_resources(cirros_image, flavor, public_network, net_subnet_router, read_heat_template, create_stack)[source]¶ Scenario: Create stack with Neutron resources.
Setup:
- Create cirros image
- Create network
- Create subnet
- Create router
- Set router default gateway to public network
- Add router interface to created network
Steps:
- Read Heat resources template from file
- Create stack with template with parameters:
- image, flavor, public_net_id, private_net_id, private_subnet_id
- Check stack reach “COMPLETE” status
Teardown:
- Delete stack
- Delete router
- Delete subnet
- Delete network
- Delete cirros image
-
stepler.heat.tests.test_stack.test_create_stack_with_nova_resources(cirros_image, flavor, public_network, net_subnet_router, read_heat_template, create_stack)[source]¶ Scenario: Create stack with Nova resources.
Setup:
- Create cirros image
- Create flavor
- Create network
- Create subnet
- Create router
- Set router default gateway to public network
- Add router interface to created network
Steps:
- Read Heat resources template from file
- Create stack with template with parameters:
- image, flavor, public_net_id, private_net_id, private_subnet_id
- Check stack reach “COMPLETE” status
Teardown:
- Delete stack
- Delete router
- Delete subnet
- Delete network
- Delete flavor
- Delete cirros image
-
stepler.heat.tests.test_stack.test_create_stack_with_wait_condition(cirros_image, flavor, net_subnet_router, read_heat_template, create_stack, port_steps)[source]¶ Scenario: Create stack with WaitCondition resources.
Setup:
- Create cirros image
- Create flavor
- Create network
- Create subnet
- Create router
- Set router default gateway to public network
Steps:
- Read template with WaitCondition resources
- Create stack with template with parameters:
- image, flavor, private_net
- Check stack reach “COMPLETE” status
Teardown:
- Delete stack
- Delete flavor
- Delete image
-
stepler.heat.tests.test_stack.test_get_stack_template(empty_stack, stack_steps)[source]¶ Scenario: Show template of created stack.
Setup:
- Create stack
Steps:
- Get template for stack
- Check that template is not empty
Teardown:
- Delete stack
-
stepler.heat.tests.test_stack.test_stack_output_list(create_stack, read_heat_template, stack_steps)[source]¶ Scenario: Check stack output list has correct output.
Steps:
- Read template from file
- Create stack with template
- Get output list
- Check that output list has correct output
Teardown:
- Delete stack
-
stepler.heat.tests.test_stack.test_stack_output_show(create_stack, read_heat_template, stack_steps)[source]¶ Scenario: Check stack output show has correct output.
Steps:
- Read template from file
- Create stack with template
- Get output show
- Check that attribute output_show exist
Teardown:
- Delete stack
-
stepler.heat.tests.test_stack.test_stack_update_parameter_replace(create_stack, read_heat_template, stack_steps, heat_resource_steps, glance_steps)[source]¶ Scenario: Update stack with changed template.
Steps:
- Read template from file
- Create stack with template
- Get physical_resource_id
- Get image
- Check that image container_format is bare
- Check that image disk_format is qcow2
- Update stack
- Check that image container_format is ami
- Check that image disk_format is ami
- Check that image_id was changed
- Check that physical_resource_id was changed
Teardown:
- Delete stack