Introduce rally.plugins.openstack.OpenStackScenario
This makes rally.task.scenario independent from OpenStack which is awsome and makes actually architecture clean and nice Plus in future it will allow us to use Rally for testing other software Change-Id: Id0227cddfce105d1fc21c472adcc5118f85b90db
This commit is contained in:
57
rally/plugins/openstack/scenario.py
Normal file
57
rally/plugins/openstack/scenario.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# Copyright 2015: Mirantis Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally import osclients
|
||||
from rally.task.scenarios import base
|
||||
|
||||
|
||||
class OpenStackScenario(base.Scenario):
|
||||
"""Base class for all OpenStack scenarios."""
|
||||
|
||||
def __init__(self, context=None):
|
||||
super(OpenStackScenario, self).__init__(context)
|
||||
if context:
|
||||
if "admin" in context:
|
||||
self._admin_clients = osclients.Clients(
|
||||
context["admin"]["endpoint"])
|
||||
if "user" in context:
|
||||
self._clients = osclients.Clients(context["user"]["endpoint"])
|
||||
|
||||
def clients(self, client_type, version=None):
|
||||
"""Returns a python openstack client of the requested type.
|
||||
|
||||
The client will be that for one of the temporary non-administrator
|
||||
users created before the benchmark launch.
|
||||
|
||||
:param client_type: Client type ("nova"/"glance" etc.)
|
||||
:param version: client version ("1"/"2" etc.)
|
||||
|
||||
:returns: Standard python OpenStack client instance
|
||||
"""
|
||||
client = getattr(self._clients, client_type)
|
||||
|
||||
return client(version) if version is not None else client()
|
||||
|
||||
def admin_clients(self, client_type, version=None):
|
||||
"""Returns a python admin openstack client of the requested type.
|
||||
|
||||
:param client_type: Client type ("nova"/"glance" etc.)
|
||||
:param version: client version ("1"/"2" etc.)
|
||||
|
||||
:returns: Python openstack client object
|
||||
"""
|
||||
client = getattr(self._admin_clients, client_type)
|
||||
|
||||
return client(version) if version is not None else client()
|
||||
@@ -12,11 +12,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
class Authenticate(base.Scenario):
|
||||
class Authenticate(scenario.OpenStackScenario):
|
||||
"""Benchmark scenarios for the authentication mechanism.
|
||||
|
||||
Benchmark scenarios for different types of OpenStack clients like Keystone,
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils as bench_utils
|
||||
|
||||
|
||||
class CeilometerScenario(base.Scenario):
|
||||
class CeilometerScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Ceilometer scenarios with basic atomic actions."""
|
||||
|
||||
RESOURCE_NAME_PREFIX = "rally_ceilometer_"
|
||||
|
||||
@@ -19,6 +19,7 @@ import time
|
||||
from oslo_config import cfg
|
||||
|
||||
from rally import exceptions
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils as bench_utils
|
||||
|
||||
@@ -48,7 +49,7 @@ 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.OpenStackScenario):
|
||||
"""Base class for Cinder scenarios with basic atomic actions."""
|
||||
|
||||
RESOURCE_NAME_PREFIX = "rally_volume_"
|
||||
|
||||
@@ -14,10 +14,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
|
||||
|
||||
class DesignateScenario(base.Scenario):
|
||||
class DesignateScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Designate scenarios with basic atomic actions."""
|
||||
|
||||
RESOURCE_NAME_PREFIX = "rally_"
|
||||
|
||||
@@ -16,6 +16,7 @@ import time
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils
|
||||
|
||||
@@ -44,7 +45,7 @@ benchmark_group = cfg.OptGroup(name="benchmark",
|
||||
CONF.register_opts(EC2_BENCHMARK_OPTS, group=benchmark_group)
|
||||
|
||||
|
||||
class EC2Scenario(base.Scenario):
|
||||
class EC2Scenario(scenario.OpenStackScenario):
|
||||
"""Base class for EC2 scenarios with basic atomic actions."""
|
||||
|
||||
RESOURCE_NAME_PREFIX = "rally_ec2server_"
|
||||
|
||||
@@ -18,6 +18,7 @@ import time
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils
|
||||
|
||||
@@ -49,7 +50,7 @@ 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.OpenStackScenario):
|
||||
"""Base class for Glance scenarios with basic atomic actions."""
|
||||
|
||||
@base.atomic_action_timer("glance.list_images")
|
||||
|
||||
@@ -20,6 +20,7 @@ import requests
|
||||
|
||||
from rally.common import log as logging
|
||||
from rally import exceptions
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils
|
||||
|
||||
@@ -106,7 +107,7 @@ benchmark_group = cfg.OptGroup(name="benchmark", title="benchmark options")
|
||||
CONF.register_opts(HEAT_BENCHMARK_OPTS, group=benchmark_group)
|
||||
|
||||
|
||||
class HeatScenario(base.Scenario):
|
||||
class HeatScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Heat scenarios with basic atomic actions."""
|
||||
|
||||
@base.atomic_action_timer("heat.list_stacks")
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
|
||||
|
||||
@@ -22,7 +23,7 @@ def is_temporary(resource):
|
||||
return resource.name.startswith(KeystoneScenario.RESOURCE_NAME_PREFIX)
|
||||
|
||||
|
||||
class KeystoneScenario(base.Scenario):
|
||||
class KeystoneScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Keystone scenarios with basic atomic actions."""
|
||||
|
||||
RESOURCE_NAME_PREFIX = "rally_keystone_"
|
||||
|
||||
@@ -17,6 +17,7 @@ import time
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils
|
||||
|
||||
@@ -52,7 +53,7 @@ benchmark_group = cfg.OptGroup(name="benchmark", title="benchmark options")
|
||||
CONF.register_opts(MANILA_BENCHMARK_OPTS, group=benchmark_group)
|
||||
|
||||
|
||||
class ManilaScenario(base.Scenario):
|
||||
class ManilaScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Manila scenarios with basic atomic actions."""
|
||||
|
||||
@base.atomic_action_timer("manila.create_share")
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
|
||||
import yaml
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
|
||||
|
||||
class MistralScenario(base.Scenario):
|
||||
class MistralScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Mistral scenarios with basic atomic actions."""
|
||||
|
||||
@base.atomic_action_timer("mistral.list_workbooks")
|
||||
|
||||
@@ -17,6 +17,7 @@ import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils
|
||||
|
||||
@@ -37,7 +38,7 @@ benchmark_group = cfg.OptGroup(name="benchmark", title="benchmark options")
|
||||
CONF.register_opts(MURANO_TIMEOUT_OPTS, group=benchmark_group)
|
||||
|
||||
|
||||
class MuranoScenario(base.Scenario):
|
||||
class MuranoScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Murano scenarios with basic atomic actions."""
|
||||
|
||||
@base.atomic_action_timer("murano.list_environments")
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
from oslo_utils import uuidutils as uid
|
||||
|
||||
from rally.common import log as logging
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.plugins.openstack.wrappers import network as network_wrapper
|
||||
from rally.task.scenarios import base
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NeutronScenario(base.Scenario):
|
||||
class NeutronScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Neutron scenarios with basic atomic actions."""
|
||||
|
||||
RESOURCE_NAME_PREFIX = "rally_net_"
|
||||
|
||||
@@ -20,6 +20,7 @@ from oslo_config import cfg
|
||||
import six
|
||||
|
||||
from rally import exceptions
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.plugins.openstack.wrappers import network as network_wrapper
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils
|
||||
@@ -87,7 +88,7 @@ CONF.register_group(benchmark_group)
|
||||
CONF.register_opts(NOVA_BENCHMARK_OPTS, group=benchmark_group)
|
||||
|
||||
|
||||
class NovaScenario(base.Scenario):
|
||||
class NovaScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Nova scenarios with basic atomic actions."""
|
||||
|
||||
@base.atomic_action_timer("nova.list_servers")
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
|
||||
import random
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
|
||||
|
||||
class QuotasScenario(base.Scenario):
|
||||
class QuotasScenario(scenario.OpenStackScenario):
|
||||
"""Base class for quotas scenarios with basic atomic actions."""
|
||||
|
||||
@base.atomic_action_timer("quotas.update_quotas")
|
||||
|
||||
@@ -23,6 +23,7 @@ from rally.common.i18n import _
|
||||
from rally.common import log as logging
|
||||
from rally import consts
|
||||
from rally import exceptions
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.plugins.openstack.scenarios.sahara import consts as sahara_consts
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils
|
||||
@@ -47,7 +48,7 @@ benchmark_group = cfg.OptGroup(name="benchmark", title="benchmark options")
|
||||
CONF.register_opts(SAHARA_TIMEOUT_OPTS, group=benchmark_group)
|
||||
|
||||
|
||||
class SaharaScenario(base.Scenario):
|
||||
class SaharaScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Sahara scenarios with basic atomic actions."""
|
||||
|
||||
RESOURCE_NAME_LENGTH = 20
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
|
||||
|
||||
class SwiftScenario(base.Scenario):
|
||||
class SwiftScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Swift scenarios with basic atomic actions."""
|
||||
|
||||
@base.atomic_action_timer("swift.list_containers")
|
||||
|
||||
@@ -22,6 +22,7 @@ import six
|
||||
from rally.common.i18n import _
|
||||
from rally.common import log as logging
|
||||
from rally.common import sshutils
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.plugins.openstack.wrappers import network as network_wrapper
|
||||
from rally.task.scenarios import base
|
||||
from rally.task import utils
|
||||
@@ -33,7 +34,7 @@ ICMP_UP_STATUS = "ICMP UP"
|
||||
ICMP_DOWN_STATUS = "ICMP DOWN"
|
||||
|
||||
|
||||
class VMScenario(base.Scenario):
|
||||
class VMScenario(scenario.OpenStackScenario):
|
||||
"""Base class for VM scenarios with basic atomic actions.
|
||||
|
||||
VM scenarios are scenarios executed inside some launched VM instance.
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.task.scenarios import base
|
||||
|
||||
|
||||
class ZaqarScenario(base.Scenario):
|
||||
class ZaqarScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Zaqar scenarios with basic atomic actions."""
|
||||
|
||||
@base.atomic_action_timer("zaqar.create_queue")
|
||||
|
||||
@@ -61,6 +61,9 @@ class DBTestCase(TestCase):
|
||||
self.useFixture(DatabaseFixture())
|
||||
|
||||
|
||||
# TODO(boris-42): This should be moved to test.plugins.test module
|
||||
# or similar
|
||||
|
||||
class ScenarioTestCase(TestCase):
|
||||
"""Base class for Scenario tests using mocked self.clients."""
|
||||
benchmark_utils = "rally.task.utils"
|
||||
@@ -115,11 +118,14 @@ class ScenarioTestCase(TestCase):
|
||||
self.useFixture(self.mock_sleep)
|
||||
|
||||
self._clients = {}
|
||||
base_path = "rally.plugins.openstack"
|
||||
self._client_mocks = [
|
||||
mock.patch("rally.task.scenarios.base.Scenario.clients",
|
||||
mock.Mock(side_effect=self.clients)),
|
||||
mock.patch("rally.task.scenarios.base.Scenario.admin_clients",
|
||||
mock.Mock(side_effect=self.admin_clients))
|
||||
mock.patch(
|
||||
"%s.scenario.OpenStackScenario.clients" % base_path,
|
||||
mock.Mock(side_effect=self.clients)),
|
||||
mock.patch(
|
||||
"%s.scenario.OpenStackScenario.admin_clients" % base_path,
|
||||
mock.Mock(side_effect=self.admin_clients))
|
||||
]
|
||||
for patcher in self._client_mocks:
|
||||
patcher.start()
|
||||
|
||||
Reference in New Issue
Block a user