Merge "Add more readonly openstack client funcitonal tests"
This commit is contained in:
commit
6c18458764
|
@ -10,6 +10,9 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import yaml
|
||||||
|
|
||||||
from tempest_lib import exceptions
|
from tempest_lib import exceptions
|
||||||
|
|
||||||
from heatclient.tests.functional import base
|
from heatclient.tests.functional import base
|
||||||
|
@ -27,14 +30,86 @@ class SimpleReadOnlyOpenStackClientTest(base.ClientTestBase):
|
||||||
self.openstack,
|
self.openstack,
|
||||||
'this-does-not-exist')
|
'this-does-not-exist')
|
||||||
|
|
||||||
def test_openstack_stack_list(self):
|
# Empty list commands
|
||||||
self.openstack('stack list')
|
def test_openstack_empty_lists(self):
|
||||||
|
cmds = [
|
||||||
|
'software config',
|
||||||
|
'software deployment',
|
||||||
|
'stack',
|
||||||
|
]
|
||||||
|
for cmd in cmds:
|
||||||
|
self.openstack(cmd + ' list')
|
||||||
|
|
||||||
|
# Stack not found commands
|
||||||
|
def test_openstack_stack_not_found(self):
|
||||||
|
cmds = [
|
||||||
|
'stack abandon',
|
||||||
|
'stack check',
|
||||||
|
'stack output list',
|
||||||
|
'stack resume',
|
||||||
|
'stack show',
|
||||||
|
'stack snapshot list',
|
||||||
|
'stack suspend',
|
||||||
|
'stack template show',
|
||||||
|
'stack cancel'
|
||||||
|
]
|
||||||
|
for cmd in cmds:
|
||||||
|
err = self.assertRaises(exceptions.CommandFailed,
|
||||||
|
self.openstack,
|
||||||
|
cmd + ' I-AM-NOT-FOUND')
|
||||||
|
self.assertIn('Stack not found: I-AM-NOT-FOUND', str(err))
|
||||||
|
|
||||||
def test_openstack_stack_list_debug(self):
|
def test_openstack_stack_list_debug(self):
|
||||||
self.openstack('stack list', flags='--debug')
|
self.openstack('stack list', flags='--debug')
|
||||||
|
|
||||||
def test_openstack_help_cmd(self):
|
def test_openstack_help_cmd(self):
|
||||||
self.openstack('help stack')
|
help_text = self.openstack('help stack list')
|
||||||
|
lines = help_text.split('\n')
|
||||||
|
self.assertFirstLineStartsWith(lines, 'usage: openstack stack list')
|
||||||
|
|
||||||
def test_openstack_version(self):
|
def test_openstack_version(self):
|
||||||
self.openstack('', flags='--version')
|
self.openstack('', flags='--version')
|
||||||
|
|
||||||
|
def test_openstack_template_version_list(self):
|
||||||
|
ret = self.openstack('orchestration template version list')
|
||||||
|
tmpl_types = self.parser.listing(ret)
|
||||||
|
self.assertTableStruct(tmpl_types, ['version', 'type'])
|
||||||
|
|
||||||
|
def test_openstack_template_function_list(self):
|
||||||
|
ret = self.openstack('orchestration template function list '
|
||||||
|
'heat_template_version.2015-10-15')
|
||||||
|
tmpl_functions = self.parser.listing(ret)
|
||||||
|
self.assertTableStruct(tmpl_functions, ['functions', 'description'])
|
||||||
|
|
||||||
|
def test_openstack_resource_type_list(self):
|
||||||
|
ret = self.openstack('orchestration resource type list')
|
||||||
|
rsrc_types = self.parser.listing(ret)
|
||||||
|
self.assertTableStruct(rsrc_types, ['Resource Type'])
|
||||||
|
|
||||||
|
def test_openstack_resource_type_show(self):
|
||||||
|
rsrc_schema = self.openstack('orchestration resource type show '
|
||||||
|
'OS::Heat::RandomString')
|
||||||
|
self.assertIsInstance(yaml.load(rsrc_schema), dict)
|
||||||
|
|
||||||
|
def _template_validate(self, templ_name, parms):
|
||||||
|
heat_template_path = os.path.join(
|
||||||
|
os.path.dirname(os.path.realpath(__file__)),
|
||||||
|
'../../templates/%s' % templ_name)
|
||||||
|
cmd = 'stack create test-stack --dry-run --template %s'\
|
||||||
|
% heat_template_path
|
||||||
|
for parm in parms:
|
||||||
|
cmd += ' --parameter ' + parm
|
||||||
|
ret = self.openstack(cmd)
|
||||||
|
self.assertRegexpMatches(ret, r'stack_name.*|.*test_stack')
|
||||||
|
|
||||||
|
def test_heat_template_validate_yaml(self):
|
||||||
|
self._template_validate(
|
||||||
|
'heat_minimal.yaml',
|
||||||
|
['ClientName=ClientName', 'WaitSecs=123']
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_heat_template_validate_hot(self):
|
||||||
|
self._template_validate(
|
||||||
|
'heat_minimal_hot.yaml',
|
||||||
|
['test_client_name=test_client_name', 'test_wait_secs=123']
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue