test/doc/source/manual_tests/heat/heat_hot_template_suite.rst

14 KiB

HOT Template

HEAT_HOT_Template_01

Test ID

HEAT_HOT_Template_01

Test Title

Heat resource creation for Cinder Volume.

Tags

HOT

Testcase Objective

This test case verify that HEAT can create a cinder volume successfully with HOT template.

Test Pre-Conditions

  1. An image with the name of cirros available
Export openstack_helm authentication - go to [0] for details.

$ wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img

$ openstack image create --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --public cirros

Test Steps

  1. Create Heat stack using <cinder_volume.yaml>
$ openstack stack create <Volume_name> -t cinder_volume.yaml
i.e.
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| id | caa42023-0669-4825-a024-28ebcbf0e3e2 |
| stack_name | Volumefer | | description | Launch a cinder volume cirros image. |
| creation_time | 2019-02-22T15:18:23Z |
| updated_time | None | | stack_status | CREATE_IN_PROGRESS |
| stack_status_reason | Stack CREATE started |
+---------------------+--------------------------------------+

2.Delete the stack

$ openstack stack delete <Volume_name>

Expected Behavior

  1. Verify 1GB cinder volume is successfully created.
$ openstack stack show <volume_name>
i.e.
 $ openstack stack show Volumefer
 +------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
 | Field                  | Value                                                                                                                                     |
 +========================+===========================================================================================================================================+
 | id                     | c0a18394-d5fc-441c-bcd9-2f3bb3fb6592                                                                                                      |
 | stack_name             | Volumefer                                                                                                                                 |
 | description            | Launch a cinder volume cirros image.                                                                                                      |
 +------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
 | ...                    | ...                                                                                                                                       |
 +------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
 | outputs                | description: Volume                                                                                                                       |
 | output_key: volume_size|                                                                                                                                           |
 | output_value: '1'      |                                                                                                                                           |
 +------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
 |  ...                    | ...                                                                                                                                       |
 +------------------------+-------------------------------------------------------------------------------------------------------------------------------------------+
  1. Verify the STACK and the resources is deleted Openstack stack list (STACK should not be there in the list)

cinder_volume.yaml

heat_template_version: 2015-10-15
description: Launch a cinder volume cirros image.
resources:
 volume:
   type: OS::Cinder::Volume
   properties:
     description: Cinder volume create
     image: cirros
     name: Vol_d
     size: 1

outputs:
  volume_size:
    description: Volume
    value: { get_attr: [volume, size ] }

HEAT_HOT_template_02

Test ID

HEAT_HOT_Template_02

Test Title

Heat resource creation for Cinder Volume Attachment.

Tags

HOT_template

Test Objective

This test case verify that OS::Cinder::VolumeAttachment resource for associate an existing volume to an existing instance.

Test Pre-Conditions

  1. A Nova Server Instance already created. Check [2] for creation.
  2. A volume already created. Check [3] for creation.

c) Create the "cinder_volume_attachment.yaml" yaml file in your controller.

controller-0:~$ touch cinder_volume_attachment.yaml
  1. Export Instance id in your current session.
controller-0:~$ export Instance_ID=$(openstack server list | awk '/stack_demo*/ {print $2}')
  1. Export Volume id in your current session.
controller-0:~$ export Volume_ID=$(openstack volume list | awk '/Vol_demo*/ {print $2}')

Test Steps

  1. Associate a volume to an instance by typing:
controller-0:~$ openstack stack create -t cinder_volume_attachment.yaml Vol_attach_Instance --parameter "Volume_ID=$Volume_ID;Instance_ID=$Instance_ID"
+---------------------+----------------------------------------------------------+
| Field               | Value                                                    |
+---------------------+----------------------------------------------------------+
| id                  | 45c92f19-b543-4216-bce5-136b140c74e8                     |
| stack_name          | Vol_attach_Instance                                      |
| description         | this is a template that attached a volume to an instance |
| creation_time       | 2019-03-07T16:00:19Z                                     |
| updated_time        | None                                                     |
| stack_status        | CREATE_IN_PROGRESS                                       |
| stack_status_reason | Stack CREATE started                                     |
+---------------------+----------------------------------------------------------+
  1. List your stacks and make sure the volume was associated to the instance.
controller-0:~$ openstack stack list
  1. Delete the stack Vol_attach_Instance and make sure the stack and the resources are deleted.
controller-0:~$ openstack stack delete

Expected Behavior

  1. Volume was associated to the instance successfully.
  2. Vol_attach_Instance listed successfully.
+--------------------------------------+---------------------+----------------------------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name          | Project                          | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+---------------------+----------------------------------+-----------------+----------------------+--------------+
| 45c92f19-b543-4216-bce5-136b140c74e8 | Vol_attach_Instance | 86ab4e9a23d644d5a378e9b637dc5f5e | CREATE_COMPLETE | 2019-03-07T16:00:19Z | None         |
| 229be306-6e5d-4b4c-93cc-a22b75f677c9 | Volume_demo_stack   | 86ab4e9a23d644d5a378e9b637dc5f5e | CREATE_COMPLETE | 2019-03-07T15:38:40Z | None         |
| 1f18959c-2d04-4def-8323-b2497bb3b745 | stack_demo          | 86ab4e9a23d644d5a378e9b637dc5f5e | CREATE_COMPLETE | 2019-03-07T15:27:58Z | None         |
+--------------------------------------+---------------------+----------------------------------+-----------------+----------------------+--------------+
  1. STACK and resources were deleted successfully
controller-0:~$ openstack stack list

Templates

cinder_volume_attachment.yaml

heat_template_version: 2015-04-30
description: this is a template that attached a volume to an instance

parameters:
  Instance_ID:
    type: string
    description: Instance ID to attach to the corresponding volume
  Volume_ID:
    type: string
    description: Volume ID to where the instance is attached

resources:
  the_resource:
    type: OS::Cinder::VolumeAttachment
    properties:
      instance_uuid:  { get_param: Instance_ID }
      volume_id:  { get_param: Volume_ID }

cinder_volume.yaml

heat_template_version: 2015-10-15
description: Launch a cinder volume cirros image.

resources:
  volume:
    type: OS::Cinder::Volume
    properties:
      description: Cinder volume create
      image: cirros
      name: Vol_demo
      size: 1

outputs:
  volume_size:
    description: Volume
    value: { get_attr: [volume, size ] }

nova_server.yaml

heat_template_version: 2015-10-15
description: Launch a basic instance with CirrOS image using the
             ``demo1.tiny`` flavor, ``mykey`` key,  and one network.

parameters:
  NetID:
    type: string
    description: Network ID to use for the instance.

resources:
  server:
    type: OS::Nova::Server
    properties:
      image: cirros
      flavor: demo1.tiny
      key_name:
      networks:
      - network: { get_param: NetID }

outputs:
  instance_name:
    description: Name of the instance
    value: { get_attr: [ server, name ] }
  instance_ip:
    description: IP address of the instance.
    value: { get_attr: [ server, first_address ] }

HEAT_HOT_Template_12

Test ID

HEAT_HOT_Template_12

Test Title

Heat resource creation for Nova Server.

Tags

HOT

Testcase Objective

This test case verify that HEAT can create a Nova Server successfully with HOT template.

Test Pre-Conditions

  1. An image with the name of cirros available
i.e.
Export openstack_helm authentication
   $ export OS_CLOUD=openstack_helm
   REMARK: go to [0] for details.

$ wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img

$ openstack image create --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --public cirros
  1. A flavor with the name flavor_name.type available.
i.e.
$ openstack flavor create --public --id 1 --ram 512 --vcpus 1 --disk 4 flavor_name.type
    REMARK: go to [1] for type of flavors.
  1. A network available
i.e.
$ openstack network create net

$ openstack subnet create --network net --ip-version 4 --subnet-range 192.168.0.0/24 --dhcp net-subnet1
  1. Execute the following command to take the network id
$ export NET_ID=$(openstack network list | awk '/ net / { print $2 }')

Test Steps

  1. Create Heat stack using nova_server.yaml by typing:
$ openstack stack create --template nova_server.yaml stack_demo --parameter "NetID=$NET_ID"
  1. Delete the stack
$ openstack stack delete stack_demo

Expected Behavior

  1. Verify Stack is successfully created and new nova instance is created.
$ openstack stack list
i.e.
+--------------------------------------+------------+----------------------------------+-----------------+----------------------+----------------------+
| ID | Stack Name | Project | Stack Status | Creation Time | Updated Time                                                                              |
+======================================+============+==================================+=================+======================+======================+
|380bb224-4c41-4b25-b4e8-7291bb1f3129 | stack_demo | 3cfea8788a9c4323937e730e1a7cbf18 | CREATE_COMPLETE | 2019-02-22T11:36:17Z | 2019-02-22T11:36:25Z |
+--------------------------------------+------------+----------------------------------+-----------------+----------------------+----------------------+
  1. Verify the STACK and the resources is deleted $ openstack stack list

<nova_server.yaml>

heat_template_version: 2015-10-15
description: Launch a basic instance with CirrOS image using the ``demo1.tiny`` flavor, ``mykey`` key,  and one network.
parameters:
  NetID:
    type: string
    description: Network ID to use for the instance.

resources:
  server:
    type: OS::Nova::Server
    properties:
      image: cirros
      flavor: demo1.tiny
      key_name:
      networks:
      - network: { get_param: NetID }

outputs:
  instance_name:
    description: Name of the instance
    value: { get_attr: [ server, name ] }
  instance_ip:
    description: IP address of the instance.
    value: { get_attr: [ server, first_address ] }

References:

[0] - [https://wiki.openstack.org/wiki/StarlingX/Containers/Installation]

[1] - [https://docs.openstack.org/nova/pike/admin/flavors2.html]

[2] - HEAT_HOT_Template_12 Test Case

[3] - HEAT_HOT_Template_01 Test Case