Merge "Refactor Move atomic actions from benchmark scenarios"
This commit is contained in:
@@ -83,22 +83,22 @@ In a toy example below, we define a scenario class *MyScenario* with one benchma
|
||||
|
||||
::
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios import utils
|
||||
|
||||
|
||||
class MyScenario(base.Scenario):
|
||||
class MyScenario(scenario_base.Scenario):
|
||||
"""My class that contains benchmark scenarios."""
|
||||
|
||||
@utils.atomic_action_timer("action_1")
|
||||
@scenario_base.atomic_action_timer("action_1")
|
||||
def _action_1(self, **kwargs):
|
||||
"""Do something with the cloud."""
|
||||
|
||||
@utils.atomic_action_timer("action_2")
|
||||
@scenario_base.atomic_action_timer("action_2")
|
||||
def _action_2(self, **kwargs):
|
||||
"""Do something with the cloud."""
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
def scenario(self, **kwargs):
|
||||
self._action_1()
|
||||
self._action_2()
|
||||
@@ -357,21 +357,20 @@ benchmark scenario results have been stored correctly.
|
||||
import random
|
||||
import time
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
|
||||
|
||||
class PluginClass(base.Scenario):
|
||||
|
||||
@scenario_utils.atomic_action_timer("test1")
|
||||
@scenario_base.atomic_action_timer("test1")
|
||||
def _test1(self, factor):
|
||||
time.sleep(random.random() * factor)
|
||||
|
||||
@scenario_utils.atomic_action_timer("test2")
|
||||
@scenario_base.atomic_action_timer("test2")
|
||||
def _test2(self, factor):
|
||||
time.sleep(random.random() * factor * 10)
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
def testplugin(self, factor=1):
|
||||
self._test1(factor)
|
||||
self._test2(factor)
|
||||
|
||||
@@ -17,21 +17,20 @@
|
||||
import random
|
||||
import time
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
|
||||
|
||||
class FakePlugin(base.Scenario):
|
||||
class FakePlugin(scenario_base.Scenario):
|
||||
|
||||
@scenario_utils.atomic_action_timer("test1")
|
||||
@scenario_base.atomic_action_timer("test1")
|
||||
def _test1(self, factor):
|
||||
time.sleep(random.random())
|
||||
|
||||
@scenario_utils.atomic_action_timer("test2")
|
||||
@scenario_base.atomic_action_timer("test2")
|
||||
def _test2(self, factor):
|
||||
time.sleep(random.random() * factor * 10)
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
def testplugin(self, factor=1):
|
||||
self._test1(factor)
|
||||
self._test2(factor)
|
||||
|
||||
@@ -22,7 +22,7 @@ import jsonschema
|
||||
from oslo.config import cfg
|
||||
|
||||
from rally.benchmark.context import base as base_ctx
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import utils
|
||||
from rally import consts
|
||||
from rally import exceptions
|
||||
@@ -199,7 +199,7 @@ class ScenarioRunner(object):
|
||||
|
||||
def run(self, name, context, args):
|
||||
cls_name, method_name = name.split(".", 1)
|
||||
cls = base.Scenario.get_by_name(cls_name)
|
||||
cls = scenario_base.Scenario.get_by_name(cls_name)
|
||||
|
||||
scenario_context = copy.deepcopy(getattr(cls, method_name).context)
|
||||
# TODO(boris-42): We should keep default behavior for `users` context
|
||||
|
||||
@@ -12,23 +12,22 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import validation
|
||||
|
||||
|
||||
class Authenticate(base.Scenario):
|
||||
class Authenticate(scenario_base.Scenario):
|
||||
"""This class should contain authentication mechanism.
|
||||
|
||||
For different types of clients like Keystone.
|
||||
"""
|
||||
|
||||
@base.scenario()
|
||||
@scenario_utils.atomic_action_timer('authenticate.keystone')
|
||||
@scenario_base.scenario()
|
||||
@scenario_base.atomic_action_timer('authenticate.keystone')
|
||||
def keystone(self, **kwargs):
|
||||
self.clients("keystone")
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_glance(self, repetitions):
|
||||
"""Check Glance Client to ensure validation of token.
|
||||
@@ -42,11 +41,11 @@ class Authenticate(base.Scenario):
|
||||
glance_client = self.clients("glance")
|
||||
image_name = "__intentionally_non_existent_image___"
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_glance'):
|
||||
with scenario_base.AtomicAction(self,
|
||||
'authenticate.validate_glance'):
|
||||
list(glance_client.images.list(name=image_name))
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_nova(self, repetitions):
|
||||
"""Check Nova Client to ensure validation of token.
|
||||
@@ -58,11 +57,11 @@ class Authenticate(base.Scenario):
|
||||
"""
|
||||
nova_client = self.clients("nova")
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_nova'):
|
||||
with scenario_base.AtomicAction(self,
|
||||
'authenticate.validate_nova'):
|
||||
nova_client.flavors.list()
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_cinder(self, repetitions):
|
||||
"""Check Cinder Client to ensure validation of token.
|
||||
@@ -74,11 +73,11 @@ class Authenticate(base.Scenario):
|
||||
"""
|
||||
cinder_client = self.clients("cinder")
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_cinder'):
|
||||
with scenario_base.AtomicAction(self,
|
||||
'authenticate.validate_cinder'):
|
||||
cinder_client.volume_types.list()
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_neutron(self, repetitions):
|
||||
"""Check Neutron Client to ensure validation of token.
|
||||
@@ -90,11 +89,11 @@ class Authenticate(base.Scenario):
|
||||
"""
|
||||
neutron_client = self.clients("neutron")
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_neutron'):
|
||||
with scenario_base.AtomicAction(self,
|
||||
'authenticate.validate_neutron'):
|
||||
neutron_client.get_auth_info()
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
@validation.add(validation.required_parameters(['repetitions']))
|
||||
def validate_heat(self, repetitions):
|
||||
"""Check Heat Client to ensure validation of token.
|
||||
@@ -106,6 +105,6 @@ class Authenticate(base.Scenario):
|
||||
"""
|
||||
heat_client = self.clients("heat")
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(self,
|
||||
'authenticate.validate_heat'):
|
||||
with scenario_base.AtomicAction(self,
|
||||
'authenticate.validate_heat'):
|
||||
list(heat_client.stacks.list(limit=0))
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import functools
|
||||
import itertools
|
||||
import random
|
||||
import string
|
||||
@@ -213,3 +214,47 @@ class Scenario(object):
|
||||
def atomic_actions(self):
|
||||
"""Returns the content of each atomic action."""
|
||||
return self._atomic_actions
|
||||
|
||||
|
||||
def atomic_action_timer(name):
|
||||
"""Provide measure of execution time.
|
||||
|
||||
Decorates methods of the Scenario class.
|
||||
This provides duration in seconds of each atomic action.
|
||||
"""
|
||||
def wrap(func):
|
||||
@functools.wraps(func)
|
||||
def func_atomic_actions(self, *args, **kwargs):
|
||||
with utils.Timer() as timer:
|
||||
f = func(self, *args, **kwargs)
|
||||
self._add_atomic_actions(name, timer.duration())
|
||||
return f
|
||||
return func_atomic_actions
|
||||
return wrap
|
||||
|
||||
|
||||
class AtomicAction(utils.Timer):
|
||||
"""A class to measure the duration of atomic operations
|
||||
|
||||
This would simplify the way measure atomic opeation duration
|
||||
in certain cases. For example if we want to get the duration
|
||||
for each operation which runs in an iteration
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(instance_of_base_scenario_subclass,
|
||||
"name_of_action"):
|
||||
self.clients(<client>).<operation>
|
||||
"""
|
||||
|
||||
def __init__(self, scenario_instance, name):
|
||||
"""Create a new instance of the AtomicAction.
|
||||
|
||||
:param scenario_instance: instance of subclass of base scenario
|
||||
:param name: name of the ActionBuilder
|
||||
"""
|
||||
super(AtomicAction, self).__init__()
|
||||
self.scenario_instance = scenario_instance
|
||||
self.name = name
|
||||
|
||||
def __exit__(self, type, value, tb):
|
||||
super(AtomicAction, self).__exit__(type, value, tb)
|
||||
self.scenario_instance._add_atomic_actions(self.name, self.duration())
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.ceilometer import utils as ceilometerutils
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
|
||||
|
||||
class CeilometerAlarms(ceilometerutils.CeilometerScenario):
|
||||
@base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def create_alarm(self, meter_name, threshold, **kwargs):
|
||||
"""Test creating an alarm.
|
||||
@@ -34,7 +34,7 @@ class CeilometerAlarms(ceilometerutils.CeilometerScenario):
|
||||
"""
|
||||
self._create_alarm(meter_name, threshold, kwargs)
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def list_alarms(self):
|
||||
"""Test fetching all alarms.
|
||||
@@ -43,7 +43,7 @@ class CeilometerAlarms(ceilometerutils.CeilometerScenario):
|
||||
"""
|
||||
self._list_alarms()
|
||||
|
||||
@base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def create_and_list_alarm(self, meter_name, threshold, **kwargs):
|
||||
"""Test creating and getting newly created alarm.
|
||||
@@ -60,7 +60,7 @@ class CeilometerAlarms(ceilometerutils.CeilometerScenario):
|
||||
alarm = self._create_alarm(meter_name, threshold, kwargs)
|
||||
self._list_alarms(alarm.alarm_id)
|
||||
|
||||
@base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def create_and_update_alarm(self, meter_name, threshold, **kwargs):
|
||||
"""Test creating and updating the newly created alarm.
|
||||
@@ -78,7 +78,7 @@ class CeilometerAlarms(ceilometerutils.CeilometerScenario):
|
||||
alarm_dict_diff = {"description": "Changed Test Description"}
|
||||
self._update_alarm(alarm.alarm_id, alarm_dict_diff)
|
||||
|
||||
@base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def create_and_delete_alarm(self, meter_name, threshold, **kwargs):
|
||||
"""Test creating and deleting the newly created alarm.
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.ceilometer import utils as ceilometerutils
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
|
||||
|
||||
class CeilometerMeters(ceilometerutils.CeilometerScenario):
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def list_meters(self):
|
||||
"""Test fetching user's meters."""
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
|
||||
import json
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.ceilometer import utils as ceilometerutils
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
|
||||
|
||||
class CeilometerQueries(ceilometerutils.CeilometerScenario):
|
||||
@base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def create_and_query_alarms(self, meter_name, threshold, filter=None,
|
||||
orderby=None, limit=None, **kwargs):
|
||||
@@ -42,7 +42,7 @@ class CeilometerQueries(ceilometerutils.CeilometerScenario):
|
||||
self._create_alarm(meter_name, threshold, kwargs)
|
||||
self._query_alarms(filter, orderby, limit)
|
||||
|
||||
@base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def create_and_query_alarm_history(self, meter_name, threshold,
|
||||
orderby=None, limit=None, **kwargs):
|
||||
@@ -61,7 +61,7 @@ class CeilometerQueries(ceilometerutils.CeilometerScenario):
|
||||
alarm_filter = json.dumps({"=": {"alarm_id": alarm.alarm_id}})
|
||||
self._query_alarm_history(alarm_filter, orderby, limit)
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def create_and_query_samples(self, counter_name, counter_type,
|
||||
counter_unit, counter_volume, resource_id,
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.ceilometer import utils as ceilometerutils
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
|
||||
|
||||
class CeilometerResource(ceilometerutils.CeilometerScenario):
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def list_resources(self):
|
||||
"""Test fetching all resources.
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.ceilometer import utils
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
|
||||
|
||||
class CeilometerStats(utils.CeilometerScenario):
|
||||
@base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
|
||||
@validation.required_services(consts.Service.CEILOMETER)
|
||||
def create_meter_and_get_stats(self, **kwargs):
|
||||
"""Test creating a meter and fetching its statistics.
|
||||
|
||||
@@ -12,11 +12,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
|
||||
|
||||
class CeilometerScenario(base.Scenario):
|
||||
class CeilometerScenario(scenario_base.Scenario):
|
||||
RESOURCE_NAME_PREFIX = "rally_ceilometer_"
|
||||
|
||||
def _get_alarm_dict(self, **kwargs):
|
||||
@@ -33,7 +32,7 @@ class CeilometerScenario(base.Scenario):
|
||||
alarm.update(kwargs)
|
||||
return alarm
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.list_alarms')
|
||||
@scenario_base.atomic_action_timer('ceilometer.list_alarms')
|
||||
def _list_alarms(self, alarm_id=None):
|
||||
"""List alarms.
|
||||
|
||||
@@ -47,7 +46,7 @@ class CeilometerScenario(base.Scenario):
|
||||
else:
|
||||
return self.clients("ceilometer").alarms.list()
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.create_alarm')
|
||||
@scenario_base.atomic_action_timer('ceilometer.create_alarm')
|
||||
def _create_alarm(self, meter_name, threshold, kwargs):
|
||||
"""Create an alarm.
|
||||
|
||||
@@ -62,7 +61,7 @@ class CeilometerScenario(base.Scenario):
|
||||
alarm = self.clients("ceilometer").alarms.create(**alarm_dict)
|
||||
return alarm
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.delete_alarm')
|
||||
@scenario_base.atomic_action_timer('ceilometer.delete_alarm')
|
||||
def _delete_alarm(self, alarm_id):
|
||||
"""Deletes an alarm.
|
||||
|
||||
@@ -70,7 +69,7 @@ class CeilometerScenario(base.Scenario):
|
||||
"""
|
||||
self.clients("ceilometer").alarms.delete(alarm_id)
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.update_alarm')
|
||||
@scenario_base.atomic_action_timer('ceilometer.update_alarm')
|
||||
def _update_alarm(self, alarm_id, alarm_dict_delta):
|
||||
"""Updates an alarm.
|
||||
|
||||
@@ -79,12 +78,12 @@ class CeilometerScenario(base.Scenario):
|
||||
"""
|
||||
self.clients("ceilometer").alarms.update(alarm_id, **alarm_dict_delta)
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.get_meters')
|
||||
@scenario_base.atomic_action_timer('ceilometer.get_meters')
|
||||
def _list_meters(self):
|
||||
"""Get list of user's meters."""
|
||||
return self.clients("ceilometer").meters.list()
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.list_resources')
|
||||
@scenario_base.atomic_action_timer('ceilometer.list_resources')
|
||||
def _list_resources(self):
|
||||
"""List all resources.
|
||||
|
||||
@@ -92,7 +91,7 @@ class CeilometerScenario(base.Scenario):
|
||||
"""
|
||||
return self.clients("ceilometer").resources.list()
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.get_stats')
|
||||
@scenario_base.atomic_action_timer('ceilometer.get_stats')
|
||||
def _get_stats(self, meter_name):
|
||||
"""Get stats for a specific meter.
|
||||
|
||||
@@ -100,7 +99,7 @@ class CeilometerScenario(base.Scenario):
|
||||
"""
|
||||
return self.clients("ceilometer").statistics.list(meter_name)
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.create_meter')
|
||||
@scenario_base.atomic_action_timer('ceilometer.create_meter')
|
||||
def _create_meter(self, **kwargs):
|
||||
"""Create a new meter.
|
||||
|
||||
@@ -113,7 +112,7 @@ class CeilometerScenario(base.Scenario):
|
||||
counter_name=name, **kwargs)
|
||||
return samples[0]
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.query_alarms')
|
||||
@scenario_base.atomic_action_timer('ceilometer.query_alarms')
|
||||
def _query_alarms(self, filter, orderby, limit):
|
||||
"""Query alarms with specific parameters.
|
||||
|
||||
@@ -126,7 +125,7 @@ class CeilometerScenario(base.Scenario):
|
||||
return self.clients("ceilometer").query_alarms.query(
|
||||
filter, orderby, limit)
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.query_alarm_history')
|
||||
@scenario_base.atomic_action_timer('ceilometer.query_alarm_history')
|
||||
def _query_alarm_history(self, filter, orderby, limit):
|
||||
"""Query history of an alarm.
|
||||
|
||||
@@ -139,7 +138,7 @@ class CeilometerScenario(base.Scenario):
|
||||
return self.clients("ceilometer").query_alarm_history.query(
|
||||
filter, orderby, limit)
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.create_sample')
|
||||
@scenario_base.atomic_action_timer('ceilometer.create_sample')
|
||||
def _create_sample(self, counter_name, counter_type, counter_unit,
|
||||
counter_volume, resource_id, **kwargs):
|
||||
"""Creates a Sample with specified parameters.
|
||||
@@ -159,7 +158,7 @@ class CeilometerScenario(base.Scenario):
|
||||
"resource_id": resource_id})
|
||||
return self.clients("ceilometer").samples.create(**kwargs)
|
||||
|
||||
@scenario_utils.atomic_action_timer('ceilometer.query_samples')
|
||||
@scenario_base.atomic_action_timer('ceilometer.query_samples')
|
||||
def _query_samples(self, filter, orderby, limit):
|
||||
"""Query samples with specified parameters.
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ import time
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import utils as bench_utils
|
||||
|
||||
|
||||
@@ -48,17 +47,17 @@ benchmark_group = cfg.OptGroup(name='benchmark', title='benchmark options')
|
||||
CONF.register_opts(cinder_benchmark_opts, group=benchmark_group)
|
||||
|
||||
|
||||
class CinderScenario(base.Scenario):
|
||||
class CinderScenario(scenario_base.Scenario):
|
||||
|
||||
RESOURCE_NAME_PREFIX = "rally_volume_"
|
||||
|
||||
@scenario_utils.atomic_action_timer('cinder.list_volumes')
|
||||
@scenario_base.atomic_action_timer('cinder.list_volumes')
|
||||
def _list_volumes(self, detailed=True):
|
||||
"""Returns user volumes list."""
|
||||
|
||||
return self.clients("cinder").volumes.list(detailed)
|
||||
|
||||
@scenario_utils.atomic_action_timer('cinder.create_volume')
|
||||
@scenario_base.atomic_action_timer('cinder.create_volume')
|
||||
def _create_volume(self, size, **kwargs):
|
||||
"""create one volume.
|
||||
|
||||
@@ -85,7 +84,7 @@ class CinderScenario(base.Scenario):
|
||||
)
|
||||
return volume
|
||||
|
||||
@scenario_utils.atomic_action_timer('cinder.delete_volume')
|
||||
@scenario_base.atomic_action_timer('cinder.delete_volume')
|
||||
def _delete_volume(self, volume):
|
||||
"""Delete the given volume.
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.cinder import utils
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
@@ -21,7 +21,7 @@ from rally import consts
|
||||
|
||||
class CinderVolumes(utils.CinderScenario):
|
||||
|
||||
@base.scenario(context={"cleanup": ["cinder"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["cinder"]})
|
||||
@validation.required_services(consts.Service.CINDER)
|
||||
def create_and_list_volume(self, size, detailed=True, **kwargs):
|
||||
"""Tests creating a volume and listing volumes.
|
||||
@@ -39,7 +39,7 @@ class CinderVolumes(utils.CinderScenario):
|
||||
self._create_volume(size, **kwargs)
|
||||
self._list_volumes(detailed)
|
||||
|
||||
@base.scenario(context={"cleanup": ["cinder"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["cinder"]})
|
||||
@validation.required_services(consts.Service.CINDER)
|
||||
def create_and_delete_volume(self, size, min_sleep=0, max_sleep=0,
|
||||
**kwargs):
|
||||
@@ -52,7 +52,7 @@ class CinderVolumes(utils.CinderScenario):
|
||||
self.sleep_between(min_sleep, max_sleep)
|
||||
self._delete_volume(volume)
|
||||
|
||||
@base.scenario(context={"cleanup": ["cinder"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["cinder"]})
|
||||
@validation.required_services(consts.Service.CINDER)
|
||||
def create_volume(self, size, **kwargs):
|
||||
"""Test creating volumes perfromance.
|
||||
|
||||
@@ -13,15 +13,15 @@
|
||||
import random
|
||||
import time
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import validation
|
||||
from rally import exceptions
|
||||
|
||||
|
||||
class Dummy(base.Scenario):
|
||||
class Dummy(scenario_base.Scenario):
|
||||
"""Benchmarks for testing Rally benchmark engine at scale."""
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
def dummy(self, sleep=0):
|
||||
"""Test the performance of ScenarioRunners.
|
||||
|
||||
@@ -36,7 +36,7 @@ class Dummy(base.Scenario):
|
||||
|
||||
@validation.add(validation.number("size_of_message", minval=1,
|
||||
integer_only=True, nullable=True))
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
def dummy_exception(self, size_of_message=1):
|
||||
"""Test if exceptions are processed properly.
|
||||
|
||||
@@ -52,7 +52,7 @@ class Dummy(base.Scenario):
|
||||
@validation.add(validation.number("exception_probability", minval=0,
|
||||
maxval=1, integer_only=False,
|
||||
nullable=True))
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
def dummy_exception_probability(self, exception_probability=0.5):
|
||||
"""Test if exceptions are processed properly.
|
||||
|
||||
@@ -69,7 +69,7 @@ class Dummy(base.Scenario):
|
||||
% exception_probability
|
||||
)
|
||||
|
||||
@base.scenario()
|
||||
@scenario_base.scenario()
|
||||
def dummy_with_scenario_output(self):
|
||||
out = {
|
||||
'value_1': random.randint(1, 100),
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.glance import utils
|
||||
from rally.benchmark.scenarios.nova import utils as nova_utils
|
||||
from rally.benchmark import types as types
|
||||
@@ -26,7 +26,7 @@ class GlanceImages(utils.GlanceScenario, nova_utils.NovaScenario):
|
||||
RESOURCE_NAME_PREFIX = "rally_image_"
|
||||
RESOURCE_NAME_LENGTH = 16
|
||||
|
||||
@base.scenario(context={"cleanup": ["glance"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["glance"]})
|
||||
@validation.required_services(consts.Service.GLANCE)
|
||||
def create_and_list_image(self, container_format,
|
||||
image_location, disk_format, **kwargs):
|
||||
@@ -48,7 +48,7 @@ class GlanceImages(utils.GlanceScenario, nova_utils.NovaScenario):
|
||||
**kwargs)
|
||||
self._list_images()
|
||||
|
||||
@base.scenario(context={"cleanup": ["glance"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["glance"]})
|
||||
@validation.required_services(consts.Service.GLANCE)
|
||||
def list_images(self):
|
||||
"""Test the glance image-list command.
|
||||
@@ -63,7 +63,7 @@ class GlanceImages(utils.GlanceScenario, nova_utils.NovaScenario):
|
||||
|
||||
self._list_images()
|
||||
|
||||
@base.scenario(context={"cleanup": ["glance"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["glance"]})
|
||||
@validation.required_services(consts.Service.GLANCE)
|
||||
def create_and_delete_image(self, container_format,
|
||||
image_location, disk_format, **kwargs):
|
||||
@@ -79,7 +79,7 @@ class GlanceImages(utils.GlanceScenario, nova_utils.NovaScenario):
|
||||
@types.set(flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.flavor_exists("flavor"))
|
||||
@validation.required_services(consts.Service.GLANCE, consts.Service.NOVA)
|
||||
@base.scenario(context={"cleanup": ["glance", "nova"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["glance", "nova"]})
|
||||
def create_image_and_boot_instances(self, container_format,
|
||||
image_location, disk_format,
|
||||
flavor, number_instances,
|
||||
|
||||
@@ -18,8 +18,7 @@ import time
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import utils as bench_utils
|
||||
|
||||
|
||||
@@ -50,15 +49,15 @@ benchmark_group = cfg.OptGroup(name='benchmark', title='benchmark options')
|
||||
CONF.register_opts(glance_benchmark_opts, group=benchmark_group)
|
||||
|
||||
|
||||
class GlanceScenario(base.Scenario):
|
||||
class GlanceScenario(scenario_base.Scenario):
|
||||
|
||||
@scenario_utils.atomic_action_timer('glance.list_images')
|
||||
@scenario_base.atomic_action_timer('glance.list_images')
|
||||
def _list_images(self):
|
||||
"""Returns user images list."""
|
||||
|
||||
return list(self.clients("glance").images.list())
|
||||
|
||||
@scenario_utils.atomic_action_timer('glance.create_image')
|
||||
@scenario_base.atomic_action_timer('glance.create_image')
|
||||
def _create_image(self, image_name, container_format,
|
||||
image_location, disk_format, **kwargs):
|
||||
"""Create a new image.
|
||||
@@ -106,7 +105,7 @@ class GlanceScenario(base.Scenario):
|
||||
|
||||
return image
|
||||
|
||||
@scenario_utils.atomic_action_timer('glance.delete_image')
|
||||
@scenario_base.atomic_action_timer('glance.delete_image')
|
||||
def _delete_image(self, image):
|
||||
"""Deletes the given image.
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.heat import utils
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
@@ -35,7 +35,7 @@ class HeatStacks(utils.HeatScenario):
|
||||
% {"template_path": template_path})
|
||||
return template
|
||||
|
||||
@base.scenario(context={"cleanup": ["heat"],
|
||||
@scenario_base.scenario(context={"cleanup": ["heat"],
|
||||
"roles": ["heat_stack_owner"]})
|
||||
@validation.required_services(consts.Service.HEAT)
|
||||
def create_and_list_stack(self, template_path=None):
|
||||
@@ -54,7 +54,7 @@ class HeatStacks(utils.HeatScenario):
|
||||
self._create_stack(stack_name, template)
|
||||
self._list_stacks()
|
||||
|
||||
@base.scenario(context={"cleanup": ["heat"],
|
||||
@scenario_base.scenario(context={"cleanup": ["heat"],
|
||||
"roles": ["heat_stack_owner"]})
|
||||
@validation.required_services(consts.Service.HEAT)
|
||||
def create_and_delete_stack(self, template_path=None):
|
||||
|
||||
@@ -17,8 +17,7 @@ import time
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import utils as bench_utils
|
||||
|
||||
|
||||
@@ -55,17 +54,17 @@ def heat_resource_is(status):
|
||||
return lambda resource: resource.stack_status.upper() == status.upper()
|
||||
|
||||
|
||||
class HeatScenario(base.Scenario):
|
||||
class HeatScenario(scenario_base.Scenario):
|
||||
|
||||
default_template = "HeatTemplateFormatVersion: '2012-12-12'"
|
||||
|
||||
@scenario_utils.atomic_action_timer('heat.list_stacks')
|
||||
@scenario_base.atomic_action_timer('heat.list_stacks')
|
||||
def _list_stacks(self):
|
||||
"""Return user stack list."""
|
||||
|
||||
return list(self.clients("heat").stacks.list())
|
||||
|
||||
@scenario_utils.atomic_action_timer('heat.create_stack')
|
||||
@scenario_base.atomic_action_timer('heat.create_stack')
|
||||
def _create_stack(self, stack_name, template=None):
|
||||
"""Create a new stack.
|
||||
|
||||
@@ -101,7 +100,7 @@ class HeatScenario(base.Scenario):
|
||||
|
||||
return stack
|
||||
|
||||
@scenario_utils.atomic_action_timer('heat.delete_stack')
|
||||
@scenario_base.atomic_action_timer('heat.delete_stack')
|
||||
def _delete_stack(self, stack):
|
||||
"""Delete the given stack.
|
||||
|
||||
|
||||
@@ -13,27 +13,27 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.keystone import utils as kutils
|
||||
from rally.benchmark import validation
|
||||
|
||||
|
||||
class KeystoneBasic(kutils.KeystoneScenario):
|
||||
|
||||
@base.scenario(admin_only=True, context={"cleanup": []})
|
||||
@scenario_base.scenario(admin_only=True, context={"cleanup": []})
|
||||
def create_user(self, name_length=10, **kwargs):
|
||||
self._user_create(name_length=name_length, **kwargs)
|
||||
|
||||
@base.scenario(admin_only=True, context={"cleanup": []})
|
||||
@scenario_base.scenario(admin_only=True, context={"cleanup": []})
|
||||
def create_delete_user(self, name_length=10, **kwargs):
|
||||
user = self._user_create(name_length=name_length, **kwargs)
|
||||
self._resource_delete(user)
|
||||
|
||||
@base.scenario(admin_only=True, context={"cleanup": []})
|
||||
@scenario_base.scenario(admin_only=True, context={"cleanup": []})
|
||||
def create_tenant(self, name_length=10, **kwargs):
|
||||
self._tenant_create(name_length=name_length, **kwargs)
|
||||
|
||||
@base.scenario(admin_only=True, context={"cleanup": []})
|
||||
@scenario_base.scenario(admin_only=True, context={"cleanup": []})
|
||||
@validation.add(validation.required_parameters(['users_per_tenant']))
|
||||
def create_tenant_with_users(self, users_per_tenant, name_length=10,
|
||||
**kwargs):
|
||||
@@ -41,12 +41,12 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
||||
self._users_create(tenant, users_per_tenant=users_per_tenant,
|
||||
name_length=name_length)
|
||||
|
||||
@base.scenario(admin_only=True, context={"cleanup": []})
|
||||
@scenario_base.scenario(admin_only=True, context={"cleanup": []})
|
||||
def create_and_list_users(self, name_length=10, **kwargs):
|
||||
self._user_create(name_length=name_length, **kwargs)
|
||||
self._list_users()
|
||||
|
||||
@base.scenario(admin_only=True, context={"cleanup": []})
|
||||
@scenario_base.scenario(admin_only=True, context={"cleanup": []})
|
||||
def create_and_list_tenants(self, name_length=10, **kwargs):
|
||||
self._tenant_create(name_length=name_length, **kwargs)
|
||||
self._list_tenants()
|
||||
|
||||
@@ -13,18 +13,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
|
||||
|
||||
def is_temporary(resource):
|
||||
return resource.name.startswith(KeystoneScenario.RESOURCE_NAME_PREFIX)
|
||||
|
||||
|
||||
class KeystoneScenario(base.Scenario):
|
||||
class KeystoneScenario(scenario_base.Scenario):
|
||||
RESOURCE_NAME_PREFIX = "rally_keystone_"
|
||||
|
||||
@scenario_utils.atomic_action_timer('keystone.create_user')
|
||||
@scenario_base.atomic_action_timer('keystone.create_user')
|
||||
def _user_create(self, name_length=10, password=None, email=None,
|
||||
**kwargs):
|
||||
"""Creates keystone user with random name.
|
||||
@@ -43,12 +42,12 @@ class KeystoneScenario(base.Scenario):
|
||||
return self.admin_clients("keystone").users.create(name, password,
|
||||
email, **kwargs)
|
||||
|
||||
@scenario_utils.atomic_action_timer('keystone.delete_resource')
|
||||
@scenario_base.atomic_action_timer('keystone.delete_resource')
|
||||
def _resource_delete(self, resource):
|
||||
""""Delete keystone resource."""
|
||||
resource.delete()
|
||||
|
||||
@scenario_utils.atomic_action_timer('keystone.create_tenant')
|
||||
@scenario_base.atomic_action_timer('keystone.create_tenant')
|
||||
def _tenant_create(self, name_length=10, **kwargs):
|
||||
"""Creates keystone tenant with random name.
|
||||
|
||||
@@ -59,7 +58,7 @@ class KeystoneScenario(base.Scenario):
|
||||
name = self._generate_random_name(length=name_length)
|
||||
return self.admin_clients("keystone").tenants.create(name, **kwargs)
|
||||
|
||||
@scenario_utils.atomic_action_timer('keystone.create_users')
|
||||
@scenario_base.atomic_action_timer('keystone.create_users')
|
||||
def _users_create(self, tenant, users_per_tenant, name_length=10):
|
||||
"""Adds users to a tenant.
|
||||
|
||||
@@ -73,12 +72,12 @@ class KeystoneScenario(base.Scenario):
|
||||
self.admin_clients("keystone").users.create(name, password, email,
|
||||
tenant_id=tenant.id)
|
||||
|
||||
@scenario_utils.atomic_action_timer('keystone.list_users')
|
||||
@scenario_base.atomic_action_timer('keystone.list_users')
|
||||
def _list_users(self):
|
||||
"""list users."""
|
||||
return self.admin_clients("keystone").users.list()
|
||||
|
||||
@scenario_utils.atomic_action_timer('keystone.list_tenants')
|
||||
@scenario_base.atomic_action_timer('keystone.list_tenants')
|
||||
def _list_tenants(self):
|
||||
"""list tenants."""
|
||||
return self.admin_clients("keystone").tenants.list()
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.neutron import utils
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
@@ -21,7 +21,7 @@ from rally import consts
|
||||
|
||||
class NeutronNetworks(utils.NeutronScenario):
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_list_networks(self, network_create_args=None):
|
||||
"""Create a network and then listing all networks.
|
||||
@@ -40,7 +40,7 @@ class NeutronNetworks(utils.NeutronScenario):
|
||||
self._create_network(network_create_args or {})
|
||||
self._list_networks()
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_delete_networks(self, network_create_args=None):
|
||||
"""Create a network and then deleting it.
|
||||
@@ -53,7 +53,7 @@ class NeutronNetworks(utils.NeutronScenario):
|
||||
network = self._create_network(network_create_args or {})
|
||||
self._delete_network(network['network'])
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.add(validation.required_parameters(['subnets_per_network']))
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_list_subnets(self,
|
||||
@@ -79,7 +79,7 @@ class NeutronNetworks(utils.NeutronScenario):
|
||||
|
||||
self._list_subnets()
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.add(validation.required_parameters(['subnets_per_network']))
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_delete_subnets(self,
|
||||
@@ -105,7 +105,7 @@ class NeutronNetworks(utils.NeutronScenario):
|
||||
subnet = self._create_subnet(network, subnet_create_args or {})
|
||||
self._delete_subnet(subnet)
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.add(validation.required_parameters(['subnets_per_network']))
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_list_routers(self,
|
||||
@@ -137,7 +137,7 @@ class NeutronNetworks(utils.NeutronScenario):
|
||||
|
||||
self._list_routers()
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.add(validation.required_parameters(["ports_per_network"]))
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_list_ports(self,
|
||||
@@ -156,7 +156,7 @@ class NeutronNetworks(utils.NeutronScenario):
|
||||
|
||||
self._list_ports()
|
||||
|
||||
@base.scenario(context={"cleanup": ["neutron"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["neutron"]})
|
||||
@validation.add(validation.required_parameters(["ports_per_network"]))
|
||||
@validation.required_services(consts.Service.NEUTRON)
|
||||
def create_and_delete_ports(self,
|
||||
|
||||
@@ -17,11 +17,10 @@ import multiprocessing
|
||||
|
||||
import netaddr
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
|
||||
|
||||
class NeutronScenario(base.Scenario):
|
||||
class NeutronScenario(scenario_base.Scenario):
|
||||
"""This class should contain base operations for benchmarking neutron."""
|
||||
|
||||
RESOURCE_NAME_PREFIX = "rally_net_"
|
||||
@@ -46,7 +45,7 @@ class NeutronScenario(base.Scenario):
|
||||
cls._subnet_cidrs[network_id] = cidr
|
||||
return cidr
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.create_network')
|
||||
@scenario_base.atomic_action_timer('neutron.create_network')
|
||||
def _create_network(self, network_create_args):
|
||||
"""Create neutron network.
|
||||
|
||||
@@ -57,12 +56,12 @@ class NeutronScenario(base.Scenario):
|
||||
return self.clients("neutron"
|
||||
).create_network({"network": network_create_args})
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.list_networks')
|
||||
@scenario_base.atomic_action_timer('neutron.list_networks')
|
||||
def _list_networks(self):
|
||||
"""Return user networks list."""
|
||||
return self.clients("neutron").list_networks()['networks']
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.delete_network')
|
||||
@scenario_base.atomic_action_timer('neutron.delete_network')
|
||||
def _delete_network(self, network):
|
||||
"""Delete neutron network.
|
||||
|
||||
@@ -70,7 +69,7 @@ class NeutronScenario(base.Scenario):
|
||||
"""
|
||||
self.clients("neutron").delete_network(network['id'])
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.create_subnet')
|
||||
@scenario_base.atomic_action_timer('neutron.create_subnet')
|
||||
def _create_subnet(self, network, subnet_create_args):
|
||||
"""Create neutron subnet.
|
||||
|
||||
@@ -90,12 +89,12 @@ class NeutronScenario(base.Scenario):
|
||||
return self.clients("neutron"
|
||||
).create_subnet({"subnet": subnet_create_args})
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.list_subnets')
|
||||
@scenario_base.atomic_action_timer('neutron.list_subnets')
|
||||
def _list_subnets(self):
|
||||
"""Returns user subnetworks list."""
|
||||
return self.clients("neutron").list_subnets()["subnets"]
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.delete_subnet')
|
||||
@scenario_base.atomic_action_timer('neutron.delete_subnet')
|
||||
def _delete_subnet(self, subnet):
|
||||
"""Delete neutron subnet
|
||||
|
||||
@@ -103,7 +102,7 @@ class NeutronScenario(base.Scenario):
|
||||
"""
|
||||
self.clients("neutron").delete_subnet(subnet['subnet']['id'])
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.create_router')
|
||||
@scenario_base.atomic_action_timer('neutron.create_router')
|
||||
def _create_router(self, router_create_args):
|
||||
"""Create neutron router.
|
||||
|
||||
@@ -115,12 +114,12 @@ class NeutronScenario(base.Scenario):
|
||||
return self.clients("neutron"
|
||||
).create_router({"router": router_create_args})
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.list_routers')
|
||||
@scenario_base.atomic_action_timer('neutron.list_routers')
|
||||
def _list_routers(self):
|
||||
"""Returns user routers list."""
|
||||
return self.clients("neutron").list_routers()["routers"]
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.create_port')
|
||||
@scenario_base.atomic_action_timer('neutron.create_port')
|
||||
def _create_port(self, network, port_create_args):
|
||||
"""Create neutron port.
|
||||
|
||||
@@ -133,12 +132,12 @@ class NeutronScenario(base.Scenario):
|
||||
"name", self._generate_random_name("rally_port_"))
|
||||
return self.clients("neutron").create_port({"port": port_create_args})
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.list_ports')
|
||||
@scenario_base.atomic_action_timer('neutron.list_ports')
|
||||
def _list_ports(self):
|
||||
"""Return user ports list."""
|
||||
return self.clients("neutron").list_ports()["ports"]
|
||||
|
||||
@scenario_utils.atomic_action_timer('neutron.delete_port')
|
||||
@scenario_base.atomic_action_timer('neutron.delete_port')
|
||||
def _delete_port(self, port):
|
||||
"""Delete neutron port.
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import random
|
||||
|
||||
import jsonschema
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.cinder import utils as cinder_utils
|
||||
from rally.benchmark.scenarios.nova import utils
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
@@ -44,7 +44,7 @@ class NovaServers(utils.NovaScenario,
|
||||
@types.set(image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
|
||||
@base.scenario(context={"cleanup": ["nova"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["nova"]})
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
def boot_and_list_server(self, image, flavor,
|
||||
detailed=True, **kwargs):
|
||||
@@ -66,7 +66,7 @@ class NovaServers(utils.NovaScenario,
|
||||
@types.set(image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
|
||||
@base.scenario(context={"cleanup": ["nova"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["nova"]})
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
def boot_and_delete_server(self, image, flavor,
|
||||
min_sleep=0, max_sleep=0, **kwargs):
|
||||
@@ -79,7 +79,7 @@ class NovaServers(utils.NovaScenario,
|
||||
@types.set(image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
|
||||
@base.scenario(context={"cleanup": ["nova", "cinder"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["nova", "cinder"]})
|
||||
@validation.required_services(consts.Service.NOVA, consts.Service.CINDER)
|
||||
def boot_server_from_volume_and_delete(self, image, flavor,
|
||||
volume_size,
|
||||
@@ -97,7 +97,7 @@ class NovaServers(utils.NovaScenario,
|
||||
@types.set(image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
|
||||
@base.scenario(context={"cleanup": ["nova"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["nova"]})
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
def boot_and_bounce_server(self, image, flavor, **kwargs):
|
||||
"""Test booting a server with further performing specified actions.
|
||||
@@ -123,7 +123,7 @@ class NovaServers(utils.NovaScenario,
|
||||
@types.set(image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
|
||||
@base.scenario(context={"cleanup": ["nova", "glance"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["nova", "glance"]})
|
||||
@validation.required_services(consts.Service.NOVA, consts.Service.GLANCE)
|
||||
def snapshot_server(self, image, flavor, **kwargs):
|
||||
"""Tests Nova instance snapshotting."""
|
||||
@@ -140,7 +140,7 @@ class NovaServers(utils.NovaScenario,
|
||||
@types.set(image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
|
||||
@base.scenario(context={"cleanup": ["nova"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["nova"]})
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
def boot_server(self, image, flavor, **kwargs):
|
||||
"""Test VM boot - assumed clean-up is done elsewhere."""
|
||||
@@ -155,7 +155,7 @@ class NovaServers(utils.NovaScenario,
|
||||
@types.set(image=types.ImageResourceType,
|
||||
flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
|
||||
@base.scenario(context={"cleanup": ["nova", "cinder"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["nova", "cinder"]})
|
||||
@validation.required_services(consts.Service.NOVA, consts.Service.CINDER)
|
||||
def boot_server_from_volume(self, image, flavor,
|
||||
volume_size, **kwargs):
|
||||
@@ -217,7 +217,7 @@ class NovaServers(utils.NovaScenario,
|
||||
flavor=types.FlavorResourceType,
|
||||
to_flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.image_valid_on_flavor("flavor", "image"))
|
||||
@base.scenario(context={"cleanup": ["nova"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["nova"]})
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
def resize_server(self, image, flavor, to_flavor, **kwargs):
|
||||
"""Tests resize serveri."""
|
||||
|
||||
@@ -17,8 +17,7 @@ import time
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import utils as bench_utils
|
||||
|
||||
|
||||
@@ -66,15 +65,15 @@ CONF.register_group(benchmark_group)
|
||||
CONF.register_opts(nova_benchmark_opts, group=benchmark_group)
|
||||
|
||||
|
||||
class NovaScenario(base.Scenario):
|
||||
class NovaScenario(scenario_base.Scenario):
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.list_servers')
|
||||
@scenario_base.atomic_action_timer('nova.list_servers')
|
||||
def _list_servers(self, detailed=True):
|
||||
"""Returns user servers list."""
|
||||
|
||||
return self.clients("nova").servers.list(detailed)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.boot_server')
|
||||
@scenario_base.atomic_action_timer('nova.boot_server')
|
||||
def _boot_server(self, server_name, image_id, flavor_id, **kwargs):
|
||||
"""Boots one server.
|
||||
|
||||
@@ -131,7 +130,7 @@ class NovaScenario(base.Scenario):
|
||||
check_interval=CONF.benchmark.nova_server_reboot_poll_interval
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.soft_reboot_server')
|
||||
@scenario_base.atomic_action_timer('nova.soft_reboot_server')
|
||||
def _soft_reboot_server(self, server):
|
||||
"""Reboots the given server using soft reboot.
|
||||
|
||||
@@ -142,7 +141,7 @@ class NovaScenario(base.Scenario):
|
||||
"""
|
||||
self._do_server_reboot(server, "SOFT")
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.reboot_server')
|
||||
@scenario_base.atomic_action_timer('nova.reboot_server')
|
||||
def _reboot_server(self, server):
|
||||
"""Reboots the given server using hard reboot.
|
||||
|
||||
@@ -153,7 +152,7 @@ class NovaScenario(base.Scenario):
|
||||
"""
|
||||
self._do_server_reboot(server, "HARD")
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.start_server')
|
||||
@scenario_base.atomic_action_timer('nova.start_server')
|
||||
def _start_server(self, server):
|
||||
"""Starts the given server.
|
||||
|
||||
@@ -170,7 +169,7 @@ class NovaScenario(base.Scenario):
|
||||
check_interval=CONF.benchmark.nova_server_start_poll_interval
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.stop_server')
|
||||
@scenario_base.atomic_action_timer('nova.stop_server')
|
||||
def _stop_server(self, server):
|
||||
"""Stop the given server.
|
||||
|
||||
@@ -187,7 +186,7 @@ class NovaScenario(base.Scenario):
|
||||
check_interval=CONF.benchmark.nova_server_stop_poll_interval
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.rescue_server')
|
||||
@scenario_base.atomic_action_timer('nova.rescue_server')
|
||||
def _rescue_server(self, server):
|
||||
"""Rescue the given server.
|
||||
|
||||
@@ -205,7 +204,7 @@ class NovaScenario(base.Scenario):
|
||||
check_interval=CONF.benchmark.nova_server_rescue_poll_interval
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.unrescue_server')
|
||||
@scenario_base.atomic_action_timer('nova.unrescue_server')
|
||||
def _unrescue_server(self, server):
|
||||
"""Unrescue the given server.
|
||||
|
||||
@@ -222,7 +221,7 @@ class NovaScenario(base.Scenario):
|
||||
check_interval=CONF.benchmark.nova_server_unrescue_poll_interval
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.suspend_server')
|
||||
@scenario_base.atomic_action_timer('nova.suspend_server')
|
||||
def _suspend_server(self, server):
|
||||
"""Suspends the given server.
|
||||
|
||||
@@ -240,7 +239,7 @@ class NovaScenario(base.Scenario):
|
||||
check_interval=CONF.benchmark.nova_server_suspend_poll_interval
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.delete_server')
|
||||
@scenario_base.atomic_action_timer('nova.delete_server')
|
||||
def _delete_server(self, server):
|
||||
"""Deletes the given server.
|
||||
|
||||
@@ -256,14 +255,14 @@ class NovaScenario(base.Scenario):
|
||||
check_interval=CONF.benchmark.nova_server_delete_poll_interval
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.delete_all_servers')
|
||||
@scenario_base.atomic_action_timer('nova.delete_all_servers')
|
||||
def _delete_all_servers(self):
|
||||
"""Deletes all servers in current tenant."""
|
||||
servers = self.clients("nova").servers.list()
|
||||
for server in servers:
|
||||
self._delete_server(server)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.delete_image')
|
||||
@scenario_base.atomic_action_timer('nova.delete_image')
|
||||
def _delete_image(self, image):
|
||||
"""Deletes the given image.
|
||||
|
||||
@@ -280,7 +279,7 @@ class NovaScenario(base.Scenario):
|
||||
check_interval=check_interval
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.create_image')
|
||||
@scenario_base.atomic_action_timer('nova.create_image')
|
||||
def _create_image(self, server):
|
||||
"""Creates an image of the given server
|
||||
|
||||
@@ -304,7 +303,7 @@ class NovaScenario(base.Scenario):
|
||||
)
|
||||
return image
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.boot_servers')
|
||||
@scenario_base.atomic_action_timer('nova.boot_servers')
|
||||
def _boot_servers(self, name_prefix, image_id, flavor_id,
|
||||
requests, instances_amount=1, **kwargs):
|
||||
"""Boots multiple servers.
|
||||
@@ -343,17 +342,17 @@ class NovaScenario(base.Scenario):
|
||||
) for server in servers]
|
||||
return servers
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.list_floating_ip_pools')
|
||||
@scenario_base.atomic_action_timer('nova.list_floating_ip_pools')
|
||||
def _list_floating_ip_pools(self):
|
||||
"""Returns user floating ip pools list."""
|
||||
return self.clients("nova").floating_ip_pools.list()
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.list_floating_ips')
|
||||
@scenario_base.atomic_action_timer('nova.list_floating_ips')
|
||||
def _list_floating_ips(self):
|
||||
"""Returns user floating ips list."""
|
||||
return self.clients("nova").floating_ips.list()
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.create_floating_ip')
|
||||
@scenario_base.atomic_action_timer('nova.create_floating_ip')
|
||||
def _create_floating_ip(self, pool):
|
||||
"""Create (allocate) a floating ip from the given pool
|
||||
|
||||
@@ -363,7 +362,7 @@ class NovaScenario(base.Scenario):
|
||||
"""
|
||||
return self.clients("nova").floating_ips.create(pool)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.delete_floating_ip')
|
||||
@scenario_base.atomic_action_timer('nova.delete_floating_ip')
|
||||
def _delete_floating_ip(self, floating_ip):
|
||||
"""Delete (deallocate) a floating ip for a tenant
|
||||
|
||||
@@ -375,7 +374,7 @@ class NovaScenario(base.Scenario):
|
||||
update_resource=bench_utils.get_from_manager()
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.associate_floating_ip')
|
||||
@scenario_base.atomic_action_timer('nova.associate_floating_ip')
|
||||
def _associate_floating_ip(self, server, address, fixed_address=None):
|
||||
"""Add floating IP to an instance
|
||||
|
||||
@@ -393,7 +392,7 @@ class NovaScenario(base.Scenario):
|
||||
# Update server data
|
||||
server.addresses = server.manager.get(server.id).addresses
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.dissociate_floating_ip')
|
||||
@scenario_base.atomic_action_timer('nova.dissociate_floating_ip')
|
||||
def _dissociate_floating_ip(self, server, address):
|
||||
"""Remove floating IP from an instance
|
||||
|
||||
@@ -421,12 +420,12 @@ class NovaScenario(base.Scenario):
|
||||
return not must_exist
|
||||
return _check_addr
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.list_networks')
|
||||
@scenario_base.atomic_action_timer('nova.list_networks')
|
||||
def _list_networks(self):
|
||||
"""Returns user networks list."""
|
||||
return self.clients("nova").networks.list()
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.resize')
|
||||
@scenario_base.atomic_action_timer('nova.resize')
|
||||
def _resize(self, server, flavor):
|
||||
server.resize(flavor)
|
||||
bench_utils.wait_for(
|
||||
@@ -437,7 +436,7 @@ class NovaScenario(base.Scenario):
|
||||
check_interval=CONF.benchmark.nova_server_resize_poll_interval
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.resize_confirm')
|
||||
@scenario_base.atomic_action_timer('nova.resize_confirm')
|
||||
def _resize_confirm(self, server):
|
||||
server.confirm_resize()
|
||||
bench_utils.wait_for(
|
||||
@@ -449,7 +448,7 @@ class NovaScenario(base.Scenario):
|
||||
CONF.benchmark.nova_server_resize_confirm_poll_interval)
|
||||
)
|
||||
|
||||
@scenario_utils.atomic_action_timer('nova.resize_revert')
|
||||
@scenario_base.atomic_action_timer('nova.resize_revert')
|
||||
def _resize_revert(self, server):
|
||||
server.revert_resize()
|
||||
bench_utils.wait_for(
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.quotas import utils
|
||||
|
||||
|
||||
class Quotas(utils.QuotasScenario):
|
||||
|
||||
@base.scenario(admin_only=True, context={"cleanup": ["quotas"]})
|
||||
@scenario_base.scenario(admin_only=True, context={"cleanup": ["quotas"]})
|
||||
def nova_update(self, max_quota=1024):
|
||||
"""Tests updating quotas for nova.
|
||||
|
||||
@@ -28,7 +28,7 @@ class Quotas(utils.QuotasScenario):
|
||||
tenant_id = self.context()["user"]["tenant_id"]
|
||||
self._update_quotas('nova', tenant_id, max_quota)
|
||||
|
||||
@base.scenario(admin_only=True, context={"cleanup": ["quotas"]})
|
||||
@scenario_base.scenario(admin_only=True, context={"cleanup": ["quotas"]})
|
||||
def nova_update_and_delete(self, max_quota=1024):
|
||||
"""Tests updating and deleting quotas for nova.
|
||||
|
||||
@@ -39,7 +39,7 @@ class Quotas(utils.QuotasScenario):
|
||||
self._update_quotas('nova', tenant_id, max_quota)
|
||||
self._delete_quotas('nova', tenant_id)
|
||||
|
||||
@base.scenario(admin_only=True, context={"cleanup": ["quotas"]})
|
||||
@scenario_base.scenario(admin_only=True, context={"cleanup": ["quotas"]})
|
||||
def cinder_update(self, max_quota=1024):
|
||||
"""Tests updating quotas for cinder.
|
||||
|
||||
|
||||
@@ -15,13 +15,12 @@
|
||||
|
||||
import random
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
|
||||
|
||||
class QuotasScenario(base.Scenario):
|
||||
class QuotasScenario(scenario_base.Scenario):
|
||||
|
||||
@scenario_utils.atomic_action_timer('quotas.update_quotas')
|
||||
@scenario_base.atomic_action_timer('quotas.update_quotas')
|
||||
def _update_quotas(self, component, tenant_id, max_quota=1024):
|
||||
"""Updates quotas.
|
||||
|
||||
@@ -34,7 +33,7 @@ class QuotasScenario(base.Scenario):
|
||||
quotas = self._generate_quota_values(max_quota, component)
|
||||
return self.admin_clients(component).quotas.update(tenant_id, **quotas)
|
||||
|
||||
@scenario_utils.atomic_action_timer('quotas.delete_quotas')
|
||||
@scenario_base.atomic_action_timer('quotas.delete_quotas')
|
||||
def _delete_quotas(self, component, tenant_id):
|
||||
"""Deletes quotas.
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.sahara import utils
|
||||
from rally.benchmark import types
|
||||
from rally.benchmark import validation
|
||||
@@ -24,7 +24,7 @@ class SaharaNodeGroupTemplates(utils.SaharaScenario):
|
||||
|
||||
@types.set(flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.flavor_exists('flavor'))
|
||||
@base.scenario(context={"cleanup": ["sahara"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["sahara"]})
|
||||
@validation.required_services(consts.Service.SAHARA)
|
||||
def create_and_list_node_group_templates(self, flavor,
|
||||
plugin_name="vanilla",
|
||||
@@ -58,7 +58,7 @@ class SaharaNodeGroupTemplates(utils.SaharaScenario):
|
||||
|
||||
@types.set(flavor=types.FlavorResourceType)
|
||||
@validation.add(validation.flavor_exists('flavor'))
|
||||
@base.scenario(context={"cleanup": ["sahara"]})
|
||||
@scenario_base.scenario(context={"cleanup": ["sahara"]})
|
||||
@validation.required_services(consts.Service.SAHARA)
|
||||
def create_delete_node_group_templates(self, flavor,
|
||||
plugin_name="vanilla",
|
||||
@@ -89,4 +89,4 @@ class SaharaNodeGroupTemplates(utils.SaharaScenario):
|
||||
hadoop_version=hadoop_version)
|
||||
|
||||
self._delete_node_group_template(master_ngt)
|
||||
self._delete_node_group_template(worker_ngt)
|
||||
self._delete_node_group_template(worker_ngt)
|
||||
|
||||
@@ -13,11 +13,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
|
||||
|
||||
class SaharaScenario(base.Scenario):
|
||||
class SaharaScenario(scenario_base.Scenario):
|
||||
|
||||
RESOURCE_NAME_LENGTH = 20
|
||||
|
||||
@@ -35,13 +34,13 @@ class SaharaScenario(base.Scenario):
|
||||
}
|
||||
}
|
||||
|
||||
@utils.atomic_action_timer('sahara.list_node_group_templates')
|
||||
@scenario_base.atomic_action_timer('sahara.list_node_group_templates')
|
||||
def _list_node_group_templates(self):
|
||||
"""Returns user Node Group Templates list."""
|
||||
|
||||
return self.clients("sahara").node_group_templates.list()
|
||||
|
||||
@utils.atomic_action_timer(
|
||||
@scenario_base.atomic_action_timer(
|
||||
'sahara.create_master_node_group_template')
|
||||
def _create_master_node_group_template(self, flavor_id, plugin_name,
|
||||
hadoop_version):
|
||||
@@ -64,7 +63,7 @@ class SaharaScenario(base.Scenario):
|
||||
node_processes=self.NODE_PROCESSES[plugin_name][hadoop_version]
|
||||
["master"])
|
||||
|
||||
@utils.atomic_action_timer(
|
||||
@scenario_base.atomic_action_timer(
|
||||
'sahara.create_worker_node_group_template')
|
||||
def _create_worker_node_group_template(self, flavor_id, plugin_name,
|
||||
hadoop_version):
|
||||
@@ -87,7 +86,7 @@ class SaharaScenario(base.Scenario):
|
||||
node_processes=self.NODE_PROCESSES[plugin_name][hadoop_version]
|
||||
["worker"])
|
||||
|
||||
@utils.atomic_action_timer('sahara.delete_node_group_template')
|
||||
@scenario_base.atomic_action_timer('sahara.delete_node_group_template')
|
||||
def _delete_node_group_template(self, node_group):
|
||||
"""Deletes a Node Group Template by id.
|
||||
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.tempest import utils
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
|
||||
|
||||
class TempestScenario(base.Scenario):
|
||||
class TempestScenario(scenario_base.Scenario):
|
||||
|
||||
@validation.add(validation.tempest_tests_exists())
|
||||
@base.scenario(context={"tempest": {}})
|
||||
@scenario_base.scenario(context={"tempest": {}})
|
||||
@utils.tempest_log_wrapper
|
||||
def single_test(self, test_name, log_file):
|
||||
"""Launch a single test
|
||||
@@ -36,7 +36,7 @@ class TempestScenario(base.Scenario):
|
||||
|
||||
self.context()["verifier"].run(test_name, log_file)
|
||||
|
||||
@base.scenario(context={"tempest": {}})
|
||||
@scenario_base.scenario(context={"tempest": {}})
|
||||
@utils.tempest_log_wrapper
|
||||
def all(self, log_file):
|
||||
"""Launch all discovered tests
|
||||
@@ -47,7 +47,7 @@ class TempestScenario(base.Scenario):
|
||||
self.context()["verifier"].run("", log_file)
|
||||
|
||||
@validation.add(validation.tempest_set_exists())
|
||||
@base.scenario(context={"tempest": {}})
|
||||
@scenario_base.scenario(context={"tempest": {}})
|
||||
@utils.tempest_log_wrapper
|
||||
def set(self, set_name, log_file):
|
||||
"""Launch one by one methods from the set
|
||||
@@ -66,7 +66,7 @@ class TempestScenario(base.Scenario):
|
||||
self._context["verifier"].run(testr_arg, log_file)
|
||||
|
||||
@validation.add(validation.tempest_tests_exists())
|
||||
@base.scenario(context={"tempest": {}})
|
||||
@scenario_base.scenario(context={"tempest": {}})
|
||||
@utils.tempest_log_wrapper
|
||||
def list_of_tests(self, test_names, log_file):
|
||||
"""Launch all tests from given list
|
||||
@@ -77,7 +77,7 @@ class TempestScenario(base.Scenario):
|
||||
|
||||
self._context["verifier"].run(" ".join(test_names), log_file)
|
||||
|
||||
@base.scenario(context={"tempest": {}})
|
||||
@scenario_base.scenario(context={"tempest": {}})
|
||||
@utils.tempest_log_wrapper
|
||||
def specific_regex(self, regex, log_file):
|
||||
"""Launch all tests which match given regex
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import functools
|
||||
|
||||
import jsonschema
|
||||
|
||||
from rally import utils
|
||||
@@ -126,47 +124,3 @@ class ActionBuilder(object):
|
||||
binding['action'], times,
|
||||
*(binding['args'] + args), **dft_kwargs))
|
||||
return bound_actions
|
||||
|
||||
|
||||
def atomic_action_timer(name):
|
||||
"""Provide measure of execution time.
|
||||
|
||||
Decorates methods of the Scenario class.
|
||||
This provides duration in seconds of each atomic action.
|
||||
"""
|
||||
def wrap(func):
|
||||
@functools.wraps(func)
|
||||
def func_atomic_actions(self, *args, **kwargs):
|
||||
with utils.Timer() as timer:
|
||||
f = func(self, *args, **kwargs)
|
||||
self._add_atomic_actions(name, timer.duration())
|
||||
return f
|
||||
return func_atomic_actions
|
||||
return wrap
|
||||
|
||||
|
||||
class AtomicAction(utils.Timer):
|
||||
"""A class to measure the duration of atomic operations
|
||||
|
||||
This would simplify the way measure atomic opeation duration
|
||||
in certain cases. For example if we want to get the duration
|
||||
for each operation which runs in an iteration
|
||||
for i in range(repetitions):
|
||||
with scenario_utils.AtomicAction(instance_of_base_scenario_subclass,
|
||||
"name_of_action"):
|
||||
self.clients(<client>).<operation>
|
||||
"""
|
||||
|
||||
def __init__(self, scenario_instance, name):
|
||||
"""Create a new instance of the AtomicAction.
|
||||
|
||||
:param scenario_instance: instance of subclass of base scenario
|
||||
:param name: name of the ActionBuilder
|
||||
"""
|
||||
super(AtomicAction, self).__init__()
|
||||
self.scenario_instance = scenario_instance
|
||||
self.name = name
|
||||
|
||||
def __exit__(self, type, value, tb):
|
||||
super(AtomicAction, self).__exit__(type, value, tb)
|
||||
self.scenario_instance._add_atomic_actions(self.name, self.duration())
|
||||
|
||||
@@ -16,15 +16,14 @@
|
||||
|
||||
import subprocess
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import utils as bench_utils
|
||||
from rally import sshutils
|
||||
|
||||
|
||||
class VMScenario(base.Scenario):
|
||||
class VMScenario(scenario_base.Scenario):
|
||||
|
||||
@scenario_utils.atomic_action_timer('vm.run_command')
|
||||
@scenario_base.atomic_action_timer('vm.run_command')
|
||||
def run_action(self, ssh, interpreter, script):
|
||||
"""Run command inside an instance.
|
||||
|
||||
@@ -32,11 +31,11 @@ class VMScenario(base.Scenario):
|
||||
"""
|
||||
return ssh.execute(interpreter, stdin=open(script, "rb"))
|
||||
|
||||
@scenario_utils.atomic_action_timer('vm.wait_for_ssh')
|
||||
@scenario_base.atomic_action_timer('vm.wait_for_ssh')
|
||||
def wait_for_ssh(self, ssh):
|
||||
ssh.wait()
|
||||
|
||||
@scenario_utils.atomic_action_timer('vm.wait_for_ping')
|
||||
@scenario_base.atomic_action_timer('vm.wait_for_ping')
|
||||
def wait_for_ping(self, server_ip):
|
||||
bench_utils.wait_for(
|
||||
server_ip,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
import json
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark.scenarios.nova import utils as nova_utils
|
||||
from rally.benchmark.scenarios.vm import utils as vm_utils
|
||||
from rally.benchmark import types as types
|
||||
@@ -37,8 +37,8 @@ class VMTasks(nova_utils.NovaScenario, vm_utils.VMScenario):
|
||||
nullable=True, integer_only=True))
|
||||
@validation.add(validation.external_network_exists("floating_network",
|
||||
"use_floatingip"))
|
||||
@base.scenario(context={"cleanup": ["nova"],
|
||||
"keypair": {}, "allow_ssh": {}})
|
||||
@scenario_base.scenario(
|
||||
context={"cleanup": ["nova"], "keypair": {}, "allow_ssh": {}})
|
||||
@validation.required_services(consts.Service.NOVA)
|
||||
def boot_runcommand_delete(self, image, flavor,
|
||||
script, interpreter, username,
|
||||
|
||||
@@ -19,7 +19,7 @@ import mock
|
||||
from rally.benchmark.runners import base
|
||||
from rally.benchmark.runners import constant
|
||||
from rally.benchmark.runners import serial
|
||||
from rally.benchmark.scenarios import base as base_scenario
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally import consts
|
||||
from rally import exceptions
|
||||
from tests import fakes
|
||||
@@ -235,7 +235,7 @@ class ScenarioRunnerTestCase(test.TestCase):
|
||||
self.assertEqual(list(runner.result_queue), [])
|
||||
|
||||
cls_name, method_name = scenario_name.split(".", 1)
|
||||
cls = base_scenario.Scenario.get_by_name(cls_name)
|
||||
cls = scenario_base.Scenario.get_by_name(cls_name)
|
||||
|
||||
context_obj = {
|
||||
"task": runner.task,
|
||||
|
||||
@@ -72,7 +72,7 @@ class RPSScenarioRunnerTestCase(test.TestCase):
|
||||
for result in runner.result_queue:
|
||||
self.assertIsNotNone(base.ScenarioRunnerResult(result))
|
||||
|
||||
@mock.patch("rally.benchmark.runners.base.base")
|
||||
@mock.patch("rally.benchmark.runners.base.scenario_base")
|
||||
@mock.patch("rally.benchmark.runners.base.osclients")
|
||||
def test_get_rps_runner(self, mock_osclients, mock_base):
|
||||
FakeScenario = mock.MagicMock()
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import mock
|
||||
|
||||
from rally.benchmark.scenarios.ceilometer import utils
|
||||
from tests.benchmark.scenarios import test_utils
|
||||
from tests.benchmark.scenarios import test_base
|
||||
from tests import fakes
|
||||
from tests import test
|
||||
|
||||
@@ -30,7 +30,7 @@ class CeilometerScenarioTestCase(test.TestCase):
|
||||
return_value=fakes.FakeCeilometerClient())
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions_time, name):
|
||||
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||
action_duration = test_base.get_atomic_action_timer_value_by_name(
|
||||
atomic_actions_time, name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import mock
|
||||
|
||||
from rally.benchmark.scenarios.cinder import utils
|
||||
from tests.benchmark.scenarios import test_utils
|
||||
from tests.benchmark.scenarios import test_base
|
||||
from tests import test
|
||||
|
||||
CINDER_UTILS = "rally.benchmark.scenarios.cinder.utils"
|
||||
@@ -25,7 +25,7 @@ CINDER_UTILS = "rally.benchmark.scenarios.cinder.utils"
|
||||
class CinderScenarioTestCase(test.TestCase):
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions, name):
|
||||
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||
action_duration = test_base.get_atomic_action_timer_value_by_name(
|
||||
atomic_actions, name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
|
||||
@@ -18,7 +18,7 @@ from oslotest import mockpatch
|
||||
from rally.benchmark.scenarios.glance import utils
|
||||
from rally.benchmark import utils as butils
|
||||
from rally import exceptions as rally_exceptions
|
||||
from tests.benchmark.scenarios import test_utils
|
||||
from tests.benchmark.scenarios import test_base
|
||||
from tests import fakes
|
||||
from tests import test
|
||||
|
||||
@@ -53,7 +53,7 @@ class GlanceScenarioTestCase(test.TestCase):
|
||||
image_manager.create('fails', 'url', 'cf', 'df'))
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions, name):
|
||||
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||
action_duration = test_base.get_atomic_action_timer_value_by_name(
|
||||
atomic_actions, name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
|
||||
@@ -17,7 +17,7 @@ import mock
|
||||
from oslotest import mockpatch
|
||||
|
||||
from rally.benchmark.scenarios.heat import utils
|
||||
from tests.benchmark.scenarios import test_utils
|
||||
from tests.benchmark.scenarios import test_base
|
||||
from tests import test
|
||||
|
||||
BM_UTILS = 'rally.benchmark.utils'
|
||||
@@ -43,7 +43,7 @@ class HeatScenarioTestCase(test.TestCase):
|
||||
self.scenario = utils.HeatScenario()
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions, name):
|
||||
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||
action_duration = test_base.get_atomic_action_timer_value_by_name(
|
||||
atomic_actions, name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import mock
|
||||
|
||||
from rally.benchmark.scenarios.keystone import utils
|
||||
from tests.benchmark.scenarios import test_utils
|
||||
from tests.benchmark.scenarios import test_base
|
||||
from tests import fakes
|
||||
from tests import test
|
||||
|
||||
@@ -52,7 +52,7 @@ class KeystoneUtilsTestCase(test.TestCase):
|
||||
class KeystoneScenarioTestCase(test.TestCase):
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions, name):
|
||||
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||
action_duration = test_base.get_atomic_action_timer_value_by_name(
|
||||
atomic_actions, name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
|
||||
@@ -17,7 +17,7 @@ import mock
|
||||
import netaddr
|
||||
|
||||
from rally.benchmark.scenarios.neutron import utils
|
||||
from tests.benchmark.scenarios import test_utils
|
||||
from tests.benchmark.scenarios import test_base
|
||||
from tests import test
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class NeutronScenarioTestCase(test.TestCase):
|
||||
self.network = mock.Mock()
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions_time, name):
|
||||
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||
action_duration = test_base.get_atomic_action_timer_value_by_name(
|
||||
atomic_actions_time, name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
|
||||
@@ -20,7 +20,7 @@ from oslotest import mockpatch
|
||||
from rally.benchmark.scenarios.nova import utils
|
||||
from rally.benchmark import utils as butils
|
||||
from rally import exceptions as rally_exceptions
|
||||
from tests.benchmark.scenarios import test_utils
|
||||
from tests.benchmark.scenarios import test_base
|
||||
from tests import fakes
|
||||
from tests import test
|
||||
|
||||
@@ -50,7 +50,7 @@ class NovaScenarioTestCase(test.TestCase):
|
||||
self.useFixture(mockpatch.Patch('time.sleep'))
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions, name):
|
||||
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||
action_duration = test_base.get_atomic_action_timer_value_by_name(
|
||||
atomic_actions, name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import mock
|
||||
|
||||
from rally.benchmark.scenarios.quotas import utils
|
||||
from tests.benchmark.scenarios import test_utils
|
||||
from tests.benchmark.scenarios import test_base
|
||||
from tests import fakes
|
||||
from tests import test
|
||||
|
||||
@@ -27,7 +27,7 @@ class QuotasScenarioTestCase(test.TestCase):
|
||||
super(QuotasScenarioTestCase, self).setUp()
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions_time, name):
|
||||
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||
action_duration = test_base.get_atomic_action_timer_value_by_name(
|
||||
atomic_actions_time, name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import mock
|
||||
|
||||
from rally.benchmark.scenarios.sahara import utils
|
||||
from tests.benchmark.scenarios import test_utils
|
||||
from tests.benchmark.scenarios import test_base
|
||||
from tests import test
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ SAHARA_UTILS = 'rally.benchmark.scenarios.sahara.utils'
|
||||
class SaharaNodeGroupTemplatesScenarioTestCase(test.TestCase):
|
||||
|
||||
def _test_atomic_action_timer(self, atomic_actions, name):
|
||||
action_duration = test_utils.get_atomic_action_timer_value_by_name(
|
||||
action_duration = test_base.get_atomic_action_timer_value_by_name(
|
||||
atomic_actions, name)
|
||||
self.assertIsNotNone(action_duration)
|
||||
self.assertIsInstance(action_duration, float)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import mock
|
||||
|
||||
from rally.benchmark.scenarios.authenticate import authenticate
|
||||
from rally.benchmark.scenarios import utils
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from tests import fakes
|
||||
from tests import test
|
||||
|
||||
@@ -46,7 +46,8 @@ class AuthenticateTestCase(test.TestCase):
|
||||
scenario._clients.glance.images.list = mock.MagicMock(
|
||||
return_value=images_list)
|
||||
image_name = "__intentionally_non_existent_image___"
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_glance"):
|
||||
with scenario_base.AtomicAction(scenario,
|
||||
"authenticate.validate_glance"):
|
||||
scenario.validate_glance(5)
|
||||
scenario._clients.glance().images.list.assert_called_with(
|
||||
name=image_name)
|
||||
@@ -63,7 +64,8 @@ class AuthenticateTestCase(test.TestCase):
|
||||
clients=mock_users_clients)
|
||||
scenario._clients.nova.flavors.list = mock.MagicMock(
|
||||
return_value=flavors_list)
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_nova"):
|
||||
with scenario_base.AtomicAction(scenario,
|
||||
"authenticate.validate_nova"):
|
||||
scenario.validate_nova(5)
|
||||
self.assertEqual(scenario._clients.nova().flavors.list.call_count, 5)
|
||||
|
||||
@@ -78,7 +80,8 @@ class AuthenticateTestCase(test.TestCase):
|
||||
clients=mock_users_clients)
|
||||
scenario._clients.cinder.volume_types.list = mock.MagicMock(
|
||||
return_value=volume_types_list)
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_cinder"):
|
||||
with scenario_base.AtomicAction(scenario,
|
||||
"authenticate.validate_cinder"):
|
||||
scenario.validate_cinder(5)
|
||||
self.assertEqual(scenario._clients.cinder().volume_types.
|
||||
list.call_count, 5)
|
||||
@@ -92,7 +95,8 @@ class AuthenticateTestCase(test.TestCase):
|
||||
scenario = authenticate.Authenticate(admin_clients=mock_admin_clients,
|
||||
clients=mock_users_clients)
|
||||
scenario._clients.neutron.get_auth_info = mock.MagicMock()
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_neutron"):
|
||||
with scenario_base.AtomicAction(scenario,
|
||||
"authenticate.validate_neutron"):
|
||||
scenario.validate_neutron(5)
|
||||
self.assertEqual(scenario._clients.neutron().get_auth_info.call_count,
|
||||
5)
|
||||
@@ -108,7 +112,8 @@ class AuthenticateTestCase(test.TestCase):
|
||||
clients=mock_users_clients)
|
||||
scenario._clients.heat.stacks.list = mock.MagicMock(
|
||||
return_value=stacks_list)
|
||||
with utils.AtomicAction(scenario, "authenticate.validate_heat"):
|
||||
with scenario_base.AtomicAction(scenario,
|
||||
"authenticate.validate_heat"):
|
||||
scenario.validate_heat(5)
|
||||
scenario._clients.heat().stacks.list.assert_called_with(limit=0)
|
||||
self.assertEqual(scenario._clients.heat().stacks.list.call_count, 5)
|
||||
|
||||
@@ -18,7 +18,7 @@ import traceback
|
||||
import mock
|
||||
|
||||
from rally.benchmark.context import base as base_ctx
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import validation
|
||||
from rally import consts
|
||||
from rally import exceptions
|
||||
@@ -30,18 +30,19 @@ class ScenarioTestCase(test.TestCase):
|
||||
|
||||
def test_get_by_name(self):
|
||||
|
||||
class Scenario1(base.Scenario):
|
||||
class Scenario1(scenario_base.Scenario):
|
||||
pass
|
||||
|
||||
class Scenario2(base.Scenario):
|
||||
class Scenario2(scenario_base.Scenario):
|
||||
pass
|
||||
|
||||
for s in [Scenario1, Scenario2]:
|
||||
self.assertEqual(s, base.Scenario.get_by_name(s.__name__))
|
||||
self.assertEqual(s, scenario_base.Scenario.get_by_name(s.__name__))
|
||||
|
||||
def test_get_by_name_not_found(self):
|
||||
self.assertRaises(exceptions.NoSuchScenario,
|
||||
base.Scenario.get_by_name, "non existing scenario")
|
||||
scenario_base.Scenario.get_by_name,
|
||||
"non existing scenario")
|
||||
|
||||
def test__validate_helper(self):
|
||||
validators = [
|
||||
@@ -51,7 +52,8 @@ class ScenarioTestCase(test.TestCase):
|
||||
clients = mock.MagicMock()
|
||||
args = {"a": 1, "b": 2}
|
||||
task = mock.MagicMock()
|
||||
base.Scenario._validate_helper(validators, clients, args, task)
|
||||
scenario_base.Scenario._validate_helper(validators, clients,
|
||||
args, task)
|
||||
for validator in validators:
|
||||
validator.assert_called_with(clients=clients, task=task, **args)
|
||||
|
||||
@@ -65,7 +67,7 @@ class ScenarioTestCase(test.TestCase):
|
||||
clients = mock.MagicMock()
|
||||
args = {"a": 1, "b": 2}
|
||||
self.assertRaises(exceptions.InvalidScenarioArgument,
|
||||
base.Scenario._validate_helper,
|
||||
scenario_base.Scenario._validate_helper,
|
||||
validators, clients, args, 'fake_uuid')
|
||||
|
||||
@mock.patch("rally.benchmark.scenarios.base.Scenario.get_by_name")
|
||||
@@ -78,7 +80,7 @@ class ScenarioTestCase(test.TestCase):
|
||||
FakeScenario.do_it.validators = []
|
||||
mock_base_get_by_name.return_value = FakeScenario
|
||||
|
||||
base.Scenario.validate("FakeScenario.do_it", {"a": 1, "b": 2})
|
||||
scenario_base.Scenario.validate("FakeScenario.do_it", {"a": 1, "b": 2})
|
||||
|
||||
mock_base_get_by_name.assert_called_once_with("FakeScenario")
|
||||
|
||||
@@ -100,8 +102,8 @@ class ScenarioTestCase(test.TestCase):
|
||||
FakeScenario.do_it.validators = validators
|
||||
task = mock.MagicMock()
|
||||
args = {"a": 1, "b": 2}
|
||||
base.Scenario.validate("FakeScenario.do_it", args, admin="admin",
|
||||
task=task)
|
||||
scenario_base.Scenario.validate(
|
||||
"FakeScenario.do_it", args, admin="admin", task=task)
|
||||
mock_validate_helper.assert_called_once_with(validators, "admin", args,
|
||||
task)
|
||||
|
||||
@@ -122,7 +124,8 @@ class ScenarioTestCase(test.TestCase):
|
||||
|
||||
FakeScenario.do_it.validators = validators
|
||||
args = {"a": 1, "b": 2}
|
||||
base.Scenario.validate("FakeScenario.do_it", args, users=["u1", "u2"])
|
||||
scenario_base.Scenario.validate(
|
||||
"FakeScenario.do_it", args, users=["u1", "u2"])
|
||||
|
||||
mock_validate_helper.assert_has_calls([
|
||||
mock.call(validators, "u1", args, None),
|
||||
@@ -178,7 +181,7 @@ class ScenarioTestCase(test.TestCase):
|
||||
empty_list)
|
||||
|
||||
def test_sleep_between_invalid_args(self):
|
||||
scenario = base.Scenario()
|
||||
scenario = scenario_base.Scenario()
|
||||
self.assertRaises(exceptions.InvalidArgumentsException,
|
||||
scenario.sleep_between, 15, 5)
|
||||
|
||||
@@ -189,12 +192,12 @@ class ScenarioTestCase(test.TestCase):
|
||||
scenario.sleep_between, 0, -2)
|
||||
|
||||
def test_sleep_between(self):
|
||||
scenario = base.Scenario()
|
||||
scenario = scenario_base.Scenario()
|
||||
scenario.sleep_between(0.001, 0.002)
|
||||
self.assertTrue(0.001 <= scenario.idle_duration() <= 0.002)
|
||||
|
||||
def test_sleep_beetween_multi(self):
|
||||
scenario = base.Scenario()
|
||||
scenario = scenario_base.Scenario()
|
||||
scenario.sleep_between(0.001, 0.001)
|
||||
scenario.sleep_between(0.004, 0.004)
|
||||
self.assertEqual(scenario.idle_duration(), 0.005)
|
||||
@@ -202,7 +205,7 @@ class ScenarioTestCase(test.TestCase):
|
||||
@mock.patch("rally.benchmark.scenarios.base.time.sleep")
|
||||
@mock.patch("rally.benchmark.scenarios.base.random.uniform")
|
||||
def test_sleep_between_internal(self, mock_uniform, mock_sleep):
|
||||
scenario = base.Scenario()
|
||||
scenario = scenario_base.Scenario()
|
||||
|
||||
mock_uniform.return_value = 1.5
|
||||
scenario.sleep_between(1, 2)
|
||||
@@ -212,29 +215,29 @@ class ScenarioTestCase(test.TestCase):
|
||||
|
||||
def test_context(self):
|
||||
context = mock.MagicMock()
|
||||
scenario = base.Scenario(context=context)
|
||||
scenario = scenario_base.Scenario(context=context)
|
||||
self.assertEqual(context, scenario.context())
|
||||
|
||||
def test_clients(self):
|
||||
clients = fakes.FakeClients()
|
||||
|
||||
scenario = base.Scenario(clients=clients)
|
||||
scenario = scenario_base.Scenario(clients=clients)
|
||||
self.assertEqual(clients.nova(), scenario.clients("nova"))
|
||||
self.assertEqual(clients.glance(), scenario.clients("glance"))
|
||||
|
||||
def test_admin_clients(self):
|
||||
clients = fakes.FakeClients()
|
||||
|
||||
scenario = base.Scenario(admin_clients=clients)
|
||||
scenario = scenario_base.Scenario(admin_clients=clients)
|
||||
self.assertEqual(clients.nova(), scenario.admin_clients("nova"))
|
||||
self.assertEqual(clients.glance(), scenario.admin_clients("glance"))
|
||||
|
||||
def test_scenario_context_are_valid(self):
|
||||
scenarios = base.Scenario.list_benchmark_scenarios()
|
||||
scenarios = scenario_base.Scenario.list_benchmark_scenarios()
|
||||
|
||||
for scenario in scenarios:
|
||||
cls_name, method_name = scenario.split(".", 1)
|
||||
cls = base.Scenario.get_by_name(cls_name)
|
||||
cls = scenario_base.Scenario.get_by_name(cls_name)
|
||||
context = getattr(cls, method_name).context
|
||||
try:
|
||||
base_ctx.ContextManager.validate(context)
|
||||
@@ -244,16 +247,17 @@ class ScenarioTestCase(test.TestCase):
|
||||
"Scenario `%s` has wrong context" % scenario)
|
||||
|
||||
def test_RESOURCE_NAME_PREFIX(self):
|
||||
self.assertTrue(isinstance(base.Scenario.RESOURCE_NAME_PREFIX,
|
||||
self.assertTrue(isinstance(scenario_base.Scenario.RESOURCE_NAME_PREFIX,
|
||||
basestring))
|
||||
|
||||
def test_RESOURCE_NAME_LENGTH(self):
|
||||
self.assertTrue(isinstance(base.Scenario.RESOURCE_NAME_LENGTH, int))
|
||||
self.assertTrue(base.Scenario.RESOURCE_NAME_LENGTH > 4)
|
||||
self.assertTrue(
|
||||
isinstance(scenario_base.Scenario.RESOURCE_NAME_LENGTH, int))
|
||||
self.assertTrue(scenario_base.Scenario.RESOURCE_NAME_LENGTH > 4)
|
||||
|
||||
@mock.patch(
|
||||
"rally.benchmark.scenarios.base.Scenario.RESOURCE_NAME_PREFIX",
|
||||
"prefix_")
|
||||
"rally.benchmark.scenarios.base."
|
||||
"Scenario.RESOURCE_NAME_PREFIX", "prefix_")
|
||||
def test_generate_random_name(self):
|
||||
set_by_length = lambda lst: set(map(len, lst))
|
||||
len_by_prefix = (lambda lst, prefix:
|
||||
@@ -262,37 +266,64 @@ class ScenarioTestCase(test.TestCase):
|
||||
range_num = 50
|
||||
|
||||
# Defaults
|
||||
result = [base.Scenario._generate_random_name()
|
||||
result = [scenario_base.Scenario._generate_random_name()
|
||||
for i in range(range_num)]
|
||||
self.assertEqual(len(result), len(set(result)))
|
||||
self.assertEqual(
|
||||
set_by_length(result),
|
||||
set([(len(
|
||||
base.Scenario.RESOURCE_NAME_PREFIX) +
|
||||
base.Scenario.RESOURCE_NAME_LENGTH)]))
|
||||
scenario_base.Scenario.RESOURCE_NAME_PREFIX) +
|
||||
scenario_base.Scenario.RESOURCE_NAME_LENGTH)]))
|
||||
self.assertEqual(
|
||||
len_by_prefix(result, base.Scenario.RESOURCE_NAME_PREFIX),
|
||||
len_by_prefix(result, scenario_base.Scenario.RESOURCE_NAME_PREFIX),
|
||||
range_num)
|
||||
|
||||
# Custom prefix
|
||||
prefix = "another_prefix_"
|
||||
result = [base.Scenario._generate_random_name(prefix)
|
||||
result = [scenario_base.Scenario._generate_random_name(prefix)
|
||||
for i in range(range_num)]
|
||||
self.assertEqual(len(result), len(set(result)))
|
||||
self.assertEqual(
|
||||
set_by_length(result),
|
||||
set([len(prefix) + base.Scenario.RESOURCE_NAME_LENGTH]))
|
||||
set([len(prefix) + scenario_base.Scenario.RESOURCE_NAME_LENGTH]))
|
||||
self.assertEqual(
|
||||
len_by_prefix(result, prefix), range_num)
|
||||
|
||||
# Custom length
|
||||
name_length = 12
|
||||
result = [base.Scenario._generate_random_name(length=name_length)
|
||||
for i in range(range_num)]
|
||||
result = [
|
||||
scenario_base.Scenario._generate_random_name(length=name_length)
|
||||
for i in range(range_num)]
|
||||
self.assertEqual(len(result), len(set(result)))
|
||||
self.assertEqual(
|
||||
set_by_length(result),
|
||||
set([len(base.Scenario.RESOURCE_NAME_PREFIX) + name_length]))
|
||||
set([len(
|
||||
scenario_base.Scenario.RESOURCE_NAME_PREFIX) + name_length]))
|
||||
self.assertEqual(
|
||||
len_by_prefix(result, base.Scenario.RESOURCE_NAME_PREFIX),
|
||||
len_by_prefix(result, scenario_base.Scenario.RESOURCE_NAME_PREFIX),
|
||||
range_num)
|
||||
|
||||
|
||||
class AtomicActionTestCase(test.TestCase):
|
||||
def test__init__(self):
|
||||
fake_scenario_instance = mock.MagicMock()
|
||||
c = scenario_base.AtomicAction(fake_scenario_instance, 'asdf')
|
||||
self.assertEqual(c.scenario_instance, fake_scenario_instance)
|
||||
self.assertEqual(c.name, 'asdf')
|
||||
|
||||
@mock.patch('rally.utils.time')
|
||||
def test__exit__(self, mock_time):
|
||||
fake_scenario_instance = mock.Mock()
|
||||
self.start = mock_time.time()
|
||||
with scenario_base.AtomicAction(fake_scenario_instance, "asdf"):
|
||||
pass
|
||||
duration = mock_time.time() - self.start
|
||||
fake_scenario_instance._add_atomic_actions.assert_called_once_with(
|
||||
'asdf', duration)
|
||||
|
||||
|
||||
def get_atomic_action_timer_value_by_name(atomic_actions, name):
|
||||
for action in atomic_actions:
|
||||
if action['action'] == name:
|
||||
return action['duration']
|
||||
return None
|
||||
|
||||
@@ -184,28 +184,3 @@ class ActionBuilderTestCase(test.TestCase):
|
||||
for i in range(3):
|
||||
mock_calls.append(mock.call('two', 'three', c=3, d=4))
|
||||
mock_action_two.assert_has_calls(mock_calls)
|
||||
|
||||
|
||||
def get_atomic_action_timer_value_by_name(atomic_actions, name):
|
||||
for action in atomic_actions:
|
||||
if action['action'] == name:
|
||||
return action['duration']
|
||||
return None
|
||||
|
||||
|
||||
class AtomicActionTestCase(test.TestCase):
|
||||
def test__init__(self):
|
||||
fake_scenario_instance = mock.MagicMock()
|
||||
c = utils.AtomicAction(fake_scenario_instance, 'asdf')
|
||||
self.assertEqual(c.scenario_instance, fake_scenario_instance)
|
||||
self.assertEqual(c.name, 'asdf')
|
||||
|
||||
@mock.patch('rally.utils.time')
|
||||
def test__exit__(self, mock_time):
|
||||
fake_scenario_instance = mock.Mock()
|
||||
self.start = mock_time.time()
|
||||
with utils.AtomicAction(fake_scenario_instance, "asdf"):
|
||||
pass
|
||||
duration = mock_time.time() - self.start
|
||||
fake_scenario_instance._add_atomic_actions.assert_called_once_with(
|
||||
'asdf', duration)
|
||||
|
||||
@@ -20,7 +20,7 @@ import traceback
|
||||
|
||||
import yaml
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.benchmark import engine
|
||||
from tests import test
|
||||
|
||||
@@ -58,7 +58,7 @@ class TaskSampleTestCase(test.TestCase):
|
||||
|
||||
# TODO(boris-42): We should refactor scenarios framework add "_" to
|
||||
# all non-benchmark methods.. Then this test will pass.
|
||||
missing = set(base.Scenario.list_benchmark_scenarios()) - scenarios
|
||||
missing = set(scenario_base.Scenario.list_benchmark_scenarios()) - scenarios
|
||||
self.assertEqual(missing, set([]),
|
||||
"These scenarios don't have samples: %s" % missing)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ from neutronclient.common import exceptions as neutron_exceptions
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
|
||||
from rally.benchmark.context import base as base_ctx
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally.objects import endpoint
|
||||
from rally import utils as rally_utils
|
||||
|
||||
@@ -56,7 +56,7 @@ def generate_mac():
|
||||
|
||||
|
||||
def setup_dict(data, required=None, defaults=None):
|
||||
"""Setup and validate dict based on mandatory keys and default data.
|
||||
"""Setup and validate dict scenario_base. on mandatory keys and default data.
|
||||
|
||||
This function reduces code that constructs dict objects
|
||||
with specific schema (e.g. for API data).
|
||||
@@ -927,7 +927,7 @@ class FakeRunner(object):
|
||||
}
|
||||
|
||||
|
||||
class FakeScenario(base.Scenario):
|
||||
class FakeScenario(scenario_base.Scenario):
|
||||
|
||||
def idle_time(self):
|
||||
return 0
|
||||
|
||||
@@ -19,7 +19,7 @@ import collections
|
||||
|
||||
import mock
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import base as scenario_base
|
||||
from rally import consts
|
||||
from rally.orchestrator import api
|
||||
from tests import fakes
|
||||
@@ -64,14 +64,14 @@ FAKE_TASK_CONFIG = {
|
||||
}
|
||||
|
||||
|
||||
class FakeScenario(base.Scenario):
|
||||
class FakeScenario(scenario_base.Scenario):
|
||||
@classmethod
|
||||
def fake(cls, context):
|
||||
pass
|
||||
|
||||
|
||||
# TODO(akscram): The test cases are very superficial because they test
|
||||
# only database operations and actually no more. Each
|
||||
# only datascenario_base.operations and actually no more. Each
|
||||
# case in this test should to mock everything external.
|
||||
class APITestCase(test.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user