Move rally/db -> rally/common/db
There is no need to have db directory on the top level. They are quite rare changed and in most case one don’t need to know about internal details of it to fulfill their task. So hiding these directory under common/* makes perfect sense Change-Id: I791b17cc101a00bfcd9bd951fac83fc4459c6c4f
This commit is contained in:
parent
bfdd3fa225
commit
37316f24f7
@ -30,10 +30,10 @@ import yaml
|
||||
from rally import api
|
||||
from rally.cli import cliutils
|
||||
from rally.cli import envutils
|
||||
from rally.common import db
|
||||
from rally.common import fileutils
|
||||
from rally.common.i18n import _
|
||||
from rally.common import utils
|
||||
from rally import db
|
||||
from rally import exceptions
|
||||
from rally import objects
|
||||
from rally import osclients
|
||||
|
@ -19,9 +19,9 @@ from __future__ import print_function
|
||||
|
||||
from rally.cli import cliutils
|
||||
from rally.cli import envutils
|
||||
from rally.common import db
|
||||
from rally.common.i18n import _
|
||||
from rally.common import utils
|
||||
from rally import db
|
||||
from rally import objects
|
||||
from rally import osclients
|
||||
|
||||
|
@ -28,13 +28,13 @@ import yaml
|
||||
from rally import api
|
||||
from rally.cli import cliutils
|
||||
from rally.cli import envutils
|
||||
from rally.common import db
|
||||
from rally.common import fileutils
|
||||
from rally.common.i18n import _
|
||||
from rally.common import junit
|
||||
from rally.common import log as logging
|
||||
from rally.common import utils as rutils
|
||||
from rally import consts
|
||||
from rally import db
|
||||
from rally import exceptions
|
||||
from rally import objects
|
||||
from rally import plugins
|
||||
|
@ -24,10 +24,10 @@ import six
|
||||
from rally import api
|
||||
from rally.cli import cliutils
|
||||
from rally.cli import envutils
|
||||
from rally.common import db
|
||||
from rally.common import fileutils
|
||||
from rally.common.i18n import _
|
||||
from rally import consts
|
||||
from rally import db
|
||||
from rally import exceptions
|
||||
from rally import objects
|
||||
from rally.verification.tempest import diff
|
||||
|
@ -22,7 +22,7 @@ import sys
|
||||
from rally import api
|
||||
from rally.cli import cliutils
|
||||
from rally.cli import envutils
|
||||
from rally import db
|
||||
from rally.common import db
|
||||
|
||||
|
||||
class DBCommands(object):
|
||||
|
@ -13,4 +13,4 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.db.api import * # noqa
|
||||
from rally.common.db.api import * # noqa
|
@ -17,8 +17,9 @@
|
||||
|
||||
The underlying driver is loaded as a :class:`LazyPluggable`.
|
||||
|
||||
Functions in this module are imported into the rally.db namespace. Call these
|
||||
functions from rally.db namespace, not the rally.db.api namespace.
|
||||
Functions in this module are imported into the rally.common.db namespace.
|
||||
Call these functions from rally.common.db namespace, not the
|
||||
rally.common.db.api namespace.
|
||||
|
||||
All functions in this module return objects that implement a dictionary-like
|
||||
interface. Currently, many of these objects are sqlalchemy objects that
|
||||
@ -58,7 +59,7 @@ def get_impl():
|
||||
global IMPL
|
||||
|
||||
if not IMPL:
|
||||
_BACKEND_MAPPING = {"sqlalchemy": "rally.db.sqlalchemy.api"}
|
||||
_BACKEND_MAPPING = {"sqlalchemy": "rally.common.db.sqlalchemy.api"}
|
||||
IMPL = db_api.DBAPI.from_config(CONF, backend_mapping=_BACKEND_MAPPING)
|
||||
|
||||
return IMPL
|
@ -23,8 +23,8 @@ from oslo_utils import timeutils
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
from rally.common.db.sqlalchemy import models
|
||||
from rally.common.i18n import _
|
||||
from rally.db.sqlalchemy import models
|
||||
from rally import exceptions
|
||||
|
||||
|
||||
@ -74,13 +74,13 @@ class Connection(object):
|
||||
"""The helper method to create query.
|
||||
|
||||
:param model: The instance of
|
||||
:class:`rally.db.sqlalchemy.models.RallyBase` to
|
||||
:class:`rally.common.db.sqlalchemy.models.RallyBase` to
|
||||
request it.
|
||||
:param session: Reuse the session object or get new one if it is
|
||||
None.
|
||||
:returns: The query object.
|
||||
:raises: :class:`Exception` when the model is not a sublcass of
|
||||
:class:`rally.db.sqlalchemy.models.RallyBase`.
|
||||
:class:`rally.common.db.sqlalchemy.models.RallyBase`.
|
||||
"""
|
||||
session = session or get_session()
|
||||
query = session.query(model)
|
@ -26,8 +26,8 @@ from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy import schema
|
||||
from sqlalchemy import types
|
||||
|
||||
from rally.common.db.sqlalchemy import types as sa_types
|
||||
from rally import consts
|
||||
from rally.db.sqlalchemy import types as sa_types
|
||||
|
||||
|
||||
BASE = declarative_base()
|
||||
@ -44,7 +44,7 @@ class RallyBase(models.ModelBase):
|
||||
onupdate=lambda: timeutils.utcnow())
|
||||
|
||||
def save(self, session=None):
|
||||
from rally.db.sqlalchemy import api as sa_api
|
||||
from rally.common.db.sqlalchemy import api as sa_api
|
||||
|
||||
if session is None:
|
||||
session = sa_api.get_session()
|
||||
@ -234,7 +234,7 @@ class Worker(BASE, RallyBase):
|
||||
|
||||
|
||||
def create_db():
|
||||
from rally.db.sqlalchemy import api as sa_api
|
||||
from rally.common.db.sqlalchemy import api as sa_api
|
||||
|
||||
BASE.metadata.create_all(sa_api.get_engine())
|
||||
|
||||
@ -281,5 +281,5 @@ def drop_all_objects(engine):
|
||||
|
||||
|
||||
def drop_db():
|
||||
from rally.db.sqlalchemy import api as sa_api
|
||||
from rally.common.db.sqlalchemy import api as sa_api
|
||||
drop_all_objects(sa_api.get_engine())
|
@ -18,8 +18,8 @@ import six
|
||||
from six.moves.urllib import parse
|
||||
|
||||
import rally
|
||||
from rally.common import db
|
||||
from rally import consts
|
||||
from rally import db
|
||||
from rally.deployment import engine
|
||||
from rally import objects
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
import datetime
|
||||
|
||||
from rally.common import db
|
||||
from rally import consts
|
||||
from rally import db
|
||||
|
||||
|
||||
class Deployment(object):
|
||||
|
@ -16,8 +16,8 @@
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from rally.common import db
|
||||
from rally import consts
|
||||
from rally import db
|
||||
|
||||
|
||||
TASK_RESULT_SCHEMA = {
|
||||
|
@ -13,8 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import db
|
||||
from rally import consts
|
||||
from rally import db
|
||||
from rally import exceptions
|
||||
|
||||
|
||||
|
@ -23,9 +23,9 @@ import requests
|
||||
from six.moves import configparser
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from rally.common import db
|
||||
from rally.common.i18n import _
|
||||
from rally.common import log as logging
|
||||
from rally import db
|
||||
from rally import exceptions
|
||||
from rally import objects
|
||||
from rally import osclients
|
||||
|
@ -95,27 +95,27 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
self.assertFalse(mock_verification_verify.called)
|
||||
|
||||
@mock.patch("rally.cli.cliutils.print_list")
|
||||
@mock.patch("rally.db.verification_list")
|
||||
def test_list(self, mock_db_verification_list, mock_print_list):
|
||||
@mock.patch("rally.common.db.verification_list")
|
||||
def test_list(self, mock_common_db_verification_list, mock_print_list):
|
||||
fields = ["UUID", "Deployment UUID", "Set name", "Tests", "Failures",
|
||||
"Created at", "Duration", "Status"]
|
||||
verifications = [{"created_at": date.datetime.now(),
|
||||
"updated_at": date.datetime.now()}]
|
||||
mock_db_verification_list.return_value = verifications
|
||||
mock_common_db_verification_list.return_value = verifications
|
||||
self.verify.list()
|
||||
|
||||
for row in verifications:
|
||||
self.assertEqual(row["updated_at"] - row["created_at"],
|
||||
row["duration"])
|
||||
|
||||
mock_db_verification_list.assert_called_once_with()
|
||||
mock_common_db_verification_list.assert_called_once_with()
|
||||
mock_print_list.assert_called_once_with(verifications, fields,
|
||||
sortby_index=fields.index(
|
||||
"Created at"))
|
||||
|
||||
@mock.patch("rally.cli.cliutils.print_list")
|
||||
@mock.patch("rally.db.verification_get")
|
||||
@mock.patch("rally.db.verification_result_get")
|
||||
@mock.patch("rally.common.db.verification_get")
|
||||
@mock.patch("rally.common.db.verification_result_get")
|
||||
@mock.patch("rally.objects.Verification")
|
||||
def test_show(self, mock_objects_verification,
|
||||
mock_verification_result_get, mock_verification_get,
|
||||
@ -147,7 +147,8 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
mock_verification_get.assert_called_once_with(verification_id)
|
||||
mock_verification_result_get.assert_called_once_with(verification_id)
|
||||
|
||||
@mock.patch("rally.db.verification_result_get", return_value={"data": {}})
|
||||
@mock.patch("rally.common.db.verification_result_get",
|
||||
return_value={"data": {}})
|
||||
@mock.patch("json.dumps")
|
||||
def test_results(self, mock_json_dumps, mock_verification_result_get):
|
||||
verification_uuid = "a0231bdf-6a4e-4daf-8ab1-ae076f75f070"
|
||||
@ -157,7 +158,7 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
mock_verification_result_get.assert_called_once_with(verification_uuid)
|
||||
mock_json_dumps.assert_called_once_with({}, sort_keys=True, indent=4)
|
||||
|
||||
@mock.patch("rally.db.verification_result_get")
|
||||
@mock.patch("rally.common.db.verification_result_get")
|
||||
def test_results_verification_not_found(
|
||||
self, mock_verification_result_get):
|
||||
verification_uuid = "9044ced5-9c84-4666-8a8f-4b73a2b62acb"
|
||||
@ -172,7 +173,8 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.cli.commands.verify.open",
|
||||
side_effect=mock.mock_open(), create=True)
|
||||
@mock.patch("rally.db.verification_result_get", return_value={"data": {}})
|
||||
@mock.patch("rally.common.db.verification_result_get",
|
||||
return_value={"data": {}})
|
||||
def test_results_with_output_json_and_output_file(
|
||||
self, mock_verification_result_get, mock_open):
|
||||
mock_open.side_effect = mock.mock_open()
|
||||
@ -186,7 +188,7 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.cli.commands.verify.open",
|
||||
side_effect=mock.mock_open(), create=True)
|
||||
@mock.patch("rally.db.verification_result_get")
|
||||
@mock.patch("rally.common.db.verification_result_get")
|
||||
@mock.patch("rally.verification.tempest.json2html.HtmlOutput")
|
||||
def test_results_with_output_html_and_output_file(
|
||||
self, mock_html_output, mock_verification_result_get, mock_open):
|
||||
@ -205,7 +207,7 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
mock_open.assert_called_once_with("results", "wb")
|
||||
mock_open.side_effect().write.assert_called_once_with("html_report")
|
||||
|
||||
@mock.patch("rally.db.verification_result_get",
|
||||
@mock.patch("rally.common.db.verification_result_get",
|
||||
return_value={"data": {"test_cases": {}}})
|
||||
@mock.patch("json.dumps")
|
||||
def test_compare(self, mock_json_dumps, mock_verification_result_get):
|
||||
@ -221,7 +223,7 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
mock_json_dumps.assert_called_once_with(fake_data, sort_keys=True,
|
||||
indent=4)
|
||||
|
||||
@mock.patch("rally.db.verification_result_get",
|
||||
@mock.patch("rally.common.db.verification_result_get",
|
||||
side_effect=exceptions.NotFoundException())
|
||||
def test_compare_verification_not_found(self,
|
||||
mock_verification_result_get):
|
||||
@ -236,7 +238,7 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.cli.commands.verify.open",
|
||||
side_effect=mock.mock_open(), create=True)
|
||||
@mock.patch("rally.db.verification_result_get",
|
||||
@mock.patch("rally.common.db.verification_result_get",
|
||||
return_value={"data": {"test_cases": {}}})
|
||||
def test_compare_with_output_csv_and_output_file(
|
||||
self, mock_verification_result_get, mock_open):
|
||||
@ -256,7 +258,7 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.cli.commands.verify.open",
|
||||
side_effect=mock.mock_open(), create=True)
|
||||
@mock.patch("rally.db.verification_result_get",
|
||||
@mock.patch("rally.common.db.verification_result_get",
|
||||
return_value={"data": {"test_cases": {}}})
|
||||
def test_compare_with_output_json_and_output_file(
|
||||
self, mock_verification_result_get, mock_open):
|
||||
@ -275,7 +277,7 @@ class VerifyCommandsTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally.cli.commands.verify.open",
|
||||
side_effect=mock.mock_open(), create=True)
|
||||
@mock.patch("rally.db.verification_result_get")
|
||||
@mock.patch("rally.common.db.verification_result_get")
|
||||
@mock.patch(("rally.verification.tempest."
|
||||
"compare2html.create_report"), return_value="")
|
||||
def test_compare_with_output_html_and_output_file(
|
||||
|
@ -179,7 +179,7 @@ class CliUtilsTestCase(test.TestCase):
|
||||
ret = cliutils.run(["rally", "show", "keypairs"], self.categories)
|
||||
self.assertEqual(ret, 1)
|
||||
|
||||
@mock.patch("rally.db.task_get",
|
||||
@mock.patch("rally.common.db.task_get",
|
||||
side_effect=exceptions.TaskNotFound(FAKE_TASK_UUID))
|
||||
def test_run_task_not_found(self, mock_task_get):
|
||||
ret = cliutils.run(["rally", "task", "status", "%s" % FAKE_TASK_UUID],
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
from six import moves
|
||||
|
||||
from rally.common import db
|
||||
from rally import consts
|
||||
from rally import db
|
||||
from rally import exceptions
|
||||
from tests.unit import test
|
||||
|
@ -20,7 +20,7 @@ from oslo_config import fixture
|
||||
from oslotest import base
|
||||
from oslotest import mockpatch
|
||||
|
||||
from rally import db
|
||||
from rally.common import db
|
||||
from rally import plugins
|
||||
from tests.unit import fakes
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user