[API] Remove the DeprecatedAPIClass
We use the instance of API now, so we can remove the DeprecatedAPIClass. Change-Id: Iac8bcdc4b9ed3e42b44ca8154c558cf156857670
This commit is contained in:
parent
f64460817d
commit
9b0a7d98d0
17
rally/api.py
17
rally/api.py
|
@ -26,7 +26,7 @@ from oslo_config import cfg
|
||||||
from requests.packages import urllib3
|
from requests.packages import urllib3
|
||||||
|
|
||||||
from rally.common import opts
|
from rally.common import opts
|
||||||
from rally.common.i18n import _, _LI, _LE, _LW
|
from rally.common.i18n import _, _LI, _LE
|
||||||
from rally.common import logging
|
from rally.common import logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.common.plugin import discover
|
from rally.common.plugin import discover
|
||||||
|
@ -1106,21 +1106,6 @@ class _Verification(object):
|
||||||
"tests": results.tests}
|
"tests": results.tests}
|
||||||
|
|
||||||
|
|
||||||
class _DeprecatedAPIClass(object):
|
|
||||||
"""Deprecates direct usage of api classes."""
|
|
||||||
def __init__(self, cls):
|
|
||||||
self._cls = cls
|
|
||||||
|
|
||||||
def __getattr__(self, attr, default=None):
|
|
||||||
LOG.warning(_LW("'%s' is deprecated since Rally 0.8.0 in favor of "
|
|
||||||
"'rally.api.API' class.") % self._cls.__name__[1:])
|
|
||||||
return getattr(self._cls, attr, default)
|
|
||||||
|
|
||||||
|
|
||||||
Deployment = _DeprecatedAPIClass(_Deployment)
|
|
||||||
Task = _DeprecatedAPIClass(_Task)
|
|
||||||
|
|
||||||
|
|
||||||
class API(object):
|
class API(object):
|
||||||
|
|
||||||
CONFIG_SEARCH_PATHS = [sys.prefix + "/etc/rally", "~/.rally", "/etc/rally"]
|
CONFIG_SEARCH_PATHS = [sys.prefix + "/etc/rally", "~/.rally", "/etc/rally"]
|
||||||
|
|
|
@ -101,4 +101,4 @@ class MultihostEngine(engine.Engine):
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
subdeploys = db.deployment_list(parent_uuid=self.deployment["uuid"])
|
subdeploys = db.deployment_list(parent_uuid=self.deployment["uuid"])
|
||||||
for subdeploy in subdeploys:
|
for subdeploy in subdeploys:
|
||||||
rally.api.Deployment.destroy(subdeploy["uuid"])
|
rally.api._Deployment.destroy(subdeploy["uuid"])
|
||||||
|
|
|
@ -63,7 +63,7 @@ class FileExporter(exporter.Exporter):
|
||||||
|
|
||||||
:param uuid: uuid of the task object
|
:param uuid: uuid of the task object
|
||||||
"""
|
"""
|
||||||
task = api.Task.get_detailed(uuid)
|
task = api._Task.get_detailed(uuid)
|
||||||
|
|
||||||
LOG.debug("Got the task object by it's uuid %s. " % uuid)
|
LOG.debug("Got the task object by it's uuid %s. " % uuid)
|
||||||
|
|
||||||
|
|
|
@ -108,9 +108,9 @@ class TestTaskSamples(unittest.TestCase):
|
||||||
with open(full_path) as task_file:
|
with open(full_path) as task_file:
|
||||||
try:
|
try:
|
||||||
input_task = task_file.read()
|
input_task = task_file.read()
|
||||||
rendered_task = api.Task.render_template(input_task)
|
rendered_task = api._Task.render_template(input_task)
|
||||||
task_config = yaml.safe_load(rendered_task)
|
task_config = yaml.safe_load(rendered_task)
|
||||||
api.Task.validate("MAIN", task_config)
|
api._Task.validate("MAIN", task_config)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not self._skip(six.text_type(e)):
|
if not self._skip(six.text_type(e)):
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
|
|
@ -111,7 +111,7 @@ class MultihostEngineTestCase(test.TestCase):
|
||||||
{"uuid": "uuid2"}]
|
{"uuid": "uuid2"}]
|
||||||
self.engine.cleanup()
|
self.engine.cleanup()
|
||||||
api_calls = [
|
api_calls = [
|
||||||
mock.call.Deployment.destroy("uuid1"),
|
mock.call._Deployment.destroy("uuid1"),
|
||||||
mock.call.Deployment.destroy("uuid2"),
|
mock.call._Deployment.destroy("uuid2"),
|
||||||
]
|
]
|
||||||
self.assertEqual(api_calls, mock_api.mock_calls)
|
self.assertEqual(api_calls, mock_api.mock_calls)
|
||||||
|
|
|
@ -33,11 +33,11 @@ class FileExporterTestCase(test.TestCase):
|
||||||
@mock.patch("rally.plugins.common.exporter.file_system.os.path.exists")
|
@mock.patch("rally.plugins.common.exporter.file_system.os.path.exists")
|
||||||
@mock.patch.object(__builtin__, "open", autospec=True)
|
@mock.patch.object(__builtin__, "open", autospec=True)
|
||||||
@mock.patch("rally.plugins.common.exporter.file_system.json.dumps")
|
@mock.patch("rally.plugins.common.exporter.file_system.json.dumps")
|
||||||
@mock.patch("rally.api.Task.get_detailed")
|
@mock.patch("rally.api._Task")
|
||||||
def test_file_exporter_export(self, mock_task_get_detailed, mock_dumps,
|
def test_file_exporter_export(self, mock___task, mock_dumps,
|
||||||
mock_open, mock_exists):
|
mock_open, mock_exists):
|
||||||
mock_exists.return_value = True
|
mock_exists.return_value = True
|
||||||
mock_task_get_detailed.return_value = {"results": [{
|
mock___task.get_detailed.return_value = {"results": [{
|
||||||
"key": "fake_key",
|
"key": "fake_key",
|
||||||
"data": {
|
"data": {
|
||||||
"raw": "bar_raw",
|
"raw": "bar_raw",
|
||||||
|
@ -54,7 +54,7 @@ class FileExporterTestCase(test.TestCase):
|
||||||
exporter.export("fake_uuid")
|
exporter.export("fake_uuid")
|
||||||
|
|
||||||
mock_open().__enter__().write.assert_called_once_with("fake_results")
|
mock_open().__enter__().write.assert_called_once_with("fake_results")
|
||||||
mock_task_get_detailed.assert_called_once_with("fake_uuid")
|
mock___task.get_detailed.assert_called_once_with("fake_uuid")
|
||||||
expected_dict = [
|
expected_dict = [
|
||||||
{
|
{
|
||||||
"load_duration": "foo_load_duration",
|
"load_duration": "foo_load_duration",
|
||||||
|
@ -68,9 +68,9 @@ class FileExporterTestCase(test.TestCase):
|
||||||
mock_dumps.assert_called_once_with(expected_dict, sort_keys=False,
|
mock_dumps.assert_called_once_with(expected_dict, sort_keys=False,
|
||||||
indent=4, separators=(",", ": "))
|
indent=4, separators=(",", ": "))
|
||||||
|
|
||||||
@mock.patch("rally.api.Task.get_detailed")
|
@mock.patch("rally.api._Task")
|
||||||
def test_file_exporter_export_running_task(self, mock_task_get_detailed):
|
def test_file_exporter_export_running_task(self, mock___task):
|
||||||
mock_task_get_detailed.return_value = {"results": []}
|
mock___task.get_detailed.return_value = {"results": []}
|
||||||
|
|
||||||
exporter = file_system.FileExporter("file-exporter:///fake_path.json")
|
exporter = file_system.FileExporter("file-exporter:///fake_path.json")
|
||||||
self.assertRaises(exceptions.RallyException, exporter.export,
|
self.assertRaises(exceptions.RallyException, exporter.export,
|
||||||
|
|
Loading…
Reference in New Issue