First commit for python client test suite

* Create a new top level directory for the tests: cli
* Adds simple read only python-novaclient (compute) test

Change-Id: I83e9171c119980951ee0866ec94847dd8c15f645
This commit is contained in:
Joe Gordon
2013-02-14 01:15:57 +00:00
parent 2b0591d953
commit c97f5c718a
4 changed files with 141 additions and 0 deletions

36
cli/__init__.py Normal file
View File

@@ -0,0 +1,36 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
# 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 tempest.openstack.common import cfg
LOG = logging.getLogger(__name__)
cli_opts = [
cfg.BoolOpt('enabled',
default=True,
help="enable cli tests"),
cfg.StrOpt('cli_dir',
default='/usr/local/bin/',
help="directory where python client binaries are located"),
]
CONF = cfg.CONF
cli_group = cfg.OptGroup(name='cli', title="cli Configuration Options")
CONF.register_group(cli_group)
CONF.register_opts(cli_opts, group=cli_group)

View File

@@ -0,0 +1 @@
This directory consists of simple read only python client tests.

View File

View File

@@ -0,0 +1,104 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
# 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
import shlex
import subprocess
import testtools
import cli
from tempest import config
from tempest.openstack.common import cfg
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
class SimpleReadOnlyNovaCLientTest(testtools.TestCase):
"""
This is a first pass at a simple read only python-novaclient test. This
only exercises client commands that are read only.
This should test commands:
* as a regular user
* as a admin user
* with and without optional parameters
* initially just check return codes, and later test command outputs
"""
@classmethod
def setUpClass(cls):
if not CONF.cli.enabled:
msg = "cli testing disabled"
raise cls.skipException(msg)
cls.identity = config.TempestConfig().identity
super(SimpleReadOnlyNovaCLientTest, cls).setUpClass()
def nova(self, action, flags='', params='', admin=True, fail_ok=False):
"""Executes nova command for the given action."""
#TODO(jogo) make admin=False work
creds = ('--os-username %s --os-tenant-name %s --os-password %s '
'--os-auth-url %s ' % (self.identity.admin_username,
self.identity.admin_tenant_name, self.identity.admin_password,
self.identity.uri))
flags = creds + ' ' + flags
cmd = ' '.join([CONF.cli.cli_dir + 'nova', flags, action, params])
LOG.info("running: '%s'" % cmd)
cmd = shlex.split(cmd)
result = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
return result
def test_admin_version(self):
self.nova('', flags='--version')
def test_admin_timing(self):
self.nova('list', flags='--timing')
def test_admin_timeout(self):
self.nova('list', flags='--timeout 2')
def test_admin_debug_list(self):
self.nova('list', flags='--debug')
def test_admin_fake_action(self):
self.assertRaises(subprocess.CalledProcessError,
self.nova,
'this-does-nova-exist')
def test_admin_aggregate_list(self):
self.nova('aggregate-list')
def test_admin_cloudpipe_list(self):
self.nova('cloudpipe-list')
def test_admin_image_list(self):
self.nova('image-list')
def test_admin_dns_domains(self):
self.nova('dns-domains')
def test_admin_flavor_list(self):
self.nova('flavor-list')
#TODO(jogo) add more tests