Debian Codegraph @

heatclient/tests/functional/osc/v1/test_stack.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
12
13 from tempest.lib.common.utils import data_utils as utils
14
15 from heatclient.tests.functional import config
16 from heatclient.tests.functional.osc.v1 import base
17
18
19 class OpenStackClientStackTest(base.OpenStackClientTestBase):
20 """Basic stack operation tests for Openstack CLI client heat plugin.
21
22 Basic smoke test for the openstack CLI stack commands.
23 """
24
25 def setUp(self):
26 super().setUp()
27 self.stack_name = utils.rand_name(name='test-stack')
28
29 def _stack_create_minimal(self, from_url=False):
30 if from_url:
31 template = config.HEAT_MINIMAL_HOT_TEMPLATE_URL
32 else:
33 template = self.get_template_path('heat_minimal_hot.yaml')
34 parameters = ['test_client_name=test_client_name']
35 return self._stack_create(self.stack_name, template=template,
36 parameters=parameters)
37
38 def test_stack_create_minimal_from_file(self):
39 stack = self._stack_create_minimal()
40 self.assertEqual(self.stack_name, stack['stack_name'])
41 self.assertEqual("CREATE_COMPLETE", stack['stack_status'])
42
43 def test_stack_create_minimal_from_url(self):
44 stack = self._stack_create_minimal(from_url=True)
45 self.assertEqual(self.stack_name, stack['stack_name'])
46 self.assertEqual("CREATE_COMPLETE", stack['stack_status'])
47
48 def test_stack_suspend_resume(self):
49 stack = self._stack_create_minimal()
50 stack = self._stack_suspend(stack['id'])
51 self.assertEqual(self.stack_name, stack['stack_name'])
52 self.assertEqual("SUSPEND_COMPLETE", stack['stack_status'])
53 stack = self._stack_resume(stack['id'])
54 self.assertEqual(self.stack_name, stack['stack_name'])
55 self.assertEqual("RESUME_COMPLETE", stack['stack_status'])
56
57 def test_stack_snapshot_create_restore(self):
58 snapshot_name = utils.rand_name(name='test-stack-snapshot')
59 stack = self._stack_create_minimal()
60 snapshot = self._stack_snapshot_create(stack['id'], snapshot_name)
61 self.assertEqual(snapshot_name, snapshot['name'])
62 self._stack_snapshot_restore(stack['id'], snapshot['id'])
63
64 def test_stack_delete(self):
65 stack = self._stack_create_minimal()
66 self._stack_delete(stack['id'])
67 stacks_raw = self.openstack('stack list')
68 self.assertNotIn(stack['id'], stacks_raw)
69
70 def test_stack_snapshot_delete(self):
71 snapshot_name = utils.rand_name(name='test-stack-snapshot')
72 stack = self._stack_create_minimal()
73 snapshot = self._stack_snapshot_create(stack['id'], snapshot_name)
74 self._stack_snapshot_delete(stack['id'], snapshot['id'])
75 stacks_raw = self.openstack(
76 'stack snapshot list' + ' ' + self.stack_name)
77 self.assertNotIn(snapshot['id'], stacks_raw)
78
79 def test_stack_show(self):
80 stack = self._stack_create_minimal()
81 stack_info = self._stack_show(stack['id'])
82 stack_props = {k: v for k, v in stack_info.items()
83 if k in stack.keys()}
84 self.assertEqual(stack, stack_props)