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
stepler.heat.conftest.stacks_cleanup(stack_steps)[source]

Callable function fixture to clear created stacks after test.

It stores ids of all stacks before test and remove all new stacks after test done.

Parameters:stack_steps (obj) – initialized heat stack steps

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 empty

Returns:

stack’s events list

Return type:

list

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:

list

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 empty

Returns:

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

get_resource(stack, name, check=True)[source]

Step to get resource.

Parameters:
  • stack (object) – heat stack
  • name (str) – resource name
  • check (bool) – flag whether check step or not
Returns:

stack resource

Return type:

object

get_resources(stack, name=None, check=True)[source]

Step to get list of resources.

Parameters:
  • stack (object) – heat stack
  • name (str) – resource name
  • check (bool) – flag whether check step or not
Returns:

resource list for stack

Return type:

list

Raises:

AssertionError – if check failed

class stepler.heat.steps.ResourceTypeSteps(client)[source]

Heat resource type steps.

get_resource_types(check=True)[source]

Step to get list of resource types.

Parameters:check (bool) – flag whether check step or not
Returns:resource types list for stack
Return type:list
Raises:AssertionError – if list is empty

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:

  1. Read template from file
  2. Launch creation stack with template
  3. Get output show
  4. Check that output contains expected attribute values

Teardown:

  1. 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:

  1. Create network
  2. Create subnet
  3. Create router
  4. Set router default gateway to public network
  5. Add router interface to created network

Steps:

  1. Read AWS template from file
  2. Create stack with template with parameters:
    internal_network, internal_subnet, external_network
  3. Check stack reach “COMPLETE” status

Teardown:

  1. Delete stack
  2. Delete router
  3. Delete subnet
  4. 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:

  1. Create network
  2. Create subnet
  3. Create router
  4. Set router default gateway to public network
  5. Add router interface to created network

Steps:

  1. Read docker host template from file
  2. Create stack with template with parameters: key, flavor, image, public_net, int_network_id
  3. Check stack reach “COMPLETE” status
  4. Get created server floating_ip
  5. Read docker_containers template
  6. Create stack with template with docker_endpoint parameter
  7. Check stack reach “COMPLETE” status

Teardown:

  1. Delete stacks
  2. Delete router
  3. Delete subnet
  4. 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:

  1. Read Heat resources template from file
  2. Create stack with template
  3. Check stack reach “COMPLETE” status

Teardown:

  1. 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:

  1. Create cirros image
  2. Create network
  3. Create subnet
  4. Create router
  5. Set router default gateway to public network
  6. Add router interface to created network

Steps:

  1. Read Heat resources template from file
  2. Create stack with template with parameters:
    image, flavor, public_net_id, private_net_id, private_subnet_id
  3. Check stack reach “COMPLETE” status

Teardown:

  1. Delete stack
  2. Delete router
  3. Delete subnet
  4. Delete network
  5. 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:

  1. Create cirros image
  2. Create flavor
  3. Create network
  4. Create subnet
  5. Create router
  6. Set router default gateway to public network
  7. Add router interface to created network

Steps:

  1. Read Heat resources template from file
  2. Create stack with template with parameters:
    image, flavor, public_net_id, private_net_id, private_subnet_id
  3. Check stack reach “COMPLETE” status

Teardown:

  1. Delete stack
  2. Delete router
  3. Delete subnet
  4. Delete network
  5. Delete flavor
  6. 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:

  1. Create cirros image
  2. Create flavor
  3. Create network
  4. Create subnet
  5. Create router
  6. Set router default gateway to public network

Steps:

  1. Read template with WaitCondition resources
  2. Create stack with template with parameters:
    image, flavor, private_net
  3. Check stack reach “COMPLETE” status

Teardown:

  1. Delete stack
  2. Delete flavor
  3. Delete image
stepler.heat.tests.test_stack.test_get_stack_template(empty_stack, stack_steps)[source]

Scenario: Show template of created stack.

Setup:

  1. Create stack

Steps:

  1. Get template for stack
  2. Check that template is not empty

Teardown:

  1. 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:

  1. Read template from file
  2. Create stack with template
  3. Get output list
  4. Check that output list has correct output

Teardown:

  1. 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:

  1. Read template from file
  2. Create stack with template
  3. Get output show
  4. Check that attribute output_show exist

Teardown:

  1. 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:

  1. Read template from file
  2. Create stack with template
  3. Get physical_resource_id
  4. Get image
  5. Check that image container_format is bare
  6. Check that image disk_format is qcow2
  7. Update stack
  8. Check that image container_format is ami
  9. Check that image disk_format is ami
  10. Check that image_id was changed
  11. Check that physical_resource_id was changed

Teardown:

  1. Delete stack