check is_admin_available for force_tenant_isolation in test.py

If force_tenant_isolation is set to True, admin credential is
needed, and this check should be put in skip_checks in test.py,
while should not be done by individual testcases.

Change-Id: I9506120a088cde270b9c787bab26bf6e4c4a23d3
This commit is contained in:
zhufl 2017-08-25 10:49:35 +08:00
parent c961a656cc
commit 75498bae68
2 changed files with 7 additions and 10 deletions

View File

@ -16,7 +16,6 @@ from oslo_log import log
from tempest.api.compute import base
from tempest.common import compute
from tempest.common import credentials_factory as credentials
from tempest.common import utils
from tempest import config
from tempest.lib.common.utils import test_utils
@ -46,11 +45,6 @@ class AutoAllocateNetworkTest(base.BaseV2ComputeTest):
@classmethod
def skip_checks(cls):
super(AutoAllocateNetworkTest, cls).skip_checks()
identity_version = cls.get_identity_version()
if not credentials.is_admin_available(
identity_version=identity_version):
msg = "Missing Identity Admin API credentials in configuration."
raise cls.skipException(msg)
if not CONF.service_available.neutron:
raise cls.skipException('Neutron is required')
if not utils.is_extension_enabled('auto-allocated-topology',

View File

@ -220,10 +220,13 @@ class BaseTestCase(testtools.testcase.WithAttributes,
resource_setup or at test level.
"""
identity_version = cls.get_identity_version()
if 'admin' in cls.credentials and not credentials.is_admin_available(
identity_version=identity_version):
msg = "Missing Identity Admin API credentials in configuration."
raise cls.skipException(msg)
# setting force_tenant_isolation to True also needs admin credentials.
if ('admin' in cls.credentials or
getattr(cls, 'force_tenant_isolation', False)):
if not credentials.is_admin_available(
identity_version=identity_version):
raise cls.skipException(
"Missing Identity Admin API credentials in configuration.")
if 'alt' in cls.credentials and not credentials.is_alt_available(
identity_version=identity_version):
msg = "Missing a 2nd set of API credentials in configuration."