Skip to content

Commit

Permalink
Update the scenario_base to base in benchmarks
Browse files Browse the repository at this point in the history
Keep the scenario_base only on places where required.
Rest keep it as base instead of scenario_base

Change-Id: Ib7887c0a0b65d67a814222e0786fc228cd5bd2ca
  • Loading branch information
Swapnil Kulkarni committed Aug 13, 2014
1 parent 72e2cf1 commit 70a90e0
Show file tree
Hide file tree
Showing 33 changed files with 232 additions and 252 deletions.
18 changes: 9 additions & 9 deletions doc/source/concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ In a toy example below, we define a scenario class *MyScenario* with one benchma

::

from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios import utils


class MyScenario(scenario_base.Scenario):
class MyScenario(base.Scenario):
"""My class that contains benchmark scenarios."""

@scenario_base.atomic_action_timer("action_1")
@base.atomic_action_timer("action_1")
def _action_1(self, **kwargs):
"""Do something with the cloud."""

@scenario_base.atomic_action_timer("action_2")
@base.atomic_action_timer("action_2")
def _action_2(self, **kwargs):
"""Do something with the cloud."""

@scenario_base.scenario()
@base.scenario()
def scenario(self, **kwargs):
self._action_1()
self._action_2()
Expand Down Expand Up @@ -354,20 +354,20 @@ benchmark scenario results have been stored correctly.
import random
import time

from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios import base


class PluginClass(base.Scenario):

@scenario_base.atomic_action_timer("test1")
@base.atomic_action_timer("test1")
def _test1(self, factor):
time.sleep(random.random() * factor)

@scenario_base.atomic_action_timer("test2")
@base.atomic_action_timer("test2")
def _test2(self, factor):
time.sleep(random.random() * factor * 10)

@scenario_base.scenario()
@base.scenario()
def testplugin(self, factor=1):
self._test1(factor)
self._test2(factor)
Expand Down
10 changes: 5 additions & 5 deletions rally-scenarios/plugins/fake_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
import random
import time

from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios import base


class FakePlugin(scenario_base.Scenario):
class FakePlugin(base.Scenario):

@scenario_base.atomic_action_timer("test1")
@base.atomic_action_timer("test1")
def _test1(self, factor):
time.sleep(random.random())

@scenario_base.atomic_action_timer("test2")
@base.atomic_action_timer("test2")
def _test2(self, factor):
time.sleep(random.random() * factor * 10)

@scenario_base.scenario()
@base.scenario()
def testplugin(self, factor=1):
self._test1(factor)
self._test2(factor)
33 changes: 14 additions & 19 deletions rally/benchmark/scenarios/authenticate/authenticate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
# License for the specific language governing permissions and limitations
# under the License.

from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios import base
from rally.benchmark import validation


class Authenticate(scenario_base.Scenario):
class Authenticate(base.Scenario):
"""This class should contain authentication mechanism.
For different types of clients like Keystone.
"""

@scenario_base.scenario()
@scenario_base.atomic_action_timer('authenticate.keystone')
@base.scenario()
@base.atomic_action_timer('authenticate.keystone')
def keystone(self, **kwargs):
self.clients("keystone")

