Move files to common lib(Part 3)

Move utils to common directory.

Change-Id: Ifaf71ea4a2a1acc85ceb2af6ed978d3e08666b41
This commit is contained in:
liyingjun 2014-12-25 15:02:44 +08:00 committed by liyingjun
parent 6d57a3be02
commit a7e2a8e4f5
51 changed files with 80 additions and 77 deletions

View File

@ -1,8 +1,8 @@
from rally.benchmark.context import base from rally.benchmark.context import base
from rally.common import utils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -1,7 +1,7 @@
import random import random
from rally.benchmark.runners import base from rally.benchmark.runners import base
from rally import utils from rally.common import utils
class RandomTimesScenarioRunner(base.ScenarioRunner): class RandomTimesScenarioRunner(base.ScenarioRunner):

View File

@ -170,7 +170,7 @@ It is possible to extend Rally with new Scenario Runner types, if needed. Basica
.. parsed-literal:: .. parsed-literal::
from rally.benchmark.runners import base from rally.benchmark.runners import base
from rally import utils from rally.common import utils
class MyScenarioRunner(base.ScenarioRunner): class MyScenarioRunner(base.ScenarioRunner):
*"""My scenario runner."""* *"""My scenario runner."""*

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from rally import utils as rutils from rally.common import utils as rutils
rutils.import_modules_from_package("rally.benchmark.context") rutils.import_modules_from_package("rally.benchmark.context")

View File

@ -18,9 +18,9 @@ import abc
import jsonschema import jsonschema
import six import six
from rally.common import utils
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -18,9 +18,9 @@ import sys
from rally.benchmark.context import base from rally.benchmark.context import base
from rally.benchmark.context.cleanup import manager from rally.benchmark.context.cleanup import manager
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -18,9 +18,9 @@ import time
from rally.benchmark.context.cleanup import base from rally.benchmark.context.cleanup import base
from rally.common import broker from rally.common import broker
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,9 +17,9 @@ from rally.benchmark.context.cleanup import manager as resource_manager
from rally.benchmark.scenarios import base as scenario_base from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios.glance import utils as glance_utils from rally.benchmark.scenarios.glance import utils as glance_utils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -18,9 +18,9 @@ import novaclient.exceptions
from rally.benchmark.context import base from rally.benchmark.context import base
from rally.benchmark.context.cleanup import manager as resource_manager from rally.benchmark.context.cleanup import manager as resource_manager
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -18,9 +18,9 @@ import six
from rally.benchmark.context import base from rally.benchmark.context import base
from rally.benchmark.wrappers import network as network_wrapper from rally.benchmark.wrappers import network as network_wrapper
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -19,9 +19,9 @@ from rally.benchmark.context.quotas import designate_quotas
from rally.benchmark.context.quotas import neutron_quotas from rally.benchmark.context.quotas import neutron_quotas
from rally.benchmark.context.quotas import nova_quotas from rally.benchmark.context.quotas import nova_quotas
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,10 +15,10 @@
from rally.benchmark.context import base from rally.benchmark.context import base
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -21,10 +21,10 @@ from rally.benchmark.scenarios.sahara import utils
from rally.benchmark import types from rally.benchmark import types
from rally.benchmark import utils as bench_utils from rally.benchmark import utils as bench_utils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils as rutils
CONF = cfg.CONF CONF = cfg.CONF

View File

