summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-08-22 01:08:44 +0000
committerGerrit Code Review <review@openstack.org>2016-08-22 01:08:44 +0000
commite71b5369e926fd5f7c6ffa9e31318e724f93f619 (patch)
tree1e265410dd94ab67e91de28a82989840339da5a0
parent1b6cc4a6bc48ef4c049c16af6e64f8da5875fc86 (diff)
parent9c5c8a685be9ca1ca1e2f7bad93e339e12c66a37 (diff)
downloadpython-novaclient-e71b5369e926fd5f7c6ffa9e31318e724f93f619.tar.gz
Merge "[functional] Skip tests if API doesn't support microversion"
-rw-r--r--novaclient/tests/functional/base.py47
1 files changed, 41 insertions, 6 deletions
diff --git a/novaclient/tests/functional/base.py b/novaclient/tests/functional/base.py
index 263f7912..1bd2e809 100644
--- a/novaclient/tests/functional/base.py
+++ b/novaclient/tests/functional/base.py
@@ -105,6 +105,7 @@ class NoCloudConfigException(Exception):
USE_NEUTRON = None
+SERVER_API_VERSIONS = None
class ClientTestBase(testtools.TestCase):
@@ -202,11 +203,6 @@ class ClientTestBase(testtools.TestCase):
else:
self.insecure = False
- if self.COMPUTE_API_VERSION == "2.latest":
- version = novaclient.API_MAX_VERSION.get_string()
- else:
- version = self.COMPUTE_API_VERSION or "2"
-
auth = identity.Password(username=user,
password=passwd,
project_name=tenant,
@@ -215,7 +211,7 @@ class ClientTestBase(testtools.TestCase):
user_domain_id=user_domain_id)
session = ksession.Session(auth=auth, verify=(not self.insecure))
- self.client = novaclient.client.Client(version, session=session)
+ self.client = self._get_novaclient(session)
self.glance = glanceclient.Client('2', session=session)
@@ -265,6 +261,45 @@ class ClientTestBase(testtools.TestCase):
else:
USE_NEUTRON = False
+ def _get_novaclient(self, session):
+ nc = novaclient.client.Client("2", session=session)
+
+ if self.COMPUTE_API_VERSION:
+ global SERVER_API_VERSIONS
+ if SERVER_API_VERSIONS is None:
+ # Obtain supported versions by API side
+ v = nc.versions.get_current()
+ if not hasattr(v, 'version') or not v.version:
+ # API doesn't support microversions
+ SERVER_API_VERSIONS = (
+ novaclient.api_versions.APIVersion("2.0"),
+ novaclient.api_versions.APIVersion("2.0"))
+ else:
+ SERVER_API_VERSIONS = (
+ novaclient.api_versions.APIVersion(v.min_version),
+ novaclient.api_versions.APIVersion(v.version))
+
+ if self.COMPUTE_API_VERSION == "2.latest":
+ requested_version = min(novaclient.API_MAX_VERSION,
+ SERVER_API_VERSIONS[1])
+ else:
+ requested_version = novaclient.api_versions.APIVersion(
+ self.COMPUTE_API_VERSION)
+
+ if not requested_version.matches(*SERVER_API_VERSIONS):
+ msg = ("%s is not supported by Nova-API. Supported version" %
+ self.COMPUTE_API_VERSION)
+ if SERVER_API_VERSIONS[0] == SERVER_API_VERSIONS[1]:
+ msg += ": %s" % SERVER_API_VERSIONS[0].get_string()
+ else:
+ msg += "s: %s - %s" % (
+ SERVER_API_VERSIONS[0].get_string(),
+ SERVER_API_VERSIONS[1].get_string())
+ self.skipTest(msg)
+
+ nc.api_version = requested_version
+ return nc
+
def nova(self, action, flags='', params='', fail_ok=False,
endpoint_type='publicURL', merge_stderr=False):
if self.COMPUTE_API_VERSION: