Merge "Move InvalidConfiguration exception to tempest.lib"

This commit is contained in:
Jenkins 2016-10-18 06:24:42 +00:00 committed by Gerrit Code Review
commit aa11f58cec
18 changed files with 28 additions and 32 deletions

View File

@ -17,7 +17,7 @@ import netaddr
from tempest.api.compute import base from tempest.api.compute import base
from tempest import config from tempest import config
from tempest import exceptions from tempest.lib import exceptions
from tempest import test from tempest import test
CONF = config.CONF CONF = config.CONF

View File

@ -23,7 +23,7 @@ from tempest.common import image as common_image
from tempest.common.utils import data_utils from tempest.common.utils import data_utils
from tempest.common import waiters from tempest.common import waiters
from tempest import config from tempest import config
from tempest import exceptions from tempest.lib import exceptions
from tempest import test from tempest import test
CONF = config.CONF CONF = config.CONF

View File

@ -24,7 +24,6 @@ from tempest.common.utils import data_utils
from tempest.common.utils.linux import remote_client from tempest.common.utils.linux import remote_client
from tempest.common import waiters from tempest.common import waiters
from tempest import config from tempest import config
from tempest import exceptions
from tempest.lib import decorators from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc from tempest.lib import exceptions as lib_exc
from tempest import test from tempest import test
@ -331,7 +330,7 @@ class ServerActionsTestJSON(base.BaseV2ComputeTest):
elif CONF.image_feature_enabled.api_v2: elif CONF.image_feature_enabled.api_v2:
glance_client = self.os.image_client_v2 glance_client = self.os.image_client_v2
else: else:
raise exceptions.InvalidConfiguration( raise lib_exc.InvalidConfiguration(
'Either api_v1 or api_v2 must be True in ' 'Either api_v1 or api_v2 must be True in '
'[image-feature-enabled].') '[image-feature-enabled].')

View File

@ -20,7 +20,7 @@ from tempest.common import image as common_image
from tempest.common.utils import data_utils from tempest.common.utils import data_utils
from tempest.common import waiters from tempest.common import waiters
from tempest import config from tempest import config
from tempest import exceptions from tempest.lib import exceptions
from tempest import test from tempest import test
CONF = config.CONF CONF = config.CONF

View File

@ -15,7 +15,7 @@
from tempest.api.network import base from tempest.api.network import base
from tempest.common.utils import data_utils from tempest.common.utils import data_utils
from tempest import config from tempest import config
from tempest import exceptions from tempest.lib import exceptions
from tempest import test from tempest import test
CONF = config.CONF CONF = config.CONF

View File

@ -23,7 +23,7 @@ from tempest.api.network import base_security_groups as sec_base
from tempest.common import custom_matchers from tempest.common import custom_matchers
from tempest.common.utils import data_utils from tempest.common.utils import data_utils
from tempest import config from tempest import config
from tempest import exceptions from tempest.lib import exceptions
from tempest import test from tempest import test
CONF = config.CONF CONF = config.CONF

View File

@ -17,8 +17,8 @@ from tempest.common import compute
from tempest.common.utils import data_utils from tempest.common.utils import data_utils
from tempest.common import waiters from tempest.common import waiters
from tempest import config from tempest import config
from tempest import exceptions
from tempest.lib.common.utils import test_utils from tempest.lib.common.utils import test_utils
from tempest.lib import exceptions
import tempest.test import tempest.test
CONF = config.CONF CONF = config.CONF

View File

@ -18,8 +18,8 @@ from tempest.api.volume import base
from tempest.common.utils import data_utils from tempest.common.utils import data_utils
from tempest.common import waiters from tempest.common import waiters
from tempest import config from tempest import config
from tempest import exceptions
from tempest.lib.common.utils import test_utils from tempest.lib.common.utils import test_utils
from tempest.lib import exceptions
from tempest import test from tempest import test
CONF = config.CONF CONF = config.CONF

View File

@ -267,14 +267,14 @@ class Manager(clients.ServiceClients):
CONF.identity.uri, **self.default_params) CONF.identity.uri, **self.default_params)
else: else:
msg = 'Identity v2 API enabled, but no identity.uri set' msg = 'Identity v2 API enabled, but no identity.uri set'
raise exceptions.InvalidConfiguration(msg) raise lib_exc.InvalidConfiguration(msg)
if CONF.identity_feature_enabled.api_v3: if CONF.identity_feature_enabled.api_v3:
if CONF.identity.uri_v3: if CONF.identity.uri_v3:
self.token_v3_client = identity.v3.V3TokenClient( self.token_v3_client = identity.v3.V3TokenClient(
CONF.identity.uri_v3, **self.default_params) CONF.identity.uri_v3, **self.default_params)
else: else:
msg = 'Identity v3 API enabled, but no identity.uri_v3 set' msg = 'Identity v3 API enabled, but no identity.uri_v3 set'
raise exceptions.InvalidConfiguration(msg) raise lib_exc.InvalidConfiguration(msg)
def _set_volume_clients(self): def _set_volume_clients(self):
# Mandatory parameters (always defined) # Mandatory parameters (always defined)

