Make func test work with keystone v3 only

neutronclient func test is broken due to missing fully support
of keystone v3 API. It seems keystone v2 API has been disbaled recently
and this triggers the test failures.

There are two causes.

The one is because tempest.lib.cli.base supports only keystone v2 auth info.
There is an on-going review in tempest, but until the next
tempest release we need a workaround. The workaround is to pass
keystone v3 related arguments in neutron() method.
'flags' argument allows us to pass extra auth info to the CLI.

The other reason is because HTTPClient (the legacy python binding class)
supports only keystone v2 API. keystone v3 API is provided via SessionClient.
I believe it is not a good idea to keep the two types of python binding
classes in future. It looks like a time to drop HTTPClient.
As a start, this commit drops HTTPClient func tests.
Note that SessionClient supports keystone v2 as well.

Closes-Bug: #1721553
Related-Bug: #1719687
Change-Id: I6f843e1412400bb1dfb4fc2352fc5cc4c3b837a4
This commit is contained in:
Akihiro Motoki
2017-10-12 08:09:29 +00:00
parent 10d55c3a0f
commit 2be24b43e9
2 changed files with 16 additions and 69 deletions

View File

@@ -64,6 +64,13 @@ class ClientTestBase(base.ClientTestBase):
return self._get_clients_from_os_cloud_config()
def neutron(self, *args, **kwargs):
# Workaround until tempest.lib.cli.base provdes fully
# keystone v3 support. It assumes the default domain.
# TODO(amotoki): Once a new tempest with a fix for bug 1719687
# is released, this should be claen up.
kwargs['flags'] = ' '.join([kwargs.get('flags', ''),
'--os-project-domain-id default',
'--os-user-domain-id default'])
return self.clients.neutron(*args,
**kwargs)
@@ -71,6 +78,13 @@ class ClientTestBase(base.ClientTestBase):
if not hasattr(self, '_non_admin_clients'):
self._non_admin_clients = self._get_clients_from_os_cloud_config(
cloud='devstack')
# Workaround until tempest.lib.cli.base provdes fully
# keystone v3 support. It assumes the default domain.
# TODO(amotoki): Once a new tempest with a fix for bug 1719687
# is released, this should be claen up.
kwargs['flags'] = ' '.join([kwargs.get('flags', ''),
'--os-project-domain-id default',
'--os-user-domain-id default'])
return self._non_admin_clients.neutron(*args, **kwargs)
def is_extension_enabled(self, extension_alias):

View File

@@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from keystoneauth1 import plugin as ksa_plugin
from keystoneauth1 import session
from oslo_utils import uuidutils
from tempest.lib import base
@@ -21,61 +19,13 @@ from neutronclient.common import exceptions
from neutronclient.tests.functional import base as func_base
from neutronclient.v2_0 import client as v2_client
# This module tests client library functionalities with
# Keystone client. Neutron client supports two types of
# HTTP clients (HTTPClient and SessionClient),
# so it is better to test both clients.
class LibraryTestBase(base.BaseTestCase):
class LibraryTestCase(base.BaseTestCase):
def setUp(self):
super(LibraryTestBase, self).setUp()
super(LibraryTestCase, self).setUp()
self.client = self._get_client()
class Libv2HTTPClientTestBase(LibraryTestBase):
def _setup_creds(self):
creds = func_base.credentials()
cloud_config = func_base.get_cloud_config()
# We're getting a session so we can find the v2 url via KSA
keystone_auth = cloud_config.get_auth()
(verify, cert) = cloud_config.get_requests_verify_args()
ks_session = session.Session(
auth=keystone_auth, verify=verify, cert=cert)
# for the old HTTPClient, we use keystone v2 API, regardless of
# whether v3 also exists or is configured
v2_auth_url = keystone_auth.get_endpoint(
ks_session, interface=ksa_plugin.AUTH_INTERFACE, version=(2, 0))
return v2_auth_url, creds
class Libv2HTTPClientTenantTestBase(Libv2HTTPClientTestBase):
def _get_client(self):
v2_auth_url, creds = self._setup_creds()
return v2_client.Client(username=creds['username'],
password=creds['password'],
tenant_name=creds['project_name'],
auth_url=v2_auth_url)
class Libv2HTTPClientProjectTestBase(Libv2HTTPClientTestBase):
def _get_client(self):
v2_auth_url, creds = self._setup_creds()
return v2_client.Client(username=creds['username'],
password=creds['password'],
project_name=creds['project_name'],
auth_url=v2_auth_url)
class Libv2SessionClientTestBase(LibraryTestBase):
def _get_client(self):
cloud_config = func_base.get_cloud_config()
keystone_auth = cloud_config.get_auth()
@@ -87,9 +37,6 @@ class Libv2SessionClientTestBase(LibraryTestBase):
cert=cert)
return v2_client.Client(session=ks_session)
class LibraryTestCase(object):
def test_list_network(self):
nets = self.client.list_networks()
self.assertIsInstance(nets['networks'], list)
@@ -112,17 +59,3 @@ class LibraryTestCase(object):
auth_ref = self.client.httpclient.get_auth_ref()
self.assertIsNotNone(auth_ref)
self.assertIsNotNone(auth_ref.role_names)
class LibraryHTTPClientTenantTest(LibraryTestCase,
Libv2HTTPClientTenantTestBase):
pass
class LibraryHTTPClientProjectTest(LibraryTestCase,
Libv2HTTPClientProjectTestBase):
pass
class LibrarySessionClientTest(LibraryTestCase, Libv2SessionClientTestBase):
pass