summaryrefslogtreecommitdiff
path: root/heatclient/tests/functional/osc/v1/test_stack.py
blob: 55ca37ac234ad012f1677f29e95fb0bb1d9ba028 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.


import logging

from heatclient.tests.functional.osc.v1 import base
from tempest.lib.common.utils import data_utils as utils

LOG = logging.getLogger(__name__)


class OpenStackClientStackTest(base.OpenStackClientTestBase):
    """Basic stack operation tests for Openstack CLI client heat plugin.

    Basic smoke test for the openstack CLI stack commands.
    """

    def setUp(self):
        super(OpenStackClientStackTest, self).setUp()
        self.stack_name = utils.rand_name(name='test-stack')

    def _stack_create_minimal(self):
        template = self.get_template_path('heat_minimal_hot.yaml')
        parameters = ['test_client_name=test_client_name']
        return self._stack_create(self.stack_name, template, parameters)

    def test_stack_create_minimal(self):
        stack = self._stack_create_minimal()
        self.assertEqual(self.stack_name, stack['stack_name'])
        self.assertEqual("CREATE_COMPLETE", stack['stack_status'])

    def test_stack_suspend_resume(self):
        stack = self._stack_create_minimal()
        stack = self._stack_suspend(stack['id'])
        self.assertEqual(self.stack_name, stack['stack_name'])
        self.assertEqual("SUSPEND_COMPLETE", stack['stack_status'])
        stack = self._stack_resume(stack['id'])
        self.assertEqual(self.stack_name, stack['stack_name'])
        self.assertEqual("RESUME_COMPLETE", stack['stack_status'])

    def test_stack_snapshot_create_restore(self):
        snapshot_name = utils.rand_name(name='test-stack-snapshot')
        stack = self._stack_create_minimal()
        snapshot = self._stack_snapshot_create(stack['id'], snapshot_name)
        self.assertEqual(snapshot_name, snapshot['name'])
        self._stack_snapshot_restore(stack['id'], snapshot['id'])