@scenario_base.scenario()
@base.scenario()
@validation.add(validation.required_parameters(['repetitions']))
def validate_glance(self, repetitions):
"""Check Glance Client to ensure validation of token.
Expand All @@ -41,11 +41,10 @@ def validate_glance(self, repetitions):
glance_client = self.clients("glance")
image_name = "__intentionally_non_existent_image___"
for i in range(repetitions):
with scenario_base.AtomicAction(self,
'authenticate.validate_glance'):
with base.AtomicAction(self, 'authenticate.validate_glance'):
list(glance_client.images.list(name=image_name))

@scenario_base.scenario()
@base.scenario()
@validation.add(validation.required_parameters(['repetitions']))
def validate_nova(self, repetitions):
"""Check Nova Client to ensure validation of token.
Expand All @@ -57,11 +56,10 @@ def validate_nova(self, repetitions):
"""
nova_client = self.clients("nova")
for i in range(repetitions):
with scenario_base.AtomicAction(self,
'authenticate.validate_nova'):
with base.AtomicAction(self, 'authenticate.validate_nova'):
nova_client.flavors.list()

@scenario_base.scenario()
@base.scenario()
@validation.add(validation.required_parameters(['repetitions']))
def validate_cinder(self, repetitions):
"""Check Cinder Client to ensure validation of token.
Expand All @@ -73,11 +71,10 @@ def validate_cinder(self, repetitions):
"""
cinder_client = self.clients("cinder")
for i in range(repetitions):
with scenario_base.AtomicAction(self,
'authenticate.validate_cinder'):
with base.AtomicAction(self, 'authenticate.validate_cinder'):
cinder_client.volume_types.list()

@scenario_base.scenario()
@base.scenario()
@validation.add(validation.required_parameters(['repetitions']))
def validate_neutron(self, repetitions):
"""Check Neutron Client to ensure validation of token.
Expand All @@ -89,11 +86,10 @@ def validate_neutron(self, repetitions):
"""
neutron_client = self.clients("neutron")
for i in range(repetitions):
with scenario_base.AtomicAction(self,
'authenticate.validate_neutron'):
with base.AtomicAction(self, 'authenticate.validate_neutron'):
neutron_client.get_auth_info()

@scenario_base.scenario()
@base.scenario()
@validation.add(validation.required_parameters(['repetitions']))
def validate_heat(self, repetitions):
"""Check Heat Client to ensure validation of token.
Expand All @@ -105,6 +101,5 @@ def validate_heat(self, repetitions):
"""
heat_client = self.clients("heat")
for i in range(repetitions):
with scenario_base.AtomicAction(self,
'authenticate.validate_heat'):
with base.AtomicAction(self, 'authenticate.validate_heat'):
list(heat_client.stacks.list(limit=0))
12 changes: 6 additions & 6 deletions rally/benchmark/scenarios/ceilometer/alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.

from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios.ceilometer import utils as ceilometerutils
from rally.benchmark import validation
from rally import consts


class CeilometerAlarms(ceilometerutils.CeilometerScenario):
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
@base.scenario(context={"cleanup": ["ceilometer"]})
@validation.required_services(consts.Service.CEILOMETER)
def create_alarm(self, meter_name, threshold, **kwargs):
"""Test creating an alarm.
Expand All @@ -34,7 +34,7 @@ def create_alarm(self, meter_name, threshold, **kwargs):
"""
self._create_alarm(meter_name, threshold, kwargs)

@scenario_base.scenario()
@base.scenario()
@validation.required_services(consts.Service.CEILOMETER)
def list_alarms(self):
"""Test fetching all alarms.
Expand All @@ -43,7 +43,7 @@ def list_alarms(self):
"""
self._list_alarms()

@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
@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.
Expand All @@ -60,7 +60,7 @@ def create_and_list_alarm(self, meter_name, threshold, **kwargs):
alarm = self._create_alarm(meter_name, threshold, kwargs)
self._list_alarms(alarm.alarm_id)

@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
@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.
Expand All @@ -78,7 +78,7 @@ def create_and_update_alarm(self, meter_name, threshold, **kwargs):
alarm_dict_diff = {"description": "Changed Test Description"}
self._update_alarm(alarm.alarm_id, alarm_dict_diff)

@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
@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.
Expand Down
4 changes: 2 additions & 2 deletions rally/benchmark/scenarios/ceilometer/meters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.

from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios.ceilometer import utils as ceilometerutils
from rally.benchmark import validation
from rally import consts


class CeilometerMeters(ceilometerutils.CeilometerScenario):
@scenario_base.scenario()
@base.scenario()
@validation.required_services(consts.Service.CEILOMETER)
def list_meters(self):
"""Test fetching user's meters."""
Expand Down
8 changes: 4 additions & 4 deletions rally/benchmark/scenarios/ceilometer/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

import json

from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios.ceilometer import utils as ceilometerutils
from rally.benchmark import validation
from rally import consts


class CeilometerQueries(ceilometerutils.CeilometerScenario):
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
@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):
Expand All @@ -42,7 +42,7 @@ def create_and_query_alarms(self, meter_name, threshold, filter=None,
self._create_alarm(meter_name, threshold, kwargs)
self._query_alarms(filter, orderby, limit)

@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
@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):
Expand All @@ -61,7 +61,7 @@ def create_and_query_alarm_history(self, meter_name, threshold,
alarm_filter = json.dumps({"=": {"alarm_id": alarm.alarm_id}})
self._query_alarm_history(alarm_filter, orderby, limit)

@scenario_base.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,
Expand Down
4 changes: 2 additions & 2 deletions rally/benchmark/scenarios/ceilometer/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.

from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios.ceilometer import utils as ceilometerutils
from rally.benchmark import validation
from rally import consts


class CeilometerResource(ceilometerutils.CeilometerScenario):
@scenario_base.scenario()
@base.scenario()
@validation.required_services(consts.Service.CEILOMETER)
def list_resources(self):
"""Test fetching all resources.
Expand Down
4 changes: 2 additions & 2 deletions rally/benchmark/scenarios/ceilometer/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.

from rally.benchmark.scenarios import base as scenario_base
from rally.benchmark.scenarios import base
from rally.benchmark.scenarios.ceilometer import utils
from rally.benchmark import validation
from rally import consts


class CeilometerStats(utils.CeilometerScenario):
@scenario_base.scenario(context={"cleanup": ["ceilometer"]})
@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.
Expand Down
Loading

0 comments on commit 70a90e0

Please sign in to comment.