Merge "Remove deprecated stuff. Part 1"
This commit is contained in:
commit
a9e515c632
@ -44,23 +44,23 @@ Deprecated
|
||||
|
||||
* a huge project restructure had happened. Old paths are deprecated now.
|
||||
|
||||
rally_openstack.cfg -> rally_openstack.common.cfg
|
||||
rally_openstack.cleanup -> rally_openstack.task.cleanup
|
||||
rally_openstack.consts -> rally_openstack.common.consts
|
||||
rally_openstack.contexts -> rally_openstack.task.contexts
|
||||
rally_openstack.credential -> rally_openstack.common.credential
|
||||
rally_openstack.embedcharts -> rally_openstack.task.ui.charts
|
||||
rally_openstack.exceptions -> rally_openstack.common.exceptions
|
||||
rally_openstack.hook -> rally_openstack.task.hooks
|
||||
rally_openstack.osclients -> rally_openstack.common.osclients
|
||||
rally_openstack.platforms -> rally_openstack.environment.platforms
|
||||
rally_openstack.scenario -> rally_openstack.task.scenario
|
||||
rally_openstack.scenarios -> rally_openstack.task.scenarios
|
||||
rally_openstack.service -> rally_openstack.common.service
|
||||
rally_openstack.services -> rally_openstack.common.services
|
||||
rally_openstack.types -> rally_openstack.task.types
|
||||
rally_openstack.validators -> rally_openstack.common.validators
|
||||
rally_openstack.wrappers -> rally_openstack.common.wrappers
|
||||
rally_openstack.cfg -> rally_openstack.common.cfg
|
||||
rally_openstack.cleanup -> rally_openstack.task.cleanup
|
||||
rally_openstack.consts -> rally_openstack.common.consts
|
||||
rally_openstack.contexts -> rally_openstack.task.contexts
|
||||
rally_openstack.credential -> rally_openstack.common.credential
|
||||
rally_openstack.embedcharts -> rally_openstack.task.ui.charts
|
||||
rally_openstack.exceptions -> rally_openstack.common.exceptions
|
||||
rally_openstack.hook -> rally_openstack.task.hooks
|
||||
rally_openstack.osclients -> rally_openstack.common.osclients
|
||||
rally_openstack.platforms -> rally_openstack.environment.platforms
|
||||
rally_openstack.scenario -> rally_openstack.task.scenario
|
||||
rally_openstack.scenarios -> rally_openstack.task.scenarios
|
||||
rally_openstack.service -> rally_openstack.common.service
|
||||
rally_openstack.services -> rally_openstack.common.services
|
||||
rally_openstack.types -> rally_openstack.task.types
|
||||
rally_openstack.validators -> rally_openstack.common.validators
|
||||
rally_openstack.wrappers -> rally_openstack.common.wrappers
|
||||
|
||||
|
||||
Removed
|
||||
@ -68,6 +68,24 @@ Removed
|
||||
|
||||
* Support for Python < 3.6
|
||||
|
||||
* *required_clients* validator was deprecated since Rally 0.10.0 (at the time
|
||||
when OpenStack plugins were part of Rally framework).
|
||||
|
||||
* `api_info` argument of OSClient plugins since it was merged into credentials
|
||||
object long time ago.
|
||||
|
||||
* The keyword arguments for *GlanceImages.create_image_and_boot_instances*
|
||||
scenario. They were deprecated since Rally 0.8.0 (at the time when OpenStack
|
||||
plugins were part of Rally framework). Use *boot_server_kwargs* for
|
||||
additional parameters when booting servers.
|
||||
|
||||
* *server_kwargs* alias for *boot_server_kwargs* of
|
||||
*NovaKeypair.boot_and_delete_server_with_keypair* scenario was deprecated
|
||||
since Rally 0.3.2 (at the time when OpenStack plugins were part of Rally
|
||||
framework).
|
||||
|
||||
* *api_versions* argument of cleanup manager.
|
||||
|
||||
[1.7.0] - 2020-12-25
|
||||
--------------------
|
||||
|
||||
|
@ -75,8 +75,7 @@ class OpenStackCredential(dict):
|
||||
|
||||
# this method is mostly used by validation step. let's refactor it and
|
||||
# deprecated this
|
||||
def clients(self, api_info=None):
|
||||
def clients(self):
|
||||
from rally_openstack.common import osclients
|
||||
|
||||
return osclients.Clients(self, api_info=api_info,
|
||||
cache=self._clients_cache)
|
||||
return osclients.Clients(self, cache=self._clients_cache)
|
||||
|
@ -108,15 +108,10 @@ def configure(name, default_version=None, default_service_type=None,
|
||||
class OSClient(plugin.Plugin):
|
||||
"""Base class for OpenStack clients"""
|
||||
|
||||
def __init__(self, credential, api_info=None, cache_obj=None):
|
||||
def __init__(self, credential, cache_obj=None):
|
||||
self.credential = credential
|
||||
if not isinstance(self.credential, oscred.OpenStackCredential):
|
||||
self.credential = oscred.OpenStackCredential(**self.credential)
|
||||
if api_info:
|
||||
LOG.warning("api_info argument of %s is deprecated. api"
|
||||
" information has been moved into credential"
|
||||
" argument." % self.__class__.__name__)
|
||||
self.credential.api_info.update(api_info)
|
||||
self.cache = cache_obj if cache_obj is not None else {}
|
||||
|
||||
def choose_version(self, version=None):
|
||||
@ -190,8 +185,7 @@ class OSClient(plugin.Plugin):
|
||||
|
||||
@property
|
||||
def keystone(self):
|
||||
return OSClient.get("keystone")(self.credential, None,
|
||||
self.cache)
|
||||
return OSClient.get("keystone")(self.credential, self.cache)
|
||||
|
||||
def _get_endpoint(self, service_type=None):
|
||||
kw = {"service_type": self.choose_service_type(service_type),
|
||||
@ -863,15 +857,13 @@ class Barbican(OSClient):
|
||||
class Clients(object):
|
||||
"""This class simplify and unify work with OpenStack python clients."""
|
||||
|
||||
def __init__(self, credential, api_info=None, cache=None):
|
||||
def __init__(self, credential, cache=None):
|
||||
self.credential = credential
|
||||
self.api_info = api_info or {}
|
||||
self.cache = cache or {}
|
||||
|
||||
def __getattr__(self, client_name):
|
||||
"""Lazy load of clients."""
|
||||
return OSClient.get(client_name)(self.credential, self.api_info,
|
||||
self.cache)
|
||||
return OSClient.get(client_name)(self.credential, self.cache)
|
||||
|
||||
@classmethod
|
||||
def create_from_env(cls):
|
||||
|
@ -372,58 +372,6 @@ class ImageValidOnFlavorValidator(FlavorExistsValidator):
|
||||
(flavor.id, image["id"]))
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@validation.configure(name="required_clients", platform="openstack")
|
||||
class RequiredClientsValidator(validation.Validator):
|
||||
|
||||
def __init__(self, components, *args, **kwargs):
|
||||
"""Validator checks if specified OpenStack clients are available.
|
||||
|
||||
:param components: list of client components names
|
||||
:param **kwargs: optional parameters:
|
||||
admin - bool, whether to use admin clients
|
||||
"""
|
||||
super(RequiredClientsValidator, self).__init__()
|
||||
if isinstance(components, (list, tuple)):
|
||||
# services argument is a list, so it is a new way of validators
|
||||
# usage, args in this case should not be provided
|
||||
self.components = components
|
||||
if args:
|
||||
LOG.warning("Positional argument is not what "
|
||||
"'required_clients' decorator expects. "
|
||||
"Use `components` argument instead")
|
||||
else:
|
||||
# it is old way validator
|
||||
self.components = [components]
|
||||
self.components.extend(args)
|
||||
self.options = kwargs
|
||||
|
||||
def _check_component(self, clients):
|
||||
for client_component in self.components:
|
||||
try:
|
||||
getattr(clients, client_component)()
|
||||
except ImportError:
|
||||
self.fail(
|
||||
"Client for {0} is not installed. To install it run "
|
||||
"`pip install python-{0}client`".format(client_component))
|
||||
|
||||
def validate(self, context, config, plugin_cls, plugin_cfg):
|
||||
LOG.warning("The validator 'required_clients' is deprecated since "
|
||||
"Rally 0.10.0. If you are interested in it, please "
|
||||
"contact Rally team via E-mail, IRC or Gitter (see "
|
||||
"https://rally.readthedocs.io/en/latest/project_info"
|
||||
"/index.html#where-can-i-discuss-and-propose-changes for "
|
||||
"more details).")
|
||||
if self.options.get("admin", False):
|
||||
clients = context["admin"]["credential"].clients()
|
||||
self._check_component(clients)
|
||||
else:
|
||||
for user in context["users"]:
|
||||
clients = user["credential"].clients()
|
||||
self._check_component(clients)
|
||||
break
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@validation.configure(name="required_services", platform="openstack")
|
||||
class RequiredServicesValidator(validation.Validator):
|
||||
|
@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class SeekAndDestroy(object):
|
||||
|
||||
def __init__(self, manager_cls, admin, users, api_versions=None,
|
||||
def __init__(self, manager_cls, admin, users,
|
||||
resource_classes=None, task_id=None):
|
||||
"""Resource deletion class.
|
||||
|
||||
@ -38,7 +38,6 @@ class SeekAndDestroy(object):
|
||||
:param manager_cls: subclass of base.ResourceManager
|
||||
:param admin: admin credential like in context["admin"]
|
||||
:param users: users credentials like in context["users"]
|
||||
:param api_versions: dict of client API versions
|
||||
:param resource_classes: Resource classes to match resource names
|
||||
against
|
||||
:param task_id: The UUID of task to match resource names against
|
||||
@ -46,7 +45,6 @@ class SeekAndDestroy(object):
|
||||
self.manager_cls = manager_cls
|
||||
self.admin = admin
|
||||
self.users = users or []
|
||||
self.api_versions = api_versions
|
||||
self.resource_classes = resource_classes or [
|
||||
rutils.RandomNameGeneratorMixin]
|
||||
self.task_id = task_id
|
||||
@ -56,7 +54,7 @@ class SeekAndDestroy(object):
|
||||
if not user:
|
||||
return None
|
||||
# NOTE(astudenov): Credential now supports caching by default
|
||||
return user["credential"].clients(api_info=self.api_versions)
|
||||
return user["credential"].clients()
|
||||
|
||||
def _delete_single_resource(self, resource):
|
||||
"""Safe resource deletion with retries and timeouts.
|
||||
@ -240,7 +238,7 @@ def find_resource_managers(names=None, admin_required=None):
|
||||
|
||||
|
||||
def cleanup(names=None, admin_required=None, admin=None, users=None,
|
||||
api_versions=None, superclass=plugin.Plugin, task_id=None):
|
||||
superclass=plugin.Plugin, task_id=None):
|
||||
"""Generic cleaner.
|
||||
|
||||
This method goes through all plugins. Filter those and left only plugins
|
||||
@ -270,11 +268,6 @@ def cleanup(names=None, admin_required=None, admin=None, users=None,
|
||||
Scenario resources.
|
||||
:param task_id: The UUID of task
|
||||
"""
|
||||
if api_versions:
|
||||
LOG.warning("'api_version' argument of 'cleanup' method is deprecated"
|
||||
" since rally-openstack 1.3.0 . API information should be"
|
||||
" included into credentials object, you can directly"
|
||||
" remove passed api_versions argument.")
|
||||
resource_classes = [cls for cls in discover.itersubclasses(superclass)
|
||||
if issubclass(cls, rutils.RandomNameGeneratorMixin)]
|
||||
if not resource_classes and issubclass(superclass,
|
||||
@ -285,6 +278,5 @@ def cleanup(names=None, admin_required=None, admin=None, users=None,
|
||||
% {"service": manager._service,
|
||||
"resource": manager._resource})
|
||||
SeekAndDestroy(manager, admin, users,
|
||||
api_versions=api_versions,
|
||||
resource_classes=resource_classes,
|
||||
task_id=task_id).exterminate()
|
||||
|
@ -212,7 +212,7 @@ class CreateImageAndBootInstances(GlanceBasic, nova_utils.NovaScenario):
|
||||
|
||||
def run(self, container_format, image_location, disk_format,
|
||||
flavor, number_instances, visibility="private", min_disk=0,
|
||||
min_ram=0, properties=None, boot_server_kwargs=None, **kwargs):
|
||||
min_ram=0, properties=None, boot_server_kwargs=None):
|
||||
"""Create an image and boot several instances from it.
|
||||
|
||||
:param container_format: container format of image. Acceptable
|
||||
@ -228,14 +228,7 @@ class CreateImageAndBootInstances(GlanceBasic, nova_utils.NovaScenario):
|
||||
:param flavor: Nova flavor to be used to launch an instance
|
||||
:param number_instances: number of Nova servers to boot
|
||||
:param boot_server_kwargs: optional parameters to boot server
|
||||
:param kwargs: optional parameters to create server (deprecated)
|
||||
"""
|
||||
boot_server_kwargs = boot_server_kwargs or kwargs or {}
|
||||
|
||||
if kwargs:
|
||||
LOG.warning("'kwargs' is deprecated in Rally v0.8.0: Use "
|
||||
"'boot_server_kwargs' for additional parameters when "
|
||||
"booting servers.")
|
||||
|
||||
image = self.glance.create_image(
|
||||
container_format=container_format,
|
||||
@ -247,7 +240,7 @@ class CreateImageAndBootInstances(GlanceBasic, nova_utils.NovaScenario):
|
||||
properties=properties)
|
||||
|
||||
self._boot_servers(image.id, flavor, number_instances,
|
||||
**boot_server_kwargs)
|
||||
**(boot_server_kwargs or {}))
|
||||
|
||||
|
||||
@validation.add("enum", param_name="container_format",
|
||||
|
@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import logging
|
||||
from rally.task import types
|
||||
from rally.task import validation
|
||||
|
||||
@ -77,11 +76,7 @@ class CreateAndDeleteKeypair(utils.NovaScenario):
|
||||
platform="openstack")
|
||||
class BootAndDeleteServerWithKeypair(utils.NovaScenario):
|
||||
|
||||
@logging.log_deprecated_args(
|
||||
"'server_kwargs' has been renamed 'boot_server_kwargs'",
|
||||
"0.3.2", ["server_kwargs"], once=True)
|
||||
def run(self, image, flavor, boot_server_kwargs=None,
|
||||
server_kwargs=None, **kwargs):
|
||||
def run(self, image, flavor, boot_server_kwargs=None, **kwargs):
|
||||
"""Boot and delete server with keypair.
|
||||
|
||||
Plan of this scenario:
|
||||
@ -95,16 +90,13 @@ class BootAndDeleteServerWithKeypair(utils.NovaScenario):
|
||||
:param flavor: ID of the flavor to be used for server creation
|
||||
:param boot_server_kwargs: Optional additional arguments for VM
|
||||
creation
|
||||
:param server_kwargs: Deprecated alias for boot_server_kwargs
|
||||
:param kwargs: Optional additional arguments for keypair creation
|
||||
"""
|
||||
|
||||
boot_server_kwargs = boot_server_kwargs or server_kwargs or {}
|
||||
|
||||
keypair = self._create_keypair(**kwargs)
|
||||
server = self._boot_server(image, flavor,
|
||||
key_name=keypair,
|
||||
**boot_server_kwargs)
|
||||
**(boot_server_kwargs) or {})
|
||||
self._delete_server(server)
|
||||
self._delete_keypair(keypair)
|
||||
|
||||
|
@ -241,7 +241,7 @@ class SaharaScenario(scenario.OpenStackScenario):
|
||||
|
||||
@logging.log_deprecated_args("`flavor_id` argument is deprecated. Use "
|
||||
"`master_flavor_id` and `worker_flavor_id` "
|
||||
"parameters.", rally_version="2.0",
|
||||
"parameters.", rally_version="0.2.0",
|
||||
deprecated_args=["flavor_id"])
|
||||
@atomic.action_timer("sahara.launch_cluster")
|
||||
def _launch_cluster(self, plugin_name, hadoop_version, master_flavor_id,
|
||||
|
@ -49,7 +49,6 @@ class OpenStackCredentialTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally_openstack.common.osclients.Clients")
|
||||
def test_clients(self, mock_clients):
|
||||
clients = self.credential.clients(api_info="fake_info")
|
||||
mock_clients.assert_called_once_with(
|
||||
self.credential, api_info="fake_info", cache={})
|
||||
clients = self.credential.clients()
|
||||
mock_clients.assert_called_once_with(self.credential, cache={})
|
||||
self.assertIs(mock_clients.return_value, clients)
|
||||
|
@ -92,7 +92,7 @@ class OSClientTestCase(test.TestCase, OSClientTestCaseUtils):
|
||||
create_client = mock.MagicMock()
|
||||
|
||||
fake_client = FakeClient({"auth_url": "url", "username": "user",
|
||||
"password": "pass"}, {}, {})
|
||||
"password": "pass"}, {})
|
||||
self.assertEqual(default_service_type,
|
||||
fake_client.choose_service_type())
|
||||
self.assertEqual("foo",
|
||||
@ -111,7 +111,7 @@ class OSClientTestCase(test.TestCase, OSClientTestCaseUtils):
|
||||
endpoint_type=endpoint_type,
|
||||
region_name=region_name)
|
||||
mock_choose_service_type = mock.MagicMock()
|
||||
osclient = osclients.OSClient(credential, {}, mock.MagicMock())
|
||||
osclient = osclients.OSClient(credential, mock.MagicMock())
|
||||
osclient.choose_service_type = mock_choose_service_type
|
||||
mock_url_for = mock_keystone_service_catalog.url_for
|
||||
self.assertEqual(mock_url_for.return_value,
|
||||
@ -135,8 +135,7 @@ class CachedTestCase(test.TestCase):
|
||||
class SomeClient(osclients.OSClient):
|
||||
pass
|
||||
|
||||
fake_client = SomeClient(clients.credential, clients.api_info,
|
||||
clients.cache)
|
||||
fake_client = SomeClient(clients.credential, clients.cache)
|
||||
fake_client.create_client = mock.MagicMock()
|
||||
|
||||
self.assertEqual({}, clients.cache)
|
||||
@ -173,7 +172,7 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
||||
# client. Hopefully one day we'll get a real fake from the
|
||||
# keystone guys.
|
||||
self.set_up_keystone_mocks()
|
||||
keystone = osclients.Keystone(self.credential, {}, mock.MagicMock())
|
||||
keystone = osclients.Keystone(self.credential, mock.MagicMock())
|
||||
keystone.get_session = mock.Mock(
|
||||
return_value=(self.ksa_session, self.ksa_identity_plugin,))
|
||||
client = keystone.create_client(version=3)
|
||||
@ -199,7 +198,7 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
||||
self.set_up_keystone_mocks()
|
||||
auth_kwargs, all_kwargs = self.make_auth_args()
|
||||
keystone = osclients.Keystone(
|
||||
self.credential, {}, mock.MagicMock())
|
||||
self.credential, mock.MagicMock())
|
||||
keystone.get_session = mock.Mock(
|
||||
return_value=(self.ksa_session, self.ksa_identity_plugin,))
|
||||
client = keystone.create_client(version="3")
|
||||
@ -224,7 +223,7 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
||||
def test__remove_url_version(self, original, cropped):
|
||||
credential = oscredential.OpenStackCredential(
|
||||
original, "user", "pass", "tenant")
|
||||
keystone = osclients.Keystone(credential, {}, {})
|
||||
keystone = osclients.Keystone(credential, {})
|
||||
self.assertEqual(cropped, keystone._remove_url_version())
|
||||
|
||||
@ddt.data("http://auth_url/v2.0", "http://auth_url/v3",
|
||||
@ -233,7 +232,7 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
||||
credential = oscredential.OpenStackCredential(
|
||||
auth_url, "user", "pass", "tenant")
|
||||
self.set_up_keystone_mocks()
|
||||
keystone = osclients.Keystone(credential, {}, {})
|
||||
keystone = osclients.Keystone(credential, {})
|
||||
|
||||
version_data = mock.Mock(return_value=[{"version": (1, 0)}])
|
||||
self.ksa_auth.discover.Discover.return_value = (
|
||||
@ -258,7 +257,7 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
||||
verify=True, cert=None)])
|
||||
|
||||
def test_keystone_property(self):
|
||||
keystone = osclients.Keystone(self.credential, None, None)
|
||||
keystone = osclients.Keystone(self.credential, None)
|
||||
self.assertRaises(exceptions.RallyException, lambda: keystone.keystone)
|
||||
|
||||
@mock.patch("%s.Keystone.get_session" % PATH)
|
||||
@ -267,7 +266,7 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
||||
auth_plugin = mock.MagicMock()
|
||||
mock_keystone_get_session.return_value = (session, auth_plugin)
|
||||
cache = {}
|
||||
keystone = osclients.Keystone(self.credential, None, cache)
|
||||
keystone = osclients.Keystone(self.credential, cache)
|
||||
|
||||
self.assertEqual(auth_plugin.get_access.return_value,
|
||||
keystone.auth_ref)
|
||||
@ -282,7 +281,7 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
||||
@mock.patch("%s.logging.is_debug" % PATH)
|
||||
def test_auth_ref_fails(self, mock_is_debug, mock_log_exception):
|
||||
mock_is_debug.return_value = False
|
||||
keystone = osclients.Keystone(self.credential, {}, {})
|
||||
keystone = osclients.Keystone(self.credential, {})
|
||||
session = mock.Mock()
|
||||
auth_plugin = mock.Mock()
|
||||
auth_plugin.get_access.side_effect = Exception
|
||||
@ -299,7 +298,7 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
||||
@mock.patch("%s.logging.is_debug" % PATH)
|
||||
def test_auth_ref_fails_debug(self, mock_is_debug, mock_log_exception):
|
||||
mock_is_debug.return_value = True
|
||||
keystone = osclients.Keystone(self.credential, {}, {})
|
||||
keystone = osclients.Keystone(self.credential, {})
|
||||
session = mock.Mock()
|
||||
auth_plugin = mock.Mock()
|
||||
auth_plugin.get_access.side_effect = Exception
|
||||
@ -319,7 +318,7 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils):
|
||||
from keystoneauth1 import exceptions as ks_exc
|
||||
|
||||
mock_is_debug.return_value = True
|
||||
keystone = osclients.Keystone(self.credential, {}, {})
|
||||
keystone = osclients.Keystone(self.credential, {})
|
||||
session = mock.Mock()
|
||||
auth_plugin = mock.Mock()
|
||||
auth_plugin.get_access.side_effect = ks_exc.ConnectFailure("foo")
|
||||
|
@ -611,44 +611,6 @@ class ImageValidOnFlavorValidatorTestCase(test.TestCase):
|
||||
clients.glance().images.get.assert_called_with("image_id")
|
||||
|
||||
|
||||
class RequiredClientsValidatorTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(RequiredClientsValidatorTestCase, self).setUp()
|
||||
self.config = copy.deepcopy(config)
|
||||
self.context = copy.deepcopy(context)
|
||||
|
||||
def test_validate(self):
|
||||
validator = validators.RequiredClientsValidator(components=["keystone",
|
||||
"nova"])
|
||||
clients = self.context["users"][0]["credential"].clients.return_value
|
||||
|
||||
result = validator.validate(self.context, self.config, None, None)
|
||||
self.assertIsNone(result)
|
||||
|
||||
clients.nova.side_effect = ImportError
|
||||
e = self.assertRaises(
|
||||
validators.validation.ValidationError,
|
||||
validator.validate, self.context, self.config, None, None)
|
||||
self.assertEqual("Client for nova is not installed. To install it "
|
||||
"run `pip install python-novaclient`", e.message)
|
||||
|
||||
def test_validate_with_admin(self):
|
||||
validator = validators.RequiredClientsValidator(components=["keystone",
|
||||
"nova"],
|
||||
admin=True)
|
||||
clients = self.context["admin"]["credential"].clients.return_value
|
||||
result = validator.validate(self.context, self.config, None, None)
|
||||
self.assertIsNone(result)
|
||||
|
||||
clients.keystone.side_effect = ImportError
|
||||
e = self.assertRaises(
|
||||
validators.validation.ValidationError,
|
||||
validator.validate, self.context, self.config, None, None)
|
||||
self.assertEqual("Client for keystone is not installed. To install it "
|
||||
"run `pip install python-keystoneclient`", e.message)
|
||||
|
||||
|
||||
class RequiredServicesValidatorTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -33,16 +33,13 @@ class SeekAndDestroyTestCase(test.TestCase):
|
||||
manager.SeekAndDestroy.cache = {}
|
||||
|
||||
def test__get_cached_client(self):
|
||||
api_versions = {"cinder": {"version": "1", "service_type": "volume"}}
|
||||
|
||||
destroyer = manager.SeekAndDestroy(None, None, None,
|
||||
api_versions=api_versions)
|
||||
destroyer = manager.SeekAndDestroy(None, None, None)
|
||||
cred = mock.Mock()
|
||||
user = {"credential": cred}
|
||||
|
||||
clients = destroyer._get_cached_client(user)
|
||||
self.assertIs(cred.clients.return_value, clients)
|
||||
cred.clients.assert_called_once_with(api_info=api_versions)
|
||||
cred.clients.assert_called_once_with()
|
||||
|
||||
self.assertIsNone(destroyer._get_cached_client(None))
|
||||
|
||||
@ -384,48 +381,16 @@ class ResourceManagerTestCase(test.TestCase):
|
||||
mock_find_resource_managers.assert_called_once_with(["a", "b"], True)
|
||||
|
||||
mock_seek_and_destroy.assert_has_calls([
|
||||
mock.call(mock_find_resource_managers.return_value[0], "admin",
|
||||
["user"], api_versions=None,
|
||||
resource_classes=[A], task_id="task_id"),
|
||||
mock.call(mock_find_resource_managers.return_value[0],
|
||||
"admin",
|
||||
["user"],
|
||||
resource_classes=[A],
|
||||
task_id="task_id"),
|
||||
mock.call().exterminate(),
|
||||
mock.call(mock_find_resource_managers.return_value[1], "admin",
|
||||
["user"], api_versions=None,
|
||||
resource_classes=[A], task_id="task_id"),
|
||||
mock.call().exterminate()
|
||||
])
|
||||
|
||||
@mock.patch("rally.common.plugin.discover.itersubclasses")
|
||||
@mock.patch("%s.SeekAndDestroy" % BASE)
|
||||
@mock.patch("%s.find_resource_managers" % BASE,
|
||||
return_value=[mock.MagicMock(), mock.MagicMock()])
|
||||
def test_cleanup_with_api_versions(self,
|
||||
mock_find_resource_managers,
|
||||
mock_seek_and_destroy,
|
||||
mock_itersubclasses):
|
||||
class A(utils.RandomNameGeneratorMixin):
|
||||
pass
|
||||
|
||||
class B(object):
|
||||
pass
|
||||
|
||||
mock_itersubclasses.return_value = [A, B]
|
||||
|
||||
api_versions = {"cinder": {"version": "1", "service_type": "volume"}}
|
||||
manager.cleanup(names=["a", "b"], admin_required=True,
|
||||
admin="admin", users=["user"],
|
||||
api_versions=api_versions,
|
||||
superclass=utils.RandomNameGeneratorMixin,
|
||||
task_id="task_id")
|
||||
|
||||
mock_find_resource_managers.assert_called_once_with(["a", "b"], True)
|
||||
|
||||
mock_seek_and_destroy.assert_has_calls([
|
||||
mock.call(mock_find_resource_managers.return_value[0], "admin",
|
||||
["user"], api_versions=api_versions,
|
||||
resource_classes=[A], task_id="task_id"),
|
||||
mock.call().exterminate(),
|
||||
mock.call(mock_find_resource_managers.return_value[1], "admin",
|
||||
["user"], api_versions=api_versions,
|
||||
resource_classes=[A], task_id="task_id"),
|
||||
mock.call(mock_find_resource_managers.return_value[1],
|
||||
"admin",
|
||||
["user"],
|
||||
resource_classes=[A],
|
||||
task_id="task_id"),
|
||||
mock.call().exterminate()
|
||||
])
|
||||
|
@ -74,14 +74,12 @@ class AdminCleanupTestCase(test.TestCase):
|
||||
mock.call(mock_find_resource_managers.return_value[0],
|
||||
ctx["admin"],
|
||||
ctx["users"],
|
||||
api_versions=None,
|
||||
resource_classes=[ResourceClass],
|
||||
task_id="task_id"),
|
||||
mock.call().exterminate(),
|
||||
mock.call(mock_find_resource_managers.return_value[1],
|
||||
ctx["admin"],
|
||||
ctx["users"],
|
||||
api_versions=None,
|
||||
resource_classes=[ResourceClass],
|
||||
task_id="task_id"),
|
||||
mock.call().exterminate()
|
||||
|
@ -72,11 +72,15 @@ class UserCleanupTestCase(test.TestCase):
|
||||
mock_find_resource_managers.assert_called_once_with(("a", "b"), False)
|
||||
mock_seek_and_destroy.assert_has_calls([
|
||||
mock.call(mock_find_resource_managers.return_value[0],
|
||||
None, ctx["users"], api_versions=None,
|
||||
resource_classes=[ResourceClass], task_id="task_id"),
|
||||
None,
|
||||
ctx["users"],
|
||||
resource_classes=[ResourceClass],
|
||||
task_id="task_id"),
|
||||
mock.call().exterminate(),
|
||||
mock.call(mock_find_resource_managers.return_value[1],
|
||||
None, ctx["users"], api_versions=None,
|
||||
resource_classes=[ResourceClass], task_id="task_id"),
|
||||
None,
|
||||
ctx["users"],
|
||||
resource_classes=[ResourceClass],
|
||||
task_id="task_id"),
|
||||
mock.call().exterminate()
|
||||
])
|
||||
|
@ -122,7 +122,7 @@ class TempestConfigfileManagerTestCase(test.TestCase):
|
||||
self.tempest.conf.add_section("identity-feature-enabled")
|
||||
self.tempest.credential.auth_url = auth_url
|
||||
process_url = osclients.Keystone(
|
||||
self.tempest.credential, 0, 0)._remove_url_version
|
||||
self.tempest.credential, 0)._remove_url_version
|
||||
self.tempest.clients.keystone._remove_url_version = process_url
|
||||
|
||||
from keystoneauth1 import discover
|
||||
|
Loading…
x
Reference in New Issue
Block a user