Merge "Rename namespace -> platform (part 1)"

This commit is contained in:
Jenkins 2017-07-18 20:25:03 +00:00 committed by Gerrit Code Review
commit 0d4c48c64e
20 changed files with 150 additions and 162 deletions

View File

@ -614,10 +614,10 @@ class _Verifier(APIGroup):
:param namespace: Verifier plugin namespace
"""
return [{"name": p.get_name(),
"namespace": p.get_namespace(),
"namespace": p.get_platform(),
"description": p.get_info()["title"],
"location": "%s.%s" % (p.__module__, p.__name__)}
for p in vmanager.VerifierManager.get_all(namespace=namespace)]
for p in vmanager.VerifierManager.get_all(platform=namespace)]
@api_wrapper(path=API_REQUEST_PREFIX + "/verifier/create", method="POST")
def create(self, name, vtype, namespace=None, source=None, version=None,
@ -637,7 +637,7 @@ class _Verifier(APIGroup):
:param extra_settings: Extra installation settings for verifier
"""
# check that the specified verifier type exists
vmanager.VerifierManager.get(vtype, namespace=namespace)
vmanager.VerifierManager.get(vtype, platform=namespace)
LOG.info("Creating verifier '%s'.", name)
@ -655,7 +655,7 @@ class _Verifier(APIGroup):
properties = {}
default_namespace = verifier.manager._meta_get("namespace")
default_namespace = verifier.manager.get_platform()
if not namespace and default_namespace:
properties["namespace"] = default_namespace

View File

@ -28,7 +28,7 @@ class PluginCommands(object):
def _print_plugins_list(plugin_list):
formatters = {
"Name": lambda p: p.get_name(),
"Namespace": lambda p: p.get_namespace(),
"Namespace": lambda p: p.get_platform(),
"Title": lambda p: p.get_info()["title"],
"Plugin base": lambda p: p._get_base().__name__
}
@ -46,7 +46,7 @@ class PluginCommands(object):
def show(self, api, name, namespace=None):
"""Show detailed information about a Rally plugin."""
name_lw = name.lower()
all_plugins = plugin.Plugin.get_all(namespace=namespace)
all_plugins = plugin.Plugin.get_all(platform=namespace)
found = [p for p in all_plugins if name_lw in p.get_name().lower()]
exact_match = [p for p in found if name_lw == p.get_name().lower()]
@ -91,7 +91,7 @@ class PluginCommands(object):
@plugins.ensure_plugins_are_loaded
def list(self, api, name=None, namespace=None, base_cls=None):
"""List all Rally plugins that match name and namespace."""
all_plugins = plugin.Plugin.get_all(namespace=namespace)
all_plugins = plugin.Plugin.get_all(platform=namespace)
matched = all_plugins
if name:
name_lw = name.lower()

View File

@ -127,7 +127,8 @@ class InfoMixin(object):
return {
"name": cls.get_name(),
"namespace": cls.get_namespace(),
"platform": cls.get_platform(),
"namespace": cls.get_platform(),
"module": cls.__module__,
"title": doc["short_description"],
"description": doc["long_description"],

View File

@ -23,22 +23,17 @@ from rally.common.plugin import meta
from rally import exceptions
def deprecated(reason, rally_version):
"""Mark plugin as deprecated.
:param reason: Message that describes reason of plugin deprecation
:param rally_version: Deprecated since this version of Rally
"""
def decorator(plugin):
plugin._set_deprecated(reason, rally_version)
return plugin
return decorator
def base():
"""Mark Plugin as a base.
Base Plugins are used to have better organization of plugins.
It basically resolved to problems:
- Having different types of plugins (e.g. Sceanrio, Context, SLA, ...)
- Auto generation of plugin reference with splitting plugins by their base
- Plugin lookup - one can easily get all plugins from some base.
.. warning:: This decorator should be added the line before
six.add_metaclass if it is used.
"""
@ -60,11 +55,13 @@ def base():
return wrapper
def configure(name, namespace="default", hidden=False):
def configure(name, platform="default", hidden=False):
"""Use this decorator to configure plugin's attributes.
Plugin is not discoverable until configure() is performed.
:param name: name of plugin that is used for searching purpose
:param namespace: plugin namespace
:param platform: platform name that plugin belongs to
:param hidden: if True the plugin will be marked as hidden and can be
loaded only explicitly
"""
@ -74,31 +71,48 @@ def configure(name, namespace="default", hidden=False):
plugin_id = "%s.%s" % (plugin.__module__, plugin.__name__)
raise ValueError("The name of the plugin %s cannot be None." %
plugin_id)
plugin._configure(name, namespace)
plugin._meta_init()
try:
existing_plugin = plugin._get_base().get(
name=name, platform=platform, allow_hidden=True,
fallback_to_default=False)
except exceptions.PluginNotFound:
plugin._meta_set("name", name)
plugin._meta_set("platform", platform)
else:
plugin.unregister()
raise exceptions.PluginWithSuchNameExists(
name=name, platform=existing_plugin.get_platform(),
existing_path=(
sys.modules[existing_plugin.__module__].__file__),
new_path=sys.modules[plugin.__module__].__file__
)
plugin._meta_set("hidden", hidden)
return plugin
return decorator
def deprecated(reason, rally_version):
"""Mark plugin as deprecated.
:param reason: Message that describes reason of plugin deprecation
:param rally_version: Deprecated since this version of Rally
"""
def decorator(plugin):
plugin._meta_set("deprecated", {
"reason": reason,
"rally_version": rally_version
})
return plugin
return decorator
class Plugin(meta.MetaMixin, info.InfoMixin):
"""Base class for all Plugins in Rally."""
@classmethod
def _configure(cls, name, namespace="default"):
"""Init plugin and set common meta information.
For now it sets only name of plugin, that is an actual identifier.
Plugin name should be unique, otherwise exception is raised.
:param name: Plugin name
:param namespace: Plugins with the same name are allowed only if they
are in various namespaces.
"""
cls._meta_init()
cls._set_name_and_namespace(name, namespace)
return cls
@classmethod
def unregister(cls):
"""Removes all plugin meta information and makes it undiscoverable."""
@ -109,63 +123,30 @@ class Plugin(meta.MetaMixin, info.InfoMixin):
return getattr(cls, "base_ref", Plugin)
@classmethod
def _set_name_and_namespace(cls, name, namespace):
try:
existing_plugin = cls._get_base().get(name=name,
namespace=namespace,
allow_hidden=True,
fallback_to_default=False)
except exceptions.PluginNotFound:
cls._meta_set("name", name)
cls._meta_set("namespace", namespace)
else:
cls.unregister()
raise exceptions.PluginWithSuchNameExists(
name=name, namespace=existing_plugin.get_namespace(),
existing_path=(
sys.modules[existing_plugin.__module__].__file__),
new_path=sys.modules[cls.__module__].__file__
)
@classmethod
def _set_deprecated(cls, reason, rally_version):
"""Mark plugin as deprecated.
:param reason: Message that describes reason of plugin deprecation
:param rally_version: Deprecated since this version of Rally
"""
cls._meta_set("deprecated", {
"reason": reason,
"rally_version": rally_version
})
return cls
@classmethod
def get(cls, name, namespace=None, allow_hidden=False,
def get(cls, name, platform=None, allow_hidden=False,
fallback_to_default=True):
"""Return plugin by its name from specified namespace.
"""Return plugin by its name for specified platform.
This method iterates over all subclasses of cls and returns plugin
by name from specified namespace.
by name for specified platform.
If namespace is not specified, it will return first found plugin from
any of namespaces.
If platform is not specified, it will return first found plugin from
any of platform.
:param name: Plugin's name
:param namespace: Namespace where to search for plugins
:param platform: Plugin's platform
:param allow_hidden: if False and found plugin is hidden then
PluginNotFound will be raised
:param fallback_to_default: if True, then it tries to find
plugin within "default" namespace
plugin within "default" platform
"""
potential_result = cls.get_all(name=name, namespace=namespace,
potential_result = cls.get_all(name=name, platform=platform,
allow_hidden=True)
if fallback_to_default and len(potential_result) == 0:
# try to find in default namespace
potential_result = cls.get_all(name=name, namespace="default",
potential_result = cls.get_all(name=name, platform="default",
allow_hidden=True)
if len(potential_result) == 1:
@ -174,27 +155,26 @@ class Plugin(meta.MetaMixin, info.InfoMixin):
return plugin
elif potential_result:
hint = _LE("Try to choose the correct Plugin base or namespace to "
hint = _LE("Try to choose the correct Plugin base or platform to "
"search in.")
if namespace:
needle = "%s at %s namespace" % (name, namespace)
if platform:
needle = "%s at %s platform" % (name, platform)
else:
needle = "%s at any of namespaces" % name
needle = "%s at any of platform" % name
raise exceptions.MultipleMatchesFound(
needle=needle,
haystack=", ".join(p.get_name() for p in potential_result),
hint=hint)
raise exceptions.PluginNotFound(
name=name, namespace=namespace or "any of")
name=name, platform=platform or "any of")
@classmethod
def get_all(cls, namespace=None, allow_hidden=False, name=None):
def get_all(cls, platform=None, allow_hidden=False, name=None):
"""Return all subclass plugins of plugin.
All plugins that are not configured will be ignored.
:param namespace: return only plugins from specified namespace.
:param platform: return only plugins for specific platform.
:param name: return only plugins with specified name.
:param allow_hidden: if False return only non hidden plugins
"""
@ -207,7 +187,7 @@ class Plugin(meta.MetaMixin, info.InfoMixin):
continue
if name and name != p.get_name():
continue
if namespace and namespace != p.get_namespace():
if platform and platform != p.get_platform():
continue
if not allow_hidden and p.is_hidden():
continue
@ -217,20 +197,20 @@ class Plugin(meta.MetaMixin, info.InfoMixin):
@classmethod
def get_name(cls):
"""Return name of plugin."""
"""Return plugin's name."""
return cls._meta_get("name")
@classmethod
def get_namespace(cls):
""""Return namespace of plugin, e.g. default or openstack."""
return cls._meta_get("namespace")
def get_platform(cls):
""""Return plugin's platform name."""
return cls._meta_get("platform")
@classmethod
def is_hidden(cls):
"""Return True if plugin is hidden."""
"""Returns whatever plugin is hidden or not."""
return cls._meta_get("hidden", False)
@classmethod
def is_deprecated(cls):
"""Return deprecation details for deprecated plugins."""
"""Returns deprecation details if plugin is deprecated."""
return cls._meta_get("deprecated", False)

View File

@ -22,12 +22,17 @@ from rally.common import logging
from rally.common.plugin import plugin
from rally import exceptions
configure = plugin.configure
LOG = logging.getLogger(__name__)
def configure(name, namespace="default"):
def wrapper(cls):
return plugin.configure(name=name, platform=namespace)(cls)
return wrapper
@plugin.base()
@six.add_metaclass(abc.ABCMeta)
class Validator(plugin.Plugin):
@ -198,7 +203,7 @@ class ValidatablePluginMixin(object):
"""
try:
plugin = cls.get(name, allow_hidden=allow_hidden,
namespace=namespace)
platform=namespace)
except exceptions.PluginNotFound:
msg = "There is no %s plugin with name: '%s'" % (
cls.__name__, name)

View File

@ -23,13 +23,13 @@ from rally.common.plugin import plugin
def configure(namespace):
def wrapper(cls):
cls = plugin.configure(name="credential", namespace=namespace)(cls)
cls = plugin.configure(name="credential", platform=namespace)(cls)
return cls
return wrapper
def get(namespace):
return Credential.get(name="credential", namespace=namespace)
return Credential.get(name="credential", platform=namespace)
@plugin.base()
@ -60,14 +60,14 @@ class Credential(plugin.Plugin):
def configure_builder(namespace):
def wrapper(cls):
cls = plugin.configure(name="credential_builder",
namespace=namespace)(cls)
platform=namespace)(cls)
return cls
return wrapper
def get_builder(namespace):
return CredentialBuilder.get(name="credential_builder",
namespace=namespace)
platform=namespace)
@plugin.base()

View File

@ -84,13 +84,12 @@ class Engine(plugin.Plugin):
try:
engine_cls = Engine.get(name)
return engine_cls(deployment)
except exceptions.PluginNotFound as e:
except exceptions.PluginNotFound:
LOG.error(_LE("Deployment %(uuid)s: Deploy engine for %(name)s "
"does not exist.") %
{"uuid": deployment["uuid"], "name": name})
deployment.update_status(consts.DeployStatus.DEPLOY_FAILED)
raise exceptions.PluginNotFound(
namespace=e.kwargs.get("namespace"), name=name)
raise
@abc.abstractmethod
def deploy(self):

View File

@ -102,13 +102,13 @@ class ThreadTimeoutException(RallyException):
class PluginNotFound(NotFoundException):
error_code = 459
msg_fmt = _("There is no plugin with name: `%(name)s` in "
"%(namespace)s namespace.")
"%(platform)s platform.")
class PluginWithSuchNameExists(RallyException):
error_code = 516
msg_fmt = _("Plugin with such name: %(name)s already exists in "
"%(namespace)s namespace. It's module allocates at "
"%(platform)s platform. It's module allocates at "
"%(existing_path)s. You are trying to add plugin whose module "
"allocates at %(new_path)s.")

View File

@ -59,7 +59,7 @@ def configure(name, default_version=None, default_service_type=None,
in client object)
"""
def wrapper(cls):
cls = plugin.configure(name=name, namespace=_NAMESPACE)(cls)
cls = plugin.configure(name=name, platform=_NAMESPACE)(cls)
cls._meta_set("default_version", default_version)
cls._meta_set("default_service_type", default_service_type)
cls._meta_set("supported_versions", supported_versions or [])
@ -212,8 +212,8 @@ class OSClient(plugin.Plugin):
return self.cache[key]
@classmethod
def get(cls, name, namespace=_NAMESPACE, **kwargs):
return super(OSClient, cls).get(name, namespace, **kwargs)
def get(cls, name, platform=_NAMESPACE, namespace=_NAMESPACE, **kwargs):
return super(OSClient, cls).get(name, platform=namespace, **kwargs)
@configure("keystone", supported_versions=("2", "3"))

View File

@ -59,7 +59,7 @@ class ArgsValidator(validation.Validator):
def validate(self, credentials, config, plugin_cls, plugin_cfg):
scenario = plugin_cls
name = scenario.get_name()
namespace = scenario.get_namespace()
namespace = scenario.get_platform()
scenario = scenario().run
args, _varargs, varkwargs, defaults = inspect.getargspec(scenario)

View File

@ -42,7 +42,7 @@ def configure(name, order, namespace="default", hidden=False):
task config
"""
def wrapper(cls):
cls = plugin.configure(name=name, namespace=namespace,
cls = plugin.configure(name=name, platform=namespace,
hidden=hidden)(cls)
cls._meta_set("order", order)
return cls
@ -164,7 +164,7 @@ class ContextManager(object):
if "@" in ctx_name:
ctx_name, ctx_namespace = ctx_name.split("@", 1)
context_list.append(Context.get(ctx_name,
namespace=ctx_namespace,
platform=ctx_namespace,
fallback_to_default=False,
allow_hidden=True))
else:
@ -176,18 +176,18 @@ class ContextManager(object):
elif len(potential_result) > 1:
scen_namespace = self.context_obj["scenario_namespace"]
another_attempt = [c for c in potential_result
if c.get_namespace() == scen_namespace]
if c.get_platform() == scen_namespace]
if another_attempt:
context_list.append(another_attempt[0])
continue
another_attempt = [c for c in potential_result
if c.get_namespace() == "default"]
if c.get_platform() == "default"]
if another_attempt:
context_list.append(another_attempt[0])
continue
raise exceptions.PluginNotFound(name=ctx_name,
namespace="any of")
platform="any of")
return sorted([ctx(self.context_obj) for ctx in context_list])

View File

@ -265,7 +265,7 @@ class TaskEngine(object):
def _validate_workload(self, workload, credentials=None, vtype=None):
scenario_cls = scenario.Scenario.get(workload.name)
namespace = scenario_cls.get_namespace()
namespace = scenario_cls.get_platform()
scenario_context = copy.deepcopy(scenario_cls.get_default_context())
results = []
@ -370,7 +370,7 @@ class TaskEngine(object):
# in future to identify what kind of users workload
# requires (regular users or admin)
scenario_cls = scenario.Scenario.get(workload.name)
namespace = scenario_cls.get_namespace()
namespace = scenario_cls.get_platform()
# TODO(andreykurilin): Remove check for plugin namespace after
# Rally 0.10.0
@ -402,7 +402,7 @@ class TaskEngine(object):
admin.verify_connection()
ctx_conf = {"task": self.task, "admin": {"credential": admin}}
user_context = context.Context.get("users", namespace=platform,
user_context = context.Context.get("users", platform=platform,
allow_hidden=True)(ctx_conf)
self._validate_config_semantic_helper(admin, user_context,
@ -437,7 +437,7 @@ class TaskEngine(object):
def _prepare_context(self, ctx, name, owner_id):
scenario_cls = scenario.Scenario.get(name)
namespace = scenario_cls.get_namespace()
namespace = scenario_cls.get_platform()
creds = self.deployment.get_credentials_for(namespace)

View File

@ -49,7 +49,7 @@ def configure(name, namespace="default", context=None):
msg = (_("Scenario name must include a dot: '%s'") % name)
raise exceptions.RallyException(msg)
cls = plugin.configure(name=name, namespace=namespace)(cls)
cls = plugin.configure(name=name, platform=namespace)(cls)
cls._meta_set("default_context", context or {})
return cls

View File

@ -57,12 +57,12 @@ def configure(name, namespace="default", default_repo=None,
:param default_version: Default version to checkout
:param context: List of contexts that should be executed for verification
"""
def decorator(plugin):
plugin._configure(name, namespace)
plugin._meta_set("default_repo", default_repo)
plugin._meta_set("default_version", default_version)
plugin._meta_set("context", context or {})
return plugin
def decorator(plugin_inst):
plugin_inst = plugin.configure(name, platform=namespace)(plugin_inst)
plugin_inst._meta_set("default_repo", default_repo)
plugin_inst._meta_set("default_version", default_version)
plugin_inst._meta_set("context", context or {})
return plugin_inst
return decorator

View File

@ -122,7 +122,7 @@ class PluginCommandsTestCase(test.TestCase):
mock_plugin_get_all.return_value = [self.Plugin2, self.Plugin3]
plugin_cmd.PluginCommands().show(None, "p", "p2_ns")
self.assertEqual(out.getvalue(), "Multiple plugins found:\n")
mock_plugin_get_all.assert_called_once_with(namespace="p2_ns")
mock_plugin_get_all.assert_called_once_with(platform="p2_ns")
mock_plugin_commands__print_plugins_list.assert_called_once_with([
self.Plugin2, self.Plugin3])

View File

@ -71,11 +71,11 @@ class PluginModuleTestCase(test.TestCase):
class SecondBase(plugin.Plugin):
pass
@plugin.configure(name, namespace=name)
@plugin.configure(name, platform=name)
class A(OneBase):
pass
@plugin.configure(name, namespace=name)
@plugin.configure(name, platform=name)
class B(SecondBase):
pass
@ -93,11 +93,11 @@ class PluginModuleTestCase(test.TestCase):
class SecondBase(plugin.Plugin):
pass
@plugin.configure(name, namespace=name)
@plugin.configure(name, platform=name)
class A(OneBase):
pass
@plugin.configure(name, namespace=name)
@plugin.configure(name, platform=name)
class B(SecondBase):
pass
@ -120,7 +120,7 @@ class MyPluginInDefault(BasePlugin):
pass
@plugin.configure(name="test_my_plugin", namespace="foo")
@plugin.configure(name="test_my_plugin", platform="foo")
class MyPluginInFoo(BasePlugin):
pass
@ -158,7 +158,7 @@ class PluginTestCase(test.TestCase):
def test_get_fallback_to_default(self):
self.assertEqual(SomePlugin,
BasePlugin.get("test_some_plugin", namespace="bar"))
BasePlugin.get("test_some_plugin", platform="bar"))
def test_get_hidden(self):
self.assertEqual(HiddenPlugin,

View File

@ -185,20 +185,20 @@ class ContextManagerTestCase(test.TestCase):
mock_context_get.return_value = a_ctx
b_ctx = mock.Mock(return_value=OrderableMock())
c_ctx = mock.Mock(get_namespace=lambda: "foo",
c_ctx = mock.Mock(get_platform=lambda: "foo",
return_value=OrderableMock())
d_ctx = mock.Mock(get_namespace=lambda: "default",
d_ctx = mock.Mock(get_platform=lambda: "default",
return_value=OrderableMock())
all_plugins = {
# it is a case when search is performed for any namespace and only
# it is a case when search is performed for any platform and only
# one possible match is found
"b": [b_ctx],
# it is a case when plugin should be filtered by the scenario
# namespace
"c": [mock.Mock(get_namespace=lambda: "default"), c_ctx],
# platform
"c": [mock.Mock(get_platform=lambda: "default"), c_ctx],
# it is a case when plugin should be filtered by the scenario
# namespace
"d": [mock.Mock(get_namespace=lambda: "bar"), d_ctx]
# platform
"d": [mock.Mock(get_platform=lambda: "bar"), d_ctx]
}
def fake_get_all(name, allow_hidden=True):
@ -217,7 +217,7 @@ class ContextManagerTestCase(test.TestCase):
c_ctx.return_value, d_ctx.return_value},
set(manager._get_sorted_context_lst()))
mock_context_get.assert_called_once_with("a", namespace="foo",
mock_context_get.assert_called_once_with("a", platform="foo",
fallback_to_default=False,
allow_hidden=True)
a_ctx.assert_called_once_with(ctx_object)
@ -249,9 +249,9 @@ class ContextManagerTestCase(test.TestCase):
manager = context.ContextManager(ctx_object)
manager.cleanup()
mock_context_get.assert_has_calls(
[mock.call("a", namespace="foo", allow_hidden=True,
[mock.call("a", platform="foo", allow_hidden=True,
fallback_to_default=False),
mock.call("b", namespace="foo", allow_hidden=True,
mock.call("b", platform="foo", allow_hidden=True,
fallback_to_default=False)],
any_order=True)
mock_context.assert_has_calls(
@ -270,9 +270,9 @@ class ContextManagerTestCase(test.TestCase):
manager.cleanup()
mock_context_get.assert_has_calls(
[mock.call("a", namespace="foo", allow_hidden=True,
[mock.call("a", platform="foo", allow_hidden=True,
fallback_to_default=False),
mock.call("b", namespace="foo", allow_hidden=True,
mock.call("b", platform="foo", allow_hidden=True,
fallback_to_default=False)],
any_order=True)
mock_context.assert_has_calls(

View File

@ -135,7 +135,7 @@ class TaskEngineTestCase(test.TestCase):
mock_trigger_validate.return_value = []
default_context = {"foo": "foo_conf"}
scenario_cls = mock_scenario_get.return_value
scenario_cls.get_namespace.return_value = "default"
scenario_cls.get_platform.return_value = "default"
scenario_cls.get_default_context.return_value = default_context
scenario_name = "Foo.bar"
@ -366,12 +366,14 @@ class TaskEngineTestCase(test.TestCase):
deployment = fakes.FakeDeployment(
uuid="deployment_uuid", admin=admin, users=users)
# TODO(boris-42): Refactor this test case to make it
# up to date with other code
class SomeScen(object):
is_classbased = True
@classmethod
def get_namespace(cls):
def get_platform(cls):
return "openstack"
@classmethod
@ -466,7 +468,7 @@ class TaskEngineTestCase(test.TestCase):
mock_scenario_runner, mock_scenario, mock_result_consumer,
mock_log, mock_task_config, mock_task_get_status):
scenario_cls = mock_scenario.get.return_value
scenario_cls.get_namespace.return_value = "openstack"
scenario_cls.get_platform.return_value = "openstack"
mock_context_manager_setup.side_effect = Exception
mock_result_consumer.is_task_in_aborting_status.return_value = False
@ -502,7 +504,7 @@ class TaskEngineTestCase(test.TestCase):
mock_context_manager_setup, mock_context_manager_cleanup,
mock_result_consumer):
scenario_cls = mock_scenario.get.return_value
scenario_cls.get_namespace.return_value = "openstack"
scenario_cls.get_platform.return_value = "openstack"
task = mock.MagicMock()
mock_result_consumer.is_task_in_aborting_status.side_effect = [False,
False,
@ -603,7 +605,7 @@ class TaskEngineTestCase(test.TestCase):
default_context = {"a": 1, "b": 2}
mock_scenario = mock_scenario_get.return_value
mock_scenario.get_default_context.return_value = default_context
mock_scenario.get_namespace.return_value = "openstack"
mock_scenario.get_platform.return_value = "openstack"
task = mock.MagicMock()
name = "a.task"
context = {"b": 3, "c": 4}

View File

@ -31,7 +31,7 @@ class ScenarioConfigureTestCase(test.TestCase):
pass
self.assertEqual("fooscenario.name", SomeScenario.get_name())
self.assertEqual("testing", SomeScenario.get_namespace())
self.assertEqual("testing", SomeScenario.get_platform())
SomeScenario.unregister()
@ -85,7 +85,7 @@ class ScenarioTestCase(test.TestCase):
def test_scenario_context_are_valid(self):
for s in scenario.Scenario.get_all():
namespace = s.get_namespace()
namespace = s.get_platform()
results = []
for context_name, context_conf in s.get_default_context().items():
results.extend(context.Context.validate(

View File

@ -1030,7 +1030,7 @@ class FakeVerifierManager(object):
return cls.NAME
@classmethod
def get_namespace(cls):
def get_platform(cls):
return cls.NAMESPACE
@classmethod
@ -1059,7 +1059,7 @@ class VerifierAPITestCase(test.TestCase):
FakeVerifierManager.__name__)}],
self.verifier_inst.list_plugins(namespace=namespace))
mock_verifier_manager_get_all.assert_called_once_with(
namespace=namespace)
platform=namespace)
@mock.patch("rally.api.objects.Verifier.get")
def test_get(self, mock_verifier_get):
@ -1097,14 +1097,15 @@ class VerifierAPITestCase(test.TestCase):
extra_settings = {"verifier_specific_option": "value_for_it"}
verifier_obj = mock_verifier_create.return_value
verifier_obj.manager._meta_get.side_effect = [namespace, source]
verifier_obj.manager.get_platform.return_value = namespace
verifier_obj.manager._meta_get.side_effect = [source]
verifier_uuid = self.verifier_inst.create(
name=name, vtype=vtype, version=version,
system_wide=system_wide, extra_settings=extra_settings)
mock_verifier_manager_get.assert_called_once_with(vtype,
namespace=None)
platform=None)
mock___verifier__get.assert_called_once_with(name)
mock_verifier_create.assert_called_once_with(
name=name, source=None, system_wide=system_wide, version=version,
@ -1140,7 +1141,7 @@ class VerifierAPITestCase(test.TestCase):
extra_settings=extra_settings)
mock_verifier_manager_get.assert_called_once_with(vtype,
namespace=namespace)
platform=namespace)
mock___verifier__get.assert_called_once_with(name)
self.assertFalse(mock_verifier_create.called)
@ -1170,7 +1171,7 @@ class VerifierAPITestCase(test.TestCase):
extra_settings=extra_settings)
mock_verifier_manager_get.assert_called_once_with(vtype,
namespace=namespace)
platform=namespace)
mock___verifier__get.assert_called_once_with(name)
mock_verifier_create.assert_called_once_with(
name=name, source=source, system_wide=system_wide, version=version,