Debian Codegraph @

heatclient/tests/functional/osc/v1/test_readonly.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 import yaml
14
15 from tempest.lib import exceptions
16
17 from heatclient.tests.functional.osc.v1 import base
18
19
20 class SimpleReadOnlyOpenStackClientTest(base.OpenStackClientTestBase):
21 """Basic, read-only tests for Openstack CLI client heat plugin.
22
23 Basic smoke test for the openstack CLI commands which do not require
24 creating or modifying stacks.
25 """
26
27 def test_openstack_fake_action(self):
28 self.assertRaises(exceptions.CommandFailed,
29 self.openstack,
30 'this-does-not-exist')
31
32 # Empty list commands
33 def test_openstack_empty_lists(self):
34 cmds = [
35 'software config',
36 'software deployment',
37 'stack',
38 ]
39 for cmd in cmds:
40 self.openstack(cmd + ' list')
41
42 # Stack not found commands
43 def test_openstack_stack_not_found(self):
44 cmds = [
45 'stack abandon',
46 'stack check',
47 'stack output list',
48 'stack resume',
49 'stack show',
50 'stack snapshot list',
51 'stack suspend',
52 'stack template show',
53 'stack cancel'
54 ]
55 for cmd in cmds:
56 err = self.assertRaises(exceptions.CommandFailed,
57 self.openstack,
58 cmd + ' I-AM-NOT-FOUND')
59 self.assertIn('Stack not found: I-AM-NOT-FOUND', str(err))
60
61 def test_openstack_stack_list_debug(self):
62 self.openstack('stack list', flags='--debug')
63
64 def test_openstack_stack_list_property(self):
65 self.openstack('stack list --property id=123')
66
67 def test_openstack_help_cmd(self):
68 help_text = self.openstack('help stack list')
69 lines = help_text.split('\n')
70 self.assertFirstLineStartsWith(lines, 'usage: openstack stack list')
71
72 def test_openstack_version(self):
73 self.openstack('', flags='--version')
74
75 def test_openstack_template_version_list(self):
76 ret = self.openstack('orchestration template version list')
77 tmpl_types = self.parser.listing(ret)
78 self.assertTableStruct(tmpl_types, ['Version', 'Type'])
79
80 def test_openstack_template_function_list(self):
81 ret = self.openstack('orchestration template function list '
82 'heat_template_version.2015-10-15')
83 tmpl_functions = self.parser.listing(ret)
84 self.assertTableStruct(tmpl_functions, ['Functions', 'Description'])
85
86 def test_openstack_resource_type_list(self):
87 ret = self.openstack('orchestration resource type list')
88 rsrc_types = self.parser.listing(ret)
89 self.assertTableStruct(rsrc_types, ['Resource Type'])
90
91 def test_openstack_resource_type_show(self):
92 rsrc_schema = self.openstack('orchestration resource type show '
93 'OS::Heat::RandomString')
94 self.assertIsInstance(yaml.safe_load(rsrc_schema), dict)
95
96 def _template_validate(self, templ_name, parms):
97 heat_template_path = self.get_template_path(templ_name)
98 cmd = 'stack create test-stack --dry-run --template %s'\
99 % heat_template_path
100 for parm in parms:
101 cmd += ' --parameter ' + parm
102 ret = self.openstack(cmd)
103 self.assertRegex(ret, r'stack_name.*|.*test_stack')
104
105 def test_heat_template_validate_yaml(self):
106 self._template_validate(
107 'heat_minimal.yaml',
108 ['ClientName=ClientName', 'WaitSecs=123']
109 )
110
111 def test_heat_template_validate_hot(self):
112 self._template_validate(
113 'heat_minimal_hot.yaml',
114 ['test_client_name=test_client_name', 'test_wait_secs=123']
115 )
116
117 def _orchestration_template_validate(self, templ_name, parms):
118 template_path = self.get_template_path(templ_name)
119 cmd = 'orchestration template validate --template %s' % template_path
120 for parm in parms:
121 cmd += ' --parameter ' + parm
122 ret = self.openstack(cmd)
123 self.assertRegex(ret, r'Value:.*123')
124
125 def test_orchestration_template_validate_yaml(self):
126 self._orchestration_template_validate(
127 'heat_minimal.yaml',
128 ['ClientName=ClientName', 'WaitSecs=123']
129 )
130
131 def test_orchestration_template_validate_hot(self):
132 self._orchestration_template_validate(
133 'heat_minimal_hot.yaml',
134 ['test_client_name=test_client_name', 'test_wait_secs=123']
135 )