View File

@ -17,8 +17,8 @@ from tempest import clients
from tempest.common import dynamic_creds from tempest.common import dynamic_creds
from tempest.common import preprov_creds from tempest.common import preprov_creds
from tempest import config from tempest import config
from tempest import exceptions
from tempest.lib import auth from tempest.lib import auth
from tempest.lib import exceptions
CONF = config.CONF CONF = config.CONF

View File

@ -18,7 +18,6 @@ import six
from tempest import clients from tempest import clients
from tempest.common import cred_client from tempest.common import cred_client
from tempest import exceptions
from tempest.lib.common import cred_provider from tempest.lib.common import cred_provider
from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc from tempest.lib import exceptions as lib_exc
@ -219,14 +218,14 @@ class DynamicCredentialProvider(cred_provider.CredentialProvider):
if self.network_resources['router']: if self.network_resources['router']:
if (not self.network_resources['subnet'] or if (not self.network_resources['subnet'] or
not self.network_resources['network']): not self.network_resources['network']):
raise exceptions.InvalidConfiguration( raise lib_exc.InvalidConfiguration(
'A router requires a subnet and network') 'A router requires a subnet and network')
elif self.network_resources['subnet']: elif self.network_resources['subnet']:
if not self.network_resources['network']: if not self.network_resources['network']:
raise exceptions.InvalidConfiguration( raise lib_exc.InvalidConfiguration(
'A subnet requires a network') 'A subnet requires a network')
elif self.network_resources['dhcp']: elif self.network_resources['dhcp']:
raise exceptions.InvalidConfiguration('DHCP requires a subnet') raise lib_exc.InvalidConfiguration('DHCP requires a subnet')
rand_name_root = data_utils.rand_name( rand_name_root = data_utils.rand_name(
self.name, prefix=self.resource_prefix) self.name, prefix=self.resource_prefix)

View File

@ -35,7 +35,7 @@ def read_accounts_yaml(path):
with open(path, 'r') as yaml_file: with open(path, 'r') as yaml_file:
accounts = yaml.load(yaml_file) accounts = yaml.load(yaml_file)
except IOError: except IOError:
raise exceptions.InvalidConfiguration( raise lib_exc.InvalidConfiguration(
'The path for the test accounts file: %s ' 'The path for the test accounts file: %s '
'could not be found' % path) 'could not be found' % path)
return accounts return accounts

View File

@ -19,7 +19,6 @@ import time
from oslo_log import log as logging from oslo_log import log as logging
from tempest import config from tempest import config
from tempest import exceptions
from tempest.lib.common import ssh from tempest.lib.common import ssh
from tempest.lib.common.utils import test_utils from tempest.lib.common.utils import test_utils
import tempest.lib.exceptions import tempest.lib.exceptions
@ -218,8 +217,8 @@ class RemoteClient(object):
supported_clients = ['udhcpc', 'dhclient'] supported_clients = ['udhcpc', 'dhclient']
dhcp_client = CONF.scenario.dhcp_client dhcp_client = CONF.scenario.dhcp_client
if dhcp_client not in supported_clients: if dhcp_client not in supported_clients:
raise exceptions.InvalidConfiguration('%s DHCP client unsupported' raise tempest.lib.exceptions.InvalidConfiguration(
% dhcp_client) '%s DHCP client unsupported' % dhcp_client)
if dhcp_client == 'udhcpc' and not fixed_ip: if dhcp_client == 'udhcpc' and not fixed_ip:
raise ValueError("need to set 'fixed_ip' for udhcpc client") raise ValueError("need to set 'fixed_ip' for udhcpc client")
return getattr(self, '_renew_lease_' + dhcp_client)(fixed_ip=fixed_ip) return getattr(self, '_renew_lease_' + dhcp_client)(fixed_ip=fixed_ip)

View File

@ -17,10 +17,6 @@
from tempest.lib import exceptions from tempest.lib import exceptions
class InvalidConfiguration(exceptions.TempestException):
message = "Invalid Configuration"
class InvalidServiceTag(exceptions.TempestException): class InvalidServiceTag(exceptions.TempestException):
message = "Invalid service tag" message = "Invalid service tag"