@ -18,10 +18,10 @@ import urllib2
from rally.benchmark.context import base from rally.benchmark.context import base
from rally.benchmark.context.cleanup import manager as resource_manager from rally.benchmark.context.cleanup import manager as resource_manager
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,9 +17,9 @@ from rally.benchmark.context.cleanup import manager as resource_manager
from rally.benchmark.scenarios import base as scenarios_base from rally.benchmark.scenarios import base as scenarios_base
from rally.benchmark.scenarios.glance import utils as glance_utils from rally.benchmark.scenarios.glance import utils as glance_utils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,9 +17,9 @@ import six
from rally.benchmark.context import base from rally.benchmark.context import base
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,9 +17,9 @@ from rally.benchmark.context.cleanup import manager as resource_manager
from rally.benchmark.scenarios.nova import utils as nova_utils from rally.benchmark.scenarios.nova import utils as nova_utils
from rally.benchmark import types as types from rally.benchmark import types as types
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -20,9 +20,9 @@ import tempfile
from rally.benchmark.context import base from rally.benchmark.context import base
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import utils
from rally.verification.verifiers.tempest import config from rally.verification.verifiers.tempest import config
from rally.verification.verifiers.tempest import tempest from rally.verification.verifiers.tempest import tempest

View File

@ -23,12 +23,12 @@ from rally.benchmark import utils
from rally.benchmark.wrappers import keystone from rally.benchmark.wrappers import keystone
from rally.common import broker from rally.common import broker
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import consts from rally import consts
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import objects from rally import objects
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,9 +16,9 @@ from rally.benchmark.context import base
from rally.benchmark.context.cleanup import manager as resource_manager from rally.benchmark.context.cleanup import manager as resource_manager
from rally.benchmark.scenarios.cinder import utils as cinder_utils from rally.benchmark.scenarios.cinder import utils as cinder_utils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -27,12 +27,12 @@ from rally.benchmark.runners import base as base_runner
from rally.benchmark.scenarios import base as base_scenario from rally.benchmark.scenarios import base as base_scenario
from rally.benchmark.sla import base as base_sla from rally.benchmark.sla import base as base_sla
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import consts from rally import consts
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import objects from rally import objects
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -23,11 +23,11 @@ import six
from rally.benchmark.scenarios import base as scenario_base from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark import types from rally.benchmark import types
from rally.benchmark import utils from rally.benchmark import utils
from rally.common import utils as rutils
from rally import consts from rally import consts
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import osclients from rally import osclients
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -21,9 +21,9 @@ from six import moves
from rally.benchmark.runners import base from rally.benchmark.runners import base
from rally.benchmark import utils from rally.benchmark import utils
from rally.common import utils as rutils
from rally import consts from rally import consts
from rally import log as logging from rally import log as logging
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -19,9 +19,9 @@ import threading
import time import time
from rally.benchmark.runners import base from rally.benchmark.runners import base
from rally.common import utils as rutils
from rally import consts from rally import consts
from rally import log as logging from rally import log as logging
from rally import utils as rutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
from rally.benchmark.runners import base from rally.benchmark.runners import base
from rally.common import utils
from rally import consts from rally import consts
from rally import utils
class SerialScenarioRunner(base.ScenarioRunner): class SerialScenarioRunner(base.ScenarioRunner):

View File

@ -20,10 +20,10 @@ import random
import string import string
import time import time
from rally.common import utils
from rally import consts from rally import consts
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,7 +14,7 @@
import jsonschema import jsonschema
from rally import utils from rally.common import utils
class ActionBuilder(object): class ActionBuilder(object):

View File

@ -26,8 +26,8 @@ import six
from rally.benchmark.processing import utils as putils from rally.benchmark.processing import utils as putils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import exceptions from rally import exceptions
from rally import utils
class SLAResult(object): class SLAResult(object):

View File

@ -18,9 +18,9 @@ import abc
import netaddr import netaddr
import six import six
from rally.common import utils
from rally import consts from rally import consts
from rally import log as logging from rally import log as logging
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -24,11 +24,11 @@ from oslo.config import cfg
import six import six
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally.common import version from rally.common import version
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally.openstack.common import cliutils from rally.openstack.common import cliutils
from rally import utils
CONF = cfg.CONF CONF = cfg.CONF

View File

@ -29,12 +29,12 @@ from rally.cmd import cliutils
from rally.cmd.commands import use from rally.cmd.commands import use
from rally.cmd import envutils from rally.cmd import envutils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import db from rally import db
from rally import exceptions from rally import exceptions
from rally import objects from rally import objects
from rally.openstack.common import cliutils as common_cliutils from rally.openstack.common import cliutils as common_cliutils
from rally import osclients from rally import osclients
from rally import utils
class DeploymentCommands(object): class DeploymentCommands(object):

View File

@ -52,10 +52,10 @@ from __future__ import print_function
from rally.benchmark.scenarios import base as scenario_base from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.sla import base as sla_base from rally.benchmark.sla import base as sla_base
from rally.cmd import cliutils from rally.cmd import cliutils
from rally.common import utils
from rally import deploy from rally import deploy
from rally.deploy import serverprovider from rally.deploy import serverprovider
from rally import exceptions from rally import exceptions
from rally import utils
class InfoCommands(object): class InfoCommands(object):

View File

@ -20,12 +20,12 @@ from __future__ import print_function
from rally.cmd import cliutils from rally.cmd import cliutils
from rally.cmd import envutils from rally.cmd import envutils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import db from rally import db
from rally import exceptions from rally import exceptions
from rally import objects from rally import objects
from rally.openstack.common import cliutils as common_cliutils from rally.openstack.common import cliutils as common_cliutils
from rally import osclients from rally import osclients
from rally import utils
class ShowCommands(object): class ShowCommands(object):

View File

@ -30,13 +30,13 @@ from rally.cmd import cliutils
from rally.cmd.commands import use from rally.cmd.commands import use
from rally.cmd import envutils from rally.cmd import envutils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils as rutils
from rally import consts from rally import consts
from rally import db from rally import db
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import objects from rally import objects
from rally.openstack.common import cliutils as common_cliutils from rally.openstack.common import cliutils as common_cliutils
from rally import utils as rutils
class TaskCommands(object): class TaskCommands(object):

View File

@ -28,6 +28,7 @@ from oslo.utils import importutils
from six import moves from six import moves
from sphinx.util import docstrings from sphinx.util import docstrings
import rally
from rally.common.i18n import _ from rally.common.i18n import _
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
@ -166,7 +167,7 @@ def import_modules_from_package(package):
:param: package - Full package name. For example: rally.deploy.engines :param: package - Full package name. For example: rally.deploy.engines
""" """
path = [os.path.dirname(__file__), '..'] + package.split('.') path = [os.path.dirname(rally.__file__), '..'] + package.split('.')
path = os.path.join(*path) path = os.path.join(*path)
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
for filename in files: for filename in files:

View File

