Merge "Fix hacking 0.9.x issues"
This commit is contained in:
commit
6afc443af2
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.benchmark.context import base
|
from rally.benchmark.context import base
|
||||||
|
from rally import exceptions
|
||||||
from rally.openstack.common.gettextutils import _
|
from rally.openstack.common.gettextutils import _
|
||||||
from rally.openstack.common import log as logging
|
from rally.openstack.common import log as logging
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
@ -57,9 +58,7 @@ class RoleGenerator(base.Context):
|
|||||||
role = def_role
|
role = def_role
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
msg = (_("Role '%(role)s' does not exist in the list of roles") %
|
raise exceptions.NoSuchRole(role=context_role)
|
||||||
{"role": context_role})
|
|
||||||
raise Exception(msg)
|
|
||||||
|
|
||||||
LOG.debug("Adding role %s to all users" % (role.id))
|
LOG.debug("Adding role %s to all users" % (role.id))
|
||||||
for user in self.context["users"]:
|
for user in self.context["users"]:
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from rally.benchmark.context import base
|
from rally.benchmark.context import base
|
||||||
from rally.benchmark import utils
|
from rally.benchmark import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import traceback
|
||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
import six
|
import six
|
||||||
import traceback
|
|
||||||
|
|
||||||
from rally.benchmark.context import base as base_ctx
|
from rally.benchmark.context import base as base_ctx
|
||||||
from rally.benchmark.context import users as users_ctx
|
from rally.benchmark.context import users as users_ctx
|
||||||
@ -65,9 +66,10 @@ CONFIG_SCHEMA = {
|
|||||||
|
|
||||||
|
|
||||||
class BenchmarkEngine(object):
|
class BenchmarkEngine(object):
|
||||||
"""The Benchmark engine class, an instance of which is initialized by the
|
"""The Benchmark engine class is used to execute benchmark scenarios.
|
||||||
Orchestrator with the benchmarks configuration and then is used to execute
|
|
||||||
all specified 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::
|
.. note::
|
||||||
|
|
||||||
Typical usage:
|
Typical usage:
|
||||||
@ -81,6 +83,7 @@ class BenchmarkEngine(object):
|
|||||||
|
|
||||||
def __init__(self, config, task):
|
def __init__(self, config, task):
|
||||||
"""BenchmarkEngine constructor.
|
"""BenchmarkEngine constructor.
|
||||||
|
|
||||||
:param config: The configuration with specified benchmark scenarios
|
:param config: The configuration with specified benchmark scenarios
|
||||||
:param task: The current task which is being performed
|
:param task: The current task which is being performed
|
||||||
"""
|
"""
|
||||||
@ -165,8 +168,9 @@ class BenchmarkEngine(object):
|
|||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Benchmarking."))
|
@rutils.log_task_wrapper(LOG.info, _("Benchmarking."))
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Runs the benchmarks according to the test configuration
|
"""Run the benchmark according to the test configuration.
|
||||||
the benchmark engine was initialized with.
|
|
||||||
|
Test configuration is specified on engine initialization.
|
||||||
|
|
||||||
:returns: List of dicts, each dict containing the results of all the
|
:returns: List of dicts, each dict containing the results of all the
|
||||||
corresponding benchmark test launches
|
corresponding benchmark test launches
|
||||||
|
@ -81,8 +81,10 @@ def calculate_number_of_bins_half(data):
|
|||||||
|
|
||||||
|
|
||||||
def hvariety(data):
|
def hvariety(data):
|
||||||
"""Returns a list of dictionaries, where every dictionary
|
"""Describe methods of calculating the number of bins.
|
||||||
describes a method 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:
|
if len(data) == 0:
|
||||||
raise ValueError("Cannot calculate number of histrogram bins "
|
raise ValueError("Cannot calculate number of histrogram bins "
|
||||||
|
@ -16,8 +16,9 @@ from rally.benchmark.scenarios import base
|
|||||||
|
|
||||||
|
|
||||||
class Authenticate(base.Scenario):
|
class Authenticate(base.Scenario):
|
||||||
"""This class should contain authentication mechanism for different
|
"""This class should contain authentication mechanism.
|
||||||
types of clients like Keystone.
|
|
||||||
|
For different types of clients like Keystone.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@base.scenario()
|
@base.scenario()
|
||||||
|
@ -25,7 +25,9 @@ from rally import utils
|
|||||||
|
|
||||||
|
|
||||||
def scenario(admin_only=False, context=None):
|
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.
|
and it adds following extra fields to the methods.
|
||||||
'is_scenario' is set to True
|
'is_scenario' is set to True
|
||||||
'admin_only' is set to True if a scenario require admin endpoints
|
'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):
|
class Scenario(object):
|
||||||
"""This is base class for any benchmark scenario.
|
"""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.
|
be auto discoverable and you will be able to specify it in test config.
|
||||||
"""
|
"""
|
||||||
RESOURCE_NAME_PREFIX = ""
|
RESOURCE_NAME_PREFIX = ""
|
||||||
|
@ -19,9 +19,6 @@ from rally.benchmark.scenarios import utils as scenario_utils
|
|||||||
|
|
||||||
|
|
||||||
class CeilometerScenario(base.Scenario):
|
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_"
|
RESOURCE_NAME_PREFIX = "rally_ceilometer_"
|
||||||
|
|
||||||
def _get_alarm_dict(self, **kwargs):
|
def _get_alarm_dict(self, **kwargs):
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# 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 oslo.config import cfg
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from rally.benchmark.scenarios import base
|
from rally.benchmark.scenarios import base
|
||||||
from rally.benchmark.scenarios import utils as scenario_utils
|
from rally.benchmark.scenarios import utils as scenario_utils
|
||||||
from rally.benchmark import utils as bench_utils
|
from rally.benchmark import utils as bench_utils
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from oslo.config import cfg
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from rally.benchmark.scenarios import base
|
from rally.benchmark.scenarios import base
|
||||||
from rally.benchmark.scenarios import utils as scenario_utils
|
from rally.benchmark.scenarios import utils as scenario_utils
|
||||||
from rally.benchmark import utils as bench_utils
|
from rally.benchmark import utils as bench_utils
|
||||||
@ -97,7 +98,7 @@ class GlanceScenario(base.Scenario):
|
|||||||
update_resource=bench_utils.get_from_manager(),
|
update_resource=bench_utils.get_from_manager(),
|
||||||
timeout=CONF.benchmark.glance_image_create_timeout,
|
timeout=CONF.benchmark.glance_image_create_timeout,
|
||||||
check_interval=CONF.benchmark.
|
check_interval=CONF.benchmark.
|
||||||
glance_image_create_poll_interval)
|
glance_image_create_poll_interval)
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if "data" in kw:
|
if "data" in kw:
|
||||||
|
@ -22,10 +22,6 @@ def is_temporary(resource):
|
|||||||
|
|
||||||
|
|
||||||
class KeystoneScenario(base.Scenario):
|
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_"
|
RESOURCE_NAME_PREFIX = "rally_keystone_"
|
||||||
|
|
||||||
@scenario_utils.atomic_action_timer('keystone.create_user')
|
@scenario_utils.atomic_action_timer('keystone.create_user')
|
||||||
|
@ -45,8 +45,10 @@ class NeutronNetworks(utils.NeutronScenario):
|
|||||||
subnet_create_args=None,
|
subnet_create_args=None,
|
||||||
subnet_cidr_start=None,
|
subnet_cidr_start=None,
|
||||||
subnets_per_network=None):
|
subnets_per_network=None):
|
||||||
"""Create a network, a given number of subnets
|
"""Test creating and listing a given number of subnets.
|
||||||
and then list all 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 network_create_args: dict, POST /v2.0/networks request options
|
||||||
:param subnet_create_args: dict, POST /v2.0/subnets 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,
|
subnet_cidr_start=None,
|
||||||
subnets_per_network=None,
|
subnets_per_network=None,
|
||||||
router_create_args=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.
|
and then list all routers.
|
||||||
|
|
||||||
:param network_create_args: dict, POST /v2.0/networks request options
|
:param network_create_args: dict, POST /v2.0/networks request options
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
|
|
||||||
from rally.benchmark.scenarios import base
|
from rally.benchmark.scenarios import base
|
||||||
@ -21,9 +22,7 @@ from rally.benchmark.scenarios import utils as scenario_utils
|
|||||||
|
|
||||||
|
|
||||||
class NeutronScenario(base.Scenario):
|
class NeutronScenario(base.Scenario):
|
||||||
"""This class should contain base operations for benchmarking neutron,
|
"""This class should contain base operations for benchmarking neutron."""
|
||||||
most of them are creating/deleting resources.
|
|
||||||
"""
|
|
||||||
|
|
||||||
RESOURCE_NAME_PREFIX = "rally_net_"
|
RESOURCE_NAME_PREFIX = "rally_net_"
|
||||||
SUBNET_IP_VERSION = 4
|
SUBNET_IP_VERSION = 4
|
||||||
@ -33,8 +32,7 @@ class NeutronScenario(base.Scenario):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _generate_subnet_cidr(cls, network_id):
|
def _generate_subnet_cidr(cls, network_id):
|
||||||
"""Generate next subnet CIDR for given network,
|
"""Generate next subnet CIDR for network, without IP overlapping.
|
||||||
without IP overlapping.
|
|
||||||
|
|
||||||
:param network_id: str, network UUID for subnet
|
:param network_id: str, network UUID for subnet
|
||||||
:returns: str, next available subnet CIDR
|
:returns: str, next available subnet CIDR
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
import jsonschema
|
||||||
|
|
||||||
from rally.benchmark.scenarios import base
|
from rally.benchmark.scenarios import base
|
||||||
from rally.benchmark.scenarios.cinder import utils as cinder_utils
|
from rally.benchmark.scenarios.cinder import utils as cinder_utils
|
||||||
from rally.benchmark.scenarios.nova import 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"))
|
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
|
||||||
@base.scenario(context={"cleanup": ["nova"]})
|
@base.scenario(context={"cleanup": ["nova"]})
|
||||||
def boot_and_bounce_server(self, image, flavor, **kwargs):
|
def boot_and_bounce_server(self, image, flavor, **kwargs):
|
||||||
"""Tests booting a server then performing stop/start or hard/soft
|
"""Test booting a server with further performing specified actions.
|
||||||
reboot a number of times.
|
|
||||||
|
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()
|
action_builder = self._bind_actions()
|
||||||
actions = kwargs.get('actions', [])
|
actions = kwargs.get('actions', [])
|
||||||
@ -190,6 +194,7 @@ class NovaServers(utils.NovaScenario,
|
|||||||
|
|
||||||
def _rescue_and_unrescue_server(self, server):
|
def _rescue_and_unrescue_server(self, server):
|
||||||
"""Rescue and then unrescue the given server.
|
"""Rescue and then unrescue the given server.
|
||||||
|
|
||||||
A rescue will be issued on the given server upon which time
|
A rescue will be issued on the given server upon which time
|
||||||
this method will wait for the server to become 'RESCUE'.
|
this method will wait for the server to become 'RESCUE'.
|
||||||
Once the server is RESCUE a unrescue will be issued and
|
Once the server is RESCUE a unrescue will be issued and
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# 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 oslo.config import cfg
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from rally.benchmark.scenarios import base
|
from rally.benchmark.scenarios import base
|
||||||
from rally.benchmark.scenarios import utils as scenario_utils
|
from rally.benchmark.scenarios import utils as scenario_utils
|
||||||
from rally.benchmark import utils as bench_utils
|
from rally.benchmark import utils as bench_utils
|
||||||
@ -241,12 +242,12 @@ class NovaScenario(base.Scenario):
|
|||||||
:param image: Image object
|
:param image: Image object
|
||||||
"""
|
"""
|
||||||
image.delete()
|
image.delete()
|
||||||
|
check_interval = CONF.benchmark.nova_server_image_delete_poll_interval
|
||||||
bench_utils.wait_for_delete(
|
bench_utils.wait_for_delete(
|
||||||
image,
|
image,
|
||||||
update_resource=bench_utils.get_from_manager(),
|
update_resource=bench_utils.get_from_manager(),
|
||||||
timeout=CONF.benchmark.nova_server_image_delete_timeout,
|
timeout=CONF.benchmark.nova_server_image_delete_timeout,
|
||||||
check_interval=
|
check_interval=check_interval
|
||||||
CONF.benchmark.nova_server_image_delete_poll_interval
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@scenario_utils.atomic_action_timer('nova.create_image')
|
@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,
|
image_uuid = self.clients("nova").servers.create_image(server,
|
||||||
server.name)
|
server.name)
|
||||||
image = self.clients("nova").images.get(image_uuid)
|
image = self.clients("nova").images.get(image_uuid)
|
||||||
|
check_interval = CONF.benchmark.nova_server_image_create_poll_interval
|
||||||
image = bench_utils.wait_for(
|
image = bench_utils.wait_for(
|
||||||
image,
|
image,
|
||||||
is_ready=bench_utils.resource_is("ACTIVE"),
|
is_ready=bench_utils.resource_is("ACTIVE"),
|
||||||
update_resource=bench_utils.get_from_manager(),
|
update_resource=bench_utils.get_from_manager(),
|
||||||
timeout=CONF.benchmark.nova_server_image_create_timeout,
|
timeout=CONF.benchmark.nova_server_image_create_timeout,
|
||||||
check_interval=
|
check_interval=check_interval
|
||||||
CONF.benchmark.nova_server_image_create_poll_interval
|
|
||||||
)
|
)
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
@ -14,10 +14,11 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.openstack.common.gettextutils import _
|
from rally.openstack.common.gettextutils import _
|
||||||
|
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
|
|
||||||
from rally import utils
|
from rally import utils
|
||||||
|
|
||||||
|
|
||||||
class ActionBuilder(object):
|
class ActionBuilder(object):
|
||||||
"""Builder class for mapping and creating action objects into
|
"""Builder class for mapping and creating action objects.
|
||||||
callable methods.
|
|
||||||
|
|
||||||
An action list is an array of single key/value dicts which takes
|
An action list is an array of single key/value dicts which takes
|
||||||
the form:
|
the form:
|
||||||
@ -56,8 +56,7 @@ class ActionBuilder(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, action_keywords):
|
def __init__(self, action_keywords):
|
||||||
"""Creates a new instance of the builder which supports the given
|
"""Create a new instance of the builder for the given action keywords.
|
||||||
action keywords.
|
|
||||||
|
|
||||||
:param action_keywords: A list of strings which are the keywords this
|
:param action_keywords: A list of strings which are the keywords this
|
||||||
instance of the builder supports.
|
instance of the builder supports.
|
||||||
@ -65,13 +64,13 @@ class ActionBuilder(object):
|
|||||||
self._bindings = {}
|
self._bindings = {}
|
||||||
self.schema = dict(ActionBuilder.SCHEMA_TEMPLATE)
|
self.schema = dict(ActionBuilder.SCHEMA_TEMPLATE)
|
||||||
for kw in action_keywords:
|
for kw in action_keywords:
|
||||||
self.schema['items']['properties'][kw] =\
|
self.schema['items']['properties'][kw] = (
|
||||||
ActionBuilder.ITEM_TEMPLATE
|
ActionBuilder.ITEM_TEMPLATE)
|
||||||
|
|
||||||
def bind_action(self, action_key, action, *args, **kwargs):
|
def bind_action(self, action_key, action, *args, **kwargs):
|
||||||
"""Binds an action and optionally static args/kwargs to an
|
"""Bind an action to an action key.
|
||||||
action key.
|
|
||||||
|
|
||||||
|
Static args/kwargs can be optionally binded.
|
||||||
:param action_key: The action keyword to bind the action to.
|
:param action_key: The action keyword to bind the action to.
|
||||||
:param action: A method/function to call for the action.
|
:param action: A method/function to call for the action.
|
||||||
:param args: (optional) Static positional args to prepend
|
:param args: (optional) Static positional args to prepend
|
||||||
@ -87,23 +86,24 @@ class ActionBuilder(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def validate(self, actions):
|
def validate(self, actions):
|
||||||
"""Validates the list of action objects against the schema
|
"""Validate the list of action objects against the builder schema.
|
||||||
for this builder.
|
|
||||||
|
|
||||||
:param actions: The list of action objects to validate.
|
:param actions: The list of action objects to validate.
|
||||||
"""
|
"""
|
||||||
jsonschema.validate(actions, self.schema)
|
jsonschema.validate(actions, self.schema)
|
||||||
|
|
||||||
def _build(self, func, times, *args, **kwargs):
|
def _build(self, func, times, *args, **kwargs):
|
||||||
"""Builds the wrapper action call."""
|
"""Build the wrapper action call."""
|
||||||
def _f():
|
def _f():
|
||||||
for i in range(times):
|
for i in range(times):
|
||||||
func(*args, **kwargs)
|
func(*args, **kwargs)
|
||||||
return _f
|
return _f
|
||||||
|
|
||||||
def build_actions(self, actions, *args, **kwargs):
|
def build_actions(self, actions, *args, **kwargs):
|
||||||
"""Builds a list of callable actions based on the given
|
"""Build a list of callable actions.
|
||||||
action object list and the actions bound to this builder.
|
|
||||||
|
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
|
:param actions: A list of action objects to build callable
|
||||||
action for.
|
action for.
|
||||||
@ -129,8 +129,10 @@ class ActionBuilder(object):
|
|||||||
|
|
||||||
|
|
||||||
def atomic_action_timer(name):
|
def atomic_action_timer(name):
|
||||||
"""Decorates methods of the Scenario class requiring a measure of execution
|
"""Provide measure of execution time.
|
||||||
time. This provides duration in seconds of each atomic action.
|
|
||||||
|
Decorates methods of the Scenario class.
|
||||||
|
This provides duration in seconds of each atomic action.
|
||||||
"""
|
"""
|
||||||
def wrap(func):
|
def wrap(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
@ -156,7 +158,8 @@ class AtomicAction(utils.Timer):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, scenario_instance, name):
|
def __init__(self, scenario_instance, name):
|
||||||
"""Constructor
|
"""Create a new instance of the AtomicAction.
|
||||||
|
|
||||||
:param scenario_instance: instance of subclass of base scenario
|
:param scenario_instance: instance of subclass of base scenario
|
||||||
:param name: name of the ActionBuilder
|
:param name: name of the ActionBuilder
|
||||||
"""
|
"""
|
||||||
|
@ -24,6 +24,7 @@ class VMScenario(base.Scenario):
|
|||||||
@scenario_utils.atomic_action_timer('vm.run_command')
|
@scenario_utils.atomic_action_timer('vm.run_command')
|
||||||
def run_action(self, ssh, interpreter, script):
|
def run_action(self, ssh, interpreter, script):
|
||||||
"""Run command inside an instance.
|
"""Run command inside an instance.
|
||||||
|
|
||||||
This is a separate function so that only script execution is timed
|
This is a separate function so that only script execution is timed
|
||||||
"""
|
"""
|
||||||
return ssh.execute(interpreter, stdin=open(script, "rb"))
|
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,
|
def run_command(self, server, username, network, port, ip_version,
|
||||||
interpreter, script):
|
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
|
available (there is a delay between server being set to ACTIVE
|
||||||
and sshd being available). Then call __run_command to actually
|
and sshd being available). Then call __run_command to actually
|
||||||
execute the command.
|
execute the command.
|
||||||
|
@ -72,7 +72,7 @@ def _id_from_name(resource_config, resources, typename):
|
|||||||
raise exceptions.InvalidScenarioArgument(
|
raise exceptions.InvalidScenarioArgument(
|
||||||
"{typename} 'id', 'name', or 'regex' not found "
|
"{typename} 'id', 'name', or 'regex' not found "
|
||||||
"in '{resource_config}' ".format(typename=typename.title(),
|
"in '{resource_config}' ".format(typename=typename.title(),
|
||||||
resource_config=resource_config))
|
resource_config=resource_config))
|
||||||
|
|
||||||
pattern = re.compile(patternstr)
|
pattern = re.compile(patternstr)
|
||||||
matching = filter(lambda resource: re.search(pattern, resource.name),
|
matching = filter(lambda resource: re.search(pattern, resource.name),
|
||||||
@ -80,13 +80,14 @@ def _id_from_name(resource_config, resources, typename):
|
|||||||
if not matching:
|
if not matching:
|
||||||
raise exceptions.InvalidScenarioArgument(
|
raise exceptions.InvalidScenarioArgument(
|
||||||
"{typename} with pattern '{pattern}' not found".format(
|
"{typename} with pattern '{pattern}' not found".format(
|
||||||
typename=typename.title(), pattern=pattern.pattern))
|
typename=typename.title(), pattern=pattern.pattern))
|
||||||
elif len(matching) > 1:
|
elif len(matching) > 1:
|
||||||
raise exceptions.InvalidScenarioArgument(
|
raise exceptions.InvalidScenarioArgument(
|
||||||
"{typename} with name '{pattern}' is ambiguous, "
|
"{typename} with name '{pattern}' is ambiguous, possible matches "
|
||||||
"possible matches by id: {ids}".format(
|
"by id: {ids}".format(typename=typename.title(),
|
||||||
typename=typename.title(), pattern=pattern.pattern,
|
pattern=pattern.pattern,
|
||||||
ids=", ".join(map(operator.attrgetter("id"), matching))))
|
ids=", ".join(map(operator.attrgetter("id"),
|
||||||
|
matching))))
|
||||||
return matching[0].id
|
return matching[0].id
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from novaclient.v1_1 import servers
|
from novaclient.v1_1 import servers
|
||||||
|
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,9 +146,9 @@ def image_exists(param_name):
|
|||||||
"""
|
"""
|
||||||
def image_exists_validator(**kwargs):
|
def image_exists_validator(**kwargs):
|
||||||
clients = kwargs.get('clients')
|
clients = kwargs.get('clients')
|
||||||
image_id = types.ImageResourceType.transform(clients=clients,
|
image_id = types.ImageResourceType.transform(
|
||||||
resource_config=
|
clients=clients,
|
||||||
kwargs.get(param_name))
|
resource_config=kwargs.get(param_name))
|
||||||
try:
|
try:
|
||||||
clients.glance().images.get(image=image_id)
|
clients.glance().images.get(image=image_id)
|
||||||
return ValidationResult()
|
return ValidationResult()
|
||||||
@ -166,9 +166,9 @@ def flavor_exists(param_name):
|
|||||||
"""
|
"""
|
||||||
def flavor_exists_validator(**kwargs):
|
def flavor_exists_validator(**kwargs):
|
||||||
clients = kwargs.get('clients')
|
clients = kwargs.get('clients')
|
||||||
flavor_id = types.FlavorResourceType.transform(clients=clients,
|
flavor_id = types.FlavorResourceType.transform(
|
||||||
resource_config=
|
clients=clients,
|
||||||
kwargs.get(param_name))
|
resource_config=kwargs.get(param_name))
|
||||||
try:
|
try:
|
||||||
clients.nova().flavors.get(flavor=flavor_id)
|
clients.nova().flavors.get(flavor=flavor_id)
|
||||||
return ValidationResult()
|
return ValidationResult()
|
||||||
@ -190,18 +190,18 @@ def image_valid_on_flavor(flavor_name, image_name):
|
|||||||
def image_valid_on_flavor_validator(**kwargs):
|
def image_valid_on_flavor_validator(**kwargs):
|
||||||
clients = kwargs.get('clients')
|
clients = kwargs.get('clients')
|
||||||
|
|
||||||
flavor_id = types.FlavorResourceType.transform(clients=clients,
|
flavor_id = types.FlavorResourceType.transform(
|
||||||
resource_config=
|
clients=clients,
|
||||||
kwargs.get(flavor_name))
|
resource_config=kwargs.get(flavor_name))
|
||||||
try:
|
try:
|
||||||
flavor = clients.nova().flavors.get(flavor=flavor_id)
|
flavor = clients.nova().flavors.get(flavor=flavor_id)
|
||||||
except nova_exc.NotFound:
|
except nova_exc.NotFound:
|
||||||
message = _("Flavor with id '%s' not found") % flavor_id
|
message = _("Flavor with id '%s' not found") % flavor_id
|
||||||
return ValidationResult(False, message)
|
return ValidationResult(False, message)
|
||||||
|
|
||||||
image_id = types.ImageResourceType.transform(clients=clients,
|
image_id = types.ImageResourceType.transform(
|
||||||
resource_config=
|
clients=clients,
|
||||||
kwargs.get(image_name))
|
resource_config=kwargs.get(image_name))
|
||||||
try:
|
try:
|
||||||
image = clients.glance().images.get(image=image_id)
|
image = clients.glance().images.get(image=image_id)
|
||||||
except glance_exc.HTTPNotFound:
|
except glance_exc.HTTPNotFound:
|
||||||
|
@ -148,6 +148,7 @@ class DeploymentCommands(object):
|
|||||||
@envutils.with_default_deploy_id
|
@envutils.with_default_deploy_id
|
||||||
def endpoint(self, deploy_id=None):
|
def endpoint(self, deploy_id=None):
|
||||||
"""Print endpoint of the deployment.
|
"""Print endpoint of the deployment.
|
||||||
|
|
||||||
:param deploy_id: a UUID of the deployment
|
:param deploy_id: a UUID of the deployment
|
||||||
"""
|
"""
|
||||||
headers = ['auth_url', 'username', 'password', 'tenant_name',
|
headers = ['auth_url', 'username', 'password', 'tenant_name',
|
||||||
|
@ -16,14 +16,13 @@
|
|||||||
""" Rally command: task """
|
""" Rally command: task """
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pprint
|
import pprint
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import yaml
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
import yaml
|
||||||
|
|
||||||
from rally.benchmark.processing import plot
|
from rally.benchmark.processing import plot
|
||||||
from rally.benchmark.processing import utils
|
from rally.benchmark.processing import utils
|
||||||
|
@ -104,8 +104,10 @@ class UseCommands(object):
|
|||||||
@cliutils.args('--uuid', type=str, dest='task_id', required=False,
|
@cliutils.args('--uuid', type=str, dest='task_id', required=False,
|
||||||
help='UUID of the task')
|
help='UUID of the task')
|
||||||
def task(self, task_id):
|
def task(self, task_id):
|
||||||
"""Set the RALLY_TASK env var so the user does not need to specify a
|
"""Set the RALLY_TASK env var.
|
||||||
task UUID in the command requiring this parameter.
|
|
||||||
|
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,
|
If the task uuid specified in parameter by the user does not exist,
|
||||||
a TaskNotFound will be raised by task_get().
|
a TaskNotFound will be raised by task_get().
|
||||||
|
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import decorator
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import decorator
|
||||||
|
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally import fileutils
|
from rally import fileutils
|
||||||
from rally.openstack.common.gettextutils import _
|
from rally.openstack.common.gettextutils import _
|
||||||
|
@ -96,9 +96,8 @@ class Connection(object):
|
|||||||
return query
|
return query
|
||||||
|
|
||||||
def _task_get(self, uuid, session=None):
|
def _task_get(self, uuid, session=None):
|
||||||
task = self.model_query(models.Task, session=session).\
|
task = (self.model_query(models.Task, session=session).
|
||||||
filter_by(uuid=uuid).\
|
filter_by(uuid=uuid).first())
|
||||||
first()
|
|
||||||
if not task:
|
if not task:
|
||||||
raise exceptions.TaskNotFound(uuid=uuid)
|
raise exceptions.TaskNotFound(uuid=uuid)
|
||||||
return task
|
return task
|
||||||
@ -107,15 +106,14 @@ class Connection(object):
|
|||||||
return self._task_get(uuid)
|
return self._task_get(uuid)
|
||||||
|
|
||||||
def task_get_detailed(self, uuid):
|
def task_get_detailed(self, uuid):
|
||||||
return self.model_query(models.Task).\
|
return (self.model_query(models.Task).
|
||||||
options(sa.orm.joinedload('results')).\
|
options(sa.orm.joinedload('results')).
|
||||||
filter_by(uuid=uuid).\
|
filter_by(uuid=uuid).first())
|
||||||
first()
|
|
||||||
|
|
||||||
def task_get_detailed_last(self):
|
def task_get_detailed_last(self):
|
||||||
return self.model_query(models.Task).\
|
return (self.model_query(models.Task).
|
||||||
options(sa.orm.joinedload('results')).\
|
options(sa.orm.joinedload('results')).
|
||||||
order_by(models.Task.id.desc()).first()
|
order_by(models.Task.id.desc()).first())
|
||||||
|
|
||||||
def task_create(self, values):
|
def task_create(self, values):
|
||||||
task = models.Task()
|
task = models.Task()
|
||||||
@ -140,14 +138,13 @@ class Connection(object):
|
|||||||
def task_delete(self, uuid, status=None):
|
def task_delete(self, uuid, status=None):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
query = base_query = self.model_query(models.Task).\
|
query = base_query = (self.model_query(models.Task).
|
||||||
filter_by(uuid=uuid)
|
filter_by(uuid=uuid))
|
||||||
if status is not None:
|
if status is not None:
|
||||||
query = base_query.filter_by(status=status)
|
query = base_query.filter_by(status=status)
|
||||||
|
|
||||||
self.model_query(models.TaskResult).\
|
(self.model_query(models.TaskResult).filter_by(task_uuid=uuid).
|
||||||
filter_by(task_uuid=uuid).\
|
delete(synchronize_session=False))
|
||||||
delete(synchronize_session=False)
|
|
||||||
|
|
||||||
count = query.delete(synchronize_session=False)
|
count = query.delete(synchronize_session=False)
|
||||||
if not count:
|
if not count:
|
||||||
@ -166,14 +163,12 @@ class Connection(object):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def task_result_get_all_by_uuid(self, uuid):
|
def task_result_get_all_by_uuid(self, uuid):
|
||||||
return self.model_query(models.TaskResult).\
|
return (self.model_query(models.TaskResult).
|
||||||
filter_by(task_uuid=uuid).\
|
filter_by(task_uuid=uuid).all())
|
||||||
all()
|
|
||||||
|
|
||||||
def _deployment_get(self, uuid, session=None):
|
def _deployment_get(self, uuid, session=None):
|
||||||
deploy = self.model_query(models.Deployment, session=session).\
|
deploy = (self.model_query(models.Deployment, session=session).
|
||||||
filter_by(uuid=uuid).\
|
filter_by(uuid=uuid).first())
|
||||||
first()
|
|
||||||
if not deploy:
|
if not deploy:
|
||||||
raise exceptions.DeploymentNotFound(uuid=uuid)
|
raise exceptions.DeploymentNotFound(uuid=uuid)
|
||||||
return deploy
|
return deploy
|
||||||
@ -187,15 +182,13 @@ class Connection(object):
|
|||||||
def deployment_delete(self, uuid):
|
def deployment_delete(self, uuid):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
count = self.model_query(models.Resource, session=session).\
|
count = (self.model_query(models.Resource, session=session).
|
||||||
filter_by(deployment_uuid=uuid).\
|
filter_by(deployment_uuid=uuid).count())
|
||||||
count()
|
|
||||||
if count:
|
if count:
|
||||||
raise exceptions.DeploymentIsBusy(uuid=uuid)
|
raise exceptions.DeploymentIsBusy(uuid=uuid)
|
||||||
|
|
||||||
count = self.model_query(models.Deployment, session=session).\
|
count = (self.model_query(models.Deployment, session=session).
|
||||||
filter_by(uuid=uuid).\
|
filter_by(uuid=uuid).delete(synchronize_session=False))
|
||||||
delete(synchronize_session=False)
|
|
||||||
if not count:
|
if not count:
|
||||||
raise exceptions.DeploymentNotFound(uuid=uuid)
|
raise exceptions.DeploymentNotFound(uuid=uuid)
|
||||||
|
|
||||||
@ -211,8 +204,8 @@ class Connection(object):
|
|||||||
return deploy
|
return deploy
|
||||||
|
|
||||||
def deployment_list(self, status=None, parent_uuid=None, name=None):
|
def deployment_list(self, status=None, parent_uuid=None, name=None):
|
||||||
query = self.model_query(models.Deployment).\
|
query = (self.model_query(models.Deployment).
|
||||||
filter_by(parent_uuid=parent_uuid)
|
filter_by(parent_uuid=parent_uuid))
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
query = query.filter_by(name=name)
|
query = query.filter_by(name=name)
|
||||||
@ -227,8 +220,8 @@ class Connection(object):
|
|||||||
return resource
|
return resource
|
||||||
|
|
||||||
def resource_get_all(self, deployment_uuid, provider_name=None, type=None):
|
def resource_get_all(self, deployment_uuid, provider_name=None, type=None):
|
||||||
query = self.model_query(models.Resource).\
|
query = (self.model_query(models.Resource).
|
||||||
filter_by(deployment_uuid=deployment_uuid)
|
filter_by(deployment_uuid=deployment_uuid))
|
||||||
if provider_name is not None:
|
if provider_name is not None:
|
||||||
query = query.filter_by(provider_name=provider_name)
|
query = query.filter_by(provider_name=provider_name)
|
||||||
if type is not None:
|
if type is not None:
|
||||||
@ -236,9 +229,8 @@ class Connection(object):
|
|||||||
return query.all()
|
return query.all()
|
||||||
|
|
||||||
def resource_delete(self, id):
|
def resource_delete(self, id):
|
||||||
count = self.model_query(models.Resource).\
|
count = (self.model_query(models.Resource).
|
||||||
filter_by(id=id).\
|
filter_by(id=id).delete(synchronize_session=False))
|
||||||
delete(synchronize_session=False)
|
|
||||||
if not count:
|
if not count:
|
||||||
raise exceptions.ResourceNotFound(id=id)
|
raise exceptions.ResourceNotFound(id=id)
|
||||||
|
|
||||||
@ -249,8 +241,8 @@ class Connection(object):
|
|||||||
return verification
|
return verification
|
||||||
|
|
||||||
def verification_get(self, verification_uuid, session=None):
|
def verification_get(self, verification_uuid, session=None):
|
||||||
verification = self.model_query(models.Verification, session=session).\
|
verification = (self.model_query(models.Verification, session=session).
|
||||||
filter_by(uuid=verification_uuid).first()
|
filter_by(uuid=verification_uuid).first())
|
||||||
if not verification:
|
if not verification:
|
||||||
raise exceptions.NotFoundException(
|
raise exceptions.NotFoundException(
|
||||||
"Can't find any verification with following UUID '%s'." %
|
"Can't find any verification with following UUID '%s'." %
|
||||||
@ -272,9 +264,9 @@ class Connection(object):
|
|||||||
return query.all()
|
return query.all()
|
||||||
|
|
||||||
def verification_delete(self, verification_uuid):
|
def verification_delete(self, verification_uuid):
|
||||||
count = self.model_query(models.Verification).\
|
count = (self.model_query(models.Verification).
|
||||||
filter_by(id=verification_uuid).\
|
filter_by(id=verification_uuid).
|
||||||
delete(synchronize_session=False)
|
delete(synchronize_session=False))
|
||||||
if not count:
|
if not count:
|
||||||
raise exceptions.NotFoundException(
|
raise exceptions.NotFoundException(
|
||||||
"Can't find any verification with following UUID '%s'." %
|
"Can't find any verification with following UUID '%s'." %
|
||||||
@ -288,8 +280,8 @@ class Connection(object):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def verification_result_get(self, verification_uuid):
|
def verification_result_get(self, verification_uuid):
|
||||||
result = self.model_query(models.VerificationResult).\
|
result = (self.model_query(models.VerificationResult).
|
||||||
filter_by(verification_uuid=verification_uuid).first()
|
filter_by(verification_uuid=verification_uuid).first())
|
||||||
if not result:
|
if not result:
|
||||||
raise exceptions.NotFoundException(
|
raise exceptions.NotFoundException(
|
||||||
"No results for following UUID '%s'." % verification_uuid)
|
"No results for following UUID '%s'." % verification_uuid)
|
||||||
|
@ -15,10 +15,12 @@
|
|||||||
"""
|
"""
|
||||||
SQLAlchemy models for rally data.
|
SQLAlchemy models for rally data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy import types
|
from sqlalchemy import types
|
||||||
import uuid
|
|
||||||
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.db.sqlalchemy import types as sa_types
|
from rally.db.sqlalchemy import types as sa_types
|
||||||
@ -65,7 +67,7 @@ class Deployment(BASE, RallyBase):
|
|||||||
completed_at = sa.Column(sa.DateTime)
|
completed_at = sa.Column(sa.DateTime)
|
||||||
# XXX(akscram): Do we need to explicitly store a name of the
|
# XXX(akscram): Do we need to explicitly store a name of the
|
||||||
# deployment engine?
|
# deployment engine?
|
||||||
#engine_name = sa.Column(sa.String(36))
|
# engine_name = sa.Column(sa.String(36))
|
||||||
|
|
||||||
config = sa.Column(
|
config = sa.Column(
|
||||||
sa_types.MutableJSONEncodedDict,
|
sa_types.MutableJSONEncodedDict,
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import netaddr
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import netaddr
|
||||||
|
|
||||||
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
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import requests
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
from rally.openstack.common import log as logging
|
from rally.openstack.common import log as logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -148,6 +148,7 @@ class ProviderFactory(object):
|
|||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def create_servers(self, image_uuid=None, type_id=None, amount=1):
|
def create_servers(self, image_uuid=None, type_id=None, amount=1):
|
||||||
"""Create VMs with chosen image.
|
"""Create VMs with chosen image.
|
||||||
|
|
||||||
:param image_uuid: Indetificator of image
|
:param image_uuid: Indetificator of image
|
||||||
:param type_id: Vm type identificator
|
:param type_id: Vm type identificator
|
||||||
:param amount: amount of required VMs
|
:param amount: amount of required VMs
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import netaddr
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import StringIO
|
import StringIO
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import netaddr
|
||||||
|
|
||||||
from rally.deploy.serverprovider import provider
|
from rally.deploy.serverprovider import provider
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.openstack.common.gettextutils import _
|
from rally.openstack.common.gettextutils import _
|
||||||
|
@ -13,11 +13,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import novaclient.exceptions
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
|
import novaclient.exceptions
|
||||||
|
|
||||||
from rally.benchmark import utils as benchmark_utils
|
from rally.benchmark import utils as benchmark_utils
|
||||||
from rally.deploy.serverprovider import provider
|
from rally.deploy.serverprovider import provider
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -13,17 +13,19 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import netaddr
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import netaddr
|
||||||
|
|
||||||
from rally.deploy.serverprovider import provider
|
from rally.deploy.serverprovider import provider
|
||||||
|
|
||||||
|
|
||||||
class VirshProvider(provider.ProviderFactory):
|
class VirshProvider(provider.ProviderFactory):
|
||||||
'''Creates VMs from prebuilt templates.
|
"""Create VMs from prebuilt templates.
|
||||||
|
|
||||||
config example:
|
config example:
|
||||||
"vm_provider": {
|
"vm_provider": {
|
||||||
"type": "VirshProvider",
|
"type": "VirshProvider",
|
||||||
@ -32,7 +34,7 @@ class VirshProvider(provider.ProviderFactory):
|
|||||||
"template_user": "ubuntu", # vm user to launch devstack
|
"template_user": "ubuntu", # vm user to launch devstack
|
||||||
"template_password": "password" # vm password to launch devstack
|
"template_password": "password" # vm password to launch devstack
|
||||||
},
|
},
|
||||||
'''
|
"""
|
||||||
|
|
||||||
CONFIG_SCHEMA = {
|
CONFIG_SCHEMA = {
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
@ -59,6 +61,7 @@ class VirshProvider(provider.ProviderFactory):
|
|||||||
|
|
||||||
def create_servers(self, image_uuid=None, type_id=None, amount=1):
|
def create_servers(self, image_uuid=None, type_id=None, amount=1):
|
||||||
"""Create VMs with chosen image.
|
"""Create VMs with chosen image.
|
||||||
|
|
||||||
:param image_uuid: Indetificator of image
|
:param image_uuid: Indetificator of image
|
||||||
:param amount: amount of required VMs
|
:param amount: amount of required VMs
|
||||||
Returns list of VMs uuids.
|
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)]
|
return [self.create_vm(str(uuid.uuid4())) for i in range(amount)]
|
||||||
|
|
||||||
def create_vm(self, vm_name):
|
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'])
|
virt_url = self._get_virt_connection_url(self.config['connection'])
|
||||||
cmd = 'virt-clone --connect=%(url)s -o %(t)s -n %(n)s --auto-clone' % {
|
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):
|
def destroy_servers(self):
|
||||||
'''Destroy already created vms.'''
|
"""Destroy already created vms."""
|
||||||
for resource in self.resources.get_all():
|
for resource in self.resources.get_all():
|
||||||
self.destroy_vm(resource['info']['name'])
|
self.destroy_vm(resource['info']['name'])
|
||||||
self.resources.delete(resource)
|
self.resources.delete(resource)
|
||||||
|
|
||||||
def destroy_vm(self, vm_name):
|
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)
|
print('Destroy VM %s' % vm_name)
|
||||||
vconnection = self._get_virt_connection_url(self.config['connection'])
|
vconnection = self._get_virt_connection_url(self.config['connection'])
|
||||||
|
|
||||||
@ -107,7 +110,7 @@ class VirshProvider(provider.ProviderFactory):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_virt_connection_url(connection):
|
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
|
return 'qemu+ssh://%s/system' % connection
|
||||||
|
|
||||||
def _determine_vm_ip(self, vm_name):
|
def _determine_vm_ip(self, vm_name):
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from oslo.config import cfg
|
||||||
|
|
||||||
from rally.openstack.common.gettextutils import _
|
from rally.openstack.common.gettextutils import _
|
||||||
from rally.openstack.common import log as logging
|
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`.")
|
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):
|
class TaskNotFound(NotFoundException):
|
||||||
msg_fmt = _("Task with uuid=%(uuid)s not found.")
|
msg_fmt = _("Task with uuid=%(uuid)s not found.")
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ def _read_env_file(path, except_env=None):
|
|||||||
with open(path, 'r') as env_file:
|
with open(path, 'r') as env_file:
|
||||||
content = env_file.readlines()
|
content = env_file.readlines()
|
||||||
for line in content:
|
for line in content:
|
||||||
if except_env is None or \
|
if except_env is None or not line.startswith("%s=" %
|
||||||
not line.startswith("%s=" % except_env):
|
except_env):
|
||||||
output.append(line)
|
output.append(line)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@ -13,6 +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.
|
||||||
|
|
||||||
|
import urlparse
|
||||||
|
|
||||||
from ceilometerclient import client as ceilometer
|
from ceilometerclient import client as ceilometer
|
||||||
from cinderclient import client as cinder
|
from cinderclient import client as cinder
|
||||||
import glanceclient as glance
|
import glanceclient as glance
|
||||||
@ -23,7 +25,6 @@ from keystoneclient.v2_0 import client as keystone
|
|||||||
from neutronclient.neutron import client as neutron
|
from neutronclient.neutron import client as neutron
|
||||||
from novaclient import client as nova
|
from novaclient import client as nova
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import urlparse
|
|
||||||
|
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
|
@ -57,12 +57,13 @@ Eventlet:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import paramiko
|
|
||||||
import select
|
import select
|
||||||
import socket
|
import socket
|
||||||
import StringIO
|
import StringIO
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import paramiko
|
||||||
|
|
||||||
from rally.openstack.common.gettextutils import _
|
from rally.openstack.common.gettextutils import _
|
||||||
from rally.openstack.common import log as logging
|
from rally.openstack.common import log as logging
|
||||||
|
|
||||||
|
@ -15,13 +15,14 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
from oslo.config import cfg
|
|
||||||
from six.moves import configparser
|
|
||||||
from six.moves import http_client as httplib
|
|
||||||
import time
|
import time
|
||||||
import urllib2
|
import urllib2
|
||||||
import urlparse
|
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 db
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.objects import endpoint
|
from rally.objects import endpoint
|
||||||
@ -184,8 +185,8 @@ class TempestConf(object):
|
|||||||
if public_net:
|
if public_net:
|
||||||
net_id = public_net[0]['id']
|
net_id = public_net[0]['id']
|
||||||
self.conf.set('network', 'public_network_id', net_id)
|
self.conf.set('network', 'public_network_id', net_id)
|
||||||
public_router = neutron.list_routers(network_id=
|
public_router = neutron.list_routers(
|
||||||
net_id)['routers'][0]
|
network_id=net_id)['routers'][0]
|
||||||
self.conf.set('network', 'public_router_id',
|
self.conf.set('network', 'public_router_id',
|
||||||
public_router['id'])
|
public_router['id'])
|
||||||
subnet = neutron.list_subnets(network_id=net_id)['subnets'][0]
|
subnet = neutron.list_subnets(network_id=net_id)['subnets'][0]
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.benchmark.context.cleanup import cleanup as cleanup_ctx
|
from rally.benchmark.context.cleanup import cleanup as cleanup_ctx
|
||||||
|
|
||||||
from tests import fakes
|
from tests import fakes
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import random
|
||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
import mock
|
import mock
|
||||||
import random
|
|
||||||
|
|
||||||
from rally.benchmark.context import quotas
|
from rally.benchmark.context import quotas
|
||||||
from tests import test
|
from tests import test
|
||||||
@ -74,10 +75,10 @@ class CinderQuotasTestCase(test.TestCase):
|
|||||||
pass
|
pass
|
||||||
# Currently, no method to delete quotas available in cinder client:
|
# Currently, no method to delete quotas available in cinder client:
|
||||||
# Will be added with https://review.openstack.org/#/c/74841/
|
# Will be added with https://review.openstack.org/#/c/74841/
|
||||||
#cinder_quotas = quotas.CinderQuotas(client_mock)
|
# cinder_quotas = quotas.CinderQuotas(client_mock)
|
||||||
#tenant_id = mock.MagicMock()
|
# tenant_id = mock.MagicMock()
|
||||||
#cinder_quotas.delete(tenant_id)
|
# cinder_quotas.delete(tenant_id)
|
||||||
#client_mock.quotas.delete.assert_called_once_with(tenant_id)
|
# client_mock.quotas.delete.assert_called_once_with(tenant_id)
|
||||||
|
|
||||||
|
|
||||||
class NeutronQuotasTestCase(test.TestCase):
|
class NeutronQuotasTestCase(test.TestCase):
|
||||||
@ -187,8 +188,8 @@ class QuotasTestCase(test.TestCase):
|
|||||||
% ctx["config"]["quotas"][service][key])
|
% ctx["config"]["quotas"][service][key])
|
||||||
|
|
||||||
# Test valid values
|
# Test valid values
|
||||||
ctx["config"]["quotas"][service][key] = \
|
ctx["config"]["quotas"][service][key] = random.randint(0,
|
||||||
random.randint(0, 1000000)
|
1000000)
|
||||||
try:
|
try:
|
||||||
quotas.Quotas.validate(ctx["config"]["quotas"])
|
quotas.Quotas.validate(ctx["config"]["quotas"])
|
||||||
except jsonschema.ValidationError:
|
except jsonschema.ValidationError:
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.benchmark.context import roles
|
from rally.benchmark.context import roles
|
||||||
|
from rally import exceptions
|
||||||
from tests import fakes
|
from tests import fakes
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
@ -71,10 +72,10 @@ class RoleGeneratorTestCase(test.TestCase):
|
|||||||
ctx = roles.RoleGenerator(self.context)
|
ctx = roles.RoleGenerator(self.context)
|
||||||
ctx.context["users"] = [{"id": "u1", "tenant_id": "t1"},
|
ctx.context["users"] = [{"id": "u1", "tenant_id": "t1"},
|
||||||
{"id": "u2", "tenant_id": "t2"}]
|
{"id": "u2", "tenant_id": "t2"}]
|
||||||
ex = self.assertRaises(Exception, ctx._add_role,
|
ex = self.assertRaises(exceptions.NoSuchRole, ctx._add_role,
|
||||||
mock.MagicMock(), "unknown_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))
|
self.assertEqual(expected, str(ex))
|
||||||
|
|
||||||
@mock.patch("rally.benchmark.context.roles.osclients")
|
@mock.patch("rally.benchmark.context.roles.osclients")
|
||||||
@ -88,8 +89,8 @@ class RoleGeneratorTestCase(test.TestCase):
|
|||||||
mock.call("u1", role["id"], tenant="t1"),
|
mock.call("u1", role["id"], tenant="t1"),
|
||||||
mock.call("u2", role["id"], tenant="t2"),
|
mock.call("u2", role["id"], tenant="t2"),
|
||||||
]
|
]
|
||||||
mock_osclients.Clients().keystone()\
|
mock_keystone = mock_osclients.Clients().keystone()
|
||||||
.roles.remove_user_role.assert_has_calls(calls)
|
mock_keystone.roles.remove_user_role.assert_has_calls(calls)
|
||||||
|
|
||||||
@mock.patch("rally.benchmark.context.roles.osclients")
|
@mock.patch("rally.benchmark.context.roles.osclients")
|
||||||
def test_setup_and_cleanup(self, mock_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"},
|
ctx.context["users"] = [{"id": "u1", "tenant_id": "t1"},
|
||||||
{"id": "u2", "tenant_id": "t2"}]
|
{"id": "u2", "tenant_id": "t2"}]
|
||||||
|
|
||||||
#self, user_id, role_id, tenant):
|
|
||||||
ctx.setup()
|
ctx.setup()
|
||||||
calls = [
|
calls = [
|
||||||
mock.call("u1", "r1", tenant="t1"),
|
mock.call("u1", "r1", tenant="t1"),
|
||||||
|
@ -34,9 +34,9 @@ class SecGroupContextTestCase(test.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(len(fake_nova.security_groups.list()), 2)
|
self.assertEqual(len(fake_nova.security_groups.list()), 2)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
secgroup.SSH_GROUP_NAME in
|
secgroup.SSH_GROUP_NAME in [
|
||||||
[sg.name for sg in fake_nova.security_groups.list()]
|
sg.name for sg in fake_nova.security_groups.list()
|
||||||
)
|
])
|
||||||
|
|
||||||
# run prep again, check that another security group is not created
|
# run prep again, check that another security group is not created
|
||||||
secgroup._prepare_open_secgroup('endpoint')
|
secgroup._prepare_open_secgroup('endpoint')
|
||||||
@ -46,7 +46,7 @@ class SecGroupContextTestCase(test.TestCase):
|
|||||||
def test_prep_ssh_sec_group_rules(self, mock_osclients):
|
def test_prep_ssh_sec_group_rules(self, mock_osclients):
|
||||||
fake_nova = fakes.FakeNovaClient()
|
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)
|
self.assertEqual(len(fake_nova.security_groups.list()), 1)
|
||||||
mock_cl = mock.MagicMock()
|
mock_cl = mock.MagicMock()
|
||||||
mock_cl.nova.return_value = fake_nova
|
mock_cl.nova.return_value = fake_nova
|
||||||
|
@ -14,17 +14,18 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.benchmark.context import users
|
from rally.benchmark.context import users
|
||||||
from rally.benchmark import utils
|
from rally.benchmark import utils
|
||||||
from tests import fakes
|
from tests import fakes
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
|
|
||||||
run_concurrent = lambda dummy, cls, f, args: \
|
run_concurrent = (lambda dummy, cls, f, args: list(
|
||||||
list(itertools.imap(getattr(cls, f), args))
|
itertools.imap(getattr(cls, f), args)))
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(utils, "run_concurrent", run_concurrent)
|
@mock.patch.object(utils, "run_concurrent", run_concurrent)
|
||||||
@ -71,9 +72,9 @@ class UserGeneratorTestCase(test.TestCase):
|
|||||||
tenant2 = mock.MagicMock()
|
tenant2 = mock.MagicMock()
|
||||||
args = (mock.MagicMock(), [tenant1, tenant2])
|
args = (mock.MagicMock(), [tenant1, tenant2])
|
||||||
users.UserGenerator._delete_tenants(args)
|
users.UserGenerator._delete_tenants(args)
|
||||||
mock_osclients.Clients().keystone()\
|
mock_osclients.Clients().keystone().tenants.delete.assert_has_calls([
|
||||||
.tenants.delete.assert_has_calls([mock.call(tenant1["id"]),
|
mock.call(tenant1["id"]),
|
||||||
mock.call(tenant2["id"])])
|
mock.call(tenant2["id"])])
|
||||||
|
|
||||||
@mock.patch("rally.benchmark.context.users.osclients")
|
@mock.patch("rally.benchmark.context.users.osclients")
|
||||||
def test_delete_users(self, mock_osclients):
|
def test_delete_users(self, mock_osclients):
|
||||||
@ -81,9 +82,9 @@ class UserGeneratorTestCase(test.TestCase):
|
|||||||
user2 = mock.MagicMock()
|
user2 = mock.MagicMock()
|
||||||
args = (mock.MagicMock(), [user1, user2])
|
args = (mock.MagicMock(), [user1, user2])
|
||||||
users.UserGenerator._delete_users(args)
|
users.UserGenerator._delete_users(args)
|
||||||
mock_osclients.Clients().keystone()\
|
mock_osclients.Clients().keystone().users.delete.assert_has_calls([
|
||||||
.users.delete.assert_has_calls([mock.call(user1["id"]),
|
mock.call(user1["id"]),
|
||||||
mock.call(user2["id"])])
|
mock.call(user2["id"])])
|
||||||
|
|
||||||
@mock.patch("rally.benchmark.context.users.osclients")
|
@mock.patch("rally.benchmark.context.users.osclients")
|
||||||
def test_setup_and_cleanup(self, mock_osclients):
|
def test_setup_and_cleanup(self, mock_osclients):
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.benchmark.processing import plot
|
from rally.benchmark.processing import plot
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.benchmark.runners import serial
|
from rally.benchmark.runners import serial
|
||||||
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from tests import fakes
|
from tests import fakes
|
||||||
from tests import test
|
from tests import test
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.benchmark.scenarios.ceilometer import queries
|
from rally.benchmark.scenarios.ceilometer import queries
|
||||||
|
@ -82,9 +82,9 @@ class GlanceImagesTestCase(test.TestCase):
|
|||||||
mock_random_name.return_value = "random_name"
|
mock_random_name.return_value = "random_name"
|
||||||
kwargs = {'fakearg': 'f'}
|
kwargs = {'fakearg': 'f'}
|
||||||
with mock.patch("rally.benchmark.scenarios.glance.utils.time.sleep"):
|
with mock.patch("rally.benchmark.scenarios.glance.utils.time.sleep"):
|
||||||
glance_scenario.\
|
glance_scenario.create_image_and_boot_instances("cf", "url",
|
||||||
create_image_and_boot_instances("cf", "url", "df",
|
"df", "fid",
|
||||||
"fid", 5, **kwargs)
|
5, **kwargs)
|
||||||
mock_create_image.assert_called_once_with("random_name", "cf",
|
mock_create_image.assert_called_once_with("random_name", "cf",
|
||||||
"url", "df", **kwargs)
|
"url", "df", **kwargs)
|
||||||
mock_boot_servers.assert_called_once_with("random_name",
|
mock_boot_servers.assert_called_once_with("random_name",
|
||||||
|
@ -90,10 +90,10 @@ class GlanceScenarioTestCase(test.TestCase):
|
|||||||
scenario = utils.GlanceScenario()
|
scenario = utils.GlanceScenario()
|
||||||
scenario._delete_image(self.image)
|
scenario._delete_image(self.image)
|
||||||
self.image.delete.assert_called_once_with()
|
self.image.delete.assert_called_once_with()
|
||||||
self.wait_for_delete.\
|
self.wait_for_delete.mock.assert_called_once_with(
|
||||||
mock.assert_called_once_with(self.image,
|
self.image,
|
||||||
update_resource=self.gfm(),
|
update_resource=self.gfm(),
|
||||||
check_interval=1,
|
check_interval=1,
|
||||||
timeout=120)
|
timeout=120)
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
'glance.delete_image')
|
'glance.delete_image')
|
||||||
|
@ -60,8 +60,9 @@ class HeatScenarioTestCase(test.TestCase):
|
|||||||
|
|
||||||
@mock.patch(HEAT_UTILS + '.HeatScenario.clients')
|
@mock.patch(HEAT_UTILS + '.HeatScenario.clients')
|
||||||
def test_create_stack(self, mock_clients):
|
def test_create_stack(self, mock_clients):
|
||||||
mock_clients("heat").stacks.create.return_value = \
|
mock_clients("heat").stacks.create.return_value = {
|
||||||
{'stack': {'id': 'test_id'}}
|
'stack': {'id': 'test_id'}
|
||||||
|
}
|
||||||
mock_clients("heat").stacks.get.return_value = self.stack
|
mock_clients("heat").stacks.get.return_value = self.stack
|
||||||
scenario = utils.HeatScenario()
|
scenario = utils.HeatScenario()
|
||||||
return_stack = scenario._create_stack('stack_name')
|
return_stack = scenario._create_stack('stack_name')
|
||||||
@ -79,10 +80,10 @@ class HeatScenarioTestCase(test.TestCase):
|
|||||||
scenario = utils.HeatScenario()
|
scenario = utils.HeatScenario()
|
||||||
scenario._delete_stack(self.stack)
|
scenario._delete_stack(self.stack)
|
||||||
self.stack.delete.assert_called_once_with()
|
self.stack.delete.assert_called_once_with()
|
||||||
self.wait_for_delete.\
|
self.wait_for_delete.mock.assert_called_once_with(
|
||||||
mock.assert_called_once_with(self.stack,
|
self.stack,
|
||||||
update_resource=self.gfm(),
|
update_resource=self.gfm(),
|
||||||
check_interval=1,
|
check_interval=1,
|
||||||
timeout=3600)
|
timeout=3600)
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
'heat.delete_stack')
|
'heat.delete_stack')
|
||||||
|
@ -17,10 +17,8 @@ import mock
|
|||||||
|
|
||||||
from rally.benchmark.scenarios.keystone import utils
|
from rally.benchmark.scenarios.keystone import utils
|
||||||
from tests.benchmark.scenarios import test_utils
|
from tests.benchmark.scenarios import test_utils
|
||||||
from tests import test
|
|
||||||
|
|
||||||
from tests import fakes
|
from tests import fakes
|
||||||
|
from tests import test
|
||||||
|
|
||||||
UTILS = "rally.benchmark.scenarios.keystone.utils."
|
UTILS = "rally.benchmark.scenarios.keystone.utils."
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.benchmark.scenarios.neutron import network
|
from rally.benchmark.scenarios.neutron import network
|
||||||
|
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
NEUTRON_NETWORKS = "rally.benchmark.scenarios.neutron.network.NeutronNetworks"
|
NEUTRON_NETWORKS = "rally.benchmark.scenarios.neutron.network.NeutronNetworks"
|
||||||
|
@ -18,7 +18,6 @@ import netaddr
|
|||||||
|
|
||||||
from rally.benchmark.scenarios.neutron import utils
|
from rally.benchmark.scenarios.neutron import utils
|
||||||
from tests.benchmark.scenarios import test_utils
|
from tests.benchmark.scenarios import test_utils
|
||||||
|
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
|
|
||||||
@ -99,8 +98,8 @@ class NeutronScenarioTestCase(test.TestCase):
|
|||||||
# Default options
|
# Default options
|
||||||
subnet_data = {"network_id": network_id}
|
subnet_data = {"network_id": network_id}
|
||||||
scenario._create_subnet(network, subnet_data)
|
scenario._create_subnet(network, subnet_data)
|
||||||
mock_clients("neutron")\
|
mock_clients("neutron").create_subnet.assert_called_once_with(
|
||||||
.create_subnet.assert_called_once_with(expected_subnet_data)
|
expected_subnet_data)
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"neutron.create_subnet")
|
"neutron.create_subnet")
|
||||||
|
|
||||||
@ -111,14 +110,15 @@ class NeutronScenarioTestCase(test.TestCase):
|
|||||||
subnet_data.update(extras)
|
subnet_data.update(extras)
|
||||||
expected_subnet_data["subnet"].update(extras)
|
expected_subnet_data["subnet"].update(extras)
|
||||||
scenario._create_subnet(network, subnet_data)
|
scenario._create_subnet(network, subnet_data)
|
||||||
mock_clients("neutron")\
|
mock_clients("neutron").create_subnet.assert_called_once_with(
|
||||||
.create_subnet.assert_called_once_with(expected_subnet_data)
|
expected_subnet_data)
|
||||||
|
|
||||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario.clients")
|
@mock.patch(NEUTRON_UTILS + "NeutronScenario.clients")
|
||||||
def test_list_subnets(self, mock_clients):
|
def test_list_subnets(self, mock_clients):
|
||||||
subnets = [{"name": "fake1"}, {"name": "fake2"}]
|
subnets = [{"name": "fake1"}, {"name": "fake2"}]
|
||||||
mock_clients("neutron")\
|
mock_clients("neutron").list_subnets.return_value = {
|
||||||
.list_subnets.return_value = {"subnets": subnets}
|
"subnets": subnets
|
||||||
|
}
|
||||||
scenario = utils.NeutronScenario()
|
scenario = utils.NeutronScenario()
|
||||||
result = scenario._list_subnets()
|
result = scenario._list_subnets()
|
||||||
self.assertEqual(subnets, result)
|
self.assertEqual(subnets, result)
|
||||||
|
@ -244,10 +244,10 @@ class NovaServersTestCase(test.TestCase):
|
|||||||
@mock.patch("rally.benchmark.scenarios.nova.servers.random.choice")
|
@mock.patch("rally.benchmark.scenarios.nova.servers.random.choice")
|
||||||
def _verify_boot_server(self, mock_choice, mock_osclients, nic=None,
|
def _verify_boot_server(self, mock_choice, mock_osclients, nic=None,
|
||||||
assert_nic=False):
|
assert_nic=False):
|
||||||
scenario, kwargs, expected_kwargs = \
|
scenario, kwargs, expected_kwargs = self._prepare_boot(
|
||||||
self._prepare_boot(mock_osclients=mock_osclients,
|
mock_osclients=mock_osclients,
|
||||||
mock_choice=mock_choice,
|
mock_choice=mock_choice,
|
||||||
nic=nic, assert_nic=assert_nic)
|
nic=nic, assert_nic=assert_nic)
|
||||||
|
|
||||||
scenario.boot_server("img", 0, **kwargs)
|
scenario.boot_server("img", 0, **kwargs)
|
||||||
scenario._boot_server.assert_called_once_with("name", "img", 0,
|
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,
|
def test_boot_server_from_volume_random_nic(self, mock_choice,
|
||||||
mock_osclients,
|
mock_osclients,
|
||||||
mock_nova_clients):
|
mock_nova_clients):
|
||||||
scenario, kwargs, expected_kwargs = \
|
scenario, kwargs, expected_kwargs = self._prepare_boot(
|
||||||
self._prepare_boot(mock_osclients=mock_osclients,
|
mock_osclients=mock_osclients,
|
||||||
mock_choice=mock_choice,
|
mock_choice=mock_choice,
|
||||||
nic=None, assert_nic=True)
|
nic=None, assert_nic=True)
|
||||||
|
|
||||||
fake_volume = fakes.FakeVolumeManager().create()
|
fake_volume = fakes.FakeVolumeManager().create()
|
||||||
fake_volume.id = "volume_id"
|
fake_volume.id = "volume_id"
|
||||||
|
@ -109,12 +109,12 @@ class NovaScenarioTestCase(test.TestCase):
|
|||||||
mock_clients("nova").images.get.return_value = self.image
|
mock_clients("nova").images.get.return_value = self.image
|
||||||
nova_scenario = utils.NovaScenario()
|
nova_scenario = utils.NovaScenario()
|
||||||
return_image = nova_scenario._create_image(self.server)
|
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.wait_for.mock.assert_called_once_with(
|
||||||
self.image,
|
self.image,
|
||||||
update_resource=self.gfm(),
|
update_resource=self.gfm(),
|
||||||
is_ready=self.res_is.mock(),
|
is_ready=self.res_is.mock(),
|
||||||
check_interval=
|
check_interval=check_interval,
|
||||||
CONF.benchmark.nova_server_image_create_poll_interval,
|
|
||||||
timeout=CONF.benchmark.nova_server_image_create_timeout
|
timeout=CONF.benchmark.nova_server_image_create_timeout
|
||||||
)
|
)
|
||||||
self.res_is.mock.assert_has_calls(mock.call('ACTIVE'))
|
self.res_is.mock.assert_has_calls(mock.call('ACTIVE'))
|
||||||
@ -216,17 +216,16 @@ class NovaScenarioTestCase(test.TestCase):
|
|||||||
self.server1]
|
self.server1]
|
||||||
nova_scenario = utils.NovaScenario()
|
nova_scenario = utils.NovaScenario()
|
||||||
nova_scenario._delete_all_servers()
|
nova_scenario._delete_all_servers()
|
||||||
|
check_interval = CONF.benchmark.nova_server_delete_poll_interval
|
||||||
expected = [
|
expected = [
|
||||||
mock.call(
|
mock.call(
|
||||||
self.server, update_resource=self.gfm(),
|
self.server, update_resource=self.gfm(),
|
||||||
check_interval=
|
check_interval=check_interval,
|
||||||
CONF.benchmark.nova_server_delete_poll_interval,
|
|
||||||
timeout=CONF.benchmark.nova_server_delete_timeout
|
timeout=CONF.benchmark.nova_server_delete_timeout
|
||||||
),
|
),
|
||||||
mock.call(
|
mock.call(
|
||||||
self.server1, update_resource=self.gfm(),
|
self.server1, update_resource=self.gfm(),
|
||||||
check_interval=
|
check_interval=check_interval,
|
||||||
CONF.benchmark.nova_server_delete_poll_interval,
|
|
||||||
timeout=CONF.benchmark.nova_server_delete_timeout
|
timeout=CONF.benchmark.nova_server_delete_timeout
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
@ -238,10 +237,10 @@ class NovaScenarioTestCase(test.TestCase):
|
|||||||
nova_scenario = utils.NovaScenario()
|
nova_scenario = utils.NovaScenario()
|
||||||
nova_scenario._delete_image(self.image)
|
nova_scenario._delete_image(self.image)
|
||||||
self.image.delete.assert_called_once_with()
|
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.wait_for_delete.mock.assert_called_once_with(
|
||||||
self.image, update_resource=self.gfm(),
|
self.image, update_resource=self.gfm(),
|
||||||
check_interval=
|
check_interval=check_interval,
|
||||||
CONF.benchmark.nova_server_image_delete_poll_interval,
|
|
||||||
timeout=CONF.benchmark.nova_server_image_delete_timeout
|
timeout=CONF.benchmark.nova_server_image_delete_timeout
|
||||||
)
|
)
|
||||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
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.benchmark import validation
|
from rally.benchmark import validation
|
||||||
@ -255,8 +256,9 @@ class ScenarioTestCase(test.TestCase):
|
|||||||
"prefix_")
|
"prefix_")
|
||||||
def test_generate_random_name(self):
|
def test_generate_random_name(self):
|
||||||
set_by_length = lambda lst: set(map(len, lst))
|
set_by_length = lambda lst: set(map(len, lst))
|
||||||
len_by_prefix = lambda lst, prefix:\
|
len_by_prefix = (lambda lst, prefix:
|
||||||
len(filter(bool, map(lambda i: i.startswith(prefix), lst)))
|
len(filter(bool, map(lambda i: i.startswith(prefix),
|
||||||
|
lst))))
|
||||||
range_num = 50
|
range_num = 50
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
# 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 jsonschema import exceptions as schema_exceptions
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from jsonschema import exceptions as schema_exceptions
|
|
||||||
from rally.benchmark.scenarios import utils
|
from rally.benchmark.scenarios import utils
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ class BenchmarkEngineTestCase(test.TestCase):
|
|||||||
def test_validate__wrong_scenarios_name(self, mova_validate):
|
def test_validate__wrong_scenarios_name(self, mova_validate):
|
||||||
task = mock.MagicMock()
|
task = mock.MagicMock()
|
||||||
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
||||||
eng._validate_config_scenarios_name = \
|
eng._validate_config_scenarios_name = mock.MagicMock(
|
||||||
mock.MagicMock(side_effect=exceptions.NotFoundScenarios)
|
side_effect=exceptions.NotFoundScenarios)
|
||||||
|
|
||||||
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
||||||
self.assertTrue(task.set_failed.called)
|
self.assertTrue(task.set_failed.called)
|
||||||
@ -78,8 +78,8 @@ class BenchmarkEngineTestCase(test.TestCase):
|
|||||||
task = mock.MagicMock()
|
task = mock.MagicMock()
|
||||||
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
||||||
eng._validate_config_scenarios_name = mock.MagicMock()
|
eng._validate_config_scenarios_name = mock.MagicMock()
|
||||||
eng._validate_config_syntax = \
|
eng._validate_config_syntax = mock.MagicMock(
|
||||||
mock.MagicMock(side_effect=exceptions.InvalidBenchmarkConfig)
|
side_effect=exceptions.InvalidBenchmarkConfig)
|
||||||
|
|
||||||
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
||||||
self.assertTrue(task.set_failed.called)
|
self.assertTrue(task.set_failed.called)
|
||||||
@ -90,8 +90,8 @@ class BenchmarkEngineTestCase(test.TestCase):
|
|||||||
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
eng = engine.BenchmarkEngine(mock.MagicMock(), task)
|
||||||
eng._validate_config_scenarios_name = mock.MagicMock()
|
eng._validate_config_scenarios_name = mock.MagicMock()
|
||||||
eng._validate_config_syntax = mock.MagicMock()
|
eng._validate_config_syntax = mock.MagicMock()
|
||||||
eng._validate_config_semantic = \
|
eng._validate_config_semantic = mock.MagicMock(
|
||||||
mock.MagicMock(side_effect=exceptions.InvalidBenchmarkConfig)
|
side_effect=exceptions.InvalidBenchmarkConfig)
|
||||||
|
|
||||||
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
self.assertRaises(exceptions.InvalidTaskException, eng.validate)
|
||||||
self.assertTrue(task.set_failed.called)
|
self.assertTrue(task.set_failed.called)
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
from rally.benchmark import types
|
from rally.benchmark import types
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
from tests import fakes
|
from tests import fakes
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
@ -32,23 +31,23 @@ class FlavorResourceTypeTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_transform_by_id(self):
|
def test_transform_by_id(self):
|
||||||
resource_config = {"id": 42}
|
resource_config = {"id": 42}
|
||||||
flavor_id = types.FlavorResourceType.transform(clients=self.clients,
|
flavor_id = types.FlavorResourceType.transform(
|
||||||
resource_config=
|
clients=self.clients,
|
||||||
resource_config)
|
resource_config=resource_config)
|
||||||
self.assertEqual(flavor_id, 42)
|
self.assertEqual(flavor_id, 42)
|
||||||
|
|
||||||
def test_transform_by_name(self):
|
def test_transform_by_name(self):
|
||||||
resource_config = {"name": "m1.nano"}
|
resource_config = {"name": "m1.nano"}
|
||||||
flavor_id = types.FlavorResourceType.transform(clients=self.clients,
|
flavor_id = types.FlavorResourceType.transform(
|
||||||
resource_config=
|
clients=self.clients,
|
||||||
resource_config)
|
resource_config=resource_config)
|
||||||
self.assertEqual(flavor_id, 42)
|
self.assertEqual(flavor_id, 42)
|
||||||
|
|
||||||
def test_transform_by_name_to_dest(self):
|
def test_transform_by_name_to_dest(self):
|
||||||
resource_config = {"name": "m1.nano"}
|
resource_config = {"name": "m1.nano"}
|
||||||
flavor_id = types.FlavorResourceType.transform(clients=self.clients,
|
flavor_id = types.FlavorResourceType.transform(
|
||||||
resource_config=
|
clients=self.clients,
|
||||||
resource_config)
|
resource_config=resource_config)
|
||||||
self.assertEqual(flavor_id, 42)
|
self.assertEqual(flavor_id, 42)
|
||||||
|
|
||||||
def test_transform_by_name_no_match(self):
|
def test_transform_by_name_no_match(self):
|
||||||
@ -59,9 +58,9 @@ class FlavorResourceTypeTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_transform_by_regex(self):
|
def test_transform_by_regex(self):
|
||||||
resource_config = {"regex": "m(1|2)\.nano"}
|
resource_config = {"regex": "m(1|2)\.nano"}
|
||||||
flavor_id = types.FlavorResourceType.transform(clients=self.clients,
|
flavor_id = types.FlavorResourceType.transform(
|
||||||
resource_config=
|
clients=self.clients,
|
||||||
resource_config)
|
resource_config=resource_config)
|
||||||
self.assertEqual(flavor_id, 42)
|
self.assertEqual(flavor_id, 42)
|
||||||
|
|
||||||
def test_transform_by_regex_no_match(self):
|
def test_transform_by_regex_no_match(self):
|
||||||
@ -83,23 +82,23 @@ class ImageResourceTypeTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_transform_by_id(self):
|
def test_transform_by_id(self):
|
||||||
resource_config = {"id": 100}
|
resource_config = {"id": 100}
|
||||||
image_id = types.ImageResourceType.transform(clients=self.clients,
|
image_id = types.ImageResourceType.transform(
|
||||||
resource_config=
|
clients=self.clients,
|
||||||
resource_config)
|
resource_config=resource_config)
|
||||||
self.assertEqual(image_id, 100)
|
self.assertEqual(image_id, 100)
|
||||||
|
|
||||||
def test_transform_by_name(self):
|
def test_transform_by_name(self):
|
||||||
resource_config = {"name": "cirros-0.3.1-uec"}
|
resource_config = {"name": "cirros-0.3.1-uec"}
|
||||||
image_id = types.ImageResourceType.transform(clients=self.clients,
|
image_id = types.ImageResourceType.transform(
|
||||||
resource_config=
|
clients=self.clients,
|
||||||
resource_config)
|
resource_config=resource_config)
|
||||||
self.assertEqual(image_id, 100)
|
self.assertEqual(image_id, 100)
|
||||||
|
|
||||||
def test_transform_by_name_to_dest(self):
|
def test_transform_by_name_to_dest(self):
|
||||||
resource_config = {"name": "cirros-0.3.1-uec"}
|
resource_config = {"name": "cirros-0.3.1-uec"}
|
||||||
image_id = types.ImageResourceType.transform(clients=self.clients,
|
image_id = types.ImageResourceType.transform(
|
||||||
resource_config=
|
clients=self.clients,
|
||||||
resource_config)
|
resource_config=resource_config)
|
||||||
self.assertEqual(image_id, 100)
|
self.assertEqual(image_id, 100)
|
||||||
|
|
||||||
def test_transform_by_name_no_match(self):
|
def test_transform_by_name_no_match(self):
|
||||||
@ -110,9 +109,9 @@ class ImageResourceTypeTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_transform_by_regex(self):
|
def test_transform_by_regex(self):
|
||||||
resource_config = {"regex": "-uec$"}
|
resource_config = {"regex": "-uec$"}
|
||||||
image_id = types.ImageResourceType.transform(clients=self.clients,
|
image_id = types.ImageResourceType.transform(
|
||||||
resource_config=
|
clients=self.clients,
|
||||||
resource_config)
|
resource_config=resource_config)
|
||||||
self.assertEqual(image_id, 100)
|
self.assertEqual(image_id, 100)
|
||||||
|
|
||||||
def test_transform_by_regex_no_match(self):
|
def test_transform_by_regex_no_match(self):
|
||||||
|
@ -13,14 +13,14 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from tests import fakes
|
|
||||||
from tests import test
|
import mock
|
||||||
|
|
||||||
from rally.benchmark import utils
|
from rally.benchmark import utils
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
from tests import fakes
|
||||||
|
from tests import test
|
||||||
|
|
||||||
|
|
||||||
class BenchmarkUtilsTestCase(test.TestCase):
|
class BenchmarkUtilsTestCase(test.TestCase):
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from glanceclient import exc as glance_exc
|
from glanceclient import exc as glance_exc
|
||||||
|
import mock
|
||||||
from novaclient import exceptions as nova_exc
|
from novaclient import exceptions as nova_exc
|
||||||
|
|
||||||
from rally.benchmark import validation
|
from rally.benchmark import validation
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.cmd.commands import deployment
|
from rally.cmd.commands import deployment
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from tests import test
|
from tests import test
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.cmd.commands import show
|
from rally.cmd.commands import show
|
||||||
from tests import fakes
|
from tests import fakes
|
||||||
from tests import test
|
from tests import test
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.cmd.commands import task
|
from rally.cmd.commands import task
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from tests import test
|
from tests import test
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.cmd.commands import use
|
from rally.cmd.commands import use
|
||||||
from rally.cmd import envutils
|
from rally.cmd import envutils
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.cmd.commands import verify
|
from rally.cmd.commands import verify
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from tests import test
|
from tests import test
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.cmd import cliutils
|
from rally.cmd import cliutils
|
||||||
|
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
import StringIO
|
import StringIO
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.cmd import envutils
|
from rally.cmd import envutils
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from tests import test
|
from tests import test
|
||||||
@ -94,7 +95,7 @@ class EnvUtilsTestCase(test.TestCase):
|
|||||||
|
|
||||||
@mock.patch.dict(os.environ,
|
@mock.patch.dict(os.environ,
|
||||||
values={envutils.ENV_DEPLOYMENT: 'test_deployment_id',
|
values={envutils.ENV_DEPLOYMENT: 'test_deployment_id',
|
||||||
envutils.ENV_TASK: 'test_task_id'},
|
envutils.ENV_TASK: 'test_task_id'},
|
||||||
clear=True)
|
clear=True)
|
||||||
@mock.patch('os.path.exists')
|
@mock.patch('os.path.exists')
|
||||||
@mock.patch('rally.cmd.envutils.fileutils.update_env_file')
|
@mock.patch('rally.cmd.envutils.fileutils.update_env_file')
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.cmd import manage
|
from rally.cmd import manage
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
import mock
|
import mock
|
||||||
import uuid
|
|
||||||
|
|
||||||
from rally.deploy.engines import devstack
|
from rally.deploy.engines import devstack
|
||||||
from tests import test
|
from tests import test
|
||||||
|
@ -163,13 +163,13 @@ class LxcHostTestCase(test.TestCase):
|
|||||||
self.assertEqual(['name'], self.host.containers)
|
self.assertEqual(['name'], self.host.containers)
|
||||||
self.host.configure_container.assert_called_once_with('name')
|
self.host.configure_container.assert_called_once_with('name')
|
||||||
|
|
||||||
#check with no btrfs
|
# check with no btrfs
|
||||||
self.host._backingstore = ''
|
self.host._backingstore = ''
|
||||||
self.host.create_container('name', 'dist')
|
self.host.create_container('name', 'dist')
|
||||||
self.assertEqual(mock.call('lxc-create -n name -t dist'),
|
self.assertEqual(mock.call('lxc-create -n name -t dist'),
|
||||||
self.server.ssh.run.mock_calls[1])
|
self.server.ssh.run.mock_calls[1])
|
||||||
|
|
||||||
#check release
|
# check release
|
||||||
self.host.create_container('name', 'ubuntu', 'raring')
|
self.host.create_container('name', 'ubuntu', 'raring')
|
||||||
self.host.create_container('name', 'debian', 'woody')
|
self.host.create_container('name', 'debian', 'woody')
|
||||||
expected = [mock.call('lxc-create -n name -t ubuntu -- -r raring'),
|
expected = [mock.call('lxc-create -n name -t ubuntu -- -r raring'),
|
||||||
@ -184,7 +184,7 @@ class LxcHostTestCase(test.TestCase):
|
|||||||
' -o src -n name')
|
' -o src -n name')
|
||||||
self.assertEqual(['name'], self.host.containers)
|
self.assertEqual(['name'], self.host.containers)
|
||||||
|
|
||||||
#check with no btrfs
|
# check with no btrfs
|
||||||
self.host._backingstore = ''
|
self.host._backingstore = ''
|
||||||
self.host.create_clone('name', 'src')
|
self.host.create_clone('name', 'src')
|
||||||
self.assertEqual(mock.call('lxc-clone -o src -n name'),
|
self.assertEqual(mock.call('lxc-clone -o src -n name'),
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
"""Tests for OpenStack VM provider."""
|
"""Tests for OpenStack VM provider."""
|
||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslotest import mockpatch
|
from oslotest import mockpatch
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
import netaddr
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import jsonschema
|
||||||
import mock
|
import mock
|
||||||
|
import netaddr
|
||||||
from oslotest import mockpatch
|
from oslotest import mockpatch
|
||||||
|
|
||||||
from rally.deploy.serverprovider.providers import virsh
|
from rally.deploy.serverprovider.providers import virsh
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
|
|
||||||
"""Test for deploy engines."""
|
"""Test for deploy engines."""
|
||||||
|
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import deploy
|
from rally import deploy
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import deploy
|
from rally import deploy
|
||||||
from tests import fakes
|
from tests import fakes
|
||||||
|
@ -19,12 +19,12 @@ import re
|
|||||||
import string
|
import string
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
from ceilometerclient import exc as ceilometer_exc
|
from ceilometerclient import exc as ceilometer_exc
|
||||||
from glanceclient import exc
|
from glanceclient import exc
|
||||||
|
import mock
|
||||||
from neutronclient.common import exceptions as neutron_exceptions
|
from neutronclient.common import exceptions as neutron_exceptions
|
||||||
from novaclient import exceptions as nova_exceptions
|
from novaclient import exceptions as nova_exceptions
|
||||||
|
|
||||||
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.objects import endpoint
|
from rally.objects import endpoint
|
||||||
@ -57,6 +57,7 @@ def generate_mac():
|
|||||||
|
|
||||||
def setup_dict(data, required=None, defaults=None):
|
def setup_dict(data, required=None, defaults=None):
|
||||||
"""Setup and validate dict based on mandatory keys and default data.
|
"""Setup and validate dict based on mandatory keys and default data.
|
||||||
|
|
||||||
This function reduces code that constructs dict objects
|
This function reduces code that constructs dict objects
|
||||||
with specific schema (e.g. for API data).
|
with specific schema (e.g. for API data).
|
||||||
|
|
||||||
@ -620,8 +621,8 @@ class FakeNeutronClient(object):
|
|||||||
def add_interface_router(self, router_id, data):
|
def add_interface_router(self, router_id, data):
|
||||||
subnet_id = data["subnet_id"]
|
subnet_id = data["subnet_id"]
|
||||||
|
|
||||||
if router_id not in self.__routers\
|
if (router_id not in self.__routers or
|
||||||
or subnet_id not in self.__subnets:
|
subnet_id not in self.__subnets):
|
||||||
raise neutron_exceptions.NeutronClientException
|
raise neutron_exceptions.NeutronClientException
|
||||||
|
|
||||||
subnet = self.__subnets[subnet_id]
|
subnet = self.__subnets[subnet_id]
|
||||||
@ -769,8 +770,8 @@ class FakeNeutronClient(object):
|
|||||||
def remove_interface_router(self, router_id, data):
|
def remove_interface_router(self, router_id, data):
|
||||||
subnet_id = data["subnet_id"]
|
subnet_id = data["subnet_id"]
|
||||||
|
|
||||||
if router_id not in self.__routers\
|
if (router_id not in self.__routers
|
||||||
or subnet_id not in self.__subnets:
|
or subnet_id not in self.__subnets):
|
||||||
raise neutron_exceptions.NeutronClientException
|
raise neutron_exceptions.NeutronClientException
|
||||||
|
|
||||||
subnet = self.__subnets[subnet_id]
|
subnet = self.__subnets[subnet_id]
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
|
|
||||||
"""Tests for db.deploy layer."""
|
"""Tests for db.deploy layer."""
|
||||||
|
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import objects
|
from rally import objects
|
||||||
from tests import test
|
from tests import test
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
"""Tests for db.task layer."""
|
"""Tests for db.task layer."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import objects
|
from rally import objects
|
||||||
from tests import test
|
from tests import test
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
|
|
||||||
""" Test for orchestrator. """
|
""" Test for orchestrator. """
|
||||||
|
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.benchmark.scenarios import base
|
from rally.benchmark.scenarios import base
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.orchestrator import api
|
from rally.orchestrator import api
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from oslotest import base
|
from oslotest import base
|
||||||
|
|
||||||
from rally import db
|
from rally import db
|
||||||
|
@ -12,9 +12,11 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally import fileutils
|
from rally import fileutils
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
|
@ -13,12 +13,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import copy
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.deploy.fuel import fuelclient
|
from rally.deploy.fuel import fuelclient
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
import copy
|
|
||||||
import mock
|
|
||||||
|
|
||||||
|
|
||||||
class FuelNodeTestCase(test.TestCase):
|
class FuelNodeTestCase(test.TestCase):
|
||||||
|
|
||||||
|
@ -13,9 +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.
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
from keystoneclient import exceptions as keystone_exceptions
|
from keystoneclient import exceptions as keystone_exceptions
|
||||||
|
import mock
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
@ -49,8 +48,8 @@ class OSClientsTestCase(test.TestCase):
|
|||||||
@mock.patch("rally.osclients.Clients.keystone")
|
@mock.patch("rally.osclients.Clients.keystone")
|
||||||
def test_verified_keystone_user_not_admin(self, mock_keystone):
|
def test_verified_keystone_user_not_admin(self, mock_keystone):
|
||||||
mock_keystone.return_value = fakes.FakeKeystoneClient()
|
mock_keystone.return_value = fakes.FakeKeystoneClient()
|
||||||
mock_keystone.return_value.auth_ref["user"]["roles"] = \
|
mock_keystone.return_value.auth_ref["user"]["roles"] = [{"name":
|
||||||
[{"name": "notadmin"}]
|
"notadmin"}]
|
||||||
self.assertRaises(exceptions.InvalidAdminException,
|
self.assertRaises(exceptions.InvalidAdminException,
|
||||||
self.clients.verified_keystone)
|
self.clients.verified_keystone)
|
||||||
|
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
"""Test for Rally utils."""
|
"""Test for Rally utils."""
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import mock
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.openstack.common.gettextutils import _
|
from rally.openstack.common.gettextutils import _
|
||||||
from rally import utils
|
from rally import utils
|
||||||
|
@ -13,8 +13,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import mock
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from six.moves import http_client as httplib
|
from six.moves import http_client as httplib
|
||||||
|
|
||||||
@ -78,10 +79,11 @@ class ConfigTestCase(test.TestCase):
|
|||||||
service = "test_service"
|
service = "test_service"
|
||||||
url = "test_url"
|
url = "test_url"
|
||||||
# mocked at setUp
|
# mocked at setUp
|
||||||
self.conf_generator.keystoneclient.auth_ref = {"serviceCatalog":
|
self.conf_generator.keystoneclient.auth_ref = {
|
||||||
[{"name": service,
|
"serviceCatalog": [{
|
||||||
"endpoints":
|
"name": service,
|
||||||
[{"publicURL": url}]}]}
|
"endpoints": [{"publicURL": url}]
|
||||||
|
}]}
|
||||||
self.assertEqual(self.conf_generator._get_url(service), url)
|
self.assertEqual(self.conf_generator._get_url(service), url)
|
||||||
|
|
||||||
@mock.patch("rally.verification.verifiers.tempest.config.TempestConf"
|
@mock.patch("rally.verification.verifiers.tempest.config.TempestConf"
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from rally.verification.verifiers.tempest import tempest
|
from rally.verification.verifiers.tempest import tempest
|
||||||
from tests import test
|
from tests import test
|
||||||
|
|
||||||
|
@ -14,13 +14,14 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
|
|
||||||
"""Test rally command line interface.
|
"""Test rally command line interface.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user