Merge "Specify api_version for functional tests"

This commit is contained in:
Jenkins 2015-09-23 12:58:02 +00:00 committed by Gerrit Code Review
commit 1f1ce37440
8 changed files with 25 additions and 12 deletions

View File

@ -70,6 +70,8 @@ class ClientTestBase(testtools.TestCase):
* initially just check return codes, and later test command outputs
"""
COMPUTE_API_VERSION = None
log_format = ('%(asctime)s %(process)d %(levelname)-8s '
'[%(name)s] %(message)s')
@ -170,9 +172,12 @@ class ClientTestBase(testtools.TestCase):
uri=auth_url,
cli_dir=cli_dir)
def nova(self, *args, **kwargs):
return self.cli_clients.nova(*args,
**kwargs)
def nova(self, action, flags='', params='', fail_ok=False,
endpoint_type='publicURL', merge_stderr=False):
if self.COMPUTE_API_VERSION:
flags += " --os-compute-api-version %s " % self.COMPUTE_API_VERSION
return self.cli_clients.nova(action, flags, params, fail_ok,
endpoint_type, merge_stderr)
def wait_for_volume_status(self, volume, status, timeout=60,
poll_interval=1):

View File

@ -20,11 +20,7 @@ from novaclient.v2 import shell
class TestFixedIPsNovaClient(base.ClientTestBase):
"""FixedIPs functional tests."""
API_VERSION = '2.1'
def nova(self, *args, **kwargs):
flags = '--os-compute-api-version %s ' % self.API_VERSION
return self.cli_clients.nova(flags=flags, *args, **kwargs)
COMPUTE_API_VERSION = '2.1'
def _create_server(self):
name = self.name_generate(prefix='server')
@ -61,7 +57,7 @@ class TestFixedIPsNovaClient(base.ClientTestBase):
class TestFixedIPsNovaClientV24(TestFixedIPsNovaClient):
"""FixedIPs functional tests for v2.4 nova-api microversion."""
API_VERSION = '2.4'
COMPUTE_API_VERSION = '2.4'
def test_fixedip_get(self):
self._test_fixedip_get(expect_reserved=True)

View File

@ -15,6 +15,8 @@ from novaclient.tests.functional import base
class TestInstanceCLI(base.ClientTestBase):
COMPUTE_API_VERSION = "2.1"
def test_attach_volume(self):
"""Test we can attach a volume via the cli.

View File

@ -23,6 +23,8 @@ class TestKeypairsNovaClient(base.ClientTestBase):
"""Keypairs functional tests.
"""
COMPUTE_API_VERSION = "2.1"
def _serialize_kwargs(self, kwargs):
kwargs_pairs = ['--%(key)s %(val)s' % {'key': key.replace('_', '-'),
'val': val}
@ -96,9 +98,7 @@ class TestKeypairsNovaClientV22(TestKeypairsNovaClient):
"""Keypairs functional tests for v2.2 nova-api microversion.
"""
def nova(self, *args, **kwargs):
return self.cli_clients.nova(flags='--os-compute-api-version 2.2 ',
*args, **kwargs)
COMPUTE_API_VERSION = "2.2"
def test_create_keypair(self):
keypair = super(TestKeypairsNovaClientV22, self).test_create_keypair()

View File

@ -17,6 +17,8 @@ class TestQuotasNovaClient(base.ClientTestBase):
"""Nova quotas functional tests.
"""
COMPUTE_API_VERSION = "2.1"
_quota_resources = ['instances', 'cores', 'ram',
'floating_ips', 'fixed_ips', 'metadata_items',
'injected_files', 'injected_file_content_bytes',

View File

@ -24,6 +24,8 @@ class SimpleReadOnlyNovaClientTest(base.ClientTestBase):
This only exercises client commands that are read only.
"""
COMPUTE_API_VERSION = "2.1"
def test_admin_fake_action(self):
self.assertRaises(exceptions.CommandFailed,
self.nova,

View File

@ -20,6 +20,8 @@ class TestServersBootNovaClient(base.ClientTestBase):
"""Servers boot functional tests.
"""
COMPUTE_API_VERSION = "2.1"
def test_boot_server_with_legacy_bdm(self):
volume_size = 1
volume_name = str(uuid.uuid4())
@ -44,6 +46,8 @@ class TestServersListNovaClient(base.ClientTestBase):
"""Servers list functional tests.
"""
COMPUTE_API_VERSION = "2.1"
def _create_servers(self, name, number):
network = self.client.networks.list()[0]
servers = []

View File

@ -32,6 +32,8 @@ def wait_for_delete(test, name, thing, get_func):
class TestVolumesAPI(base.ClientTestBase):
COMPUTE_API_VERSION = "2.1"
def test_volumes_snapshots_types_create_get_list_delete(self):
# Create a volume
volume = self.client.volumes.create(1)