@ -21,7 +21,7 @@ so to avoid copy paste or dirrect usage of enums values we create singltons
for each enum. (e.g TaskStatus) for each enum. (e.g TaskStatus)
""" """
from rally import utils from rally.common import utils
TEMPEST_TEST_SETS = ("full", TEMPEST_TEST_SETS = ("full",

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
from rally.deploy.engine import * # noqa from rally.deploy.engine import * # noqa
from rally import utils from rally.common import utils
utils.import_modules_from_package('rally.deploy.engines') utils.import_modules_from_package('rally.deploy.engines')

View File

@ -19,11 +19,11 @@ import jsonschema
import six import six
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import consts from rally import consts
from rally.deploy.serverprovider import provider from rally.deploy.serverprovider import provider
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -18,12 +18,12 @@ import os
import six import six
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import consts from rally import consts
from rally.deploy import engine from rally.deploy import engine
from rally.deploy.serverprovider import provider from rally.deploy.serverprovider import provider
from rally import log as logging from rally import log as logging
from rally import objects from rally import objects
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -19,13 +19,13 @@ import netaddr
import six import six
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally.deploy import engine from rally.deploy import engine
from rally.deploy.serverprovider import provider from rally.deploy.serverprovider import provider
from rally.deploy.serverprovider.providers import lxc from rally.deploy.serverprovider.providers import lxc
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import objects from rally import objects
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
START_SCRIPT = 'start.sh' START_SCRIPT = 'start.sh'

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from rally.common import utils
from rally.deploy.serverprovider.provider import * # noqa from rally.deploy.serverprovider.provider import * # noqa
from rally import utils
utils.import_modules_from_package('rally.deploy.serverprovider.providers') utils.import_modules_from_package('rally.deploy.serverprovider.providers')

View File

@ -19,8 +19,8 @@ import jsonschema
import six import six
from rally.common import sshutils from rally.common import sshutils
from rally.common import utils
from rally import exceptions from rally import exceptions
from rally import utils
class Server(utils.ImmutableMixin): class Server(utils.ImmutableMixin):

View File

@ -22,10 +22,10 @@ import six
from six import moves from six import moves
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally.deploy.serverprovider import provider from rally.deploy.serverprovider import provider
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -22,9 +22,9 @@ import sys
from oslo.serialization import jsonutils from oslo.serialization import jsonutils
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import exceptions from rally import exceptions
from rally import log as logging from rally import log as logging
from rally import utils
from rally.verification.verifiers.tempest import config from rally.verification.verifiers.tempest import config
from rally.verification.verifiers.tempest import subunit2json from rally.verification.verifiers.tempest import subunit2json

View File

@ -19,7 +19,7 @@ from neutronclient.common import exceptions as neutron_exceptions
from rally.benchmark.context.cleanup import base from rally.benchmark.context.cleanup import base
from rally.benchmark.context.cleanup import resources from rally.benchmark.context.cleanup import resources
from rally.benchmark.scenarios.keystone import utils as keystone_utils from rally.benchmark.scenarios.keystone import utils as keystone_utils
from rally import utils from rally.common import utils
from tests.unit import test from tests.unit import test
BASE = "rally.benchmark.context.cleanup.resources" BASE = "rally.benchmark.context.cleanup.resources"

View File

@ -345,7 +345,7 @@ class AtomicActionTestCase(test.TestCase):
self.assertEqual(c.name, 'asdf') self.assertEqual(c.name, 'asdf')
@mock.patch('tests.unit.fakes.FakeScenario._add_atomic_actions') @mock.patch('tests.unit.fakes.FakeScenario._add_atomic_actions')
@mock.patch('rally.utils.time') @mock.patch('rally.common.utils.time')
def test__exit__(self, mock_time, mock__add_atomic_actions): def test__exit__(self, mock_time, mock__add_atomic_actions):
fake_scenario_instance = fakes.FakeScenario() fake_scenario_instance = fakes.FakeScenario()
self.start = mock_time.time() self.start = mock_time.time()

View File

@ -53,7 +53,8 @@ class NovaNetworkWrapperTestCase(test.TestCase):
self.assertEqual(service._generate_cidr(), 9) self.assertEqual(service._generate_cidr(), 9)
self.assertEqual(mock_cidr.mock_calls, [mock.call(start_cidr=3)] * 7) self.assertEqual(mock_cidr.mock_calls, [mock.call(start_cidr=3)] * 7)
@mock.patch("rally.utils.generate_random_name", return_value="foo_name") @mock.patch("rally.common.utils.generate_random_name",
return_value="foo_name")
def test_create_network(self, mock_name): def test_create_network(self, mock_name):
service = self.get_wrapper() service = self.get_wrapper()
service.client.networks.create.side_effect = ( service.client.networks.create.side_effect = (
@ -105,7 +106,7 @@ class NeutronWrapperTestCase(test.TestCase):
self.assertEqual(service._generate_cidr(), 7) self.assertEqual(service._generate_cidr(), 7)
self.assertEqual(mock_cidr.mock_calls, [mock.call(start_cidr=3)] * 5) self.assertEqual(mock_cidr.mock_calls, [mock.call(start_cidr=3)] * 5)
@mock.patch("rally.utils.generate_random_name") @mock.patch("rally.common.utils.generate_random_name")
def test_create_network(self, mock_name): def test_create_network(self, mock_name):
mock_name.return_value = "foo_name" mock_name.return_value = "foo_name"
service = self.get_wrapper() service = self.get_wrapper()
@ -125,7 +126,7 @@ class NeutronWrapperTestCase(test.TestCase):
"router_id": None, "router_id": None,
"subnets": []}) "subnets": []})
@mock.patch("rally.utils.generate_random_name") @mock.patch("rally.common.utils.generate_random_name")
def test_create_network_with_subnets(self, mock_name): def test_create_network_with_subnets(self, mock_name):
subnets_num = 4 subnets_num = 4
mock_name.return_value = "foo_name" mock_name.return_value = "foo_name"
@ -162,7 +163,7 @@ class NeutronWrapperTestCase(test.TestCase):
"cidr": "cidr-%d" % i}}) "cidr": "cidr-%d" % i}})
for i in range(subnets_num)]) for i in range(subnets_num)])
@mock.patch("rally.utils.generate_random_name") @mock.patch("rally.common.utils.generate_random_name")
def test_create_network_with_router(self, mock_name): def test_create_network_with_router(self, mock_name):
mock_name.return_value = "foo_name" mock_name.return_value = "foo_name"
service = self.get_wrapper() service = self.get_wrapper()
@ -184,7 +185,7 @@ class NeutronWrapperTestCase(test.TestCase):
service.client.create_router.assert_called_once_with( service.client.create_router.assert_called_once_with(
{"router": {"tenant_id": "foo_tenant", "name": "foo_name"}}) {"router": {"tenant_id": "foo_tenant", "name": "foo_name"}})
@mock.patch("rally.utils.generate_random_name") @mock.patch("rally.common.utils.generate_random_name")
def test_create_network_with_router_external(self, mock_name): def test_create_network_with_router_external(self, mock_name):
mock_name.return_value = "foo_name" mock_name.return_value = "foo_name"
service = self.get_wrapper() service = self.get_wrapper()
@ -209,7 +210,7 @@ class NeutronWrapperTestCase(test.TestCase):
"external_gateway_info": {"network_id": "bar_id", "external_gateway_info": {"network_id": "bar_id",
"enable_snat": True}}}) "enable_snat": True}}})
@mock.patch("rally.utils.generate_random_name") @mock.patch("rally.common.utils.generate_random_name")
def test_create_network_with_router_and_subnets(self, mock_name): def test_create_network_with_router_and_subnets(self, mock_name):
subnets_num = 4 subnets_num = 4
mock_name.return_value = "foo_name" mock_name.return_value = "foo_name"

