diff --git a/doc/samples/plugins/context/context_plugin.py b/doc/samples/plugins/context/context_plugin.py index 20e587b279..fa44067fed 100644 --- a/doc/samples/plugins/context/context_plugin.py +++ b/doc/samples/plugins/context/context_plugin.py @@ -1,8 +1,8 @@ from rally.benchmark.context import base +from rally.common import utils from rally import log as logging from rally import osclients -from rally import utils LOG = logging.getLogger(__name__) diff --git a/doc/samples/plugins/runner/runner_plugin.py b/doc/samples/plugins/runner/runner_plugin.py index 857ac21bd2..bf5ba9ac50 100644 --- a/doc/samples/plugins/runner/runner_plugin.py +++ b/doc/samples/plugins/runner/runner_plugin.py @@ -1,7 +1,7 @@ import random from rally.benchmark.runners import base -from rally import utils +from rally.common import utils class RandomTimesScenarioRunner(base.ScenarioRunner): diff --git a/doc/source/concepts.rst b/doc/source/concepts.rst index 5de8144810..77909c25ba 100644 --- a/doc/source/concepts.rst +++ b/doc/source/concepts.rst @@ -170,7 +170,7 @@ It is possible to extend Rally with new Scenario Runner types, if needed. Basica .. parsed-literal:: from rally.benchmark.runners import base - from rally import utils + from rally.common import utils class MyScenarioRunner(base.ScenarioRunner): *"""My scenario runner."""* diff --git a/rally/benchmark/__init__.py b/rally/benchmark/__init__.py index ccc4f60763..5374b1e89b 100644 --- a/rally/benchmark/__init__.py +++ b/rally/benchmark/__init__.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally import utils as rutils +from rally.common import utils as rutils rutils.import_modules_from_package("rally.benchmark.context") diff --git a/rally/benchmark/context/base.py b/rally/benchmark/context/base.py index 5e7f13c701..c0a743e359 100644 --- a/rally/benchmark/context/base.py +++ b/rally/benchmark/context/base.py @@ -18,9 +18,9 @@ import abc import jsonschema import six +from rally.common import utils from rally import exceptions from rally import log as logging -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/cleanup/context.py b/rally/benchmark/context/cleanup/context.py index b468912f2b..8ec188516b 100644 --- a/rally/benchmark/context/cleanup/context.py +++ b/rally/benchmark/context/cleanup/context.py @@ -18,9 +18,9 @@ import sys from rally.benchmark.context import base from rally.benchmark.context.cleanup import manager from rally.common.i18n import _ +from rally.common import utils as rutils from rally import exceptions from rally import log as logging -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/cleanup/manager.py b/rally/benchmark/context/cleanup/manager.py index 44c35487ef..9d45f1ef4c 100644 --- a/rally/benchmark/context/cleanup/manager.py +++ b/rally/benchmark/context/cleanup/manager.py @@ -18,9 +18,9 @@ import time from rally.benchmark.context.cleanup import base from rally.common import broker from rally.common.i18n import _ +from rally.common import utils as rutils from rally import log as logging from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/images.py b/rally/benchmark/context/images.py index c33d499f8f..2f785af198 100644 --- a/rally/benchmark/context/images.py +++ b/rally/benchmark/context/images.py @@ -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.glance import utils as glance_utils from rally.common.i18n import _ +from rally.common import utils as rutils from rally import log as logging from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/keypair.py b/rally/benchmark/context/keypair.py index a672a27257..fe48b3c43e 100644 --- a/rally/benchmark/context/keypair.py +++ b/rally/benchmark/context/keypair.py @@ -18,9 +18,9 @@ import novaclient.exceptions from rally.benchmark.context import base from rally.benchmark.context.cleanup import manager as resource_manager from rally.common.i18n import _ +from rally.common import utils from rally import log as logging from rally import osclients -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/network.py b/rally/benchmark/context/network.py index 7f7703f339..cfc3495ece 100644 --- a/rally/benchmark/context/network.py +++ b/rally/benchmark/context/network.py @@ -18,9 +18,9 @@ import six from rally.benchmark.context import base from rally.benchmark.wrappers import network as network_wrapper from rally.common.i18n import _ +from rally.common import utils from rally import log as logging from rally import osclients -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/quotas/quotas.py b/rally/benchmark/context/quotas/quotas.py index fe83008b4c..5ce58a75c7 100644 --- a/rally/benchmark/context/quotas/quotas.py +++ b/rally/benchmark/context/quotas/quotas.py @@ -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 nova_quotas from rally.common.i18n import _ +from rally.common import utils from rally import log as logging from rally import osclients -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/roles.py b/rally/benchmark/context/roles.py index 9d23b7da28..44721ceb3d 100644 --- a/rally/benchmark/context/roles.py +++ b/rally/benchmark/context/roles.py @@ -15,10 +15,10 @@ from rally.benchmark.context import base from rally.common.i18n import _ +from rally.common import utils as rutils from rally import exceptions from rally import log as logging from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/sahara/sahara_cluster.py b/rally/benchmark/context/sahara/sahara_cluster.py index 86dc7ce104..789caaf867 100644 --- a/rally/benchmark/context/sahara/sahara_cluster.py +++ b/rally/benchmark/context/sahara/sahara_cluster.py @@ -21,10 +21,10 @@ from rally.benchmark.scenarios.sahara import utils from rally.benchmark import types from rally.benchmark import utils as bench_utils from rally.common.i18n import _ +from rally.common import utils as rutils from rally import exceptions from rally import log as logging from rally import osclients -from rally import utils as rutils CONF = cfg.CONF diff --git a/rally/benchmark/context/sahara/sahara_edp.py b/rally/benchmark/context/sahara/sahara_edp.py index ffac832f55..6ae99977b5 100644 --- a/rally/benchmark/context/sahara/sahara_edp.py +++ b/rally/benchmark/context/sahara/sahara_edp.py @@ -18,10 +18,10 @@ import urllib2 from rally.benchmark.context import base from rally.benchmark.context.cleanup import manager as resource_manager from rally.common.i18n import _ +from rally.common import utils as rutils from rally import exceptions from rally import log as logging from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/sahara/sahara_image.py b/rally/benchmark/context/sahara/sahara_image.py index 0e588046dd..edea05bfb3 100644 --- a/rally/benchmark/context/sahara/sahara_image.py +++ b/rally/benchmark/context/sahara/sahara_image.py @@ -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.glance import utils as glance_utils from rally.common.i18n import _ +from rally.common import utils as rutils from rally import log as logging from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/secgroup.py b/rally/benchmark/context/secgroup.py index a773d30148..4543b7f1b0 100644 --- a/rally/benchmark/context/secgroup.py +++ b/rally/benchmark/context/secgroup.py @@ -17,9 +17,9 @@ import six from rally.benchmark.context import base from rally.common.i18n import _ +from rally.common import utils from rally import log as logging from rally import osclients -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/servers.py b/rally/benchmark/context/servers.py index 28c6686564..9f201cdf0b 100755 --- a/rally/benchmark/context/servers.py +++ b/rally/benchmark/context/servers.py @@ -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 import types as types from rally.common.i18n import _ +from rally.common import utils as rutils from rally import log as logging from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/tempest.py b/rally/benchmark/context/tempest.py index e22d7fd36e..a95e93cd1c 100644 --- a/rally/benchmark/context/tempest.py +++ b/rally/benchmark/context/tempest.py @@ -20,9 +20,9 @@ import tempfile from rally.benchmark.context import base from rally.common.i18n import _ +from rally.common import utils from rally import exceptions from rally import log as logging -from rally import utils from rally.verification.verifiers.tempest import config from rally.verification.verifiers.tempest import tempest diff --git a/rally/benchmark/context/users.py b/rally/benchmark/context/users.py index 80ad28c3cd..96ecc37ad1 100644 --- a/rally/benchmark/context/users.py +++ b/rally/benchmark/context/users.py @@ -23,12 +23,12 @@ from rally.benchmark import utils from rally.benchmark.wrappers import keystone from rally.common import broker from rally.common.i18n import _ +from rally.common import utils as rutils from rally import consts from rally import exceptions from rally import log as logging from rally import objects from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/volumes.py b/rally/benchmark/context/volumes.py index 45cb4f2557..d031ee4638 100644 --- a/rally/benchmark/context/volumes.py +++ b/rally/benchmark/context/volumes.py @@ -16,9 +16,9 @@ from rally.benchmark.context import base from rally.benchmark.context.cleanup import manager as resource_manager from rally.benchmark.scenarios.cinder import utils as cinder_utils from rally.common.i18n import _ +from rally.common import utils as rutils from rally import log as logging from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/engine.py b/rally/benchmark/engine.py index 3f32b5d9dc..7019e99970 100644 --- a/rally/benchmark/engine.py +++ b/rally/benchmark/engine.py @@ -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.sla import base as base_sla from rally.common.i18n import _ +from rally.common import utils as rutils from rally import consts from rally import exceptions from rally import log as logging from rally import objects from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/runners/base.py b/rally/benchmark/runners/base.py index bc5e1d6208..b0dd73a83d 100644 --- a/rally/benchmark/runners/base.py +++ b/rally/benchmark/runners/base.py @@ -23,11 +23,11 @@ import six from rally.benchmark.scenarios import base as scenario_base from rally.benchmark import types from rally.benchmark import utils +from rally.common import utils as rutils from rally import consts from rally import exceptions from rally import log as logging from rally import osclients -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/runners/constant.py b/rally/benchmark/runners/constant.py index 14dea88389..de96b545a4 100644 --- a/rally/benchmark/runners/constant.py +++ b/rally/benchmark/runners/constant.py @@ -21,9 +21,9 @@ from six import moves from rally.benchmark.runners import base from rally.benchmark import utils +from rally.common import utils as rutils from rally import consts from rally import log as logging -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/runners/rps.py b/rally/benchmark/runners/rps.py index 9ad989dddc..7ecf2e9dfb 100644 --- a/rally/benchmark/runners/rps.py +++ b/rally/benchmark/runners/rps.py @@ -19,9 +19,9 @@ import threading import time from rally.benchmark.runners import base +from rally.common import utils as rutils from rally import consts from rally import log as logging -from rally import utils as rutils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/runners/serial.py b/rally/benchmark/runners/serial.py index 5b7ce4c48b..67295f085c 100644 --- a/rally/benchmark/runners/serial.py +++ b/rally/benchmark/runners/serial.py @@ -14,8 +14,8 @@ # under the License. from rally.benchmark.runners import base +from rally.common import utils from rally import consts -from rally import utils class SerialScenarioRunner(base.ScenarioRunner): diff --git a/rally/benchmark/scenarios/base.py b/rally/benchmark/scenarios/base.py index ce77ae8228..5b9a7d24ad 100644 --- a/rally/benchmark/scenarios/base.py +++ b/rally/benchmark/scenarios/base.py @@ -20,10 +20,10 @@ import random import string import time +from rally.common import utils from rally import consts from rally import exceptions from rally import log as logging -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/scenarios/utils.py b/rally/benchmark/scenarios/utils.py index df43bf2200..aa87ce53d3 100644 --- a/rally/benchmark/scenarios/utils.py +++ b/rally/benchmark/scenarios/utils.py @@ -14,7 +14,7 @@ import jsonschema -from rally import utils +from rally.common import utils class ActionBuilder(object): diff --git a/rally/benchmark/sla/base.py b/rally/benchmark/sla/base.py index 4883345762..15073ac3f4 100644 --- a/rally/benchmark/sla/base.py +++ b/rally/benchmark/sla/base.py @@ -26,8 +26,8 @@ import six from rally.benchmark.processing import utils as putils from rally.common.i18n import _ +from rally.common import utils from rally import exceptions -from rally import utils class SLAResult(object): diff --git a/rally/benchmark/wrappers/network.py b/rally/benchmark/wrappers/network.py index 34a26ca4b7..4cb910712d 100644 --- a/rally/benchmark/wrappers/network.py +++ b/rally/benchmark/wrappers/network.py @@ -18,9 +18,9 @@ import abc import netaddr import six +from rally.common import utils from rally import consts from rally import log as logging -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/cmd/cliutils.py b/rally/cmd/cliutils.py index ac22df9ecf..2c810875c5 100644 --- a/rally/cmd/cliutils.py +++ b/rally/cmd/cliutils.py @@ -24,11 +24,11 @@ from oslo.config import cfg import six from rally.common.i18n import _ +from rally.common import utils from rally.common import version from rally import exceptions from rally import log as logging from rally.openstack.common import cliutils -from rally import utils CONF = cfg.CONF diff --git a/rally/cmd/commands/deployment.py b/rally/cmd/commands/deployment.py index 93c77ba4ed..9a59f41a84 100644 --- a/rally/cmd/commands/deployment.py +++ b/rally/cmd/commands/deployment.py @@ -29,12 +29,12 @@ from rally.cmd import cliutils from rally.cmd.commands import use from rally.cmd import envutils from rally.common.i18n import _ +from rally.common import utils from rally import db from rally import exceptions from rally import objects from rally.openstack.common import cliutils as common_cliutils from rally import osclients -from rally import utils class DeploymentCommands(object): diff --git a/rally/cmd/commands/info.py b/rally/cmd/commands/info.py index c5e0e007a2..9677f2f629 100644 --- a/rally/cmd/commands/info.py +++ b/rally/cmd/commands/info.py @@ -52,10 +52,10 @@ from __future__ import print_function from rally.benchmark.scenarios import base as scenario_base from rally.benchmark.sla import base as sla_base from rally.cmd import cliutils +from rally.common import utils from rally import deploy from rally.deploy import serverprovider from rally import exceptions -from rally import utils class InfoCommands(object): diff --git a/rally/cmd/commands/show.py b/rally/cmd/commands/show.py index b1e8d2517d..fbb8c7acad 100644 --- a/rally/cmd/commands/show.py +++ b/rally/cmd/commands/show.py @@ -20,12 +20,12 @@ from __future__ import print_function from rally.cmd import cliutils from rally.cmd import envutils from rally.common.i18n import _ +from rally.common import utils from rally import db from rally import exceptions from rally import objects from rally.openstack.common import cliutils as common_cliutils from rally import osclients -from rally import utils class ShowCommands(object): diff --git a/rally/cmd/commands/task.py b/rally/cmd/commands/task.py index 109e4c3553..10ac84f127 100644 --- a/rally/cmd/commands/task.py +++ b/rally/cmd/commands/task.py @@ -30,13 +30,13 @@ from rally.cmd import cliutils from rally.cmd.commands import use from rally.cmd import envutils from rally.common.i18n import _ +from rally.common import utils as rutils from rally import consts from rally import db from rally import exceptions from rally import log as logging from rally import objects from rally.openstack.common import cliutils as common_cliutils -from rally import utils as rutils class TaskCommands(object): diff --git a/rally/utils.py b/rally/common/utils.py similarity index 99% rename from rally/utils.py rename to rally/common/utils.py index 47e3ac6fcc..b0dad4d90f 100644 --- a/rally/utils.py +++ b/rally/common/utils.py @@ -28,6 +28,7 @@ from oslo.utils import importutils from six import moves from sphinx.util import docstrings +import rally from rally.common.i18n import _ from rally import exceptions 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 """ - path = [os.path.dirname(__file__), '..'] + package.split('.') + path = [os.path.dirname(rally.__file__), '..'] + package.split('.') path = os.path.join(*path) for root, dirs, files in os.walk(path): for filename in files: diff --git a/rally/consts.py b/rally/consts.py index 6ce515566b..f3473f821b 100644 --- a/rally/consts.py +++ b/rally/consts.py @@ -21,7 +21,7 @@ so to avoid copy paste or dirrect usage of enums values we create singltons for each enum. (e.g TaskStatus) """ -from rally import utils +from rally.common import utils TEMPEST_TEST_SETS = ("full", diff --git a/rally/deploy/__init__.py b/rally/deploy/__init__.py index d99e9a51ea..3ad7a13111 100644 --- a/rally/deploy/__init__.py +++ b/rally/deploy/__init__.py @@ -14,7 +14,7 @@ # under the License. from rally.deploy.engine import * # noqa -from rally import utils +from rally.common import utils utils.import_modules_from_package('rally.deploy.engines') diff --git a/rally/deploy/engine.py b/rally/deploy/engine.py index a573e01808..f7bd0157a1 100644 --- a/rally/deploy/engine.py +++ b/rally/deploy/engine.py @@ -19,11 +19,11 @@ import jsonschema import six from rally.common.i18n import _ +from rally.common import utils from rally import consts from rally.deploy.serverprovider import provider from rally import exceptions from rally import log as logging -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/deploy/engines/devstack.py b/rally/deploy/engines/devstack.py index 523c59b33e..ec13081ad0 100644 --- a/rally/deploy/engines/devstack.py +++ b/rally/deploy/engines/devstack.py @@ -18,12 +18,12 @@ import os import six from rally.common.i18n import _ +from rally.common import utils from rally import consts from rally.deploy import engine from rally.deploy.serverprovider import provider from rally import log as logging from rally import objects -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/deploy/engines/lxc.py b/rally/deploy/engines/lxc.py index 79a5b7ef57..7df3d2e5a9 100644 --- a/rally/deploy/engines/lxc.py +++ b/rally/deploy/engines/lxc.py @@ -19,13 +19,13 @@ import netaddr import six from rally.common.i18n import _ +from rally.common import utils from rally.deploy import engine from rally.deploy.serverprovider import provider from rally.deploy.serverprovider.providers import lxc from rally import exceptions from rally import log as logging from rally import objects -from rally import utils LOG = logging.getLogger(__name__) START_SCRIPT = 'start.sh' diff --git a/rally/deploy/serverprovider/__init__.py b/rally/deploy/serverprovider/__init__.py index dffbcf43d6..d5bfd836aa 100644 --- a/rally/deploy/serverprovider/__init__.py +++ b/rally/deploy/serverprovider/__init__.py @@ -13,8 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +from rally.common import utils from rally.deploy.serverprovider.provider import * # noqa -from rally import utils utils.import_modules_from_package('rally.deploy.serverprovider.providers') diff --git a/rally/deploy/serverprovider/provider.py b/rally/deploy/serverprovider/provider.py index cc851c1f27..2f14ebaf7d 100644 --- a/rally/deploy/serverprovider/provider.py +++ b/rally/deploy/serverprovider/provider.py @@ -19,8 +19,8 @@ import jsonschema import six from rally.common import sshutils +from rally.common import utils from rally import exceptions -from rally import utils class Server(utils.ImmutableMixin): diff --git a/rally/deploy/serverprovider/providers/lxc.py b/rally/deploy/serverprovider/providers/lxc.py index 631d7b419b..c7195206a2 100644 --- a/rally/deploy/serverprovider/providers/lxc.py +++ b/rally/deploy/serverprovider/providers/lxc.py @@ -22,10 +22,10 @@ import six from six import moves from rally.common.i18n import _ +from rally.common import utils from rally.deploy.serverprovider import provider from rally import exceptions from rally import log as logging -from rally import utils LOG = logging.getLogger(__name__) diff --git a/rally/verification/verifiers/tempest/tempest.py b/rally/verification/verifiers/tempest/tempest.py index e402d584d6..2a9629e378 100644 --- a/rally/verification/verifiers/tempest/tempest.py +++ b/rally/verification/verifiers/tempest/tempest.py @@ -22,9 +22,9 @@ import sys from oslo.serialization import jsonutils from rally.common.i18n import _ +from rally.common import utils from rally import exceptions from rally import log as logging -from rally import utils from rally.verification.verifiers.tempest import config from rally.verification.verifiers.tempest import subunit2json diff --git a/tests/unit/benchmark/context/cleanup/test_resources.py b/tests/unit/benchmark/context/cleanup/test_resources.py index c6965eca09..bf30017fbe 100644 --- a/tests/unit/benchmark/context/cleanup/test_resources.py +++ b/tests/unit/benchmark/context/cleanup/test_resources.py @@ -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 resources from rally.benchmark.scenarios.keystone import utils as keystone_utils -from rally import utils +from rally.common import utils from tests.unit import test BASE = "rally.benchmark.context.cleanup.resources" diff --git a/tests/unit/benchmark/scenarios/test_base.py b/tests/unit/benchmark/scenarios/test_base.py index b308b75acf..621204938d 100644 --- a/tests/unit/benchmark/scenarios/test_base.py +++ b/tests/unit/benchmark/scenarios/test_base.py @@ -345,7 +345,7 @@ class AtomicActionTestCase(test.TestCase): self.assertEqual(c.name, 'asdf') @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): fake_scenario_instance = fakes.FakeScenario() self.start = mock_time.time() diff --git a/tests/unit/benchmark/wrappers/test_network.py b/tests/unit/benchmark/wrappers/test_network.py index f40f020cb9..f2218202c0 100644 --- a/tests/unit/benchmark/wrappers/test_network.py +++ b/tests/unit/benchmark/wrappers/test_network.py @@ -53,7 +53,8 @@ class NovaNetworkWrapperTestCase(test.TestCase): self.assertEqual(service._generate_cidr(), 9) 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): service = self.get_wrapper() service.client.networks.create.side_effect = ( @@ -105,7 +106,7 @@ class NeutronWrapperTestCase(test.TestCase): self.assertEqual(service._generate_cidr(), 7) 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): mock_name.return_value = "foo_name" service = self.get_wrapper() @@ -125,7 +126,7 @@ class NeutronWrapperTestCase(test.TestCase): "router_id": None, "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): subnets_num = 4 mock_name.return_value = "foo_name" @@ -162,7 +163,7 @@ class NeutronWrapperTestCase(test.TestCase): "cidr": "cidr-%d" % i}}) 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): mock_name.return_value = "foo_name" service = self.get_wrapper() @@ -184,7 +185,7 @@ class NeutronWrapperTestCase(test.TestCase): service.client.create_router.assert_called_once_with( {"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): mock_name.return_value = "foo_name" service = self.get_wrapper() @@ -209,7 +210,7 @@ class NeutronWrapperTestCase(test.TestCase): "external_gateway_info": {"network_id": "bar_id", "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): subnets_num = 4 mock_name.return_value = "foo_name" diff --git a/tests/unit/test_utils.py b/tests/unit/common/test_utils.py similarity index 91% rename from tests/unit/test_utils.py rename to tests/unit/common/test_utils.py index 26fed146d2..5f5b8e76d8 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/common/test_utils.py @@ -23,8 +23,8 @@ import time import mock from rally.common.i18n import _ +from rally.common import utils from rally import exceptions -from rally import utils from tests.unit import test @@ -89,7 +89,7 @@ class TimerTestCase(test.TestCase): start_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) with utils.Timer() as timer: mock_time.time = mock.MagicMock(return_value=end_time) @@ -172,15 +172,15 @@ class LogTestCase(test.TestCase): class LoadExtraModulesTestCase(test.TestCase): - @mock.patch("rally.utils.imp.load_module") - @mock.patch("rally.utils.imp.find_module", return_value=(mock.MagicMock(), - None, None)) - @mock.patch("rally.utils.os.walk", return_value=[ + @mock.patch("rally.common.utils.imp.load_module") + @mock.patch("rally.common.utils.imp.find_module", + return_value=(mock.MagicMock(), None, None)) + @mock.patch("rally.common.utils.os.walk", return_value=[ ('/somewhere', ('/subdir', ), ('plugin1.py', )), ('/somewhere/subdir', ('/subsubdir', ), ('plugin2.py', 'withoutextension')), ('/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, mock_oswalk, mock_find_module, mock_load_module): @@ -194,7 +194,7 @@ class LoadExtraModulesTestCase(test.TestCase): self.assertEqual(mock_find_module.mock_calls, expected) 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): # test no fails for nonexisting directory mock_os.path.exists.return_value = False @@ -204,11 +204,11 @@ class LoadExtraModulesTestCase(test.TestCase): mock_os.walk.return_value = [] utils.load_plugins("/somewhere") - @mock.patch("rally.utils.imp.load_module", side_effect=Exception()) - @mock.patch("rally.utils.imp.find_module") - @mock.patch("rally.utils.os.path", return_value=True) - @mock.patch("rally.utils.os.walk", return_value=[('/etc/.rally/plugins', - [], ('load_it.py', ))]) + @mock.patch("rally.common.utils.imp.load_module", side_effect=Exception()) + @mock.patch("rally.common.utils.imp.find_module") + @mock.patch("rally.common.utils.os.path", return_value=True) + @mock.patch("rally.common.utils.os.walk", + return_value=[('/etc/.rally/plugins', [], ('load_it.py', ))]) def test_load_plugins_fails(self, mock_oswalk, mock_ospath, mock_load_module, mock_find_module): # test no fails if module is broken @@ -354,28 +354,28 @@ class TenantIteratorTestCase(test.TestCase): class RAMIntTestCase(test.TestCase): - @mock.patch("rally.utils.multiprocessing") + @mock.patch("rally.common.utils.multiprocessing") def test__init__(self, mock_multi): utils.RAMInt() mock_multi.Lock.assert_called_once_with() 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): mock_multi.Value.return_value = mock.Mock(value=42) self.assertEqual(int(utils.RAMInt()), 42) - @mock.patch("rally.utils.multiprocessing") + @mock.patch("rally.common.utils.multiprocessing") def test__str__(self, mock_multi): mock_multi.Value.return_value = mock.Mock(value=42) self.assertEqual(str(utils.RAMInt()), "42") - @mock.patch("rally.utils.multiprocessing") + @mock.patch("rally.common.utils.multiprocessing") def test__iter__(self, mock_multi): ram_int = utils.RAMInt() self.assertEqual(iter(ram_int), ram_int) - @mock.patch("rally.utils.multiprocessing") + @mock.patch("rally.common.utils.multiprocessing") def test__next__(self, mock_multi): class MemInt(int): THRESHOLD = 5 @@ -396,13 +396,14 @@ class RAMIntTestCase(test.TestCase): [mock.call()] * 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.utils.multiprocessing") + @mock.patch("rally.common.utils.RAMInt.__next__", + return_value="next_value") + @mock.patch("rally.common.utils.multiprocessing") def test_next(self, mock_multi, mock_next): self.assertEqual(utils.RAMInt().next(), "next_value") mock_next.assert_called_once_with() - @mock.patch("rally.utils.multiprocessing") + @mock.patch("rally.common.utils.multiprocessing") def test_reset(self, mock_multi): ram_int = utils.RAMInt() self.assertRaises(TypeError, int, ram_int) @@ -412,7 +413,7 @@ class RAMIntTestCase(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): choice = "foobarspamchoicestring" diff --git a/tests/unit/fakes.py b/tests/unit/fakes.py index 2c4beebffa..fb281f5afc 100644 --- a/tests/unit/fakes.py +++ b/tests/unit/fakes.py @@ -28,8 +28,8 @@ import six from rally.benchmark.context import base as base_ctx from rally.benchmark.scenarios import base +from rally.common import utils as rally_utils from rally import objects -from rally import utils as rally_utils def generate_uuid(): diff --git a/tests/unit/rally_jobs/test_jobs.py b/tests/unit/rally_jobs/test_jobs.py index 8ffd887a29..d58196c174 100644 --- a/tests/unit/rally_jobs/test_jobs.py +++ b/tests/unit/rally_jobs/test_jobs.py @@ -19,7 +19,7 @@ import mock import yaml from rally.benchmark import engine -import rally.utils as rutils +import rally.common.utils as rutils from tests.unit import test diff --git a/tests/unit/test_docstrings.py b/tests/unit/test_docstrings.py index 59e65a9813..e8c2cacbf9 100644 --- a/tests/unit/test_docstrings.py +++ b/tests/unit/test_docstrings.py @@ -15,9 +15,9 @@ from rally.benchmark.scenarios import base from rally.benchmark.sla import base as sla_base +from rally.common import utils from rally import deploy from rally.deploy import serverprovider -from rally import utils from tests.unit import test