Introduce a base class for all OpenStack context
Currently this class is a new home for _iterate_per_tenants method that was deprecated at rally framework. Change-Id: I1f301455dc32c78270ed0411c6a79a5f2c68e827
This commit is contained in:
parent
83eae7f02a
commit
e43b0728c8
@ -19,6 +19,12 @@ Changelog
|
||||
[unreleased]
|
||||
------------
|
||||
|
||||
Added
|
||||
~~~~~
|
||||
|
||||
* The *rally_openstack.task.context.OpenStackContext* class which provides
|
||||
helpers for all OpenStack context.
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
||||
|
@ -14,10 +14,10 @@ import random
|
||||
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.configure("check_api_versions")
|
||||
@ -44,7 +44,7 @@ class CheckOpenStackAPIVersionsValidator(validation.Validator):
|
||||
|
||||
@validation.add("check_api_versions")
|
||||
@context.configure(name="api_versions", platform="openstack", order=150)
|
||||
class OpenStackAPIVersions(context.Context):
|
||||
class OpenStackAPIVersions(context.OpenStackContext):
|
||||
"""Context for specifying OpenStack clients versions and service types.
|
||||
|
||||
Some OpenStack services support several API versions. To recognize
|
||||
|
@ -15,13 +15,12 @@
|
||||
import time
|
||||
|
||||
from rally.common import logging
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.ceilometer import utils as ceilo_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -29,7 +28,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="ceilometer", platform="openstack", order=450)
|
||||
class CeilometerSampleGenerator(context.Context):
|
||||
class CeilometerSampleGenerator(context.OpenStackContext):
|
||||
"""Creates ceilometer samples and resources."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -128,8 +127,7 @@ class CeilometerSampleGenerator(context.Context):
|
||||
}
|
||||
resources = []
|
||||
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
self.context["tenants"][tenant_id]["samples"] = []
|
||||
self.context["tenants"][tenant_id]["resources"] = []
|
||||
scenario = ceilo_utils.CeilometerScenario(
|
||||
|
@ -15,12 +15,12 @@
|
||||
from rally.common import logging
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.services.storage import block
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
@validation.add("required_platform", platform="openstack", admin=True)
|
||||
@context.configure(name="volume_types", platform="openstack", order=410)
|
||||
class VolumeTypeGenerator(context.Context):
|
||||
class VolumeTypeGenerator(context.OpenStackContext):
|
||||
"""Adds cinder volumes types."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
|
@ -12,17 +12,15 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.services.storage import block
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@context.configure(name="volumes", platform="openstack", order=420)
|
||||
class VolumeGenerator(context.Context):
|
||||
class VolumeGenerator(context.OpenStackContext):
|
||||
"""Creates volumes for each tenant."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -59,8 +57,7 @@ class VolumeGenerator(context.Context):
|
||||
volume_type = self.config.get("type", None)
|
||||
volumes_per_tenant = self.config["volumes_per_tenant"]
|
||||
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
self.context["tenants"][tenant_id].setdefault("volumes", [])
|
||||
clients = osclients.Clients(user["credential"])
|
||||
cinder_service = block.BlockStorage(
|
||||
|
@ -16,18 +16,18 @@
|
||||
import sys
|
||||
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager
|
||||
from rally_openstack.contexts.cleanup import base
|
||||
from rally_openstack import scenario
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add(name="check_cleanup_resources", admin_required=True)
|
||||
# NOTE(amaretskiy): Set order to run this just before UserCleanup
|
||||
@context.configure(name="admin_cleanup", platform="openstack",
|
||||
order=(sys.maxsize - 1), hidden=True)
|
||||
class AdminCleanup(base.CleanupMixin, context.Context):
|
||||
class AdminCleanup(base.CleanupMixin, context.OpenStackContext):
|
||||
"""Context class for admin resources cleanup."""
|
||||
|
||||
def cleanup(self):
|
||||
|
@ -16,18 +16,18 @@
|
||||
import sys
|
||||
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager
|
||||
from rally_openstack.contexts.cleanup import base
|
||||
from rally_openstack import scenario
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add(name="check_cleanup_resources", admin_required=False)
|
||||
# NOTE(amaretskiy): Set maximum order to run this last
|
||||
@context.configure(name="cleanup", platform="openstack", order=sys.maxsize,
|
||||
hidden=True)
|
||||
class UserCleanup(base.CleanupMixin, context.Context):
|
||||
class UserCleanup(base.CleanupMixin, context.OpenStackContext):
|
||||
"""Context class for user resources cleanup."""
|
||||
|
||||
def cleanup(self):
|
||||
|
@ -18,12 +18,12 @@ import pkgutil
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.scenarios.heat import utils as heat_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
def get_data(filename_or_resource):
|
||||
@ -34,7 +34,7 @@ def get_data(filename_or_resource):
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="heat_dataplane", platform="openstack", order=435)
|
||||
class HeatDataplane(context.Context):
|
||||
class HeatDataplane(context.OpenStackContext):
|
||||
"""Context class for create stack by given template.
|
||||
|
||||
This context will create stacks by given template for each tenant and
|
||||
@ -125,8 +125,7 @@ class HeatDataplane(context.Context):
|
||||
with parameters.unlocked():
|
||||
if "network_id" not in parameters:
|
||||
parameters["network_id"] = self._get_public_network_id()
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
for name, path in self.config.get("context_parameters",
|
||||
{}).items():
|
||||
parameters[name] = self._get_context_parameter(user,
|
||||
|
@ -12,18 +12,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.designate import utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="zones", platform="openstack", order=600)
|
||||
class ZoneGenerator(context.Context):
|
||||
class ZoneGenerator(context.OpenStackContext):
|
||||
"""Context to add `zones_per_tenant` zones for each tenant."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -43,7 +42,7 @@ class ZoneGenerator(context.Context):
|
||||
}
|
||||
|
||||
def setup(self):
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
for user, tenant_id in self._iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
self.context["tenants"][tenant_id].setdefault("zones", [])
|
||||
designate_util = utils.DesignateScenario(
|
||||
|
@ -16,12 +16,12 @@ from rally.common import cfg
|
||||
from rally.common import logging
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.services.image import image
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -31,7 +31,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="images", platform="openstack", order=410)
|
||||
class ImageGenerator(context.Context):
|
||||
class ImageGenerator(context.OpenStackContext):
|
||||
"""Uploads specified Glance images to every tenant."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -159,8 +159,7 @@ class ImageGenerator(context.Context):
|
||||
if "image_name" in self.config and images_per_tenant == 1:
|
||||
image_name = self.config["image_name"]
|
||||
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
current_images = []
|
||||
clients = osclients.Clients(user["credential"])
|
||||
image_service = image.Image(
|
||||
|
@ -13,18 +13,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.heat import utils as heat_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="stacks", platform="openstack", order=435)
|
||||
class StackGenerator(context.Context):
|
||||
class StackGenerator(context.OpenStackContext):
|
||||
"""Context class for create temporary stacks with resources.
|
||||
|
||||
Stack generator allows to generate arbitrary number of stacks for
|
||||
@ -72,8 +71,7 @@ class StackGenerator(context.Context):
|
||||
def setup(self):
|
||||
template = self._prepare_stack_template(
|
||||
self.config["resources_per_stack"])
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
heat_scenario = heat_utils.HeatScenario(
|
||||
{"user": user, "task": self.context["task"],
|
||||
"owner_id": self.context["owner_id"]})
|
||||
|
@ -18,11 +18,11 @@ from rally.common import cfg
|
||||
from rally.common import logging
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.services.identity import identity
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -32,7 +32,7 @@ CONF = cfg.CONF
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="roles", platform="openstack", order=330)
|
||||
class RoleGenerator(context.Context):
|
||||
class RoleGenerator(context.OpenStackContext):
|
||||
"""Context class for assigning roles for users."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
|
@ -20,15 +20,14 @@ import uuid
|
||||
from rally.common import broker
|
||||
from rally.common import cfg
|
||||
from rally.common import logging
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import credential
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.services.identity import identity
|
||||
from rally_openstack.task import context
|
||||
from rally_openstack.wrappers import network
|
||||
|
||||
|
||||
@ -44,7 +43,7 @@ USER_DOMAIN_DESCR = "ID of domain in which users will be created."
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="users", platform="openstack", order=100)
|
||||
class UserGenerator(context.Context):
|
||||
class UserGenerator(context.OpenStackContext):
|
||||
"""Creates specified amount of keystone users and tenants."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -149,8 +148,7 @@ class UserGenerator(context.Context):
|
||||
LOG.debug("Security group context is disabled: %s" % msg)
|
||||
return
|
||||
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
with logging.ExceptionLogger(
|
||||
LOG, "Unable to delete default security group"):
|
||||
uclients = osclients.Clients(user["credential"])
|
||||
|
@ -16,15 +16,15 @@ import os
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.magnum import utils as magnum_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="ca_certs", platform="openstack", order=490)
|
||||
class CaCertGenerator(context.Context):
|
||||
class CaCertGenerator(context.OpenStackContext):
|
||||
"""Creates ca certs."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -70,8 +70,7 @@ class CaCertGenerator(context.Context):
|
||||
return result
|
||||
|
||||
def setup(self):
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
|
||||
magnum_scenario = magnum_utils.MagnumScenario({
|
||||
"user": user,
|
||||
|
@ -12,18 +12,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.magnum import utils as magnum_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="cluster_templates", platform="openstack", order=470)
|
||||
class ClusterTemplateGenerator(context.Context):
|
||||
class ClusterTemplateGenerator(context.OpenStackContext):
|
||||
"""Creates Magnum cluster template."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -102,8 +101,7 @@ class ClusterTemplateGenerator(context.Context):
|
||||
}
|
||||
|
||||
def setup(self):
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
|
||||
magnum_scenario = magnum_utils.MagnumScenario({
|
||||
"user": user,
|
||||
|
@ -12,19 +12,18 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.magnum import utils as magnum_utils
|
||||
from rally_openstack.scenarios.nova import utils as nova_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="clusters", platform="openstack", order=480)
|
||||
class ClusterGenerator(context.Context):
|
||||
class ClusterGenerator(context.OpenStackContext):
|
||||
"""Creates specified amount of Magnum clusters."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -45,8 +44,7 @@ class ClusterGenerator(context.Context):
|
||||
DEFAULT_CONFIG = {"node_count": 1}
|
||||
|
||||
def setup(self):
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
|
||||
nova_scenario = nova_utils.NovaScenario({
|
||||
"user": user,
|
||||
|
@ -14,14 +14,13 @@
|
||||
# under the License.
|
||||
|
||||
from rally.common import cfg
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts as rally_consts
|
||||
from rally_openstack.contexts.manila import consts
|
||||
from rally_openstack.scenarios.manila import utils as manila_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -30,7 +29,7 @@ CONTEXT_NAME = consts.SECURITY_SERVICES_CONTEXT_NAME
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name=CONTEXT_NAME, platform="openstack", order=445)
|
||||
class SecurityServices(context.Context):
|
||||
class SecurityServices(context.OpenStackContext):
|
||||
"""This context creates 'security services' for Manila project."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -65,7 +64,7 @@ class SecurityServices(context.Context):
|
||||
}
|
||||
|
||||
def setup(self):
|
||||
for user, tenant_id in (utils.iterate_per_tenants(
|
||||
for user, tenant_id in (self._iterate_per_tenants(
|
||||
self.context.get("users", []))):
|
||||
self.context["tenants"][tenant_id][CONTEXT_NAME] = {
|
||||
"security_services": [],
|
||||
|
@ -15,15 +15,14 @@
|
||||
|
||||
from rally.common import cfg
|
||||
from rally.common import logging
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts as rally_consts
|
||||
from rally_openstack.contexts.manila import consts
|
||||
from rally_openstack.scenarios.manila import utils as manila_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -63,7 +62,7 @@ users that does not satisfy criteria.
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name=CONTEXT_NAME, platform="openstack", order=450)
|
||||
class ShareNetworks(context.Context):
|
||||
class ShareNetworks(context.OpenStackContext):
|
||||
"""This context creates share networks for Manila project."""
|
||||
CONFIG_SCHEMA = {
|
||||
"type": "object",
|
||||
@ -141,7 +140,7 @@ class ShareNetworks(context.Context):
|
||||
|
||||
def _setup_for_autocreated_users(self):
|
||||
# Create share network for each network of tenant
|
||||
for user, tenant_id in (utils.iterate_per_tenants(
|
||||
for user, tenant_id in (self._iterate_per_tenants(
|
||||
self.context.get("users", []))):
|
||||
networks = self.context["tenants"][tenant_id].get("networks")
|
||||
manila_scenario = manila_utils.ManilaScenario({
|
||||
|
@ -14,14 +14,13 @@
|
||||
# under the License.
|
||||
|
||||
from rally.common import cfg
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts as rally_consts
|
||||
from rally_openstack.contexts.manila import consts
|
||||
from rally_openstack.scenarios.manila import utils as manila_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONTEXT_NAME = consts.SHARES_CONTEXT_NAME
|
||||
@ -29,7 +28,7 @@ CONTEXT_NAME = consts.SHARES_CONTEXT_NAME
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name=CONTEXT_NAME, platform="openstack", order=455)
|
||||
class Shares(context.Context):
|
||||
class Shares(context.OpenStackContext):
|
||||
"""This context creates shares for Manila project."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -78,8 +77,7 @@ class Shares(context.Context):
|
||||
tenant_ctxt["shares"].append(share.to_dict())
|
||||
|
||||
def setup(self):
|
||||
for user, tenant_id in (
|
||||
utils.iterate_per_tenants(self.context.get("users", []))):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
manila_scenario = manila_utils.ManilaScenario({
|
||||
"task": self.task,
|
||||
"owner_id": self.context["owner_id"],
|
||||
|
@ -14,15 +14,15 @@
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.monasca import utils as monasca_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="monasca_metrics", platform="openstack", order=510)
|
||||
class MonascaMetricGenerator(context.Context):
|
||||
class MonascaMetricGenerator(context.OpenStackContext):
|
||||
"""Creates Monasca Metrics."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -85,8 +85,7 @@ class MonascaMetricGenerator(context.Context):
|
||||
"dimensions": self.config["dimensions"]
|
||||
}
|
||||
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
scenario = monasca_utils.MonascaScenario(
|
||||
context={"user": user, "task": self.context["task"]}
|
||||
)
|
||||
|
@ -13,18 +13,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.murano import utils as murano_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="murano_environments", platform="openstack", order=402)
|
||||
class EnvironmentGenerator(context.Context):
|
||||
class EnvironmentGenerator(context.OpenStackContext):
|
||||
"""Context class for creating murano environments."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -41,8 +40,7 @@ class EnvironmentGenerator(context.Context):
|
||||
}
|
||||
|
||||
def setup(self):
|
||||
for user, tenant_id in utils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
self.context["tenants"][tenant_id]["environments"] = []
|
||||
for i in range(self.config["environments_per_tenant"]):
|
||||
murano_util = murano_utils.MuranoScenario(
|
||||
|
@ -16,20 +16,19 @@
|
||||
import os
|
||||
import zipfile
|
||||
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.scenarios.murano import utils as mutils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="murano_packages", platform="openstack", order=401)
|
||||
class PackageGenerator(context.Context):
|
||||
class PackageGenerator(context.OpenStackContext):
|
||||
"""Context class for uploading applications for murano."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -57,8 +56,7 @@ class PackageGenerator(context.Context):
|
||||
raise exceptions.ContextSetupFailure(msg=msg % pckg_path,
|
||||
ctx_name=self.get_name())
|
||||
|
||||
for user, tenant_id in utils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
clients = osclients.Clients(user["credential"])
|
||||
self.context["tenants"][tenant_id]["packages"] = []
|
||||
if is_config_app_dir:
|
||||
|
@ -14,11 +14,10 @@
|
||||
# under the License.
|
||||
|
||||
from rally.common import logging
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.task import context
|
||||
from rally_openstack.wrappers import network
|
||||
|
||||
|
||||
@ -117,7 +116,7 @@ def _prepare_open_secgroup(credential, secgroup_name):
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="allow_ssh", platform="openstack", order=320)
|
||||
class AllowSSH(context.Context):
|
||||
class AllowSSH(context.OpenStackContext):
|
||||
"""Sets up security groups for all users to access VM via SSH."""
|
||||
|
||||
def setup(self):
|
||||
@ -138,8 +137,7 @@ class AllowSSH(context.Context):
|
||||
secgroup_name)
|
||||
|
||||
def cleanup(self):
|
||||
for user, tenant_id in utils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
with logging.ExceptionLogger(
|
||||
LOG,
|
||||
"Unable to delete security group: %s."
|
||||
|
@ -12,18 +12,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.task import context
|
||||
from rally_openstack.wrappers import network as network_wrapper
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="existing_network", platform="openstack", order=349)
|
||||
class ExistingNetwork(context.Context):
|
||||
class ExistingNetwork(context.OpenStackContext):
|
||||
"""This context supports using existing networks in Rally.
|
||||
|
||||
This context should be used on a deployment with existing users.
|
||||
@ -36,8 +35,7 @@ class ExistingNetwork(context.Context):
|
||||
}
|
||||
|
||||
def setup(self):
|
||||
for user, tenant_id in utils.iterate_per_tenants(
|
||||
self.context.get("users", [])):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
net_wrapper = network_wrapper.wrap(
|
||||
osclients.Clients(user["credential"]), self,
|
||||
config=self.config)
|
||||
|
@ -14,17 +14,17 @@
|
||||
|
||||
from rally.common import logging
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.task import context
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", admin=True)
|
||||
@context.configure(name="networking_agents", platform="openstack", order=349)
|
||||
class NetworkingAgents(context.Context):
|
||||
class NetworkingAgents(context.OpenStackContext):
|
||||
"""This context supports querying Neutron agents in Rally."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
|
@ -14,12 +14,11 @@
|
||||
# under the License.
|
||||
|
||||
from rally.common import logging
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.task import context
|
||||
from rally_openstack.wrappers import network as network_wrapper
|
||||
|
||||
|
||||
@ -30,7 +29,7 @@ LOG = logging.getLogger(__name__)
|
||||
@validation.add("required_platform", platform="openstack", admin=True,
|
||||
users=True)
|
||||
@context.configure(name="network", platform="openstack", order=350)
|
||||
class Network(context.Context):
|
||||
class Network(context.OpenStackContext):
|
||||
"""Create networking resources.
|
||||
|
||||
This creates networks for all tenants, and optionally creates
|
||||
@ -107,8 +106,7 @@ class Network(context.Context):
|
||||
kwargs = {}
|
||||
if self.config["dns_nameservers"] is not None:
|
||||
kwargs["dns_nameservers"] = self.config["dns_nameservers"]
|
||||
for user, tenant_id in (utils.iterate_per_tenants(
|
||||
self.context.get("users", []))):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
self.context["tenants"][tenant_id]["networks"] = []
|
||||
for i in range(self.config["networks_per_tenant"]):
|
||||
# NOTE(amaretskiy): router_create_args and subnets_num take
|
||||
|
@ -13,19 +13,18 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.neutron import utils as neutron_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", admin=True,
|
||||
users=True)
|
||||
@context.configure(name="router", platform="openstack", order=351)
|
||||
class Router(context.Context):
|
||||
class Router(context.OpenStackContext):
|
||||
"""Create networking resources.
|
||||
|
||||
This creates router for all tenants.
|
||||
@ -96,8 +95,7 @@ class Router(context.Context):
|
||||
for parameter in parameters:
|
||||
if parameter in self.config:
|
||||
kwargs[parameter] = self.config[parameter]
|
||||
for user, tenant_id in (utils.iterate_per_tenants(
|
||||
self.context.get("users", []))):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
self.context["tenants"][tenant_id]["routers"] = []
|
||||
scenario = neutron_utils.NeutronScenario(
|
||||
context={"user": user, "task": self.context["task"],
|
||||
|
@ -11,13 +11,11 @@
|
||||
# under the License.
|
||||
|
||||
from rally.common import logging
|
||||
from rally.common import utils
|
||||
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.task import context
|
||||
from rally_openstack.wrappers import network as network_wrapper
|
||||
|
||||
|
||||
@ -27,7 +25,7 @@ LOG = logging.getLogger(__name__)
|
||||
@validation.add("required_platform", platform="openstack", admin=True,
|
||||
users=True)
|
||||
@context.configure(name="lbaas", platform="openstack", order=360)
|
||||
class Lbaas(context.Context):
|
||||
class Lbaas(context.OpenStackContext):
|
||||
"""Creates a lb-pool for every subnet created in network context."""
|
||||
CONFIG_SCHEMA = {
|
||||
"type": "object",
|
||||
@ -64,8 +62,7 @@ class Lbaas(context.Context):
|
||||
return
|
||||
|
||||
# Creates a lb-pool for every subnet created in network context.
|
||||
for user, tenant_id in (utils.iterate_per_tenants(
|
||||
self.context.get("users", []))):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
for network in self.context["tenants"][tenant_id]["networks"]:
|
||||
for subnet in network.get("subnets", []):
|
||||
if self.config["lbaas_version"] == 1:
|
||||
|
@ -16,11 +16,11 @@
|
||||
from rally.common import logging
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
@validation.add("required_platform", platform="openstack", admin=True)
|
||||
@context.configure(name="flavors", platform="openstack", order=340)
|
||||
class FlavorsGenerator(context.Context):
|
||||
class FlavorsGenerator(context.OpenStackContext):
|
||||
"""Context creates a list of flavors."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
|
@ -14,15 +14,15 @@
|
||||
# under the License.
|
||||
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="keypair", platform="openstack", order=310)
|
||||
class Keypair(context.Context):
|
||||
class Keypair(context.OpenStackContext):
|
||||
"""Create Nova KeyPair for each user."""
|
||||
|
||||
# NOTE(andreykurilin): "type" != "null", since we need to support backward
|
||||
|
@ -13,12 +13,11 @@
|
||||
# under the License.
|
||||
|
||||
from rally.common import logging
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack.scenarios.nova import utils as nova_utils
|
||||
from rally_openstack.task import context
|
||||
from rally_openstack import types
|
||||
|
||||
|
||||
@ -27,7 +26,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="servers", platform="openstack", order=430)
|
||||
class ServerGenerator(context.Context):
|
||||
class ServerGenerator(context.OpenStackContext):
|
||||
"""Creates specified amount of Nova Servers per each tenant."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -105,8 +104,7 @@ class ServerGenerator(context.Context):
|
||||
flavor_id = types.Flavor(self.context).pre_process(
|
||||
resource_spec=flavor, config={})
|
||||
|
||||
for iter_, (user, tenant_id) in enumerate(rutils.iterate_per_tenants(
|
||||
self.context["users"])):
|
||||
for iter_, (user, tenant_id) in enumerate(self._iterate_per_tenants()):
|
||||
LOG.debug("Booting servers for user tenant %s" % user["tenant_id"])
|
||||
tmp_context = {"user": user,
|
||||
"tenant": self.context["tenants"][tenant_id],
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
from rally.common import logging
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.contexts.quotas import cinder_quotas
|
||||
@ -24,6 +23,7 @@ from rally_openstack.contexts.quotas import manila_quotas
|
||||
from rally_openstack.contexts.quotas import neutron_quotas
|
||||
from rally_openstack.contexts.quotas import nova_quotas
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -31,7 +31,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
@validation.add("required_platform", platform="openstack", admin=True)
|
||||
@context.configure(name="quotas", platform="openstack", order=300)
|
||||
class Quotas(context.Context):
|
||||
class Quotas(context.OpenStackContext):
|
||||
"""Sets OpenStack Tenants quotas."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
|
@ -14,15 +14,14 @@
|
||||
# under the License.
|
||||
|
||||
from rally.common import cfg
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
from rally.task import utils as bench_utils
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.sahara import utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -30,7 +29,7 @@ CONF = cfg.CONF
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="sahara_cluster", platform="openstack", order=441)
|
||||
class SaharaCluster(context.Context):
|
||||
class SaharaCluster(context.OpenStackContext):
|
||||
"""Context class for setting up the Cluster an EDP job."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -105,8 +104,7 @@ class SaharaCluster(context.Context):
|
||||
|
||||
wait_dict = {}
|
||||
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
|
||||
image_id = self.context["tenants"][tenant_id]["sahara"]["image"]
|
||||
|
||||
|
@ -12,21 +12,20 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.scenarios.sahara import utils
|
||||
from rally_openstack.services.image import image as image_services
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="sahara_image", platform="openstack", order=440)
|
||||
class SaharaImage(context.Context):
|
||||
class SaharaImage(context.OpenStackContext):
|
||||
"""Context class for adding and tagging Sahara images."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -103,13 +102,11 @@ class SaharaImage(context.Context):
|
||||
)
|
||||
image_id = image_uuid
|
||||
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
self.context["tenants"][tenant_id]["sahara"]["image"] = (
|
||||
image_id)
|
||||
else:
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
|
||||
image_id = self._create_image(
|
||||
hadoop_version=self.config["hadoop_version"],
|
||||
|
@ -17,21 +17,20 @@ from urllib.parse import urlparse
|
||||
|
||||
import requests
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.scenarios.sahara import utils
|
||||
from rally_openstack.scenarios.swift import utils as swift_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="sahara_input_data_sources", platform="openstack",
|
||||
order=443)
|
||||
class SaharaInputDataSources(context.Context):
|
||||
class SaharaInputDataSources(context.OpenStackContext):
|
||||
"""Context class for setting up Input Data Sources for an EDP job."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -70,8 +69,7 @@ class SaharaInputDataSources(context.Context):
|
||||
self.context["sahara"]["swift_objects"] = []
|
||||
self.context["sahara"]["container_name"] = None
|
||||
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
clients = osclients.Clients(user["credential"])
|
||||
if self.config["input_type"] == "swift":
|
||||
self.setup_inputs_swift(clients, tenant_id,
|
||||
|
@ -15,20 +15,19 @@
|
||||
|
||||
import requests
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.scenarios.sahara import utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="sahara_job_binaries", platform="openstack", order=442)
|
||||
class SaharaJobBinaries(context.Context):
|
||||
class SaharaJobBinaries(context.OpenStackContext):
|
||||
"""Context class for setting up Job Binaries for an EDP job."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -77,8 +76,7 @@ class SaharaJobBinaries(context.Context):
|
||||
|
||||
def setup(self):
|
||||
utils.init_sahara_context(self)
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
|
||||
clients = osclients.Clients(user["credential"])
|
||||
sahara = clients.sahara()
|
||||
|
@ -13,21 +13,20 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.scenarios.sahara import utils
|
||||
from rally_openstack.scenarios.swift import utils as swift_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="sahara_output_data_sources", platform="openstack",
|
||||
order=444)
|
||||
class SaharaOutputDataSources(context.Context):
|
||||
class SaharaOutputDataSources(context.OpenStackContext):
|
||||
"""Context class for setting up Output Data Sources for an EDP job."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -47,8 +46,7 @@ class SaharaOutputDataSources(context.Context):
|
||||
|
||||
def setup(self):
|
||||
utils.init_sahara_context(self)
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
|
||||
clients = osclients.Clients(user["credential"])
|
||||
sahara = clients.sahara()
|
||||
|
@ -10,17 +10,16 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally.common import utils as rutils
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.senlin import utils as senlin_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="profiles", platform="openstack", order=190)
|
||||
class ProfilesGenerator(context.Context):
|
||||
class ProfilesGenerator(context.OpenStackContext):
|
||||
"""Context creates a temporary profile for Senlin test."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
@ -44,8 +43,7 @@ class ProfilesGenerator(context.Context):
|
||||
|
||||
def setup(self):
|
||||
"""Create test profiles."""
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
|
||||
senlin_scenario = senlin_utils.SenlinScenario({
|
||||
"user": user,
|
||||
@ -57,8 +55,7 @@ class ProfilesGenerator(context.Context):
|
||||
|
||||
def cleanup(self):
|
||||
"""Delete created test profiles."""
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
|
||||
senlin_scenario = senlin_utils.SenlinScenario({
|
||||
"user": user,
|
||||
|
@ -16,17 +16,18 @@
|
||||
from rally.common import logging
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.contexts.swift import utils as swift_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
@context.configure(name="swift_objects", platform="openstack", order=360)
|
||||
class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
||||
class SwiftObjectGenerator(swift_utils.SwiftObjectMixin,
|
||||
context.OpenStackContext):
|
||||
"""Create containers and objects in each tenant."""
|
||||
CONFIG_SCHEMA = {
|
||||
"type": "object",
|
||||
@ -67,8 +68,7 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
||||
containers_num = len(self.context["tenants"]) * containers_per_tenant
|
||||
LOG.debug("Creating %d containers using %d threads."
|
||||
% (containers_num, threads))
|
||||
containers_count = len(self._create_containers(self.context,
|
||||
containers_per_tenant,
|
||||
containers_count = len(self._create_containers(containers_per_tenant,
|
||||
threads))
|
||||
if containers_count != containers_num:
|
||||
raise exceptions.ContextSetupFailure(
|
||||
@ -81,8 +81,7 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
||||
objects_num = containers_num * objects_per_container
|
||||
LOG.debug("Creating %d objects using %d threads."
|
||||
% (objects_num, threads))
|
||||
objects_count = len(self._create_objects(self.context,
|
||||
objects_per_container,
|
||||
objects_count = len(self._create_objects(objects_per_container,
|
||||
self.config["object_size"],
|
||||
threads))
|
||||
if objects_count != objects_num:
|
||||
@ -96,5 +95,5 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
||||
"""Delete containers and objects, using the broker pattern."""
|
||||
threads = self.config["resource_management_workers"]
|
||||
|
||||
self._delete_objects(self.context, threads)
|
||||
self._delete_containers(self.context, threads)
|
||||
self._delete_objects(threads)
|
||||
self._delete_containers(threads)
|
||||
|
@ -16,7 +16,6 @@
|
||||
import tempfile
|
||||
|
||||
from rally.common import broker
|
||||
from rally.common import utils as rutils
|
||||
|
||||
from rally_openstack.scenarios.swift import utils as swift_utils
|
||||
|
||||
@ -24,10 +23,9 @@ from rally_openstack.scenarios.swift import utils as swift_utils
|
||||
class SwiftObjectMixin(object):
|
||||
"""Mix-in method for Swift Object Context."""
|
||||
|
||||
def _create_containers(self, context, containers_per_tenant, threads):
|
||||
def _create_containers(self, containers_per_tenant, threads):
|
||||
"""Create containers and store results in Rally context.
|
||||
|
||||
:param context: dict, Rally context environment
|
||||
:param containers_per_tenant: int, number of containers to create
|
||||
per tenant
|
||||
:param threads: int, number of threads to use for broker pattern
|
||||
@ -37,18 +35,18 @@ class SwiftObjectMixin(object):
|
||||
containers = []
|
||||
|
||||
def publish(queue):
|
||||
for user, tenant_id in (rutils.iterate_per_tenants(
|
||||
context.get("users", []))):
|
||||
context["tenants"][tenant_id]["containers"] = []
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
self.context["tenants"][tenant_id]["containers"] = []
|
||||
for i in range(containers_per_tenant):
|
||||
args = (user, context["tenants"][tenant_id]["containers"])
|
||||
args = (user,
|
||||
self.context["tenants"][tenant_id]["containers"])
|
||||
queue.append(args)
|
||||
|
||||
def consume(cache, args):
|
||||
user, tenant_containers = args
|
||||
if user["id"] not in cache:
|
||||
cache[user["id"]] = swift_utils.SwiftScenario(
|
||||
{"user": user, "task": context.get("task", {})})
|
||||
{"user": user, "task": self.context.get("task", {})})
|
||||
container_name = cache[user["id"]]._create_container()
|
||||
tenant_containers.append({"user": user,
|
||||
"container": container_name,
|
||||
@ -59,11 +57,9 @@ class SwiftObjectMixin(object):
|
||||
|
||||
return containers
|
||||
|
||||
def _create_objects(self, context, objects_per_container, object_size,
|
||||
threads):
|
||||
def _create_objects(self, objects_per_container, object_size, threads):
|
||||
"""Create objects and store results in Rally context.
|
||||
|
||||
:param context: dict, Rally context environment
|
||||
:param objects_per_container: int, number of objects to create
|
||||
per container
|
||||
:param object_size: int, size of created swift objects in byte
|
||||
@ -78,9 +74,9 @@ class SwiftObjectMixin(object):
|
||||
dummy_file.truncate(object_size)
|
||||
|
||||
def publish(queue):
|
||||
for tenant_id in context["tenants"]:
|
||||
containers = context["tenants"][tenant_id]["containers"]
|
||||
for container in containers:
|
||||
for tenant_id in self.context["tenants"]:
|
||||
items = self.context["tenants"][tenant_id]["containers"]
|
||||
for container in items:
|
||||
for i in range(objects_per_container):
|
||||
queue.append(container)
|
||||
|
||||
@ -88,7 +84,7 @@ class SwiftObjectMixin(object):
|
||||
user = container["user"]
|
||||
if user["id"] not in cache:
|
||||
cache[user["id"]] = swift_utils.SwiftScenario(
|
||||
{"user": user, "task": context.get("task", {})})
|
||||
{"user": user, "task": self.context.get("task", {})})
|
||||
dummy_file.seek(0)
|
||||
object_name = cache[user["id"]]._upload_object(
|
||||
container["container"],
|
||||
@ -101,15 +97,14 @@ class SwiftObjectMixin(object):
|
||||
|
||||
return objects
|
||||
|
||||
def _delete_containers(self, context, threads):
|
||||
def _delete_containers(self, threads):
|
||||
"""Delete containers created by Swift context and update Rally context.
|
||||
|
||||
:param context: dict, Rally context environment
|
||||
:param threads: int, number of threads to use for broker pattern
|
||||
"""
|
||||
def publish(queue):
|
||||
for tenant_id in context["tenants"]:
|
||||
containers = context["tenants"][tenant_id]["containers"]
|
||||
for tenant_id in self.context["tenants"]:
|
||||
containers = self.context["tenants"][tenant_id]["containers"]
|
||||
for container in containers[:]:
|
||||
args = container, containers
|
||||
queue.append(args)
|
||||
@ -119,21 +114,20 @@ class SwiftObjectMixin(object):
|
||||
user = container["user"]
|
||||
if user["id"] not in cache:
|
||||
cache[user["id"]] = swift_utils.SwiftScenario(
|
||||
{"user": user, "task": context.get("task", {})})
|
||||
{"user": user, "task": self.context.get("task", {})})
|
||||
cache[user["id"]]._delete_container(container["container"])
|
||||
tenant_containers.remove(container)
|
||||
|
||||
broker.run(publish, consume, threads)
|
||||
|
||||
def _delete_objects(self, context, threads):
|
||||
def _delete_objects(self, threads):
|
||||
"""Delete objects created by Swift context and update Rally context.
|
||||
|
||||
:param context: dict, Rally context environment
|
||||
:param threads: int, number of threads to use for broker pattern
|
||||
"""
|
||||
def publish(queue):
|
||||
for tenant_id in context["tenants"]:
|
||||
containers = context["tenants"][tenant_id]["containers"]
|
||||
for tenant_id in self.context["tenants"]:
|
||||
containers = self.context["tenants"][tenant_id]["containers"]
|
||||
for container in containers:
|
||||
for object_name in container["objects"][:]:
|
||||
args = object_name, container
|
||||
@ -144,7 +138,7 @@ class SwiftObjectMixin(object):
|
||||
user = container["user"]
|
||||
if user["id"] not in cache:
|
||||
cache[user["id"]] = swift_utils.SwiftScenario(
|
||||
{"user": user, "task": context.get("task", {})})
|
||||
{"user": user, "task": self.context.get("task", {})})
|
||||
cache[user["id"]]._delete_object(container["container"],
|
||||
object_name)
|
||||
container["objects"].remove(object_name)
|
||||
|
@ -18,19 +18,20 @@ import abc
|
||||
from rally.common import broker
|
||||
from rally.common import logging
|
||||
from rally.common import utils
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack import consts
|
||||
from rally_openstack import osclients
|
||||
from rally_openstack.scenarios.vm import vmtasks
|
||||
from rally_openstack.services.image import image
|
||||
from rally_openstack.task import context
|
||||
from rally_openstack import types
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BaseCustomImageGenerator(context.Context, metaclass=abc.ABCMeta):
|
||||
class BaseCustomImageGenerator(context.OpenStackContext,
|
||||
metaclass=abc.ABCMeta):
|
||||
"""Base plugin for the contexts providing customized image with.
|
||||
|
||||
Every context plugin for the specific customization must implement
|
||||
@ -131,8 +132,7 @@ class BaseCustomImageGenerator(context.Context, metaclass=abc.ABCMeta):
|
||||
tenant["custom_image"] = custom_image
|
||||
else:
|
||||
def publish(queue):
|
||||
users = self.context.get("users", [])
|
||||
for user, tenant_id in utils.iterate_per_tenants(users):
|
||||
for user, tenant_id in self._iterate_per_tenants():
|
||||
queue.append((user, tenant_id))
|
||||
|
||||
def consume(cache, args):
|
||||
|
@ -17,10 +17,10 @@ import copy
|
||||
|
||||
from rally.common import validation
|
||||
from rally import exceptions
|
||||
import rally.task.context as context
|
||||
|
||||
from rally_openstack.contexts.vm import custom_image
|
||||
from rally_openstack.scenarios.vm import utils as vm_utils
|
||||
from rally_openstack.task import context
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", users=True)
|
||||
|
@ -15,17 +15,17 @@
|
||||
import random
|
||||
|
||||
from rally.common import validation
|
||||
from rally.task import context
|
||||
|
||||
from rally_openstack.cleanup import manager as resource_manager
|
||||
from rally_openstack import consts
|
||||
from rally_openstack.scenarios.watcher import utils as watcher_utils
|
||||
from rally_openstack.task import context
|
||||
from rally_openstack import types
|
||||
|
||||
|
||||
@validation.add("required_platform", platform="openstack", admin=True)
|
||||
@context.configure(name="audit_templates", platform="openstack", order=550)
|
||||
class AuditTemplateGenerator(context.Context):
|
||||
class AuditTemplateGenerator(context.OpenStackContext):
|
||||
"""Creates Watcher audit templates for tenants."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
|
0
rally_openstack/task/__init__.py
Normal file
0
rally_openstack/task/__init__.py
Normal file
37
rally_openstack/task/context.py
Normal file
37
rally_openstack/task/context.py
Normal file
@ -0,0 +1,37 @@
|
||||
# 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.
|
||||
|
||||
import functools
|
||||
|
||||
from rally.task import context
|
||||
|
||||
|
||||
configure = functools.partial(context.configure, platform="openstack")
|
||||
|
||||
|
||||
class OpenStackContext(context.Context):
|
||||
"""A base class for all OpenStack context classes."""
|
||||
|
||||
def _iterate_per_tenants(self, users=None):
|
||||
"""Iterate of a single arbitrary user from each tenant
|
||||
|
||||
:type users: list of users
|
||||
:return: iterator of a single user from each tenant
|
||||
"""
|
||||
if users is None:
|
||||
users = self.context.get("users", [])
|
||||
|
||||
processed_tenants = set()
|
||||
for user in users:
|
||||
if user["tenant_id"] not in processed_tenants:
|
||||
processed_tenants.add(user["tenant_id"])
|
||||
yield user, user["tenant_id"]
|
@ -292,10 +292,8 @@ class UserGeneratorForNewUsersTestCase(test.ScenarioTestCase):
|
||||
net_wrapper.supports_extension.assert_called_once_with(
|
||||
"security-group")
|
||||
|
||||
@mock.patch("rally.common.utils.iterate_per_tenants")
|
||||
@mock.patch("%s.network" % CTX)
|
||||
def test__remove_default_security_group(
|
||||
self, mock_network, mock_iterate_per_tenants):
|
||||
def test__remove_default_security_group(self, mock_network):
|
||||
net_wrapper = mock.Mock(SERVICE_IMPL=consts.Service.NEUTRON)
|
||||
net_wrapper.supports_extension.return_value = (True, None)
|
||||
mock_network.wrap.return_value = net_wrapper
|
||||
@ -317,20 +315,22 @@ class UserGeneratorForNewUsersTestCase(test.ScenarioTestCase):
|
||||
user_clients = [user1, user2]
|
||||
self.osclients.Clients.side_effect = [admin_clients] + user_clients
|
||||
|
||||
mock_iterate_per_tenants.return_value = [
|
||||
(mock.MagicMock(), "t1"),
|
||||
(mock.MagicMock(), "t2")]
|
||||
user_generator._iterate_per_tenants = mock.MagicMock(
|
||||
return_value=[
|
||||
(mock.MagicMock(), "t1"),
|
||||
(mock.MagicMock(), "t2")
|
||||
]
|
||||
)
|
||||
|
||||
user_generator._remove_default_security_group()
|
||||
|
||||
mock_network.wrap.assert_called_once_with(admin_clients,
|
||||
user_generator)
|
||||
|
||||
mock_iterate_per_tenants.assert_called_once_with(
|
||||
user_generator.context["users"])
|
||||
user_generator._iterate_per_tenants.assert_called_once_with()
|
||||
expected = [mock.call(user_generator.credential)] + [
|
||||
mock.call(u["credential"])
|
||||
for u, t in mock_iterate_per_tenants.return_value]
|
||||
for u, t in user_generator._iterate_per_tenants.return_value]
|
||||
self.osclients.Clients.assert_has_calls(expected, any_order=True)
|
||||
|
||||
user_net = user1.neutron.return_value
|
||||
|
@ -66,20 +66,20 @@ class NetworkTestCase(test.TestCase):
|
||||
{"dns_nameservers": ["1.2.3.4", "5.6.7.8"]})
|
||||
@ddt.unpack
|
||||
@mock.patch(NET + "wrap")
|
||||
@mock.patch("rally_openstack.contexts.network.networks.utils")
|
||||
@mock.patch("rally_openstack.osclients.Clients")
|
||||
def test_setup(self, mock_clients, mock_utils, mock_wrap, **dns_kwargs):
|
||||
mock_utils.iterate_per_tenants.return_value = [
|
||||
("foo_user", "foo_tenant"),
|
||||
("bar_user", "bar_tenant")]
|
||||
def test_setup(self, mock_clients, mock_wrap, **dns_kwargs):
|
||||
mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
|
||||
mock_utils.generate_random_name = mock.Mock()
|
||||
mock_wrap.return_value = mock.Mock(create_network=mock_create)
|
||||
nets_per_tenant = 2
|
||||
net_context = network_context.Network(
|
||||
self.get_context(networks_per_tenant=nets_per_tenant,
|
||||
network_create_args={"fakearg": "fake"},
|
||||
**dns_kwargs))
|
||||
net_context._iterate_per_tenants = mock.MagicMock(
|
||||
return_value=[
|
||||
("foo_user", "foo_tenant"),
|
||||
("bar_user", "bar_tenant")]
|
||||
)
|
||||
|
||||
net_context.setup()
|
||||
|
||||
@ -91,11 +91,10 @@ class NetworkTestCase(test.TestCase):
|
||||
subnets_num=1, network_create_args={"fakearg": "fake"},
|
||||
router_create_args={"external": True},
|
||||
**dns_kwargs)
|
||||
for user, tenant in mock_utils.iterate_per_tenants.return_value]
|
||||
for user, tenant in net_context._iterate_per_tenants.return_value]
|
||||
mock_create.assert_has_calls(create_calls)
|
||||
|
||||
mock_utils.iterate_per_tenants.assert_called_once_with(
|
||||
net_context.context["users"])
|
||||
net_context._iterate_per_tenants.assert_called_once_with()
|
||||
expected_networks = ["bar_tenant-net",
|
||||
"foo_tenant-net"] * nets_per_tenant
|
||||
actual_networks = []
|
||||
|
@ -57,12 +57,8 @@ class LbaasTestCase(test.TestCase):
|
||||
"LEAST_CONNECTIONS")
|
||||
|
||||
@mock.patch(NET + "wrap")
|
||||
@mock.patch("rally_openstack.contexts.neutron.lbaas.utils")
|
||||
@mock.patch("rally_openstack.osclients.Clients")
|
||||
def test_setup_with_lbaas(self, mock_clients, mock_utils, mock_wrap):
|
||||
mock_utils.iterate_per_tenants.return_value = [
|
||||
("foo_user", "foo_tenant"),
|
||||
("bar_user", "bar_tenant")]
|
||||
def test_setup_with_lbaas(self, mock_clients, mock_wrap):
|
||||
foo_net = {"id": "foo_net",
|
||||
"tenant_id": "foo_tenant",
|
||||
"subnets": ["foo_subnet"],
|
||||
@ -83,10 +79,17 @@ class LbaasTestCase(test.TestCase):
|
||||
net_wrapper = mock_wrap(mock_clients.return_value)
|
||||
net_wrapper.supports_extension.return_value = (True, None)
|
||||
fake_args = {"lbaas_version": 1}
|
||||
|
||||
lb_context = lbaas_context.Lbaas(self.get_context(**fake_args))
|
||||
lb_context._iterate_per_tenants = mock.MagicMock(
|
||||
return_value=[
|
||||
("foo_user", "foo_tenant"),
|
||||
("bar_user", "bar_tenant")]
|
||||
)
|
||||
|
||||
lb_context.setup()
|
||||
mock_utils.iterate_per_tenants.assert_called_once_with(
|
||||
lb_context.context["users"])
|
||||
|
||||
lb_context._iterate_per_tenants.assert_called_once_with()
|
||||
net_wrapper.supports_extension.assert_called_once_with("lbaas")
|
||||
for tenant_id, tenant_ctx in (
|
||||
sorted(lb_context.context["tenants"].items())):
|
||||
@ -95,33 +98,35 @@ class LbaasTestCase(test.TestCase):
|
||||
self.assertEqual(expected_net, actual_net)
|
||||
|
||||
@mock.patch(NET + "wrap")
|
||||
@mock.patch("rally_openstack.contexts.neutron.lbaas.utils")
|
||||
@mock.patch("rally_openstack.osclients.Clients")
|
||||
def test_setup_with_no_lbaas(self, mock_clients, mock_utils, mock_wrap):
|
||||
mock_utils.iterate_per_tenants.return_value = [
|
||||
("bar_user", "bar_tenant")]
|
||||
def test_setup_with_no_lbaas(self, mock_clients, mock_wrap):
|
||||
mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
|
||||
mock_wrap.return_value = mock.Mock(create_v1_pool=mock_create)
|
||||
fake_args = {"lbaas_version": 1}
|
||||
lb_context = lbaas_context.Lbaas(self.get_context(**fake_args))
|
||||
net_wrapper = mock_wrap(mock_clients.return_value)
|
||||
net_wrapper.supports_extension.return_value = (False, None)
|
||||
|
||||
lb_context._iterate_per_tenants = mock.MagicMock(
|
||||
return_value=[("bar_user", "bar_tenant")]
|
||||
)
|
||||
lb_context.setup()
|
||||
mock_utils.iterate_per_tenants.assert_not_called()
|
||||
|
||||
lb_context._iterate_per_tenants.assert_not_called()
|
||||
net_wrapper.supports_extension.assert_called_once_with("lbaas")
|
||||
assert not net_wrapper.create_v1_pool.called
|
||||
|
||||
@mock.patch(NET + "wrap")
|
||||
@mock.patch("rally_openstack.contexts.neutron.lbaas.utils")
|
||||
@mock.patch("rally_openstack.osclients.Clients")
|
||||
def test_setup_with_lbaas_version_not_one(self, mock_clients,
|
||||
mock_utils, mock_wrap):
|
||||
mock_utils.iterate_per_tenants.return_value = [
|
||||
("bar_user", "bar_tenant")]
|
||||
def test_setup_with_lbaas_version_not_one(self, mock_clients, mock_wrap):
|
||||
mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
|
||||
mock_wrap.return_value = mock.Mock(create_v1_pool=mock_create)
|
||||
fake_args = {"lbaas_version": 2}
|
||||
|
||||
lb_context = lbaas_context.Lbaas(self.get_context(**fake_args))
|
||||
lb_context._iterate_per_tenants = mock.MagicMock(
|
||||
return_value=[("bar_user", "bar_tenant")]
|
||||
)
|
||||
net_wrapper = mock_wrap(mock_clients.return_value)
|
||||
net_wrapper.supports_extension.return_value = (True, None)
|
||||
self.assertRaises(NotImplementedError, lb_context.setup)
|
||||
|
@ -16,9 +16,21 @@
|
||||
from unittest import mock
|
||||
|
||||
from rally_openstack.contexts.swift import utils
|
||||
from rally_openstack.task import context
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
class SwiftContext(utils.SwiftObjectMixin, context.OpenStackContext):
|
||||
def __init__(self, context):
|
||||
self.context = context
|
||||
|
||||
def setup(self):
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
pass
|
||||
|
||||
|
||||
class SwiftObjectMixinTestCase(test.TestCase):
|
||||
|
||||
@mock.patch("rally_openstack.osclients.Clients")
|
||||
@ -38,9 +50,8 @@ class SwiftObjectMixinTestCase(test.TestCase):
|
||||
]
|
||||
})
|
||||
|
||||
mixin = utils.SwiftObjectMixin()
|
||||
containers = mixin._create_containers(context, containers_per_tenant,
|
||||
15)
|
||||
mixin = SwiftContext(context)
|
||||
containers = mixin._create_containers(containers_per_tenant, 15)
|
||||
|
||||
self.assertEqual(tenants * containers_per_tenant, len(containers))
|
||||
for index, container in enumerate(sorted(containers)):
|
||||
@ -87,9 +98,8 @@ class SwiftObjectMixinTestCase(test.TestCase):
|
||||
}
|
||||
})
|
||||
|
||||
mixin = utils.SwiftObjectMixin()
|
||||
objects_list = mixin._create_objects(context, objects_per_container,
|
||||
1024, 25)
|
||||
mixin = SwiftContext(context)
|
||||
objects_list = mixin._create_objects(objects_per_container, 1024, 25)
|
||||
|
||||
self.assertEqual(
|
||||
tenants * containers_per_tenant * objects_per_container,
|
||||
@ -133,8 +143,7 @@ class SwiftObjectMixinTestCase(test.TestCase):
|
||||
}
|
||||
})
|
||||
|
||||
mixin = utils.SwiftObjectMixin()
|
||||
mixin._delete_containers(context, 1)
|
||||
SwiftContext(context)._delete_containers(1)
|
||||
|
||||
mock_swift = mock_clients.return_value.swift.return_value
|
||||
expected_containers = ["c1", "c2"]
|
||||
@ -173,8 +182,7 @@ class SwiftObjectMixinTestCase(test.TestCase):
|
||||
}
|
||||
})
|
||||
|
||||
mixin = utils.SwiftObjectMixin()
|
||||
mixin._delete_objects(context, 1)
|
||||
SwiftContext(context)._delete_objects(1)
|
||||
|
||||
mock_swift = mock_clients.return_value.swift.return_value
|
||||
expected_objects = [("c1", "o1"), ("c1", "o2"), ("c1", "o3"),
|
||||
|
0
tests/unit/task/__init__.py
Normal file
0
tests/unit/task/__init__.py
Normal file
47
tests/unit/task/test_context.py
Normal file
47
tests/unit/task/test_context.py
Normal file
@ -0,0 +1,47 @@
|
||||
# Copyright 2013: 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_openstack.task import context
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
class TenantIteratorTestCase(test.TestCase):
|
||||
|
||||
def test__iterate_per_tenant(self):
|
||||
|
||||
class DummyContext(context.OpenStackContext):
|
||||
def __init__(self, ctx):
|
||||
self.context = ctx
|
||||
|
||||
def setup(self):
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
pass
|
||||
|
||||
users = []
|
||||
tenants_count = 2
|
||||
users_per_tenant = 5
|
||||
for tenant_id in range(tenants_count):
|
||||
for user_id in range(users_per_tenant):
|
||||
users.append({"id": str(user_id),
|
||||
"tenant_id": str(tenant_id)})
|
||||
|
||||
expected_result = [
|
||||
({"id": "0", "tenant_id": str(i)}, str(i)) for i in range(
|
||||
tenants_count)]
|
||||
real_result = [
|
||||
i for i in DummyContext({"users": users})._iterate_per_tenants()]
|
||||
|
||||
self.assertEqual(expected_result, real_result)
|
Loading…
Reference in New Issue
Block a user