View File

@ -23,8 +23,8 @@ import time
import mock import mock
from rally.common.i18n import _ from rally.common.i18n import _
from rally.common import utils
from rally import exceptions from rally import exceptions
from rally import utils
from tests.unit import test from tests.unit import test
@ -89,7 +89,7 @@ class TimerTestCase(test.TestCase):
start_time = time.time() start_time = time.time()
end_time = time.time() end_time = time.time()
with mock.patch('rally.utils.time') as mock_time: with mock.patch('rally.common.utils.time') as mock_time:
mock_time.time = mock.MagicMock(return_value=start_time) mock_time.time = mock.MagicMock(return_value=start_time)
with utils.Timer() as timer: with utils.Timer() as timer:
mock_time.time = mock.MagicMock(return_value=end_time) mock_time.time = mock.MagicMock(return_value=end_time)
@ -172,15 +172,15 @@ class LogTestCase(test.TestCase):
class LoadExtraModulesTestCase(test.TestCase): class LoadExtraModulesTestCase(test.TestCase):
@mock.patch("rally.utils.imp.load_module") @mock.patch("rally.common.utils.imp.load_module")
@mock.patch("rally.utils.imp.find_module", return_value=(mock.MagicMock(), @mock.patch("rally.common.utils.imp.find_module",
None, None)) return_value=(mock.MagicMock(), None, None))
@mock.patch("rally.utils.os.walk", return_value=[ @mock.patch("rally.common.utils.os.walk", return_value=[
('/somewhere', ('/subdir', ), ('plugin1.py', )), ('/somewhere', ('/subdir', ), ('plugin1.py', )),
('/somewhere/subdir', ('/subsubdir', ), ('plugin2.py', ('/somewhere/subdir', ('/subsubdir', ), ('plugin2.py',
'withoutextension')), 'withoutextension')),
('/somewhere/subdir/subsubdir', [], ('plugin3.py', ))]) ('/somewhere/subdir/subsubdir', [], ('plugin3.py', ))])
@mock.patch("rally.utils.os.path.exists", return_value=True) @mock.patch("rally.common.utils.os.path.exists", return_value=True)
def test_load_plugins_successfull(self, mock_exists, def test_load_plugins_successfull(self, mock_exists,
mock_oswalk, mock_find_module, mock_oswalk, mock_find_module,
mock_load_module): mock_load_module):
@ -194,7 +194,7 @@ class LoadExtraModulesTestCase(test.TestCase):
self.assertEqual(mock_find_module.mock_calls, expected) self.assertEqual(mock_find_module.mock_calls, expected)
self.assertEqual(len(mock_load_module.mock_calls), 3) self.assertEqual(len(mock_load_module.mock_calls), 3)
@mock.patch("rally.utils.os") @mock.patch("rally.common.utils.os")
def test_load_plugins_from_nonexisting_and_empty_dir(self, mock_os): def test_load_plugins_from_nonexisting_and_empty_dir(self, mock_os):
# test no fails for nonexisting directory # test no fails for nonexisting directory
mock_os.path.exists.return_value = False mock_os.path.exists.return_value = False
@ -204,11 +204,11 @@ class LoadExtraModulesTestCase(test.TestCase):
mock_os.walk.return_value = [] mock_os.walk.return_value = []
utils.load_plugins("/somewhere") utils.load_plugins("/somewhere")
@mock.patch("rally.utils.imp.load_module", side_effect=Exception()) @mock.patch("rally.common.utils.imp.load_module", side_effect=Exception())
@mock.patch("rally.utils.imp.find_module") @mock.patch("rally.common.utils.imp.find_module")
@mock.patch("rally.utils.os.path", return_value=True) @mock.patch("rally.common.utils.os.path", return_value=True)
@mock.patch("rally.utils.os.walk", return_value=[('/etc/.rally/plugins', @mock.patch("rally.common.utils.os.walk",
[], ('load_it.py', ))]) return_value=[('/etc/.rally/plugins', [], ('load_it.py', ))])
def test_load_plugins_fails(self, mock_oswalk, mock_ospath, def test_load_plugins_fails(self, mock_oswalk, mock_ospath,
mock_load_module, mock_find_module): mock_load_module, mock_find_module):
# test no fails if module is broken # test no fails if module is broken
@ -354,28 +354,28 @@ class TenantIteratorTestCase(test.TestCase):
class RAMIntTestCase(test.TestCase): class RAMIntTestCase(test.TestCase):
@mock.patch("rally.utils.multiprocessing") @mock.patch("rally.common.utils.multiprocessing")
def test__init__(self, mock_multi): def test__init__(self, mock_multi):
utils.RAMInt() utils.RAMInt()
mock_multi.Lock.assert_called_once_with() mock_multi.Lock.assert_called_once_with()
mock_multi.Value.assert_called_once_with("I", 0) mock_multi.Value.assert_called_once_with("I", 0)
@mock.patch("rally.utils.multiprocessing") @mock.patch("rally.common.utils.multiprocessing")
def test__int__(self, mock_multi): def test__int__(self, mock_multi):
mock_multi.Value.return_value = mock.Mock(value=42) mock_multi.Value.return_value = mock.Mock(value=42)
self.assertEqual(int(utils.RAMInt()), 42) self.assertEqual(int(utils.RAMInt()), 42)
@mock.patch("rally.utils.multiprocessing") @mock.patch("rally.common.utils.multiprocessing")
def test__str__(self, mock_multi): def test__str__(self, mock_multi):
mock_multi.Value.return_value = mock.Mock(value=42) mock_multi.Value.return_value = mock.Mock(value=42)
self.assertEqual(str(utils.RAMInt()), "42") self.assertEqual(str(utils.RAMInt()), "42")
@mock.patch("rally.utils.multiprocessing") @mock.patch("rally.common.utils.multiprocessing")
def test__iter__(self, mock_multi): def test__iter__(self, mock_multi):
ram_int = utils.RAMInt() ram_int = utils.RAMInt()
self.assertEqual(iter(ram_int), ram_int) self.assertEqual(iter(ram_int), ram_int)
@mock.patch("rally.utils.multiprocessing") @mock.patch("rally.common.utils.multiprocessing")
def test__next__(self, mock_multi): def test__next__(self, mock_multi):
class MemInt(int): class MemInt(int):
THRESHOLD = 5 THRESHOLD = 5
@ -396,13 +396,14 @@ class RAMIntTestCase(test.TestCase):
[mock.call()] * MemInt.THRESHOLD) [mock.call()] * MemInt.THRESHOLD)
self.assertEqual(len(mock_lock.__exit__.mock_calls), MemInt.THRESHOLD) self.assertEqual(len(mock_lock.__exit__.mock_calls), MemInt.THRESHOLD)
@mock.patch("rally.utils.RAMInt.__next__", return_value="next_value") @mock.patch("rally.common.utils.RAMInt.__next__",
@mock.patch("rally.utils.multiprocessing") return_value="next_value")
@mock.patch("rally.common.utils.multiprocessing")
def test_next(self, mock_multi, mock_next): def test_next(self, mock_multi, mock_next):
self.assertEqual(utils.RAMInt().next(), "next_value") self.assertEqual(utils.RAMInt().next(), "next_value")
mock_next.assert_called_once_with() mock_next.assert_called_once_with()
@mock.patch("rally.utils.multiprocessing") @mock.patch("rally.common.utils.multiprocessing")
def test_reset(self, mock_multi): def test_reset(self, mock_multi):
ram_int = utils.RAMInt() ram_int = utils.RAMInt()
self.assertRaises(TypeError, int, ram_int) self.assertRaises(TypeError, int, ram_int)
@ -412,7 +413,7 @@ class RAMIntTestCase(test.TestCase):
class GenerateRandomTestCase(test.TestCase): class GenerateRandomTestCase(test.TestCase):
@mock.patch("rally.utils.random") @mock.patch("rally.common.utils.random")
def test_generate_random_name(self, mock_random): def test_generate_random_name(self, mock_random):
choice = "foobarspamchoicestring" choice = "foobarspamchoicestring"

View File

@ -28,8 +28,8 @@ import six
from rally.benchmark.context import base as base_ctx from rally.benchmark.context import base as base_ctx
from rally.benchmark.scenarios import base from rally.benchmark.scenarios import base
from rally.common import utils as rally_utils
from rally import objects from rally import objects
from rally import utils as rally_utils
def generate_uuid(): def generate_uuid():

View File

@ -19,7 +19,7 @@ import mock
import yaml import yaml
from rally.benchmark import engine from rally.benchmark import engine
import rally.utils as rutils import rally.common.utils as rutils
from tests.unit import test from tests.unit import test

View File

@ -15,9 +15,9 @@
from rally.benchmark.scenarios import base from rally.benchmark.scenarios import base
from rally.benchmark.sla import base as sla_base from rally.benchmark.sla import base as sla_base
from rally.common import utils
from rally import deploy from rally import deploy
from rally.deploy import serverprovider from rally.deploy import serverprovider
from rally import utils
from tests.unit import test from tests.unit import test