Set interface=admin for keystonev2 keystone tests

Keystone v2 needs to perform admin tasks over the admin interface.
Be explicit about doing that.

Change-Id: If3352fccd244a5515af8d4f95c9992df74cfb39d
This commit is contained in:
Monty Taylor 2017-04-27 19:01:30 -05:00
parent 7a4789fde5
commit a5c49cb0ef
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
6 changed files with 40 additions and 15 deletions

View File

@ -22,22 +22,31 @@ class BaseFunctionalTestCase(base.TestCase):
def setUp(self):
super(BaseFunctionalTestCase, self).setUp()
demo_name = os.environ.get('SHADE_DEMO_CLOUD', 'devstack')
op_name = os.environ.get('SHADE_OPERATOR_CLOUD', 'devstack-admin')
self._demo_name = os.environ.get('SHADE_DEMO_CLOUD', 'devstack')
self._op_name = os.environ.get(
'SHADE_OPERATOR_CLOUD', 'devstack-admin')
self.config = occ.OpenStackConfig()
demo_config = self.config.get_one_cloud(cloud=demo_name)
self.user_cloud = shade.OpenStackCloud(
cloud_config=demo_config,
log_inner_exceptions=True)
operator_config = self.config.get_one_cloud(cloud=op_name)
self.operator_cloud = shade.OperatorCloud(
cloud_config=operator_config,
log_inner_exceptions=True)
self._set_user_cloud()
self._set_operator_cloud()
self.identity_version = \
self.operator_cloud.cloud_config.get_api_version('identity')
def _set_user_cloud(self, **kwargs):
user_config = self.config.get_one_cloud(
cloud=self._demo_name, **kwargs)
self.user_cloud = shade.OpenStackCloud(
cloud_config=user_config,
log_inner_exceptions=True)
def _set_operator_cloud(self, **kwargs):
operator_config = self.config.get_one_cloud(
cloud=self._op_name, **kwargs)
self.operator_cloud = shade.OperatorCloud(
cloud_config=operator_config,
log_inner_exceptions=True)
def pick_image(self):
images = self.user_cloud.list_images()
self.add_info_on_exception('images', images)
@ -64,3 +73,19 @@ class BaseFunctionalTestCase(base.TestCase):
if image.name.lower().startswith('centos'):
return image
self.assertFalse('no sensible image available')
class KeystoneBaseFunctionalTestCase(BaseFunctionalTestCase):
def setUp(self):
super(KeystoneBaseFunctionalTestCase, self).setUp()
use_keystone_v2 = os.environ.get('SHADE_USE_KEYSTONE_V2', False)
if use_keystone_v2:
# keystone v2 has special behavior for the admin
# interface and some of the operations, so make a new cloud
# object with interface set to admin.
# We only do it for keystone tests on v2 because otherwise
# the admin interface is not a thing that wants to actually
# be used
self._set_operator_cloud(interface='admin')

View File

@ -29,7 +29,7 @@ from shade.exc import OpenStackCloudUnavailableFeature
from shade.tests.functional import base
class TestEndpoints(base.BaseFunctionalTestCase):
class TestEndpoints(base.KeystoneBaseFunctionalTestCase):
endpoint_attributes = ['id', 'region', 'publicurl', 'internalurl',
'service_id', 'adminurl']

View File

@ -24,7 +24,7 @@ from shade import OpenStackCloudException
from shade.tests.functional import base
class TestIdentity(base.BaseFunctionalTestCase):
class TestIdentity(base.KeystoneBaseFunctionalTestCase):
def setUp(self):
super(TestIdentity, self).setUp()
self.role_prefix = 'test_role' + ''.join(

View File

@ -25,7 +25,7 @@ from shade.exc import OpenStackCloudException
from shade.tests.functional import base
class TestProject(base.BaseFunctionalTestCase):
class TestProject(base.KeystoneBaseFunctionalTestCase):
def setUp(self):
super(TestProject, self).setUp()

View File

@ -29,7 +29,7 @@ from shade.exc import OpenStackCloudUnavailableFeature
from shade.tests.functional import base
class TestServices(base.BaseFunctionalTestCase):
class TestServices(base.KeystoneBaseFunctionalTestCase):
service_attributes = ['id', 'name', 'type', 'description']

View File

@ -22,7 +22,7 @@ from shade import OpenStackCloudException
from shade.tests.functional import base
class TestUsers(base.BaseFunctionalTestCase):
class TestUsers(base.KeystoneBaseFunctionalTestCase):
def setUp(self):
super(TestUsers, self).setUp()
self.user_prefix = self.getUniqueString('user')