View File

@ -149,6 +149,10 @@ class UnexpectedResponseCode(OtherRestClientException):
message = "Unexpected response code received" message = "Unexpected response code received"
class InvalidConfiguration(TempestException):
message = "Invalid Configuration"
class InvalidIdentityVersion(TempestException): class InvalidIdentityVersion(TempestException):
message = "Invalid version %(identity_version)s of the identity service" message = "Invalid version %(identity_version)s of the identity service"

View File

@ -57,7 +57,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
elif CONF.image_feature_enabled.api_v2: elif CONF.image_feature_enabled.api_v2:
cls.image_client = cls.manager.image_client_v2 cls.image_client = cls.manager.image_client_v2
else: else:
raise exceptions.InvalidConfiguration( raise lib_exc.InvalidConfiguration(
'Either api_v1 or api_v2 must be True in ' 'Either api_v1 or api_v2 must be True in '
'[image-feature-enabled].') '[image-feature-enabled].')
# Compute image client # Compute image client
@ -639,7 +639,7 @@ class ScenarioTest(tempest.test.BaseTestCase):
return address['addr'] return address['addr']
raise exceptions.ServerUnreachable(server_id=server['id']) raise exceptions.ServerUnreachable(server_id=server['id'])
else: else:
raise exceptions.InvalidConfiguration() raise lib_exc.InvalidConfiguration()
class NetworkScenarioTest(ScenarioTest): class NetworkScenarioTest(ScenarioTest):
@ -1177,7 +1177,7 @@ class NetworkScenarioTest(ScenarioTest):
# https://blueprints.launchpad.net/tempest/+spec/test-accounts # https://blueprints.launchpad.net/tempest/+spec/test-accounts
if not CONF.compute.fixed_network_name: if not CONF.compute.fixed_network_name:
m = 'fixed_network_name must be specified in config' m = 'fixed_network_name must be specified in config'
raise exceptions.InvalidConfiguration(m) raise lib_exc.InvalidConfiguration(m)
network = self._get_network_by_name( network = self._get_network_by_name(
CONF.compute.fixed_network_name) CONF.compute.fixed_network_name)
router = None router = None

View File

@ -15,7 +15,7 @@
from tempest import config from tempest import config
from tempest import exceptions from tempest.lib import exceptions
from tempest.scenario import manager from tempest.scenario import manager
from tempest import test from tempest import test

View File

@ -19,7 +19,6 @@ from oslotest import mockpatch
from tempest.common import credentials_factory as credentials from tempest.common import credentials_factory as credentials
from tempest.common import dynamic_creds from tempest.common import dynamic_creds
from tempest import config from tempest import config
from tempest import exceptions
from tempest.lib.common import rest_client from tempest.lib.common import rest_client
from tempest.lib import exceptions as lib_exc from tempest.lib import exceptions as lib_exc
from tempest.lib.services.identity.v2 import identity_client as v2_iden_client from tempest.lib.services.identity.v2 import identity_client as v2_iden_client
@ -572,7 +571,7 @@ class TestDynamicCredentialProvider(base.TestCase):
self._mock_list_role() self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user') self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant') self._mock_tenant_create('1234', 'fake_prim_tenant')
self.assertRaises(exceptions.InvalidConfiguration, self.assertRaises(lib_exc.InvalidConfiguration,
creds.get_primary_creds) creds.get_primary_creds)
@mock.patch('tempest.lib.common.rest_client.RestClient') @mock.patch('tempest.lib.common.rest_client.RestClient')
@ -592,7 +591,7 @@ class TestDynamicCredentialProvider(base.TestCase):
self._mock_list_role() self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user') self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant') self._mock_tenant_create('1234', 'fake_prim_tenant')
self.assertRaises(exceptions.InvalidConfiguration, self.assertRaises(lib_exc.InvalidConfiguration,
creds.get_primary_creds) creds.get_primary_creds)
@mock.patch('tempest.lib.common.rest_client.RestClient') @mock.patch('tempest.lib.common.rest_client.RestClient')
@ -612,7 +611,7 @@ class TestDynamicCredentialProvider(base.TestCase):
self._mock_list_role() self._mock_list_role()
self._mock_user_create('1234', 'fake_prim_user') self._mock_user_create('1234', 'fake_prim_user')
self._mock_tenant_create('1234', 'fake_prim_tenant') self._mock_tenant_create('1234', 'fake_prim_tenant')
self.assertRaises(exceptions.InvalidConfiguration, self.assertRaises(lib_exc.InvalidConfiguration,
creds.get_primary_creds) creds.get_primary_creds)