Merge "Fix hacking 0.9.x issues"

This commit is contained in:
Jenkins 2014-06-18 14:31:41 +00:00 committed by Gerrit Code Review
commit 6afc443af2
85 changed files with 352 additions and 300 deletions

View File

@ -14,6 +14,7 @@
# under the License.
from rally.benchmark.context import base
from rally import exceptions
from rally.openstack.common.gettextutils import _
from rally.openstack.common import log as logging
from rally import osclients
@ -57,9 +58,7 @@ class RoleGenerator(base.Context):
role = def_role
break
else:
msg = (_("Role '%(role)s' does not exist in the list of roles") %
{"role": context_role})
raise Exception(msg)
raise exceptions.NoSuchRole(role=context_role)
LOG.debug("Adding role %s to all users" % (role.id))
for user in self.context["users"]:

View File

@ -14,6 +14,7 @@
# under the License.
from oslo.config import cfg
from rally.benchmark.context import base
from rally.benchmark import utils
from rally import consts

View File

@ -14,9 +14,10 @@
# under the License.
import json
import traceback
import jsonschema
import six
import traceback
from rally.benchmark.context import base as base_ctx
from rally.benchmark.context import users as users_ctx
@ -65,9 +66,10 @@ CONFIG_SCHEMA = {
class BenchmarkEngine(object):
"""The Benchmark engine class, an instance of which is initialized by the
Orchestrator with the benchmarks configuration and then is used to execute
all specified benchmark scenarios.
"""The Benchmark engine class is used to execute benchmark scenarios.
An instance of class is initialized by the Orchestrator with the benchmarks
configuration and then is used to execute all specified scenarios.
.. note::
Typical usage:
@ -81,6 +83,7 @@ class BenchmarkEngine(object):
def __init__(self, config, task):
"""BenchmarkEngine constructor.
:param config: The configuration with specified benchmark scenarios
:param task: The current task which is being performed
"""
@ -165,8 +168,9 @@ class BenchmarkEngine(object):
@rutils.log_task_wrapper(LOG.info, _("Benchmarking."))
def run(self):
"""Runs the benchmarks according to the test configuration
the benchmark engine was initialized with.
"""Run the benchmark according to the test configuration.
Test configuration is specified on engine initialization.
:returns: List of dicts, each dict containing the results of all the
corresponding benchmark test launches

View File

@ -81,8 +81,10 @@ def calculate_number_of_bins_half(data):
def hvariety(data):
"""Returns a list of dictionaries, where every dictionary
describes a method of calculating the number of bins.
"""Describe methods of calculating the number of bins.
:returns: List of dictionaries, where every dictionary
describes a method of calculating the number of bins.
"""
if len(data) == 0:
raise ValueError("Cannot calculate number of histrogram bins "

View File

@ -16,8 +16,9 @@ from rally.benchmark.scenarios import base
class Authenticate(base.Scenario):
"""This class should contain authentication mechanism for different
types of clients like Keystone.
"""This class should contain authentication mechanism.
For different types of clients like Keystone.
"""
@base.scenario()

View File

@ -25,7 +25,9 @@ from rally import utils
def scenario(admin_only=False, context=None):
"""This method is used as decorator for the methods of benchmark scenarios
"""Add extra fields to benchmark scenarios methods.
This method is used as decorator for the methods of benchmark scenarios
and it adds following extra fields to the methods.
'is_scenario' is set to True
'admin_only' is set to True if a scenario require admin endpoints
@ -40,7 +42,8 @@ def scenario(admin_only=False, context=None):
class Scenario(object):
"""This is base class for any benchmark scenario.
You should create subclass of this class. And you test scenarios will
You should create subclass of this class. And your test scenarios will
be auto discoverable and you will be able to specify it in test config.
"""
RESOURCE_NAME_PREFIX = ""

View File

@ -19,9 +19,6 @@ from rally.benchmark.scenarios import utils as scenario_utils
class CeilometerScenario(base.Scenario):
"""This class should contain base operations for benchmarking Ceilometer,
most of them are GET/PUT/POST/DELETE Api calls.
"""
RESOURCE_NAME_PREFIX = "rally_ceilometer_"
def _get_alarm_dict(self, **kwargs):

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
import time
from oslo.config import cfg
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios import utils as scenario_utils
from rally.benchmark import utils as bench_utils

View File

@ -14,9 +14,10 @@
# under the License.
import os
from oslo.config import cfg
import time
from oslo.config import cfg
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios import utils as scenario_utils
from rally.benchmark import utils as bench_utils
@ -97,7 +98,7 @@ class GlanceScenario(base.Scenario):
update_resource=bench_utils.get_from_manager(),
timeout=CONF.benchmark.glance_image_create_timeout,
check_interval=CONF.benchmark.
glance_image_create_poll_interval)
glance_image_create_poll_interval)
finally:
if "data" in kw:

View File

@ -22,10 +22,6 @@ def is_temporary(resource):
class KeystoneScenario(base.Scenario):
"""This class should contain base operations for benchmarking keystone,
most of them are creating/deleting resources.
"""
RESOURCE_NAME_PREFIX = "rally_keystone_"
@scenario_utils.atomic_action_timer('keystone.create_user')

View File

@ -45,8 +45,10 @@ class NeutronNetworks(utils.NeutronScenario):
subnet_create_args=None,
subnet_cidr_start=None,
subnets_per_network=None):
"""Create a network, a given number of subnets
and then list all subnets.
"""Test creating and listing a given number of subnets.
The scenario creates a network, a given number of subnets and then
lists subnets.
:param network_create_args: dict, POST /v2.0/networks request options
:param subnet_create_args: dict, POST /v2.0/subnets request options
@ -69,7 +71,9 @@ class NeutronNetworks(utils.NeutronScenario):
subnet_cidr_start=None,
subnets_per_network=None,
router_create_args=None):
"""Create a network, a given number of subnets and routers
"""Test creating and listing a given number of routers.
Create a network, a given number of subnets and routers
and then list all routers.
:param network_create_args: dict, POST /v2.0/networks request options

View File

@ -14,6 +14,7 @@
# under the License.
import multiprocessing
import netaddr
from rally.benchmark.scenarios import base
@ -21,9 +22,7 @@ from rally.benchmark.scenarios import utils as scenario_utils
class NeutronScenario(base.Scenario):
"""This class should contain base operations for benchmarking neutron,
most of them are creating/deleting resources.
"""
"""This class should contain base operations for benchmarking neutron."""
RESOURCE_NAME_PREFIX = "rally_net_"
SUBNET_IP_VERSION = 4
@ -33,8 +32,7 @@ class NeutronScenario(base.Scenario):
@classmethod
def _generate_subnet_cidr(cls, network_id):
"""Generate next subnet CIDR for given network,
without IP overlapping.
"""Generate next subnet CIDR for network, without IP overlapping.
:param network_id: str, network UUID for subnet
:returns: str, next available subnet CIDR

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import jsonschema
import random
import jsonschema
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios.cinder import utils as cinder_utils
from rally.benchmark.scenarios.nova import utils
@ -94,8 +95,11 @@ class NovaServers(utils.NovaScenario,
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
@base.scenario(context={"cleanup": ["nova"]})
def boot_and_bounce_server(self, image, flavor, **kwargs):
"""Tests booting a server then performing stop/start or hard/soft
reboot a number of times.
"""Test booting a server with further performing specified actions.
Actions should be passed into kwargs. Available actions are
'hard_reboot', 'soft_reboot', 'stop_start' and 'rescue_unrescue'.
Delete server after all actions.
"""
action_builder = self._bind_actions()
actions = kwargs.get('actions', [])
@ -190,6 +194,7 @@ class NovaServers(utils.NovaScenario,
def _rescue_and_unrescue_server(self, server):
"""Rescue and then unrescue the given server.
A rescue will be issued on the given server upon which time
this method will wait for the server to become 'RESCUE'.
Once the server is RESCUE a unrescue will be issued and

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
import time
from oslo.config import cfg
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios import utils as scenario_utils
from rally.benchmark import utils as bench_utils
@ -241,12 +242,12 @@ class NovaScenario(base.Scenario):
:param image: Image object
"""
image.delete()
check_interval = CONF.benchmark.nova_server_image_delete_poll_interval
bench_utils.wait_for_delete(
image,
update_resource=bench_utils.get_from_manager(),
timeout=CONF.benchmark.nova_server_image_delete_timeout,
check_interval=
CONF.benchmark.nova_server_image_delete_poll_interval
check_interval=check_interval
)
@scenario_utils.atomic_action_timer('nova.create_image')
@ -263,13 +264,13 @@ class NovaScenario(base.Scenario):
image_uuid = self.clients("nova").servers.create_image(server,
server.name)
image = self.clients("nova").images.get(image_uuid)
check_interval = CONF.benchmark.nova_server_image_create_poll_interval
image = bench_utils.wait_for(
image,
is_ready=bench_utils.resource_is("ACTIVE"),
update_resource=bench_utils.get_from_manager(),
timeout=CONF.benchmark.nova_server_image_create_timeout,
check_interval=
CONF.benchmark.nova_server_image_create_poll_interval
check_interval=check_interval
)
return image

View File

@ -14,10 +14,11 @@
# under the License.
import os
import six
import subprocess
import tempfile
import six
from rally import exceptions
from rally.openstack.common.gettextutils import _

View File

@ -15,14 +15,14 @@
# under the License.
import functools
import jsonschema
from rally import utils
class ActionBuilder(object):
"""Builder class for mapping and creating action objects into
callable methods.
"""Builder class for mapping and creating action objects.
An action list is an array of single key/value dicts which takes
the form:
@ -56,8 +56,7 @@ class ActionBuilder(object):
}
def __init__(self, action_keywords):
"""Creates a new instance of the builder which supports the given
action keywords.
"""Create a new instance of the builder for the given action keywords.
:param action_keywords: A list of strings which are the keywords this
instance of the builder supports.
@ -65,13 +64,13 @@ class ActionBuilder(object):
self._bindings = {}
self.schema = dict(ActionBuilder.SCHEMA_TEMPLATE)
for kw in action_keywords:
self.schema['items']['properties'][kw] =\
ActionBuilder.ITEM_TEMPLATE
self.schema['items']['properties'][kw] = (
ActionBuilder.ITEM_TEMPLATE)
def bind_action(self, action_key, action, *args, **kwargs):
"""Binds an action and optionally static args/kwargs to an
action key.
"""Bind an action to an action key.
Static args/kwargs can be optionally binded.
:param action_key: The action keyword to bind the action to.
:param action: A method/function to call for the action.
:param args: (optional) Static positional args to prepend
@ -87,23 +86,24 @@ class ActionBuilder(object):
}
def validate(self, actions):
"""Validates the list of action objects against the schema
for this builder.
"""Validate the list of action objects against the builder schema.
:param actions: The list of action objects to validate.
"""
jsonschema.validate(actions, self.schema)
def _build(self, func, times, *args, **kwargs):
"""Builds the wrapper action call."""
"""Build the wrapper action call."""
def _f():
for i in range(times):
func(*args, **kwargs)
return _f
def build_actions(self, actions, *args, **kwargs):
"""Builds a list of callable actions based on the given
action object list and the actions bound to this builder.
"""Build a list of callable actions.
A list of callable actions based on the given action object list and
the actions bound to this builder.
:param actions: A list of action objects to build callable
action for.
@ -129,8 +129,10 @@ class ActionBuilder(object):
def atomic_action_timer(name):
"""Decorates methods of the Scenario class requiring a measure of execution
time. This provides duration in seconds of each atomic action.
"""Provide measure of execution time.
Decorates methods of the Scenario class.
This provides duration in seconds of each atomic action.
"""
def wrap(func):
@functools.wraps(func)
@ -156,7 +158,8 @@ class AtomicAction(utils.Timer):
"""
def __init__(self, scenario_instance, name):
"""Constructor
"""Create a new instance of the AtomicAction.
:param scenario_instance: instance of subclass of base scenario
:param name: name of the ActionBuilder
"""

View File

@ -24,6 +24,7 @@ class VMScenario(base.Scenario):
@scenario_utils.atomic_action_timer('vm.run_command')
def run_action(self, ssh, interpreter, script):
"""Run command inside an instance.
This is a separate function so that only script execution is timed
"""
return ssh.execute(interpreter, stdin=open(script, "rb"))
@ -34,7 +35,9 @@ class VMScenario(base.Scenario):
def run_command(self, server, username, network, port, ip_version,
interpreter, script):
"""Create SSH connection for server, wait for server to become
"""Run command via SSH on server.
Create SSH connection for server, wait for server to become
available (there is a delay between server being set to ACTIVE
and sshd being available). Then call __run_command to actually
execute the command.

View File

@ -72,7 +72,7 @@ def _id_from_name(resource_config, resources, typename):
raise exceptions.InvalidScenarioArgument(
"{typename} 'id', 'name', or 'regex' not found "
"in '{resource_config}' ".format(typename=typename.title(),
resource_config=resource_config))
resource_config=resource_config))
pattern = re.compile(patternstr)
matching = filter(lambda resource: re.search(pattern, resource.name),
@ -80,13 +80,14 @@ def _id_from_name(resource_config, resources, typename):
if not matching:
raise exceptions.InvalidScenarioArgument(
"{typename} with pattern '{pattern}' not found".format(
typename=typename.title(), pattern=pattern.pattern))
typename=typename.title(), pattern=pattern.pattern))
elif len(matching) > 1:
raise exceptions.InvalidScenarioArgument(
"{typename} with name '{pattern}' is ambiguous, "
"possible matches by id: {ids}".format(
typename=typename.title(), pattern=pattern.pattern,
ids=", ".join(map(operator.attrgetter("id"), matching))))
"{typename} with name '{pattern}' is ambiguous, possible matches "
"by id: {ids}".format(typename=typename.title(),
pattern=pattern.pattern,
ids=", ".join(map(operator.attrgetter("id"),
matching))))
return matching[0].id

View File

@ -20,6 +20,7 @@ import time
import traceback
from novaclient.v1_1 import servers
from rally import exceptions

View File

@ -146,9 +146,9 @@ def image_exists(param_name):
"""
def image_exists_validator(**kwargs):
clients = kwargs.get('clients')
image_id = types.ImageResourceType.transform(clients=clients,
resource_config=
kwargs.get(param_name))
image_id = types.ImageResourceType.transform(
clients=clients,
resource_config=kwargs.get(param_name))
try:
clients.glance().images.get(image=image_id)
return ValidationResult()
@ -166,9 +166,9 @@ def flavor_exists(param_name):
"""
def flavor_exists_validator(**kwargs):
clients = kwargs.get('clients')
flavor_id = types.FlavorResourceType.transform(clients=clients,
resource_config=
kwargs.get(param_name))
flavor_id = types.FlavorResourceType.transform(
clients=clients,
resource_config=kwargs.get(param_name))
try:
clients.nova().flavors.get(flavor=flavor_id)
return ValidationResult()
@ -190,18 +190,18 @@ def image_valid_on_flavor(flavor_name, image_name):
def image_valid_on_flavor_validator(**kwargs):
clients = kwargs.get('clients')
flavor_id = types.FlavorResourceType.transform(clients=clients,
resource_config=
kwargs.get(flavor_name))
flavor_id = types.FlavorResourceType.transform(
clients=clients,
resource_config=kwargs.get(flavor_name))
try:
flavor = clients.nova().flavors.get(flavor=flavor_id)
except nova_exc.NotFound:
message = _("Flavor with id '%s' not found") % flavor_id
return ValidationResult(False, message)
image_id = types.ImageResourceType.transform(clients=clients,
resource_config=
kwargs.get(image_name))
image_id = types.ImageResourceType.transform(
clients=clients,
resource_config=kwargs.get(image_name))
try:
image = clients.glance().images.get(image=image_id)
except glance_exc.HTTPNotFound:

View File

@ -148,6 +148,7 @@ class DeploymentCommands(object):
@envutils.with_default_deploy_id
def endpoint(self, deploy_id=None):
"""Print endpoint of the deployment.
:param deploy_id: a UUID of the deployment
"""
headers = ['auth_url', 'username', 'password', 'tenant_name',

View File

@ -16,14 +16,13 @@
""" Rally command: task """
from __future__ import print_function
import json
import os
import pprint
import webbrowser
import yaml
from oslo.config import cfg
import yaml
from rally.benchmark.processing import plot
from rally.benchmark.processing import utils

View File

@ -104,8 +104,10 @@ class UseCommands(object):
@cliutils.args('--uuid', type=str, dest='task_id', required=False,
help='UUID of the task')
def task(self, task_id):
"""Set the RALLY_TASK env var so the user does not need to specify a
task UUID in the command requiring this parameter.
"""Set the RALLY_TASK env var.
Is used to allow the user not to specify a task UUID in the command
requiring this parameter.
If the task uuid specified in parameter by the user does not exist,
a TaskNotFound will be raised by task_get().

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import decorator
import os
import decorator
from rally import exceptions
from rally import fileutils
from rally.openstack.common.gettextutils import _

View File

@ -96,9 +96,8 @@ class Connection(object):
return query
def _task_get(self, uuid, session=None):
task = self.model_query(models.Task, session=session).\
filter_by(uuid=uuid).\
first()
task = (self.model_query(models.Task, session=session).
filter_by(uuid=uuid).first())
if not task:
raise exceptions.TaskNotFound(uuid=uuid)
return task
@ -107,15 +106,14 @@ class Connection(object):
return self._task_get(uuid)
def task_get_detailed(self, uuid):
return self.model_query(models.Task).\
options(sa.orm.joinedload('results')).\
filter_by(uuid=uuid).\
first()
return (self.model_query(models.Task).
options(sa.orm.joinedload('results')).
filter_by(uuid=uuid).first())
def task_get_detailed_last(self):
return self.model_query(models.Task).\
options(sa.orm.joinedload('results')).\
order_by(models.Task.id.desc()).first()
return (self.model_query(models.Task).
options(sa.orm.joinedload('results')).
order_by(models.Task.id.desc()).first())
def task_create(self, values):
task = models.Task()
@ -140,14 +138,13 @@ class Connection(object):
def task_delete(self, uuid, status=None):
session = get_session()
with session.begin():
query = base_query = self.model_query(models.Task).\
filter_by(uuid=uuid)
query = base_query = (self.model_query(models.Task).
filter_by(uuid=uuid))
if status is not None:
query = base_query.filter_by(status=status)
self.model_query(models.TaskResult).\
filter_by(task_uuid=uuid).\
delete(synchronize_session=False)
(self.model_query(models.TaskResult).filter_by(task_uuid=uuid).
delete(synchronize_session=False))
count = query.delete(synchronize_session=False)
if not count:
@ -166,14 +163,12 @@ class Connection(object):
return result
def task_result_get_all_by_uuid(self, uuid):
return self.model_query(models.TaskResult).\
filter_by(task_uuid=uuid).\
all()
return (self.model_query(models.TaskResult).
filter_by(task_uuid=uuid).all())
def _deployment_get(self, uuid, session=None):
deploy = self.model_query(models.Deployment, session=session).\
filter_by(uuid=uuid).\
first()
deploy = (self.model_query(models.Deployment, session=session).
filter_by(uuid=uuid).first())
if not deploy:
raise exceptions.DeploymentNotFound(uuid=uuid)
return deploy
@ -187,15 +182,13 @@ class Connection(object):
def deployment_delete(self, uuid):
session = get_session()
with session.begin():
count = self.model_query(models.Resource, session=session).\
filter_by(deployment_uuid=uuid).\
count()
count = (self.model_query(models.Resource, session=session).
filter_by(deployment_uuid=uuid).count())
if count:
raise exceptions.DeploymentIsBusy(uuid=uuid)
count = self.model_query(models.Deployment, session=session).\
filter_by(uuid=uuid).\
delete(synchronize_session=False)
count = (self.model_query(models.Deployment, session=session).
filter_by(uuid=uuid).delete(synchronize_session=False))
if not count:
raise exceptions.DeploymentNotFound(uuid=uuid)
@ -211,8 +204,8 @@ class Connection(object):
return deploy
def deployment_list(self, status=None, parent_uuid=None, name=None):
query = self.model_query(models.Deployment).\
filter_by(parent_uuid=parent_uuid)
query = (self.model_query(models.Deployment).
filter_by(parent_uuid=parent_uuid))
if name:
query = query.filter_by(name=name)
@ -227,8 +220,8 @@ class Connection(object):
return resource
def resource_get_all(self, deployment_uuid, provider_name=None, type=None):
query = self.model_query(models.Resource).\
filter_by(deployment_uuid=deployment_uuid)
query = (self.model_query(models.Resource).
filter_by(deployment_uuid=deployment_uuid))
if provider_name is not None:
query = query.filter_by(provider_name=provider_name)
if type is not None:
@ -236,9 +229,8 @@ class Connection(object):
return query.all()
def resource_delete(self, id):
count = self.model_query(models.Resource).\
filter_by(id=id).\
delete(synchronize_session=False)
count = (self.model_query(models.Resource).
filter_by(id=id).delete(synchronize_session=False))
if not count:
raise exceptions.ResourceNotFound(id=id)
@ -249,8 +241,8 @@ class Connection(object):
return verification
def verification_get(self, verification_uuid, session=None):
verification = self.model_query(models.Verification, session=session).\
filter_by(uuid=verification_uuid).first()
verification = (self.model_query(models.Verification, session=session).
filter_by(uuid=verification_uuid).first())
if not verification:
raise exceptions.NotFoundException(
"Can't find any verification with following UUID '%s'." %
@ -272,9 +264,9 @@ class Connection(object):
return query.all()
def verification_delete(self, verification_uuid):
count = self.model_query(models.Verification).\
filter_by(id=verification_uuid).\
delete(synchronize_session=False)
count = (self.model_query(models.Verification).
filter_by(id=verification_uuid).
delete(synchronize_session=False))
if not count:
raise exceptions.NotFoundException(
"Can't find any verification with following UUID '%s'." %
@ -288,8 +280,8 @@ class Connection(object):
return result
def verification_result_get(self, verification_uuid):
result = self.model_query(models.VerificationResult).\
filter_by(verification_uuid=verification_uuid).first()
result = (self.model_query(models.VerificationResult).
filter_by(verification_uuid=verification_uuid).first())
if not result:
raise exceptions.NotFoundException(
"No results for following UUID '%s'." % verification_uuid)

View File

@ -15,10 +15,12 @@
"""
SQLAlchemy models for rally data.
"""
import uuid
import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import types
import uuid
from rally import consts
from rally.db.sqlalchemy import types as sa_types
@ -65,7 +67,7 @@ class Deployment(BASE, RallyBase):
completed_at = sa.Column(sa.DateTime)
# XXX(akscram): Do we need to explicitly store a name of the
# deployment engine?
#engine_name = sa.Column(sa.String(36))
# engine_name = sa.Column(sa.String(36))
config = sa.Column(
sa_types.MutableJSONEncodedDict,

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import netaddr
import os
import netaddr
from rally.deploy import engine
from rally.deploy.serverprovider import provider
from rally.deploy.serverprovider.providers import lxc

View File

@ -15,9 +15,10 @@
import json
import re
import requests
import time
import requests
from rally.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@ -148,6 +148,7 @@ class ProviderFactory(object):
@abc.abstractmethod
def create_servers(self, image_uuid=None, type_id=None, amount=1):
"""Create VMs with chosen image.
:param image_uuid: Indetificator of image
:param type_id: Vm type identificator
:param amount: amount of required VMs

View File

@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import netaddr
import os
import re
import StringIO
import time
import netaddr
from rally.deploy.serverprovider import provider
from rally import exceptions
from rally.openstack.common.gettextutils import _

View File

@ -13,11 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import novaclient.exceptions
import os
import time
import urllib2
import novaclient.exceptions
from rally.benchmark import utils as benchmark_utils
from rally.deploy.serverprovider import provider
from rally import exceptions

View File

@ -13,17 +13,19 @@
# License for the specific language governing permissions and limitations
# under the License.
import netaddr
import os
import subprocess
import time
import uuid
import netaddr
from rally.deploy.serverprovider import provider
class VirshProvider(provider.ProviderFactory):
'''Creates VMs from prebuilt templates.
"""Create VMs from prebuilt templates.
config example:
"vm_provider": {
"type": "VirshProvider",
@ -32,7 +34,7 @@ class VirshProvider(provider.ProviderFactory):
"template_user": "ubuntu", # vm user to launch devstack
"template_password": "password" # vm password to launch devstack
},
'''
"""
CONFIG_SCHEMA = {
'type': 'object',
@ -59,6 +61,7 @@ class VirshProvider(provider.ProviderFactory):
def create_servers(self, image_uuid=None, type_id=None, amount=1):
"""Create VMs with chosen image.
:param image_uuid: Indetificator of image
:param amount: amount of required VMs
Returns list of VMs uuids.
@ -66,7 +69,7 @@ class VirshProvider(provider.ProviderFactory):
return [self.create_vm(str(uuid.uuid4())) for i in range(amount)]
def create_vm(self, vm_name):
'''Clones prebuilt VM template and starts it.'''
"""Clone prebuilt VM template and start it."""
virt_url = self._get_virt_connection_url(self.config['connection'])
cmd = 'virt-clone --connect=%(url)s -o %(t)s -n %(n)s --auto-clone' % {
@ -87,13 +90,13 @@ class VirshProvider(provider.ProviderFactory):
)
def destroy_servers(self):
'''Destroy already created vms.'''
"""Destroy already created vms."""
for resource in self.resources.get_all():
self.destroy_vm(resource['info']['name'])
self.resources.delete(resource)
def destroy_vm(self, vm_name):
'''Destroy single vm and delete all allocated resources.'''
"""Destroy single vm and delete all allocated resources."""
print('Destroy VM %s' % vm_name)
vconnection = self._get_virt_connection_url(self.config['connection'])
@ -107,7 +110,7 @@ class VirshProvider(provider.ProviderFactory):
@staticmethod
def _get_virt_connection_url(connection):
'''Formats QEMU connection string from SSH url.'''
"""Format QEMU connection string from SSH url."""
return 'qemu+ssh://%s/system' % connection
def _determine_vm_ip(self, vm_name):

View File

@ -14,9 +14,10 @@
# under the License.
from oslo.config import cfg
import sys
from oslo.config import cfg
from rally.openstack.common.gettextutils import _
from rally.openstack.common import log as logging
@ -144,6 +145,10 @@ class NoSuchConfigField(NotFoundException):
msg_fmt = _("There is no field in the task config with name `%(name)s`.")
class NoSuchRole(NotFoundException):
msg_fmt = _("There is no role with name `%(role)s`.")
class TaskNotFound(NotFoundException):
msg_fmt = _("Task with uuid=%(uuid)s not found.")

View File

@ -30,8 +30,8 @@ def _read_env_file(path, except_env=None):
with open(path, 'r') as env_file:
content = env_file.readlines()
for line in content:
if except_env is None or \
not line.startswith("%s=" % except_env):
if except_env is None or not line.startswith("%s=" %
except_env):
output.append(line)
return output

View File

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import urlparse
from ceilometerclient import client as ceilometer
from cinderclient import client as cinder
import glanceclient as glance
@ -23,7 +25,6 @@ from keystoneclient.v2_0 import client as keystone
from neutronclient.neutron import client as neutron
from novaclient import client as nova
from oslo.config import cfg
import urlparse
from rally import exceptions

View File

@ -57,12 +57,13 @@ Eventlet:
"""
import paramiko
import select
import socket
import StringIO
import time
import paramiko
from rally.openstack.common.gettextutils import _
from rally.openstack.common import log as logging

View File

@ -15,13 +15,14 @@
import datetime
import os
from oslo.config import cfg
from six.moves import configparser
from six.moves import http_client as httplib
import time
import urllib2
import urlparse
from oslo.config import cfg
from six.moves import configparser
from six.moves import http_client as httplib
from rally import db
from rally import exceptions
from rally.objects import endpoint
@ -184,8 +185,8 @@ class TempestConf(object):
if public_net:
net_id = public_net[0]['id']
self.conf.set('network', 'public_network_id', net_id)
public_router = neutron.list_routers(network_id=
net_id)['routers'][0]
public_router = neutron.list_routers(
network_id=net_id)['routers'][0]
self.conf.set('network', 'public_router_id',
public_router['id'])
subnet = neutron.list_subnets(network_id=net_id)['subnets'][0]

View File

@ -16,7 +16,6 @@
import mock
from rally.benchmark.context.cleanup import cleanup as cleanup_ctx
from tests import fakes
from tests import test

View File

@ -14,9 +14,10 @@
# under the License.
import copy
import random
import jsonschema
import mock
import random
from rally.benchmark.context import quotas
from tests import test
@ -74,10 +75,10 @@ class CinderQuotasTestCase(test.TestCase):
pass
# Currently, no method to delete quotas available in cinder client:
# Will be added with https://review.openstack.org/#/c/74841/
#cinder_quotas = quotas.CinderQuotas(client_mock)
#tenant_id = mock.MagicMock()
#cinder_quotas.delete(tenant_id)
#client_mock.quotas.delete.assert_called_once_with(tenant_id)
# cinder_quotas = quotas.CinderQuotas(client_mock)
# tenant_id = mock.MagicMock()
# cinder_quotas.delete(tenant_id)
# client_mock.quotas.delete.assert_called_once_with(tenant_id)
class NeutronQuotasTestCase(test.TestCase):
@ -187,8 +188,8 @@ class QuotasTestCase(test.TestCase):
% ctx["config"]["quotas"][service][key])
# Test valid values
ctx["config"]["quotas"][service][key] = \
random.randint(0, 1000000)
ctx["config"]["quotas"][service][key] = random.randint(0,
1000000)
try:
quotas.Quotas.validate(ctx["config"]["quotas"])
except jsonschema.ValidationError:

View File

@ -16,6 +16,7 @@
import mock
from rally.benchmark.context import roles
from rally import exceptions
from tests import fakes
from tests import test
@ -71,10 +72,10 @@ class RoleGeneratorTestCase(test.TestCase):
ctx = roles.RoleGenerator(self.context)
ctx.context["users"] = [{"id": "u1", "tenant_id": "t1"},
{"id": "u2", "tenant_id": "t2"}]
ex = self.assertRaises(Exception, ctx._add_role,
ex = self.assertRaises(exceptions.NoSuchRole, ctx._add_role,
mock.MagicMock(), "unknown_role")
expected = "Role 'unknown_role' does not exist in the list of roles"
expected = "There is no role with name `unknown_role`."
self.assertEqual(expected, str(ex))
@mock.patch("rally.benchmark.context.roles.osclients")
@ -88,8 +89,8 @@ class RoleGeneratorTestCase(test.TestCase):
mock.call("u1", role["id"], tenant="t1"),
mock.call("u2", role["id"], tenant="t2"),
]
mock_osclients.Clients().keystone()\
.roles.remove_user_role.assert_has_calls(calls)
mock_keystone = mock_osclients.Clients().keystone()
mock_keystone.roles.remove_user_role.assert_has_calls(calls)
@mock.patch("rally.benchmark.context.roles.osclients")
def test_setup_and_cleanup(self, mock_osclients):
@ -101,7 +102,6 @@ class RoleGeneratorTestCase(test.TestCase):
ctx.context["users"] = [{"id": "u1", "tenant_id": "t1"},
{"id": "u2", "tenant_id": "t2"}]
#self, user_id, role_id, tenant):
ctx.setup()
calls = [
mock.call("u1", "r1", tenant="t1"),

View File

@ -34,9 +34,9 @@ class SecGroupContextTestCase(test.TestCase):
self.assertEqual(len(fake_nova.security_groups.list()), 2)
self.assertTrue(
secgroup.SSH_GROUP_NAME in
[sg.name for sg in fake_nova.security_groups.list()]
)
secgroup.SSH_GROUP_NAME in [
sg.name for sg in fake_nova.security_groups.list()
])
# run prep again, check that another security group is not created
secgroup._prepare_open_secgroup('endpoint')
@ -46,7 +46,7 @@ class SecGroupContextTestCase(test.TestCase):
def test_prep_ssh_sec_group_rules(self, mock_osclients):
fake_nova = fakes.FakeNovaClient()
#NOTE(hughsaunders) Default security group is precreated
# NOTE(hughsaunders) Default security group is precreated
self.assertEqual(len(fake_nova.security_groups.list()), 1)
mock_cl = mock.MagicMock()
mock_cl.nova.return_value = fake_nova

View File

@ -14,17 +14,18 @@
# under the License.
import itertools
import mock
import uuid
import mock
from rally.benchmark.context import users
from rally.benchmark import utils
from tests import fakes
from tests import test
run_concurrent = lambda dummy, cls, f, args: \
list(itertools.imap(getattr(cls, f), args))
run_concurrent = (lambda dummy, cls, f, args: list(
itertools.imap(getattr(cls, f), args)))
@mock.patch.object(utils, "run_concurrent", run_concurrent)
@ -71,9 +72,9 @@ class UserGeneratorTestCase(test.TestCase):
tenant2 = mock.MagicMock()
args = (mock.MagicMock(), [tenant1, tenant2])
users.UserGenerator._delete_tenants(args)
mock_osclients.Clients().keystone()\
.tenants.delete.assert_has_calls([mock.call(tenant1["id"]),
mock.call(tenant2["id"])])
mock_osclients.Clients().keystone().tenants.delete.assert_has_calls([
mock.call(tenant1["id"]),
mock.call(tenant2["id"])])
@mock.patch("rally.benchmark.context.users.osclients")
def test_delete_users(self, mock_osclients):
@ -81,9 +82,9 @@ class UserGeneratorTestCase(test.TestCase):
user2 = mock.MagicMock()
args = (mock.MagicMock(), [user1, user2])
users.UserGenerator._delete_users(args)
mock_osclients.Clients().keystone()\
.users.delete.assert_has_calls([mock.call(user1["id"]),
mock.call(user2["id"])])
mock_osclients.Clients().keystone().users.delete.assert_has_calls([
mock.call(user1["id"]),
mock.call(user2["id"])])
@mock.patch("rally.benchmark.context.users.osclients")
def test_setup_and_cleanup(self, mock_osclients):

View File

@ -14,6 +14,7 @@
# under the License.
import json
import mock
from rally.benchmark.processing import plot

View File

@ -16,7 +16,6 @@
import mock
from rally.benchmark.runners import serial
from rally import consts
from tests import fakes
from tests import test

View File

@ -13,6 +13,7 @@
# under the License.
import json
import mock
from rally.benchmark.scenarios.ceilometer import queries

View File

@ -82,9 +82,9 @@ class GlanceImagesTestCase(test.TestCase):
mock_random_name.return_value = "random_name"
kwargs = {'fakearg': 'f'}
with mock.patch("rally.benchmark.scenarios.glance.utils.time.sleep"):
glance_scenario.\
create_image_and_boot_instances("cf", "url", "df",
"fid", 5, **kwargs)
glance_scenario.create_image_and_boot_instances("cf", "url",
"df", "fid",
5, **kwargs)
mock_create_image.assert_called_once_with("random_name", "cf",
"url", "df", **kwargs)
mock_boot_servers.assert_called_once_with("random_name",

View File

@ -90,10 +90,10 @@ class GlanceScenarioTestCase(test.TestCase):
scenario = utils.GlanceScenario()
scenario._delete_image(self.image)
self.image.delete.assert_called_once_with()
self.wait_for_delete.\
mock.assert_called_once_with(self.image,
update_resource=self.gfm(),
check_interval=1,
timeout=120)
self.wait_for_delete.mock.assert_called_once_with(
self.image,
update_resource=self.gfm(),
check_interval=1,
timeout=120)
self._test_atomic_action_timer(scenario.atomic_actions(),
'glance.delete_image')

View File

@ -60,8 +60,9 @@ class HeatScenarioTestCase(test.TestCase):
@mock.patch(HEAT_UTILS + '.HeatScenario.clients')
def test_create_stack(self, mock_clients):
mock_clients("heat").stacks.create.return_value = \
{'stack': {'id': 'test_id'}}
mock_clients("heat").stacks.create.return_value = {
'stack': {'id': 'test_id'}
}
mock_clients("heat").stacks.get.return_value = self.stack
scenario = utils.HeatScenario()
return_stack = scenario._create_stack('stack_name')
@ -79,10 +80,10 @@ class HeatScenarioTestCase(test.TestCase):
scenario = utils.HeatScenario()
scenario._delete_stack(self.stack)
self.stack.delete.assert_called_once_with()
self.wait_for_delete.\
mock.assert_called_once_with(self.stack,
update_resource=self.gfm(),
check_interval=1,
timeout=3600)
self.wait_for_delete.mock.assert_called_once_with(
self.stack,
update_resource=self.gfm(),
check_interval=1,
timeout=3600)
self._test_atomic_action_timer(scenario.atomic_actions(),
'heat.delete_stack')

View File

@ -17,10 +17,8 @@ import mock
from rally.benchmark.scenarios.keystone import utils
from tests.benchmark.scenarios import test_utils
from tests import test
from tests import fakes
from tests import test
UTILS = "rally.benchmark.scenarios.keystone.utils."

View File

@ -16,7 +16,6 @@
import mock
from rally.benchmark.scenarios.neutron import network
from tests import test
NEUTRON_NETWORKS = "rally.benchmark.scenarios.neutron.network.NeutronNetworks"

View File

@ -18,7 +18,6 @@ import netaddr
from rally.benchmark.scenarios.neutron import utils
from tests.benchmark.scenarios import test_utils
from tests import test
@ -99,8 +98,8 @@ class NeutronScenarioTestCase(test.TestCase):
# Default options
subnet_data = {"network_id": network_id}
scenario._create_subnet(network, subnet_data)
mock_clients("neutron")\
.create_subnet.assert_called_once_with(expected_subnet_data)
mock_clients("neutron").create_subnet.assert_called_once_with(
expected_subnet_data)
self._test_atomic_action_timer(scenario.atomic_actions(),
"neutron.create_subnet")
@ -111,14 +110,15 @@ class NeutronScenarioTestCase(test.TestCase):
subnet_data.update(extras)
expected_subnet_data["subnet"].update(extras)
scenario._create_subnet(network, subnet_data)
mock_clients("neutron")\
.create_subnet.assert_called_once_with(expected_subnet_data)
mock_clients("neutron").create_subnet.assert_called_once_with(
expected_subnet_data)
@mock.patch(NEUTRON_UTILS + "NeutronScenario.clients")
def test_list_subnets(self, mock_clients):
subnets = [{"name": "fake1"}, {"name": "fake2"}]
mock_clients("neutron")\
.list_subnets.return_value = {"subnets": subnets}
mock_clients("neutron").list_subnets.return_value = {
"subnets": subnets
}
scenario = utils.NeutronScenario()
result = scenario._list_subnets()
self.assertEqual(subnets, result)

View File

@ -244,10 +244,10 @@ class NovaServersTestCase(test.TestCase):
@mock.patch("rally.benchmark.scenarios.nova.servers.random.choice")
def _verify_boot_server(self, mock_choice, mock_osclients, nic=None,
assert_nic=False):
scenario, kwargs, expected_kwargs = \
self._prepare_boot(mock_osclients=mock_osclients,
mock_choice=mock_choice,
nic=nic, assert_nic=assert_nic)
scenario, kwargs, expected_kwargs = self._prepare_boot(
mock_osclients=mock_osclients,
mock_choice=mock_choice,
nic=nic, assert_nic=assert_nic)
scenario.boot_server("img", 0, **kwargs)
scenario._boot_server.assert_called_once_with("name", "img", 0,
@ -277,10 +277,10 @@ class NovaServersTestCase(test.TestCase):
def test_boot_server_from_volume_random_nic(self, mock_choice,
mock_osclients,
mock_nova_clients):
scenario, kwargs, expected_kwargs = \
self._prepare_boot(mock_osclients=mock_osclients,
mock_choice=mock_choice,
nic=None, assert_nic=True)
scenario, kwargs, expected_kwargs = self._prepare_boot(
mock_osclients=mock_osclients,
mock_choice=mock_choice,
nic=None, assert_nic=True)
fake_volume = fakes.FakeVolumeManager().create()
fake_volume.id = "volume_id"

View File

@ -109,12 +109,12 @@ class NovaScenarioTestCase(test.TestCase):
mock_clients("nova").images.get.return_value = self.image
nova_scenario = utils.NovaScenario()
return_image = nova_scenario._create_image(self.server)
check_interval = CONF.benchmark.nova_server_image_create_poll_interval
self.wait_for.mock.assert_called_once_with(
self.image,
update_resource=self.gfm(),
is_ready=self.res_is.mock(),
check_interval=
CONF.benchmark.nova_server_image_create_poll_interval,
check_interval=check_interval,
timeout=CONF.benchmark.nova_server_image_create_timeout
)
self.res_is.mock.assert_has_calls(mock.call('ACTIVE'))
@ -216,17 +216,16 @@ class NovaScenarioTestCase(test.TestCase):
self.server1]
nova_scenario = utils.NovaScenario()
nova_scenario._delete_all_servers()
check_interval = CONF.benchmark.nova_server_delete_poll_interval
expected = [
mock.call(
self.server, update_resource=self.gfm(),
check_interval=
CONF.benchmark.nova_server_delete_poll_interval,
check_interval=check_interval,
timeout=CONF.benchmark.nova_server_delete_timeout
),
mock.call(
self.server1, update_resource=self.gfm(),
check_interval=
CONF.benchmark.nova_server_delete_poll_interval,
check_interval=check_interval,
timeout=CONF.benchmark.nova_server_delete_timeout
)
]
@ -238,10 +237,10 @@ class NovaScenarioTestCase(test.TestCase):
nova_scenario = utils.NovaScenario()
nova_scenario._delete_image(self.image)
self.image.delete.assert_called_once_with()
check_interval = CONF.benchmark.nova_server_image_delete_poll_interval
self.wait_for_delete.mock.assert_called_once_with(
self.image, update_resource=self.gfm(),
check_interval=
CONF.benchmark.nova_server_image_delete_poll_interval,
check_interval=check_interval,
timeout=CONF.benchmark.nova_server_image_delete_timeout
)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import traceback
import mock
from rally.benchmark.context import base as base_ctx
from rally.benchmark.scenarios import base
from rally.benchmark import validation
@ -255,8 +256,9 @@ class ScenarioTestCase(test.TestCase):
"prefix_")
def test_generate_random_name(self):
set_by_length = lambda lst: set(map(len, lst))
len_by_prefix = lambda lst, prefix:\
len(filter(bool, map(lambda i: i.startswith(prefix), lst)))
len_by_prefix = (lambda lst, prefix:
len(filter(bool, map(lambda i: i.startswith(prefix),
lst))))
range_num = 50
# Defaults

View File

@ -14,9 +14,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from jsonschema import exceptions as schema_exceptions
import mock
from jsonschema import exceptions as schema_exceptions
from rally.benchmark.scenarios import utils
from tests import test

View File

@ -67,8 +67,8 @@ class BenchmarkEngineTestCase(test.TestCase):
def test_validate__wrong_scenarios_name(self, mova_validate):
task = mock.MagicMock()
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
eng._validate_config_scenarios_name = \
mock.MagicMock(side_effect=exceptions.NotFoundScenarios)
eng._validate_config_scenarios_name = mock.MagicMock(
side_effect=exceptions.NotFoundScenarios)
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
self.assertTrue(task.set_failed.called)
@ -78,8 +78,8 @@ class BenchmarkEngineTestCase(test.TestCase):
task = mock.MagicMock()
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
eng._validate_config_scenarios_name = mock.MagicMock()
eng._validate_config_syntax = \
mock.MagicMock(side_effect=exceptions.InvalidBenchmarkConfig)
eng._validate_config_syntax = mock.MagicMock(
side_effect=exceptions.InvalidBenchmarkConfig)
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
self.assertTrue(task.set_failed.called)
@ -90,8 +90,8 @@ class BenchmarkEngineTestCase(test.TestCase):
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
eng._validate_config_scenarios_name = mock.MagicMock()
eng._validate_config_syntax = mock.MagicMock()
eng._validate_config_semantic = \
mock.MagicMock(side_effect=exceptions.InvalidBenchmarkConfig)
eng._validate_config_semantic = mock.MagicMock(
side_effect=exceptions.InvalidBenchmarkConfig)
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
self.assertTrue(task.set_failed.called)

View File

@ -15,7 +15,6 @@
from rally.benchmark import types
from rally import exceptions
from tests import fakes
from tests import test
@ -32,23 +31,23 @@ class FlavorResourceTypeTestCase(test.TestCase):
def test_transform_by_id(self):
resource_config = {"id": 42}
flavor_id = types.FlavorResourceType.transform(clients=self.clients,
resource_config=
resource_config)
flavor_id = types.FlavorResourceType.transform(
clients=self.clients,
resource_config=resource_config)
self.assertEqual(flavor_id, 42)
def test_transform_by_name(self):
resource_config = {"name": "m1.nano"}
flavor_id = types.FlavorResourceType.transform(clients=self.clients,
resource_config=
resource_config)
flavor_id = types.FlavorResourceType.transform(
clients=self.clients,
resource_config=resource_config)
self.assertEqual(flavor_id, 42)
def test_transform_by_name_to_dest(self):
resource_config = {"name": "m1.nano"}
flavor_id = types.FlavorResourceType.transform(clients=self.clients,
resource_config=
resource_config)
flavor_id = types.FlavorResourceType.transform(
clients=self.clients,
resource_config=resource_config)
self.assertEqual(flavor_id, 42)
def test_transform_by_name_no_match(self):
@ -59,9 +58,9 @@ class FlavorResourceTypeTestCase(test.TestCase):
def test_transform_by_regex(self):
resource_config = {"regex": "m(1|2)\.nano"}
flavor_id = types.FlavorResourceType.transform(clients=self.clients,
resource_config=
resource_config)
flavor_id = types.FlavorResourceType.transform(
clients=self.clients,
resource_config=resource_config)
self.assertEqual(flavor_id, 42)
def test_transform_by_regex_no_match(self):
@ -83,23 +82,23 @@ class ImageResourceTypeTestCase(test.TestCase):
def test_transform_by_id(self):
resource_config = {"id": 100}
image_id = types.ImageResourceType.transform(clients=self.clients,
resource_config=
resource_config)
image_id = types.ImageResourceType.transform(
clients=self.clients,
resource_config=resource_config)
self.assertEqual(image_id, 100)
def test_transform_by_name(self):
resource_config = {"name": "cirros-0.3.1-uec"}
image_id = types.ImageResourceType.transform(clients=self.clients,
resource_config=
resource_config)
image_id = types.ImageResourceType.transform(
clients=self.clients,
resource_config=resource_config)
self.assertEqual(image_id, 100)
def test_transform_by_name_to_dest(self):
resource_config = {"name": "cirros-0.3.1-uec"}
image_id = types.ImageResourceType.transform(clients=self.clients,
resource_config=
resource_config)
image_id = types.ImageResourceType.transform(
clients=self.clients,
resource_config=resource_config)
self.assertEqual(image_id, 100)
def test_transform_by_name_no_match(self):
@ -110,9 +109,9 @@ class ImageResourceTypeTestCase(test.TestCase):
def test_transform_by_regex(self):
resource_config = {"regex": "-uec$"}
image_id = types.ImageResourceType.transform(clients=self.clients,
resource_config=
resource_config)
image_id = types.ImageResourceType.transform(
clients=self.clients,
resource_config=resource_config)
self.assertEqual(image_id, 100)
def test_transform_by_regex_no_match(self):

View File

@ -13,14 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import datetime
from tests import fakes
from tests import test
import mock
from rally.benchmark import utils
from rally import exceptions
from tests import fakes
from tests import test
class BenchmarkUtilsTestCase(test.TestCase):

View File

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
from glanceclient import exc as glance_exc
import mock
from novaclient import exceptions as nova_exc
from rally.benchmark import validation

View File

@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import uuid
import mock
from rally.cmd.commands import deployment
from rally import exceptions
from tests import test

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import uuid
import mock
from rally.cmd.commands import show
from tests import fakes
from tests import test

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import uuid
import mock
from rally.cmd.commands import task
from rally import exceptions
from tests import test

View File

@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import uuid
import mock
from rally.cmd.commands import use
from rally.cmd import envutils
from rally import exceptions

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import uuid
import mock
from rally.cmd.commands import verify
from rally import consts
from tests import test

View File

@ -14,7 +14,6 @@
# under the License.
from rally.cmd import cliutils
from tests import test

View File

@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import StringIO
import mock
from rally.cmd import envutils
from rally import exceptions
from tests import test
@ -94,7 +95,7 @@ class EnvUtilsTestCase(test.TestCase):
@mock.patch.dict(os.environ,
values={envutils.ENV_DEPLOYMENT: 'test_deployment_id',
envutils.ENV_TASK: 'test_task_id'},
envutils.ENV_TASK: 'test_task_id'},
clear=True)
@mock.patch('os.path.exists')
@mock.patch('rally.cmd.envutils.fileutils.update_env_file')

View File

@ -13,10 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import sys
import uuid
import mock
from rally.cmd import manage
from tests import test

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
import jsonschema
import mock
import uuid
from rally.deploy.engines import devstack
from tests import test

View File

@ -163,13 +163,13 @@ class LxcHostTestCase(test.TestCase):
self.assertEqual(['name'], self.host.containers)
self.host.configure_container.assert_called_once_with('name')
#check with no btrfs
# check with no btrfs
self.host._backingstore = ''
self.host.create_container('name', 'dist')
self.assertEqual(mock.call('lxc-create -n name -t dist'),
self.server.ssh.run.mock_calls[1])
#check release
# check release
self.host.create_container('name', 'ubuntu', 'raring')
self.host.create_container('name', 'debian', 'woody')
expected = [mock.call('lxc-create -n name -t ubuntu -- -r raring'),
@ -184,7 +184,7 @@ class LxcHostTestCase(test.TestCase):
' -o src -n name')
self.assertEqual(['name'], self.host.containers)
#check with no btrfs
# check with no btrfs
self.host._backingstore = ''
self.host.create_clone('name', 'src')
self.assertEqual(mock.call('lxc-clone -o src -n name'),

View File

@ -16,7 +16,6 @@
"""Tests for OpenStack VM provider."""
import jsonschema
import mock
from oslotest import mockpatch

View File

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import jsonschema
import netaddr
import os
import jsonschema
import mock
import netaddr
from oslotest import mockpatch
from rally.deploy.serverprovider.providers import virsh

View File

@ -15,9 +15,10 @@
"""Test for deploy engines."""
import mock
import uuid
import mock
from rally import consts
from rally import deploy
from rally import exceptions

View File

@ -14,9 +14,10 @@
# under the License.
import mock
import uuid
import mock
from rally import consts
from rally import deploy
from tests import fakes

View File

@ -19,12 +19,12 @@ import re
import string
import uuid
import mock
from ceilometerclient import exc as ceilometer_exc
from glanceclient import exc
import mock
from neutronclient.common import exceptions as neutron_exceptions
from novaclient import exceptions as nova_exceptions
from rally.benchmark.context import base as base_ctx
from rally.benchmark.scenarios import base
from rally.objects import endpoint
@ -57,6 +57,7 @@ def generate_mac():
def setup_dict(data, required=None, defaults=None):
"""Setup and validate dict based on mandatory keys and default data.
This function reduces code that constructs dict objects
with specific schema (e.g. for API data).
@ -620,8 +621,8 @@ class FakeNeutronClient(object):
def add_interface_router(self, router_id, data):
subnet_id = data["subnet_id"]
if router_id not in self.__routers\
or subnet_id not in self.__subnets:
if (router_id not in self.__routers or
subnet_id not in self.__subnets):
raise neutron_exceptions.NeutronClientException
subnet = self.__subnets[subnet_id]
@ -769,8 +770,8 @@ class FakeNeutronClient(object):
def remove_interface_router(self, router_id, data):
subnet_id = data["subnet_id"]
if router_id not in self.__routers\
or subnet_id not in self.__subnets:
if (router_id not in self.__routers
or subnet_id not in self.__subnets):
raise neutron_exceptions.NeutronClientException
subnet = self.__subnets[subnet_id]

View File

@ -15,9 +15,10 @@
"""Tests for db.deploy layer."""
import mock
import uuid
import mock
from rally import consts
from rally import objects
from tests import test

View File

@ -16,9 +16,10 @@
"""Tests for db.task layer."""
import json
import mock
import uuid
import mock
from rally import consts
from rally import objects
from tests import test

View File

@ -15,9 +15,10 @@
""" Test for orchestrator. """
import mock
import uuid
import mock
from rally.benchmark.scenarios import base
from rally import consts
from rally.orchestrator import api

View File

@ -14,7 +14,6 @@
# under the License.
import mock
from oslotest import base
from rally import db

View File

@ -12,9 +12,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import mock
from rally import fileutils
from tests import test

View File

@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import mock
from rally.deploy.fuel import fuelclient
from tests import test
import copy
import mock
class FuelNodeTestCase(test.TestCase):

View File

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from keystoneclient import exceptions as keystone_exceptions
import mock
from oslo.config import cfg
from rally import exceptions
@ -49,8 +48,8 @@ class OSClientsTestCase(test.TestCase):
@mock.patch("rally.osclients.Clients.keystone")
def test_verified_keystone_user_not_admin(self, mock_keystone):
mock_keystone.return_value = fakes.FakeKeystoneClient()
mock_keystone.return_value.auth_ref["user"]["roles"] = \
[{"name": "notadmin"}]
mock_keystone.return_value.auth_ref["user"]["roles"] = [{"name":
"notadmin"}]
self.assertRaises(exceptions.InvalidAdminException,
self.clients.verified_keystone)

View File

@ -16,11 +16,11 @@
"""Test for Rally utils."""
from __future__ import print_function
import mock
import sys
import time
import mock
from rally import exceptions
from rally.openstack.common.gettextutils import _
from rally import utils

View File

@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import mock
from oslo.config import cfg
from six.moves import http_client as httplib
@ -78,10 +79,11 @@ class ConfigTestCase(test.TestCase):
service = "test_service"
url = "test_url"
# mocked at setUp
self.conf_generator.keystoneclient.auth_ref = {"serviceCatalog":
[{"name": service,
"endpoints":
[{"publicURL": url}]}]}
self.conf_generator.keystoneclient.auth_ref = {
"serviceCatalog": [{
"name": service,
"endpoints": [{"publicURL": url}]
}]}
self.assertEqual(self.conf_generator._get_url(service), url)
@mock.patch("rally.verification.verifiers.tempest.config.TempestConf"

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import mock
from rally.verification.verifiers.tempest import tempest
from tests import test

View File

@ -14,13 +14,14 @@
# under the License.
import ConfigParser
import mock
import os
import shutil
import subprocess
import tempfile
import unittest
import mock
"""Test rally command line interface.