Implement new random name generator for remaining scenario plugins
This switches all remaining scenarios to using the new consistent random name generator. Keystone scenarios were switched in a previous commit. Implements blueprint: consistent-resource-names Change-Id: I4d7defc328a516e7f84744c9a0fcaeb3b5f94d0c
This commit is contained in:
parent
b07f27db6a
commit
54398ac6a6
@ -1,8 +1,7 @@
|
|||||||
---
|
---
|
||||||
ZaqarBasic.create_queue:
|
ZaqarBasic.create_queue:
|
||||||
-
|
-
|
||||||
args:
|
args: {}
|
||||||
name_length: 10
|
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
times: 100
|
times: 100
|
||||||
@ -14,7 +13,6 @@
|
|||||||
ZaqarBasic.producer_consumer:
|
ZaqarBasic.producer_consumer:
|
||||||
-
|
-
|
||||||
args:
|
args:
|
||||||
name_length: 10
|
|
||||||
min_msg_count: 50
|
min_msg_count: 50
|
||||||
max_msg_count: 200
|
max_msg_count: 200
|
||||||
runner:
|
runner:
|
||||||
|
@ -86,8 +86,7 @@ class ImageGenerator(context.Context):
|
|||||||
|
|
||||||
image = glance_scenario._create_image(
|
image = glance_scenario._create_image(
|
||||||
image_container, image_url, image_type,
|
image_container, image_url, image_type,
|
||||||
name=cur_name, prefix="rally_ctx_image_",
|
name=cur_name, min_ram=self.config.get("min_ram", 0),
|
||||||
min_ram=self.config.get("min_ram", 0),
|
|
||||||
min_disk=self.config.get("min_disk", 0))
|
min_disk=self.config.get("min_disk", 0))
|
||||||
current_images.append(image.id)
|
current_images.append(image.id)
|
||||||
|
|
||||||
|
@ -155,7 +155,6 @@ class BaseCustomImageGenerator(context.Context):
|
|||||||
vm_scenario = vmtasks.VMTasks(self.context, clients=clients)
|
vm_scenario = vmtasks.VMTasks(self.context, clients=clients)
|
||||||
|
|
||||||
server, fip = vm_scenario._boot_server_with_fip(
|
server, fip = vm_scenario._boot_server_with_fip(
|
||||||
name=self.generate_random_name(),
|
|
||||||
image=image_id, flavor=flavor_id,
|
image=image_id, flavor=flavor_id,
|
||||||
floating_network=self.config.get("floating_network"),
|
floating_network=self.config.get("floating_network"),
|
||||||
userdata=self.config.get("userdata"),
|
userdata=self.config.get("userdata"),
|
||||||
|
@ -24,6 +24,10 @@ configure = scenario.configure
|
|||||||
class OpenStackScenario(scenario.Scenario):
|
class OpenStackScenario(scenario.Scenario):
|
||||||
"""Base class for all OpenStack scenarios."""
|
"""Base class for all OpenStack scenarios."""
|
||||||
|
|
||||||
|
# TODO(stpierre): this is still used by some cleanup routines;
|
||||||
|
# remove it when they're using the new random name generator
|
||||||
|
RESOURCE_NAME_PREFIX = "rally_"
|
||||||
|
|
||||||
def __init__(self, context=None, admin_clients=None, clients=None):
|
def __init__(self, context=None, admin_clients=None, clients=None):
|
||||||
super(OpenStackScenario, self).__init__(context)
|
super(OpenStackScenario, self).__init__(context)
|
||||||
if context:
|
if context:
|
||||||
|
@ -20,15 +20,13 @@ from rally.task import utils as bench_utils
|
|||||||
class CeilometerScenario(scenario.OpenStackScenario):
|
class CeilometerScenario(scenario.OpenStackScenario):
|
||||||
"""Base class for Ceilometer scenarios with basic atomic actions."""
|
"""Base class for Ceilometer scenarios with basic atomic actions."""
|
||||||
|
|
||||||
RESOURCE_NAME_PREFIX = "rally_ceilometer_"
|
|
||||||
|
|
||||||
def _get_alarm_dict(self, **kwargs):
|
def _get_alarm_dict(self, **kwargs):
|
||||||
"""Prepare and return an alarm dict for creating an alarm.
|
"""Prepare and return an alarm dict for creating an alarm.
|
||||||
|
|
||||||
:param kwargs: optional parameters to create alarm
|
:param kwargs: optional parameters to create alarm
|
||||||
:returns: alarm dictionary used to create an alarm
|
:returns: alarm dictionary used to create an alarm
|
||||||
"""
|
"""
|
||||||
alarm_id = self._generate_random_name()
|
alarm_id = self.generate_random_name()
|
||||||
alarm = {"alarm_id": alarm_id,
|
alarm = {"alarm_id": alarm_id,
|
||||||
"name": alarm_id,
|
"name": alarm_id,
|
||||||
"description": "Test Alarm"}
|
"description": "Test Alarm"}
|
||||||
@ -205,11 +203,10 @@ class CeilometerScenario(scenario.OpenStackScenario):
|
|||||||
def _create_meter(self, **kwargs):
|
def _create_meter(self, **kwargs):
|
||||||
"""Create a new meter.
|
"""Create a new meter.
|
||||||
|
|
||||||
:param name_length: Length of meter name to be generated
|
|
||||||
:param kwargs: Contains the optional attributes for meter creation
|
:param kwargs: Contains the optional attributes for meter creation
|
||||||
:returns: Newly created meter
|
:returns: Newly created meter
|
||||||
"""
|
"""
|
||||||
name = self._generate_random_name()
|
name = self.generate_random_name()
|
||||||
samples = self.clients("ceilometer").samples.create(
|
samples = self.clients("ceilometer").samples.create(
|
||||||
counter_name=name, **kwargs)
|
counter_name=name, **kwargs)
|
||||||
return samples[0]
|
return samples[0]
|
||||||
@ -262,8 +259,7 @@ class CeilometerScenario(scenario.OpenStackScenario):
|
|||||||
"counter_unit": counter_unit,
|
"counter_unit": counter_unit,
|
||||||
"counter_volume": counter_volume,
|
"counter_volume": counter_volume,
|
||||||
"resource_id": resource_id if resource_id
|
"resource_id": resource_id if resource_id
|
||||||
else self._generate_random_name(
|
else self.generate_random_name()})
|
||||||
prefix="rally_resource_")})
|
|
||||||
return self.clients("ceilometer").samples.create(**kwargs)
|
return self.clients("ceilometer").samples.create(**kwargs)
|
||||||
|
|
||||||
@atomic.action_timer("ceilometer.query_samples")
|
@atomic.action_timer("ceilometer.query_samples")
|
||||||
|
@ -52,8 +52,6 @@ CONF.register_opts(CINDER_BENCHMARK_OPTS, group=benchmark_group)
|
|||||||
class CinderScenario(scenario.OpenStackScenario):
|
class CinderScenario(scenario.OpenStackScenario):
|
||||||
"""Base class for Cinder scenarios with basic atomic actions."""
|
"""Base class for Cinder scenarios with basic atomic actions."""
|
||||||
|
|
||||||
RESOURCE_NAME_PREFIX = "rally_volume_"
|
|
||||||
|
|
||||||
@atomic.action_timer("cinder.list_volumes")
|
@atomic.action_timer("cinder.list_volumes")
|
||||||
def _list_volumes(self, detailed=True):
|
def _list_volumes(self, detailed=True):
|
||||||
"""Returns user volumes list."""
|
"""Returns user volumes list."""
|
||||||
@ -80,9 +78,9 @@ class CinderScenario(scenario.OpenStackScenario):
|
|||||||
for i in range(sets):
|
for i in range(sets):
|
||||||
metadata = {}
|
metadata = {}
|
||||||
for j in range(set_size):
|
for j in range(set_size):
|
||||||
key = self._generate_random_name()
|
key = self.generate_random_name()
|
||||||
keys.append(key)
|
keys.append(key)
|
||||||
metadata[key] = self._generate_random_name()
|
metadata[key] = self.generate_random_name()
|
||||||
|
|
||||||
self.clients("cinder").volumes.set_metadata(volume, metadata)
|
self.clients("cinder").volumes.set_metadata(volume, metadata)
|
||||||
return keys
|
return keys
|
||||||
@ -130,7 +128,7 @@ class CinderScenario(scenario.OpenStackScenario):
|
|||||||
:returns: Created volume object
|
:returns: Created volume object
|
||||||
"""
|
"""
|
||||||
kwargs["display_name"] = kwargs.get("display_name",
|
kwargs["display_name"] = kwargs.get("display_name",
|
||||||
self._generate_random_name())
|
self.generate_random_name())
|
||||||
|
|
||||||
if isinstance(size, dict):
|
if isinstance(size, dict):
|
||||||
size = random.randint(size["min"], size["max"])
|
size = random.randint(size["min"], size["max"])
|
||||||
@ -152,17 +150,15 @@ class CinderScenario(scenario.OpenStackScenario):
|
|||||||
def _update_volume(self, volume, **update_volume_args):
|
def _update_volume(self, volume, **update_volume_args):
|
||||||
"""Update name and description for this volume
|
"""Update name and description for this volume
|
||||||
|
|
||||||
This atomic function updates volume display name and description
|
This atomic function updates volume information. The volume
|
||||||
|
display name is always changed, and additional update
|
||||||
|
arguments may also be specified.
|
||||||
|
|
||||||
:param volume: volume object
|
:param volume: volume object
|
||||||
:param update_volume_args: dict, contains values to be updated.
|
:param update_volume_args: dict, contains values to be updated.
|
||||||
"""
|
"""
|
||||||
kwargs = {}
|
update_volume_args["display_name"] = self.generate_random_name()
|
||||||
kwargs["display_name"] = update_volume_args.get(
|
self.clients("cinder").volumes.update(volume, **update_volume_args)
|
||||||
"display_name", self._generate_random_name("_"))
|
|
||||||
kwargs["display_description"] = update_volume_args.get(
|
|
||||||
"display_description", self._generate_random_name("_"))
|
|
||||||
self.clients("cinder").volumes.update(volume, **kwargs)
|
|
||||||
|
|
||||||
@atomic.action_timer("cinder.delete_volume")
|
@atomic.action_timer("cinder.delete_volume")
|
||||||
def _delete_volume(self, volume):
|
def _delete_volume(self, volume):
|
||||||
@ -224,7 +220,7 @@ class CinderScenario(scenario.OpenStackScenario):
|
|||||||
ami, ari, aki, vhd, vmdk, raw, qcow2, vdi and iso
|
ami, ari, aki, vhd, vmdk, raw, qcow2, vdi and iso
|
||||||
:returns: Returns created image object
|
:returns: Returns created image object
|
||||||
"""
|
"""
|
||||||
resp, img = volume.upload_to_image(force, self._generate_random_name(),
|
resp, img = volume.upload_to_image(force, self.generate_random_name(),
|
||||||
container_format, disk_format)
|
container_format, disk_format)
|
||||||
# NOTE (e0ne): upload_to_image changes volume status to uploading so
|
# NOTE (e0ne): upload_to_image changes volume status to uploading so
|
||||||
# we need to wait until it will be available.
|
# we need to wait until it will be available.
|
||||||
@ -261,7 +257,7 @@ class CinderScenario(scenario.OpenStackScenario):
|
|||||||
:returns: Created snapshot object
|
:returns: Created snapshot object
|
||||||
"""
|
"""
|
||||||
kwargs["display_name"] = kwargs.get("display_name",
|
kwargs["display_name"] = kwargs.get("display_name",
|
||||||
self._generate_random_name())
|
self.generate_random_name())
|
||||||
kwargs["force"] = force
|
kwargs["force"] = force
|
||||||
snapshot = self.clients("cinder").volume_snapshots.create(volume_id,
|
snapshot = self.clients("cinder").volume_snapshots.create(volume_id,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
@ -21,8 +21,6 @@ from rally.task import atomic
|
|||||||
class DesignateScenario(scenario.OpenStackScenario):
|
class DesignateScenario(scenario.OpenStackScenario):
|
||||||
"""Base class for Designate scenarios with basic atomic actions."""
|
"""Base class for Designate scenarios with basic atomic actions."""
|
||||||
|
|
||||||
RESOURCE_NAME_PREFIX = "rally_"
|
|
||||||
|
|
||||||
@atomic.action_timer("designate.create_domain")
|
@atomic.action_timer("designate.create_domain")
|
||||||
def _create_domain(self, domain=None):
|
def _create_domain(self, domain=None):
|
||||||
"""Create domain.
|
"""Create domain.
|
||||||
@ -33,7 +31,7 @@ class DesignateScenario(scenario.OpenStackScenario):
|
|||||||
domain = domain or {}
|
domain = domain or {}
|
||||||
|
|
||||||
domain.setdefault("email", "root@random.name")
|
domain.setdefault("email", "root@random.name")
|
||||||
domain.setdefault("name", "%s.name." % self._generate_random_name())
|
domain["name"] = "%s.name." % self.generate_random_name()
|
||||||
return self.clients("designate").domains.create(domain)
|
return self.clients("designate").domains.create(domain)
|
||||||
|
|
||||||
@atomic.action_timer("designate.list_domains")
|
@atomic.action_timer("designate.list_domains")
|
||||||
@ -63,8 +61,8 @@ class DesignateScenario(scenario.OpenStackScenario):
|
|||||||
"""
|
"""
|
||||||
record = record or {}
|
record = record or {}
|
||||||
record.setdefault("type", "A")
|
record.setdefault("type", "A")
|
||||||
record.setdefault("name", "%s.%s" % (self._generate_random_name(),
|
record["name"] = "%s.%s" % (self.generate_random_name(),
|
||||||
domain["name"]))
|
domain["name"])
|
||||||
record.setdefault("data", "10.0.0.1")
|
record.setdefault("data", "10.0.0.1")
|
||||||
|
|
||||||
client = self.clients("designate")
|
client = self.clients("designate")
|
||||||
@ -102,7 +100,7 @@ class DesignateScenario(scenario.OpenStackScenario):
|
|||||||
"""
|
"""
|
||||||
server = server or {}
|
server = server or {}
|
||||||
|
|
||||||
server.setdefault("name", "name.%s." % self._generate_random_name())
|
server["name"] = "name.%s." % self.generate_random_name()
|
||||||
return self.admin_clients("designate").servers.create(server)
|
return self.admin_clients("designate").servers.create(server)
|
||||||
|
|
||||||
@atomic.action_timer("designate.list_servers")
|
@atomic.action_timer("designate.list_servers")
|
||||||
|
@ -24,9 +24,6 @@ from rally.task import validation
|
|||||||
class GlanceImages(utils.GlanceScenario, nova_utils.NovaScenario):
|
class GlanceImages(utils.GlanceScenario, nova_utils.NovaScenario):
|
||||||
"""Benchmark scenarios for Glance images."""
|
"""Benchmark scenarios for Glance images."""
|
||||||
|
|
||||||
RESOURCE_NAME_PREFIX = "rally_image_"
|
|
||||||
RESOURCE_NAME_LENGTH = 16
|
|
||||||
|
|
||||||
@types.set(image_location=types.FilePathOrUrlType)
|
@types.set(image_location=types.FilePathOrUrlType)
|
||||||
@validation.required_services(consts.Service.GLANCE)
|
@validation.required_services(consts.Service.GLANCE)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
|
@ -60,7 +60,7 @@ class GlanceScenario(scenario.OpenStackScenario):
|
|||||||
|
|
||||||
@atomic.action_timer("glance.create_image")
|
@atomic.action_timer("glance.create_image")
|
||||||
def _create_image(self, container_format, image_location, disk_format,
|
def _create_image(self, container_format, image_location, disk_format,
|
||||||
name=None, prefix=None, length=None, **kwargs):
|
**kwargs):
|
||||||
"""Create a new image.
|
"""Create a new image.
|
||||||
|
|
||||||
:param container_format: container format of image. Acceptable
|
:param container_format: container format of image. Acceptable
|
||||||
@ -68,18 +68,12 @@ class GlanceScenario(scenario.OpenStackScenario):
|
|||||||
:param image_location: image file location
|
:param image_location: image file location
|
||||||
:param disk_format: disk format of image. Acceptable formats:
|
:param disk_format: disk format of image. Acceptable formats:
|
||||||
ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso
|
ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso
|
||||||
:param name: string used to name the image
|
|
||||||
:param prefix: prefix of generated image name if name not specified
|
|
||||||
ignore if name specified
|
|
||||||
:param length: length of autometic generated part in image name
|
|
||||||
ignore if name specified
|
|
||||||
:param kwargs: optional parameters to create image
|
:param kwargs: optional parameters to create image
|
||||||
|
|
||||||
:returns: image object
|
:returns: image object
|
||||||
"""
|
"""
|
||||||
name = name or self._generate_random_name(prefix, length)
|
|
||||||
kw = {
|
kw = {
|
||||||
"name": name,
|
"name": self.generate_random_name(),
|
||||||
"container_format": container_format,
|
"container_format": container_format,
|
||||||
"disk_format": disk_format,
|
"disk_format": disk_format,
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,6 @@ from rally.task import validation
|
|||||||
class HeatStacks(utils.HeatScenario):
|
class HeatStacks(utils.HeatScenario):
|
||||||
"""Benchmark scenarios for Heat stacks."""
|
"""Benchmark scenarios for Heat stacks."""
|
||||||
|
|
||||||
RESOURCE_NAME_PREFIX = "rally_stack_"
|
|
||||||
RESOURCE_NAME_LENGTH = 7
|
|
||||||
|
|
||||||
@types.set(template_path=types.FileType, files=types.FileTypeDict)
|
@types.set(template_path=types.FileType, files=types.FileTypeDict)
|
||||||
@validation.required_services(consts.Service.HEAT)
|
@validation.required_services(consts.Service.HEAT)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
|
@ -128,7 +128,7 @@ class HeatScenario(scenario.OpenStackScenario):
|
|||||||
|
|
||||||
:returns: object of stack
|
:returns: object of stack
|
||||||
"""
|
"""
|
||||||
stack_name = self._generate_random_name(prefix="rally_stack_")
|
stack_name = self.generate_random_name()
|
||||||
kw = {
|
kw = {
|
||||||
"stack_name": stack_name,
|
"stack_name": stack_name,
|
||||||
"disable_rollback": True,
|
"disable_rollback": True,
|
||||||
|
@ -17,8 +17,6 @@ import string
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
|
||||||
from rally.common import utils
|
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.task import atomic
|
from rally.task import atomic
|
||||||
|
|
||||||
@ -38,6 +36,20 @@ CONF.register_opts(IRONIC_BENCHMARK_OPTS, group=benchmark_group)
|
|||||||
class IronicScenario(scenario.OpenStackScenario):
|
class IronicScenario(scenario.OpenStackScenario):
|
||||||
"""Base class for Ironic scenarios with basic atomic actions."""
|
"""Base class for Ironic scenarios with basic atomic actions."""
|
||||||
|
|
||||||
|
# NOTE(stpierre): Ironic has two name checkers. The new-style
|
||||||
|
# checker, in API v1.10+, is quite relaxed and will Just Work with
|
||||||
|
# the default random name pattern. (See
|
||||||
|
# https://bugs.launchpad.net/ironic/+bug/1434376.) The old-style
|
||||||
|
# checker *claims* to implement RFCs 952 and 1123, but it doesn't
|
||||||
|
# actually. (See https://bugs.launchpad.net/ironic/+bug/1468508
|
||||||
|
# for details.) The default RESOURCE_NAME_FORMAT works fine for
|
||||||
|
# the new-style checker, but the old-style checker only allows
|
||||||
|
# underscores after the first dot, for reasons that I'm sure are
|
||||||
|
# entirely obvious, so we have to supply a bespoke format for
|
||||||
|
# Ironic names.
|
||||||
|
RESOURCE_NAME_FORMAT = "s-rally-XXXXXXXX-XXXXXXXX"
|
||||||
|
RESOURCE_NAME_ALLOWED_CHARACTERS = string.ascii_lowercase + string.digits
|
||||||
|
|
||||||
@atomic.action_timer("ironic.create_node")
|
@atomic.action_timer("ironic.create_node")
|
||||||
def _create_node(self, **kwargs):
|
def _create_node(self, **kwargs):
|
||||||
"""Create node immediately.
|
"""Create node immediately.
|
||||||
@ -45,17 +57,7 @@ class IronicScenario(scenario.OpenStackScenario):
|
|||||||
:param kwargs: optional parameters to create image
|
:param kwargs: optional parameters to create image
|
||||||
:returns: node object
|
:returns: node object
|
||||||
"""
|
"""
|
||||||
if "name" not in kwargs:
|
kwargs["name"] = self.generate_random_name()
|
||||||
# NOTE(rvasilets): can't use _generate_random_name() because
|
|
||||||
# ironic have specific format for node name.
|
|
||||||
# Check that the supplied hostname conforms to:
|
|
||||||
# * http://en.wikipedia.org/wiki/Hostname
|
|
||||||
# * http://tools.ietf.org/html/rfc952
|
|
||||||
# * http://tools.ietf.org/html/rfc1123
|
|
||||||
# or the name could be just uuid.
|
|
||||||
kwargs["name"] = utils.generate_random_name(
|
|
||||||
prefix="rally", choice=string.ascii_lowercase + string.digits)
|
|
||||||
|
|
||||||
return self.admin_clients("ironic").node.create(**kwargs)
|
return self.admin_clients("ironic").node.create(**kwargs)
|
||||||
|
|
||||||
@atomic.action_timer("ironic.list_nodes")
|
@atomic.action_timer("ironic.list_nodes")
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.plugins.openstack.scenarios.manila import utils
|
from rally.plugins.openstack.scenarios.manila import utils
|
||||||
@ -64,6 +65,9 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
@validation.required_services(consts.Service.MANILA)
|
@validation.required_services(consts.Service.MANILA)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@scenario.configure(context={"cleanup": ["manila"]})
|
@scenario.configure(context={"cleanup": ["manila"]})
|
||||||
|
@rutils.log_deprecated_args(
|
||||||
|
"The 'name' argument to create_and_delete_service will be ignored",
|
||||||
|
"1.1.2", ["name"], once=True)
|
||||||
def create_share_network_and_delete(self,
|
def create_share_network_and_delete(self,
|
||||||
neutron_net_id=None,
|
neutron_net_id=None,
|
||||||
neutron_subnet_id=None,
|
neutron_subnet_id=None,
|
||||||
@ -75,14 +79,12 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
:param neutron_net_id: ID of Neutron network
|
:param neutron_net_id: ID of Neutron network
|
||||||
:param neutron_subnet_id: ID of Neutron subnet
|
:param neutron_subnet_id: ID of Neutron subnet
|
||||||
:param nova_net_id: ID of Nova network
|
:param nova_net_id: ID of Nova network
|
||||||
:param name: share network name
|
|
||||||
:param description: share network description
|
:param description: share network description
|
||||||
"""
|
"""
|
||||||
share_network = self._create_share_network(
|
share_network = self._create_share_network(
|
||||||
neutron_net_id=neutron_net_id,
|
neutron_net_id=neutron_net_id,
|
||||||
neutron_subnet_id=neutron_subnet_id,
|
neutron_subnet_id=neutron_subnet_id,
|
||||||
nova_net_id=nova_net_id,
|
nova_net_id=nova_net_id,
|
||||||
name=name,
|
|
||||||
description=description,
|
description=description,
|
||||||
)
|
)
|
||||||
self._delete_share_network(share_network)
|
self._delete_share_network(share_network)
|
||||||
@ -90,6 +92,9 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
@validation.required_services(consts.Service.MANILA)
|
@validation.required_services(consts.Service.MANILA)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@scenario.configure(context={"cleanup": ["manila"]})
|
@scenario.configure(context={"cleanup": ["manila"]})
|
||||||
|
@rutils.log_deprecated_args(
|
||||||
|
"The 'name' argument to create_and_delete_service will be ignored",
|
||||||
|
"1.1.2", ["name"], once=True)
|
||||||
def create_share_network_and_list(self,
|
def create_share_network_and_list(self,
|
||||||
neutron_net_id=None,
|
neutron_net_id=None,
|
||||||
neutron_subnet_id=None,
|
neutron_subnet_id=None,
|
||||||
@ -103,7 +108,6 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
:param neutron_net_id: ID of Neutron network
|
:param neutron_net_id: ID of Neutron network
|
||||||
:param neutron_subnet_id: ID of Neutron subnet
|
:param neutron_subnet_id: ID of Neutron subnet
|
||||||
:param nova_net_id: ID of Nova network
|
:param nova_net_id: ID of Nova network
|
||||||
:param name: share network name
|
|
||||||
:param description: share network description
|
:param description: share network description
|
||||||
:param detailed: defines either to return detailed list of
|
:param detailed: defines either to return detailed list of
|
||||||
objects or not.
|
objects or not.
|
||||||
@ -114,7 +118,6 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
neutron_net_id=neutron_net_id,
|
neutron_net_id=neutron_net_id,
|
||||||
neutron_subnet_id=neutron_subnet_id,
|
neutron_subnet_id=neutron_subnet_id,
|
||||||
nova_net_id=nova_net_id,
|
nova_net_id=nova_net_id,
|
||||||
name=name,
|
|
||||||
description=description,
|
description=description,
|
||||||
)
|
)
|
||||||
self._list_share_networks(
|
self._list_share_networks(
|
||||||
@ -138,6 +141,9 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
@validation.required_services(consts.Service.MANILA)
|
@validation.required_services(consts.Service.MANILA)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@scenario.configure(context={"cleanup": ["manila"]})
|
@scenario.configure(context={"cleanup": ["manila"]})
|
||||||
|
@rutils.log_deprecated_args(
|
||||||
|
"The 'name' argument to create_and_delete_service will be ignored",
|
||||||
|
"1.1.2", ["name"], once=True)
|
||||||
def create_security_service_and_delete(self, security_service_type,
|
def create_security_service_and_delete(self, security_service_type,
|
||||||
dns_ip=None, server=None,
|
dns_ip=None, server=None,
|
||||||
domain=None, user=None,
|
domain=None, user=None,
|
||||||
@ -152,7 +158,6 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
:param domain: security service domain
|
:param domain: security service domain
|
||||||
:param user: security identifier used by tenant
|
:param user: security identifier used by tenant
|
||||||
:param password: password used by user
|
:param password: password used by user
|
||||||
:param name: security service name
|
|
||||||
:param description: security service description
|
:param description: security service description
|
||||||
"""
|
"""
|
||||||
security_service = self._create_security_service(
|
security_service = self._create_security_service(
|
||||||
@ -162,7 +167,6 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
domain=domain,
|
domain=domain,
|
||||||
user=user,
|
user=user,
|
||||||
password=password,
|
password=password,
|
||||||
name=name,
|
|
||||||
description=description,
|
description=description,
|
||||||
)
|
)
|
||||||
self._delete_security_service(security_service)
|
self._delete_security_service(security_service)
|
||||||
|
@ -84,7 +84,7 @@ class ManilaScenario(scenario.OpenStackScenario):
|
|||||||
kwargs["share_network"] = share_networks[index]
|
kwargs["share_network"] = share_networks[index]
|
||||||
|
|
||||||
if not kwargs.get("name"):
|
if not kwargs.get("name"):
|
||||||
kwargs["name"] = self._generate_random_name()
|
kwargs["name"] = self.generate_random_name()
|
||||||
|
|
||||||
share = self.clients("manila").shares.create(
|
share = self.clients("manila").shares.create(
|
||||||
share_proto, size, **kwargs)
|
share_proto, size, **kwargs)
|
||||||
@ -129,22 +129,20 @@ class ManilaScenario(scenario.OpenStackScenario):
|
|||||||
@atomic.action_timer("manila.create_share_network")
|
@atomic.action_timer("manila.create_share_network")
|
||||||
def _create_share_network(self, neutron_net_id=None,
|
def _create_share_network(self, neutron_net_id=None,
|
||||||
neutron_subnet_id=None,
|
neutron_subnet_id=None,
|
||||||
nova_net_id=None, name=None, description=None):
|
nova_net_id=None, description=None):
|
||||||
"""Create share network.
|
"""Create share network.
|
||||||
|
|
||||||
:param neutron_net_id: ID of Neutron network
|
:param neutron_net_id: ID of Neutron network
|
||||||
:param neutron_subnet_id: ID of Neutron subnet
|
:param neutron_subnet_id: ID of Neutron subnet
|
||||||
:param nova_net_id: ID of Nova network
|
:param nova_net_id: ID of Nova network
|
||||||
:param name: share network name
|
|
||||||
:param description: share network description
|
:param description: share network description
|
||||||
:returns: instance of :class:`ShareNetwork`
|
:returns: instance of :class:`ShareNetwork`
|
||||||
"""
|
"""
|
||||||
name = name or self._generate_random_name()
|
|
||||||
share_network = self.clients("manila").share_networks.create(
|
share_network = self.clients("manila").share_networks.create(
|
||||||
neutron_net_id=neutron_net_id,
|
neutron_net_id=neutron_net_id,
|
||||||
neutron_subnet_id=neutron_subnet_id,
|
neutron_subnet_id=neutron_subnet_id,
|
||||||
nova_net_id=nova_net_id,
|
nova_net_id=nova_net_id,
|
||||||
name=name,
|
name=self.generate_random_name(),
|
||||||
description=description)
|
description=description)
|
||||||
return share_network
|
return share_network
|
||||||
|
|
||||||
@ -192,7 +190,7 @@ class ManilaScenario(scenario.OpenStackScenario):
|
|||||||
@atomic.action_timer("manila.create_security_service")
|
@atomic.action_timer("manila.create_security_service")
|
||||||
def _create_security_service(self, security_service_type, dns_ip=None,
|
def _create_security_service(self, security_service_type, dns_ip=None,
|
||||||
server=None, domain=None, user=None,
|
server=None, domain=None, user=None,
|
||||||
password=None, name=None, description=None):
|
password=None, description=None):
|
||||||
"""Create security service.
|
"""Create security service.
|
||||||
|
|
||||||
'Security service' is data container in Manila that stores info
|
'Security service' is data container in Manila that stores info
|
||||||
@ -206,7 +204,6 @@ class ManilaScenario(scenario.OpenStackScenario):
|
|||||||
:param domain: security service domain
|
:param domain: security service domain
|
||||||
:param user: security identifier used by tenant
|
:param user: security identifier used by tenant
|
||||||
:param password: password used by user
|
:param password: password used by user
|
||||||
:param name: security service name
|
|
||||||
:param description: security service description
|
:param description: security service description
|
||||||
:returns: instance of :class:`SecurityService`
|
:returns: instance of :class:`SecurityService`
|
||||||
"""
|
"""
|
||||||
@ -217,7 +214,7 @@ class ManilaScenario(scenario.OpenStackScenario):
|
|||||||
domain=domain,
|
domain=domain,
|
||||||
user=user,
|
user=user,
|
||||||
password=password,
|
password=password,
|
||||||
name=name,
|
name=self.generate_random_name(),
|
||||||
description=description)
|
description=description)
|
||||||
return security_service
|
return security_service
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class MistralScenario(scenario.OpenStackScenario):
|
|||||||
:returns: workbook object
|
:returns: workbook object
|
||||||
"""
|
"""
|
||||||
definition = yaml.safe_load(definition)
|
definition = yaml.safe_load(definition)
|
||||||
definition["name"] = self._generate_random_name(definition["name"])
|
definition["name"] = self.generate_random_name()
|
||||||
definition = yaml.safe_dump(definition)
|
definition = yaml.safe_dump(definition)
|
||||||
|
|
||||||
return self.clients("mistral").workbooks.create(definition)
|
return self.clients("mistral").workbooks.create(definition)
|
||||||
|
@ -52,14 +52,14 @@ class MuranoScenario(scenario.OpenStackScenario):
|
|||||||
return self.clients("murano").environments.list()
|
return self.clients("murano").environments.list()
|
||||||
|
|
||||||
@atomic.action_timer("murano.create_environment")
|
@atomic.action_timer("murano.create_environment")
|
||||||
def _create_environment(self, env_name=None):
|
def _create_environment(self):
|
||||||
"""Create environment.
|
"""Create environment.
|
||||||
|
|
||||||
:param env_name: String used to name environment
|
:param env_name: String used to name environment
|
||||||
|
|
||||||
:returns: Environment instance
|
:returns: Environment instance
|
||||||
"""
|
"""
|
||||||
env_name = env_name or self._generate_random_name()
|
env_name = self.generate_random_name()
|
||||||
return self.clients("murano").environments.create({"name": env_name})
|
return self.clients("murano").environments.create({"name": env_name})
|
||||||
|
|
||||||
@atomic.action_timer("murano.delete_environment")
|
@atomic.action_timer("murano.delete_environment")
|
||||||
@ -99,7 +99,7 @@ class MuranoScenario(scenario.OpenStackScenario):
|
|||||||
app_id = str(uuid.uuid4())
|
app_id = str(uuid.uuid4())
|
||||||
data = {"?": {"id": app_id,
|
data = {"?": {"id": app_id,
|
||||||
"type": full_package_name},
|
"type": full_package_name},
|
||||||
"name": self._generate_random_name("rally_")}
|
"name": self.generate_random_name()}
|
||||||
|
|
||||||
return self.clients("murano").services.post(
|
return self.clients("murano").services.post(
|
||||||
environment_id=environment.id, path="/", data=data,
|
environment_id=environment.id, path="/", data=data,
|
||||||
|
@ -26,8 +26,6 @@ LOG = logging.getLogger(__name__)
|
|||||||
class NeutronScenario(scenario.OpenStackScenario):
|
class NeutronScenario(scenario.OpenStackScenario):
|
||||||
"""Base class for Neutron scenarios with basic atomic actions."""
|
"""Base class for Neutron scenarios with basic atomic actions."""
|
||||||
|
|
||||||
RESOURCE_NAME_PREFIX = "rally_net_"
|
|
||||||
RESOURCE_NAME_LENGTH = 16
|
|
||||||
SUBNET_IP_VERSION = 4
|
SUBNET_IP_VERSION = 4
|
||||||
# TODO(rkiran): modify in case LBaaS-v2 requires
|
# TODO(rkiran): modify in case LBaaS-v2 requires
|
||||||
LB_METHOD = "ROUND_ROBIN"
|
LB_METHOD = "ROUND_ROBIN"
|
||||||
@ -61,7 +59,7 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
:returns: None; kwargs is modified in situ.
|
:returns: None; kwargs is modified in situ.
|
||||||
"""
|
"""
|
||||||
if "name" in kwargs:
|
if "name" in kwargs:
|
||||||
kwargs["name"] = self._generate_random_name()
|
kwargs["name"] = self.generate_random_name()
|
||||||
LOG.warning(_("Cannot set name of %(type)s %(id)s explicitly; "
|
LOG.warning(_("Cannot set name of %(type)s %(id)s explicitly; "
|
||||||
"setting to random string %(name)s") %
|
"setting to random string %(name)s") %
|
||||||
{"type": list(resource.keys())[0],
|
{"type": list(resource.keys())[0],
|
||||||
@ -89,7 +87,7 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
:param network_create_args: dict, POST /v2.0/networks request options
|
:param network_create_args: dict, POST /v2.0/networks request options
|
||||||
:returns: neutron network dict
|
:returns: neutron network dict
|
||||||
"""
|
"""
|
||||||
network_create_args.setdefault("name", self._generate_random_name())
|
network_create_args["name"] = self.generate_random_name()
|
||||||
return self.clients("neutron").create_network(
|
return self.clients("neutron").create_network(
|
||||||
{"network": network_create_args})
|
{"network": network_create_args})
|
||||||
|
|
||||||
@ -143,8 +141,7 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
network_wrapper.generate_cidr(start_cidr=start_cidr))
|
network_wrapper.generate_cidr(start_cidr=start_cidr))
|
||||||
|
|
||||||
subnet_create_args["network_id"] = network_id
|
subnet_create_args["network_id"] = network_id
|
||||||
subnet_create_args.setdefault(
|
subnet_create_args["name"] = self.generate_random_name()
|
||||||
"name", self._generate_random_name("rally_subnet_"))
|
|
||||||
subnet_create_args.setdefault("ip_version", self.SUBNET_IP_VERSION)
|
subnet_create_args.setdefault("ip_version", self.SUBNET_IP_VERSION)
|
||||||
|
|
||||||
return self.clients("neutron").create_subnet(
|
return self.clients("neutron").create_subnet(
|
||||||
@ -185,8 +182,7 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
:param router_create_args: POST /v2.0/routers request options
|
:param router_create_args: POST /v2.0/routers request options
|
||||||
:returns: neutron router dict
|
:returns: neutron router dict
|
||||||
"""
|
"""
|
||||||
router_create_args.setdefault(
|
router_create_args["name"] = self.generate_random_name()
|
||||||
"name", self._generate_random_name("rally_router_"))
|
|
||||||
|
|
||||||
if external_gw:
|
if external_gw:
|
||||||
for network in self._list_networks():
|
for network in self._list_networks():
|
||||||
@ -237,8 +233,7 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
:returns: neutron port dict
|
:returns: neutron port dict
|
||||||
"""
|
"""
|
||||||
port_create_args["network_id"] = network["network"]["id"]
|
port_create_args["network_id"] = network["network"]["id"]
|
||||||
port_create_args.setdefault(
|
port_create_args["name"] = self.generate_random_name()
|
||||||
"name", self._generate_random_name("rally_port_"))
|
|
||||||
return self.clients("neutron").create_port({"port": port_create_args})
|
return self.clients("neutron").create_port({"port": port_create_args})
|
||||||
|
|
||||||
@atomic.action_timer("neutron.list_ports")
|
@atomic.action_timer("neutron.list_ports")
|
||||||
@ -323,7 +318,7 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
"""
|
"""
|
||||||
args = {"lb_method": self.LB_METHOD,
|
args = {"lb_method": self.LB_METHOD,
|
||||||
"protocol": self.LB_PROTOCOL,
|
"protocol": self.LB_PROTOCOL,
|
||||||
"name": self._generate_random_name("rally_pool_"),
|
"name": self.generate_random_name(),
|
||||||
"subnet_id": subnet_id}
|
"subnet_id": subnet_id}
|
||||||
args.update(pool_create_args)
|
args.update(pool_create_args)
|
||||||
return self.clients("neutron").create_pool({"pool": args})
|
return self.clients("neutron").create_pool({"pool": args})
|
||||||
@ -382,7 +377,7 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
"""
|
"""
|
||||||
args = {"protocol": self.LB_PROTOCOL,
|
args = {"protocol": self.LB_PROTOCOL,
|
||||||
"protocol_port": self.LB_PROTOCOL_PORT,
|
"protocol_port": self.LB_PROTOCOL_PORT,
|
||||||
"name": self._generate_random_name("rally_vip_"),
|
"name": self.generate_random_name(),
|
||||||
"pool_id": pool["pool"]["id"],
|
"pool_id": pool["pool"]["id"],
|
||||||
"subnet_id": pool["pool"]["subnet_id"]}
|
"subnet_id": pool["pool"]["subnet_id"]}
|
||||||
args.update(vip_create_args)
|
args.update(vip_create_args)
|
||||||
|
@ -33,9 +33,6 @@ class NovaServers(utils.NovaScenario,
|
|||||||
cinder_utils.CinderScenario):
|
cinder_utils.CinderScenario):
|
||||||
"""Benchmark scenarios for Nova servers."""
|
"""Benchmark scenarios for Nova servers."""
|
||||||
|
|
||||||
RESOURCE_NAME_PREFIX = "rally_novaserver_"
|
|
||||||
RESOURCE_NAME_LENGTH = 16
|
|
||||||
|
|
||||||
@types.set(image=types.ImageResourceType,
|
@types.set(image=types.ImageResourceType,
|
||||||
flavor=types.FlavorResourceType)
|
flavor=types.FlavorResourceType)
|
||||||
@validation.image_valid_on_flavor("flavor", "image")
|
@validation.image_valid_on_flavor("flavor", "image")
|
||||||
@ -642,6 +639,6 @@ class NovaServers(utils.NovaScenario,
|
|||||||
"""
|
"""
|
||||||
server = self._boot_server(image, flavor, **kwargs)
|
server = self._boot_server(image, flavor, **kwargs)
|
||||||
address = network_wrapper.wrap(
|
address = network_wrapper.wrap(
|
||||||
self.clients, self.context["task"]).create_floating_ip(
|
self.clients, self.task).create_floating_ip(
|
||||||
tenant_id=server.tenant_id)
|
tenant_id=server.tenant_id)
|
||||||
self._associate_floating_ip(server, address["ip"])
|
self._associate_floating_ip(server, address["ip"])
|
||||||
|
@ -108,7 +108,7 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
|
|
||||||
@atomic.action_timer("nova.boot_server")
|
@atomic.action_timer("nova.boot_server")
|
||||||
def _boot_server(self, image_id, flavor_id,
|
def _boot_server(self, image_id, flavor_id,
|
||||||
auto_assign_nic=False, name=None, **kwargs):
|
auto_assign_nic=False, **kwargs):
|
||||||
"""Boot a server.
|
"""Boot a server.
|
||||||
|
|
||||||
Returns when the server is actually booted and in "ACTIVE" state.
|
Returns when the server is actually booted and in "ACTIVE" state.
|
||||||
@ -119,11 +119,10 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
:param image_id: int, image ID for server creation
|
:param image_id: int, image ID for server creation
|
||||||
:param flavor_id: int, flavor ID for server creation
|
:param flavor_id: int, flavor ID for server creation
|
||||||
:param auto_assign_nic: bool, whether or not to auto assign NICs
|
:param auto_assign_nic: bool, whether or not to auto assign NICs
|
||||||
:param name: str, server name
|
|
||||||
:param kwargs: other optional parameters to initialize the server
|
:param kwargs: other optional parameters to initialize the server
|
||||||
:returns: nova Server instance
|
:returns: nova Server instance
|
||||||
"""
|
"""
|
||||||
server_name = name or self._generate_random_name()
|
server_name = self.generate_random_name()
|
||||||
secgroup = self.context.get("user", {}).get("secgroup")
|
secgroup = self.context.get("user", {}).get("secgroup")
|
||||||
if secgroup:
|
if secgroup:
|
||||||
if "security_groups" not in kwargs:
|
if "security_groups" not in kwargs:
|
||||||
@ -485,7 +484,7 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
|
|
||||||
:returns: Created keypair name
|
:returns: Created keypair name
|
||||||
"""
|
"""
|
||||||
keypair_name = self._generate_random_name(prefix="rally_keypair_")
|
keypair_name = self.generate_random_name()
|
||||||
keypair = self.clients("nova").keypairs.create(keypair_name, **kwargs)
|
keypair = self.clients("nova").keypairs.create(keypair_name, **kwargs)
|
||||||
return keypair.name
|
return keypair.name
|
||||||
|
|
||||||
@ -503,8 +502,8 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
self.clients("nova").keypairs.delete(keypair_name)
|
self.clients("nova").keypairs.delete(keypair_name)
|
||||||
|
|
||||||
@atomic.action_timer("nova.boot_servers")
|
@atomic.action_timer("nova.boot_servers")
|
||||||
def _boot_servers(self, image_id, flavor_id, requests, name_prefix=None,
|
def _boot_servers(self, image_id, flavor_id, requests, instances_amount=1,
|
||||||
instances_amount=1, auto_assign_nic=False, **kwargs):
|
auto_assign_nic=False, **kwargs):
|
||||||
"""Boot multiple servers.
|
"""Boot multiple servers.
|
||||||
|
|
||||||
Returns when all the servers are actually booted and are in the
|
Returns when all the servers are actually booted and are in the
|
||||||
@ -513,22 +512,18 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
:param image_id: ID of the image to be used for server creation
|
:param image_id: ID of the image to be used for server creation
|
||||||
:param flavor_id: ID of the flavor to be used for server creation
|
:param flavor_id: ID of the flavor to be used for server creation
|
||||||
:param requests: Number of booting requests to perform
|
:param requests: Number of booting requests to perform
|
||||||
:param name_prefix: The prefix to use while naming the created servers.
|
|
||||||
The rest of the server names will be '_<number>'
|
|
||||||
:param instances_amount: Number of instances to boot per each request
|
:param instances_amount: Number of instances to boot per each request
|
||||||
:param auto_assign_nic: bool, whether or not to auto assign NICs
|
:param auto_assign_nic: bool, whether or not to auto assign NICs
|
||||||
:param kwargs: other optional parameters to initialize the servers
|
:param kwargs: other optional parameters to initialize the servers
|
||||||
|
|
||||||
:returns: List of created server objects
|
:returns: List of created server objects
|
||||||
"""
|
"""
|
||||||
if not name_prefix:
|
|
||||||
name_prefix = self._generate_random_name()
|
|
||||||
|
|
||||||
if auto_assign_nic and not kwargs.get("nics", False):
|
if auto_assign_nic and not kwargs.get("nics", False):
|
||||||
nic = self._pick_random_nic()
|
nic = self._pick_random_nic()
|
||||||
if nic:
|
if nic:
|
||||||
kwargs["nics"] = nic
|
kwargs["nics"] = nic
|
||||||
|
|
||||||
|
name_prefix = self.generate_random_name()
|
||||||
for i in range(requests):
|
for i in range(requests):
|
||||||
self.clients("nova").servers.create("%s_%d" % (name_prefix, i),
|
self.clients("nova").servers.create("%s_%d" % (name_prefix, i),
|
||||||
image_id, flavor_id,
|
image_id, flavor_id,
|
||||||
@ -538,8 +533,8 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
# NOTE(msdubov): Nova python client returns only one server even when
|
# NOTE(msdubov): Nova python client returns only one server even when
|
||||||
# min_count > 1, so we have to rediscover all the
|
# min_count > 1, so we have to rediscover all the
|
||||||
# created servers manually.
|
# created servers manually.
|
||||||
servers = filter(lambda server: server.name.startswith(name_prefix),
|
servers = [s for s in self.clients("nova").servers.list()
|
||||||
self.clients("nova").servers.list())
|
if s.name.startswith(name_prefix)]
|
||||||
time.sleep(CONF.benchmark.nova_server_boot_prepoll_delay)
|
time.sleep(CONF.benchmark.nova_server_boot_prepoll_delay)
|
||||||
servers = [utils.wait_for(
|
servers = [utils.wait_for(
|
||||||
server,
|
server,
|
||||||
@ -760,7 +755,7 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
with atomic.ActionTimer(self, "nova.create_%s_security_groups" %
|
with atomic.ActionTimer(self, "nova.create_%s_security_groups" %
|
||||||
security_group_count):
|
security_group_count):
|
||||||
for i in range(security_group_count):
|
for i in range(security_group_count):
|
||||||
sg_name = self._generate_random_name()
|
sg_name = self.generate_random_name()
|
||||||
sg = self.clients("nova").security_groups.create(sg_name,
|
sg = self.clients("nova").security_groups.create(sg_name,
|
||||||
sg_name)
|
sg_name)
|
||||||
security_groups.append(sg)
|
security_groups.append(sg)
|
||||||
@ -790,8 +785,8 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
with atomic.ActionTimer(self, "nova.update_%s_security_groups" %
|
with atomic.ActionTimer(self, "nova.update_%s_security_groups" %
|
||||||
len(security_groups)):
|
len(security_groups)):
|
||||||
for sec_group in security_groups:
|
for sec_group in security_groups:
|
||||||
sg_new_name = self._generate_random_name()
|
sg_new_name = self.generate_random_name()
|
||||||
sg_new_desc = self._generate_random_name()
|
sg_new_desc = self.generate_random_name()
|
||||||
self.clients("nova").security_groups.update(sec_group.id,
|
self.clients("nova").security_groups.update(sec_group.id,
|
||||||
sg_new_name,
|
sg_new_name,
|
||||||
sg_new_desc)
|
sg_new_desc)
|
||||||
@ -816,7 +811,7 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
def _create_floating_ips_bulk(self, ip_range, **kwargs):
|
def _create_floating_ips_bulk(self, ip_range, **kwargs):
|
||||||
"""Create floating IPs by range."""
|
"""Create floating IPs by range."""
|
||||||
ip_range = network_wrapper.generate_cidr(start_cidr=ip_range)
|
ip_range = network_wrapper.generate_cidr(start_cidr=ip_range)
|
||||||
pool_name = self._generate_random_name(prefix="rally_fip_pool_")
|
pool_name = self.generate_random_name()
|
||||||
return self.admin_clients("nova").floating_ips_bulk.create(
|
return self.admin_clients("nova").floating_ips_bulk.create(
|
||||||
ip_range=ip_range, pool=pool_name, **kwargs)
|
ip_range=ip_range, pool=pool_name, **kwargs)
|
||||||
|
|
||||||
@ -852,7 +847,7 @@ class NovaScenario(scenario.OpenStackScenario):
|
|||||||
|
|
||||||
:param ip_range: IP range in CIDR notation to create
|
:param ip_range: IP range in CIDR notation to create
|
||||||
"""
|
"""
|
||||||
net_label = self._generate_random_name(prefix="rally_novanet")
|
net_label = self.generate_random_name()
|
||||||
ip_range = network_wrapper.generate_cidr(start_cidr=ip_range)
|
ip_range = network_wrapper.generate_cidr(start_cidr=ip_range)
|
||||||
return self.admin_clients("nova").networks.create(
|
return self.admin_clients("nova").networks.create(
|
||||||
label=net_label, cidr=ip_range, **kwargs)
|
label=net_label, cidr=ip_range, **kwargs)
|
||||||
|
@ -45,7 +45,7 @@ class SaharaJob(utils.SaharaScenario):
|
|||||||
mains = self.context["tenant"]["sahara_mains"]
|
mains = self.context["tenant"]["sahara_mains"]
|
||||||
libs = self.context["tenant"]["sahara_libs"]
|
libs = self.context["tenant"]["sahara_libs"]
|
||||||
|
|
||||||
name = self._generate_random_name(prefix="job_")
|
name = self.generate_random_name()
|
||||||
job = self.clients("sahara").jobs.create(name=name,
|
job = self.clients("sahara").jobs.create(name=name,
|
||||||
type=job_type,
|
type=job_type,
|
||||||
description="",
|
description="",
|
||||||
|
@ -58,8 +58,6 @@ CONF.register_opts(SAHARA_BENCHMARK_OPTS, group=benchmark_group)
|
|||||||
class SaharaScenario(scenario.OpenStackScenario):
|
class SaharaScenario(scenario.OpenStackScenario):
|
||||||
"""Base class for Sahara scenarios with basic atomic actions."""
|
"""Base class for Sahara scenarios with basic atomic actions."""
|
||||||
|
|
||||||
RESOURCE_NAME_LENGTH = 20
|
|
||||||
|
|
||||||
@atomic.action_timer("sahara.list_node_group_templates")
|
@atomic.action_timer("sahara.list_node_group_templates")
|
||||||
def _list_node_group_templates(self):
|
def _list_node_group_templates(self):
|
||||||
"""Return user Node Group Templates list."""
|
"""Return user Node Group Templates list."""
|
||||||
@ -76,7 +74,7 @@ class SaharaScenario(scenario.OpenStackScenario):
|
|||||||
the plugin
|
the plugin
|
||||||
:returns: The created Template
|
:returns: The created Template
|
||||||
"""
|
"""
|
||||||
name = self._generate_random_name(prefix="master-ngt-")
|
name = self.generate_random_name()
|
||||||
|
|
||||||
return self.clients("sahara").node_group_templates.create(
|
return self.clients("sahara").node_group_templates.create(
|
||||||
name=name,
|
name=name,
|
||||||
@ -97,7 +95,7 @@ class SaharaScenario(scenario.OpenStackScenario):
|
|||||||
the plugin
|
the plugin
|
||||||
:returns: The created Template
|
:returns: The created Template
|
||||||
"""
|
"""
|
||||||
name = self._generate_random_name(prefix="worker-ngt-")
|
name = self.generate_random_name()
|
||||||
|
|
||||||
return self.clients("sahara").node_group_templates.create(
|
return self.clients("sahara").node_group_templates.create(
|
||||||
name=name,
|
name=name,
|
||||||
@ -354,7 +352,7 @@ class SaharaScenario(scenario.OpenStackScenario):
|
|||||||
aa_processes = (sahara_consts.ANTI_AFFINITY_PROCESSES[plugin_name]
|
aa_processes = (sahara_consts.ANTI_AFFINITY_PROCESSES[plugin_name]
|
||||||
[hadoop_version])
|
[hadoop_version])
|
||||||
|
|
||||||
name = self._generate_random_name(prefix="sahara-cluster-")
|
name = self.generate_random_name()
|
||||||
|
|
||||||
cluster_object = self.clients("sahara").clusters.create(
|
cluster_object = self.clients("sahara").clusters.create(
|
||||||
name=name,
|
name=name,
|
||||||
@ -458,11 +456,10 @@ class SaharaScenario(scenario.OpenStackScenario):
|
|||||||
raise exceptions.RallyException(
|
raise exceptions.RallyException(
|
||||||
_("Swift Data Sources are not implemented yet"))
|
_("Swift Data Sources are not implemented yet"))
|
||||||
|
|
||||||
url = (url_prefix.rstrip("/") + "/%s" %
|
url = url_prefix.rstrip("/") + "/%s" % self.generate_random_name()
|
||||||
self._generate_random_name(length=10))
|
|
||||||
|
|
||||||
return self.clients("sahara").data_sources.create(
|
return self.clients("sahara").data_sources.create(
|
||||||
name=self._generate_random_name(prefix="out_"),
|
name=self.generate_random_name(),
|
||||||
description="",
|
description="",
|
||||||
data_source_type=ds_type,
|
data_source_type=ds_type,
|
||||||
url=url)
|
url=url)
|
||||||
|
@ -33,10 +33,9 @@ class SwiftScenario(scenario.OpenStackScenario):
|
|||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
@atomic.optional_action_timer("swift.create_container")
|
@atomic.optional_action_timer("swift.create_container")
|
||||||
def _create_container(self, container_name=None, public=False, **kwargs):
|
def _create_container(self, public=False, **kwargs):
|
||||||
"""Create a new container with given name.
|
"""Create a new container.
|
||||||
|
|
||||||
:param container_name: str, name of the container to create
|
|
||||||
:param public: bool, set container as public
|
:param public: bool, set container as public
|
||||||
:param atomic_action: bool, enable create container to be
|
:param atomic_action: bool, enable create container to be
|
||||||
tracked as an atomic action. added and
|
tracked as an atomic action. added and
|
||||||
@ -50,9 +49,7 @@ class SwiftScenario(scenario.OpenStackScenario):
|
|||||||
kwargs.setdefault("headers", {})
|
kwargs.setdefault("headers", {})
|
||||||
kwargs["headers"].setdefault("X-Container-Read", ".r:*,.rlistings")
|
kwargs["headers"].setdefault("X-Container-Read", ".r:*,.rlistings")
|
||||||
|
|
||||||
if container_name is None:
|
container_name = self.generate_random_name()
|
||||||
container_name = self._generate_random_name(
|
|
||||||
prefix="rally_container_")
|
|
||||||
|
|
||||||
self.clients("swift").put_container(container_name, **kwargs)
|
self.clients("swift").put_container(container_name, **kwargs)
|
||||||
return container_name
|
return container_name
|
||||||
@ -89,13 +86,11 @@ class SwiftScenario(scenario.OpenStackScenario):
|
|||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
@atomic.optional_action_timer("swift.upload_object")
|
@atomic.optional_action_timer("swift.upload_object")
|
||||||
def _upload_object(self, container_name, content, object_name=None,
|
def _upload_object(self, container_name, content, **kwargs):
|
||||||
**kwargs):
|
|
||||||
"""Upload content to a given container.
|
"""Upload content to a given container.
|
||||||
|
|
||||||
:param container_name: str, name of the container to upload object to
|
:param container_name: str, name of the container to upload object to
|
||||||
:param content: file stream, content to upload
|
:param content: file stream, content to upload
|
||||||
:param object_name: str, name of the object to upload
|
|
||||||
:param atomic_action: bool, enable upload object to be tracked
|
:param atomic_action: bool, enable upload object to be tracked
|
||||||
as an atomic action. added and handled
|
as an atomic action. added and handled
|
||||||
by the optional_action_timer() decorator
|
by the optional_action_timer() decorator
|
||||||
@ -103,8 +98,7 @@ class SwiftScenario(scenario.OpenStackScenario):
|
|||||||
|
|
||||||
:returns: tuple, (etag and object name)
|
:returns: tuple, (etag and object name)
|
||||||
"""
|
"""
|
||||||
if object_name is None:
|
object_name = self.generate_random_name()
|
||||||
object_name = self._generate_random_name(prefix="rally_object_")
|
|
||||||
|
|
||||||
return (self.clients("swift").put_object(container_name, object_name,
|
return (self.clients("swift").put_object(container_name, object_name,
|
||||||
content, **kwargs),
|
content, **kwargs),
|
||||||
|
@ -128,8 +128,7 @@ class VMScenario(nova_utils.NovaScenario, cinder_utils.CinderScenario):
|
|||||||
internal_network = list(server.networks)[0]
|
internal_network = list(server.networks)[0]
|
||||||
fixed_ip = server.addresses[internal_network][0]["addr"]
|
fixed_ip = server.addresses[internal_network][0]["addr"]
|
||||||
|
|
||||||
fip = network_wrapper.wrap(self.clients,
|
fip = network_wrapper.wrap(self.clients, self.task).create_floating_ip(
|
||||||
self.context["task"]).create_floating_ip(
|
|
||||||
ext_network=floating_network,
|
ext_network=floating_network,
|
||||||
tenant_id=server.tenant_id, fixed_ip=fixed_ip)
|
tenant_id=server.tenant_id, fixed_ip=fixed_ip)
|
||||||
|
|
||||||
@ -146,7 +145,7 @@ class VMScenario(nova_utils.NovaScenario, cinder_utils.CinderScenario):
|
|||||||
self._dissociate_floating_ip(server, fip["ip"],
|
self._dissociate_floating_ip(server, fip["ip"],
|
||||||
atomic_action=False)
|
atomic_action=False)
|
||||||
network_wrapper.wrap(
|
network_wrapper.wrap(
|
||||||
self.clients, self.context["task"]).delete_floating_ip(
|
self.clients, self.task).delete_floating_ip(
|
||||||
fip["id"],
|
fip["id"],
|
||||||
wait=True)
|
wait=True)
|
||||||
|
|
||||||
|
@ -14,42 +14,44 @@
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
from rally.common import utils
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.plugins.openstack.scenarios.zaqar import utils as zutils
|
from rally.plugins.openstack.scenarios.zaqar import utils as zutils
|
||||||
from rally.task import validation
|
|
||||||
|
|
||||||
|
|
||||||
class ZaqarBasic(zutils.ZaqarScenario):
|
class ZaqarBasic(zutils.ZaqarScenario):
|
||||||
"""Benchmark scenarios for Zaqar."""
|
"""Benchmark scenarios for Zaqar."""
|
||||||
|
|
||||||
@validation.number("name_length", minval=10)
|
|
||||||
@scenario.configure(context={"cleanup": ["zaqar"]})
|
@scenario.configure(context={"cleanup": ["zaqar"]})
|
||||||
def create_queue(self, name_length=10, **kwargs):
|
@utils.log_deprecated_args(
|
||||||
|
"The 'name_length' argument to create_queue is ignored",
|
||||||
|
"0.1.2", ["name_length"], once=True)
|
||||||
|
def create_queue(self, name_length=None, **kwargs):
|
||||||
"""Create a Zaqar queue with a random name.
|
"""Create a Zaqar queue with a random name.
|
||||||
|
|
||||||
:param name_length: length of generated (random) part of name
|
|
||||||
:param kwargs: other optional parameters to create queues like
|
:param kwargs: other optional parameters to create queues like
|
||||||
"metadata"
|
"metadata"
|
||||||
"""
|
"""
|
||||||
self._queue_create(name_length=name_length, **kwargs)
|
self._queue_create(**kwargs)
|
||||||
|
|
||||||
@validation.number("name_length", minval=10)
|
|
||||||
@scenario.configure(context={"cleanup": ["zaqar"]})
|
@scenario.configure(context={"cleanup": ["zaqar"]})
|
||||||
def producer_consumer(self, name_length=10,
|
@utils.log_deprecated_args(
|
||||||
|
"The 'name_length' argument to producer_consumer is ignored",
|
||||||
|
"0.1.2", ["name_length"], once=True)
|
||||||
|
def producer_consumer(self, name_length=None,
|
||||||
min_msg_count=50, max_msg_count=200, **kwargs):
|
min_msg_count=50, max_msg_count=200, **kwargs):
|
||||||
"""Serial message producer/consumer.
|
"""Serial message producer/consumer.
|
||||||
|
|
||||||
Creates a Zaqar queue with random name, sends a set of messages
|
Creates a Zaqar queue with random name, sends a set of messages
|
||||||
and then retrieves an iterator containing those.
|
and then retrieves an iterator containing those.
|
||||||
|
|
||||||
:param name_length: length of generated (random) part of name
|
|
||||||
:param min_msg_count: min number of messages to be posted
|
:param min_msg_count: min number of messages to be posted
|
||||||
:param max_msg_count: max number of messages to be posted
|
:param max_msg_count: max number of messages to be posted
|
||||||
:param kwargs: other optional parameters to create queues like
|
:param kwargs: other optional parameters to create queues like
|
||||||
"metadata"
|
"metadata"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queue = self._queue_create(name_length=name_length, **kwargs)
|
queue = self._queue_create(**kwargs)
|
||||||
msg_count = random.randint(min_msg_count, max_msg_count)
|
msg_count = random.randint(min_msg_count, max_msg_count)
|
||||||
messages = [{"body": {"id": idx}, "ttl": 360} for idx
|
messages = [{"body": {"id": idx}, "ttl": 360} for idx
|
||||||
in range(msg_count)]
|
in range(msg_count)]
|
||||||
|
@ -20,15 +20,14 @@ class ZaqarScenario(scenario.OpenStackScenario):
|
|||||||
"""Base class for Zaqar scenarios with basic atomic actions."""
|
"""Base class for Zaqar scenarios with basic atomic actions."""
|
||||||
|
|
||||||
@atomic.action_timer("zaqar.create_queue")
|
@atomic.action_timer("zaqar.create_queue")
|
||||||
def _queue_create(self, name_length=10, **kwargs):
|
def _queue_create(self, **kwargs):
|
||||||
"""Create a Zaqar queue with random name.
|
"""Create a Zaqar queue with random name.
|
||||||
|
|
||||||
:param name_length: length of generated (random) part of name
|
|
||||||
:param kwargs: other optional parameters to create queues like
|
:param kwargs: other optional parameters to create queues like
|
||||||
"metadata"
|
"metadata"
|
||||||
:returns: Zaqar queue instance
|
:returns: Zaqar queue instance
|
||||||
"""
|
"""
|
||||||
name = self._generate_random_name(length=name_length)
|
name = self.generate_random_name()
|
||||||
return self.clients("zaqar").queue(name, **kwargs)
|
return self.clients("zaqar").queue(name, **kwargs)
|
||||||
|
|
||||||
@atomic.action_timer("zaqar.delete_queue")
|
@atomic.action_timer("zaqar.delete_queue")
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ZaqarBasic.create_queue": [
|
"ZaqarBasic.create_queue": [
|
||||||
{
|
{
|
||||||
"args": {
|
"args": {},
|
||||||
"name_length": 10
|
|
||||||
},
|
|
||||||
"runner": {
|
"runner": {
|
||||||
"type": "constant",
|
"type": "constant",
|
||||||
"times": 100,
|
"times": 100,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
---
|
---
|
||||||
ZaqarBasic.create_queue:
|
ZaqarBasic.create_queue:
|
||||||
-
|
-
|
||||||
args:
|
args: {}
|
||||||
name_length: 10
|
|
||||||
runner:
|
runner:
|
||||||
type: "constant"
|
type: "constant"
|
||||||
times: 100
|
times: 100
|
||||||
|
@ -85,7 +85,6 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
|
|||||||
|
|
||||||
generator_ctx = TestImageGenerator(self.context)
|
generator_ctx = TestImageGenerator(self.context)
|
||||||
generator_ctx._customize_image = mock.MagicMock()
|
generator_ctx._customize_image = mock.MagicMock()
|
||||||
generator_ctx.generate_random_name = mock.Mock()
|
|
||||||
|
|
||||||
user = {
|
user = {
|
||||||
"endpoint": "endpoint",
|
"endpoint": "endpoint",
|
||||||
@ -107,7 +106,6 @@ class BaseCustomImageContextVMTestCase(test.TestCase):
|
|||||||
|
|
||||||
mock_vm_scenario._boot_server_with_fip.assert_called_once_with(
|
mock_vm_scenario._boot_server_with_fip.assert_called_once_with(
|
||||||
image="image", flavor="flavor",
|
image="image", flavor="flavor",
|
||||||
name=generator_ctx.generate_random_name.return_value,
|
|
||||||
floating_network="floating",
|
floating_network="floating",
|
||||||
key_name="keypair_name", security_groups=["secgroup_name"],
|
key_name="keypair_name", security_groups=["secgroup_name"],
|
||||||
userdata=None, foo_arg="foo_value")
|
userdata=None, foo_arg="foo_value")
|
||||||
|
@ -45,7 +45,7 @@ class CeilometerScenarioTestCase(test.ScenarioTestCase):
|
|||||||
def test__create_alarm(self):
|
def test__create_alarm(self):
|
||||||
alarm_dict = {"alarm_id": "fake-alarm-id"}
|
alarm_dict = {"alarm_id": "fake-alarm-id"}
|
||||||
orig_alarm_dict = copy.copy(alarm_dict)
|
orig_alarm_dict = copy.copy(alarm_dict)
|
||||||
self.scenario._generate_random_name = mock.Mock()
|
self.scenario.generate_random_name = mock.Mock()
|
||||||
self.assertEqual(self.scenario._create_alarm("fake-meter-name", 100,
|
self.assertEqual(self.scenario._create_alarm("fake-meter-name", 100,
|
||||||
alarm_dict),
|
alarm_dict),
|
||||||
self.clients("ceilometer").alarms.create.return_value)
|
self.clients("ceilometer").alarms.create.return_value)
|
||||||
@ -54,7 +54,7 @@ class CeilometerScenarioTestCase(test.ScenarioTestCase):
|
|||||||
threshold=100,
|
threshold=100,
|
||||||
description="Test Alarm",
|
description="Test Alarm",
|
||||||
alarm_id="fake-alarm-id",
|
alarm_id="fake-alarm-id",
|
||||||
name=self.scenario._generate_random_name.return_value)
|
name=self.scenario.generate_random_name.return_value)
|
||||||
# ensure that _create_alarm() doesn't modify the alarm dict as
|
# ensure that _create_alarm() doesn't modify the alarm dict as
|
||||||
# a side-effect
|
# a side-effect
|
||||||
self.assertDictEqual(alarm_dict, orig_alarm_dict)
|
self.assertDictEqual(alarm_dict, orig_alarm_dict)
|
||||||
@ -199,12 +199,12 @@ class CeilometerScenarioTestCase(test.ScenarioTestCase):
|
|||||||
"ceilometer.get_stats")
|
"ceilometer.get_stats")
|
||||||
|
|
||||||
def test__create_meter(self):
|
def test__create_meter(self):
|
||||||
self.scenario._generate_random_name = mock.Mock()
|
self.scenario.generate_random_name = mock.Mock()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.scenario._create_meter(fakearg="fakearg"),
|
self.scenario._create_meter(fakearg="fakearg"),
|
||||||
self.clients("ceilometer").samples.create.return_value[0])
|
self.clients("ceilometer").samples.create.return_value[0])
|
||||||
self.clients("ceilometer").samples.create.assert_called_once_with(
|
self.clients("ceilometer").samples.create.assert_called_once_with(
|
||||||
counter_name=self.scenario._generate_random_name.return_value,
|
counter_name=self.scenario.generate_random_name.return_value,
|
||||||
fakearg="fakearg")
|
fakearg="fakearg")
|
||||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||||
"ceilometer.create_meter")
|
"ceilometer.create_meter")
|
||||||
@ -239,7 +239,7 @@ class CeilometerScenarioTestCase(test.ScenarioTestCase):
|
|||||||
"ceilometer.query_samples")
|
"ceilometer.query_samples")
|
||||||
|
|
||||||
def test__create_sample_no_resource_id(self):
|
def test__create_sample_no_resource_id(self):
|
||||||
self.scenario._generate_random_name = mock.Mock()
|
self.scenario.generate_random_name = mock.Mock()
|
||||||
created_sample = self.scenario._create_sample("test-counter-name",
|
created_sample = self.scenario._create_sample("test-counter-name",
|
||||||
"test-counter-type",
|
"test-counter-type",
|
||||||
"test-counter-unit",
|
"test-counter-unit",
|
||||||
@ -252,7 +252,7 @@ class CeilometerScenarioTestCase(test.ScenarioTestCase):
|
|||||||
counter_type="test-counter-type",
|
counter_type="test-counter-type",
|
||||||
counter_unit="test-counter-unit",
|
counter_unit="test-counter-unit",
|
||||||
counter_volume="test-counter-volume",
|
counter_volume="test-counter-volume",
|
||||||
resource_id=self.scenario._generate_random_name.return_value)
|
resource_id=self.scenario.generate_random_name.return_value)
|
||||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||||
"ceilometer.create_sample")
|
"ceilometer.create_sample")
|
||||||
|
|
||||||
|
@ -131,9 +131,12 @@ class CinderScenarioTestCase(test.ScenarioTestCase):
|
|||||||
fake_volume = mock.MagicMock()
|
fake_volume = mock.MagicMock()
|
||||||
volume_update_args = {"display_name": "_updated",
|
volume_update_args = {"display_name": "_updated",
|
||||||
"display_description": "_updated"}
|
"display_description": "_updated"}
|
||||||
|
self.scenario.generate_random_name = mock.Mock()
|
||||||
|
|
||||||
self.scenario._update_volume(fake_volume, **volume_update_args)
|
self.scenario._update_volume(fake_volume, **volume_update_args)
|
||||||
self.clients("cinder").volumes.update.assert_called_once_with(
|
self.clients("cinder").volumes.update.assert_called_once_with(
|
||||||
fake_volume, display_name="_updated",
|
fake_volume,
|
||||||
|
display_name=self.scenario.generate_random_name.return_value,
|
||||||
display_description="_updated")
|
display_description="_updated")
|
||||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||||
"cinder.update_volume")
|
"cinder.update_volume")
|
||||||
@ -197,7 +200,7 @@ class CinderScenarioTestCase(test.ScenarioTestCase):
|
|||||||
volume.upload_to_image.return_value = (None, image)
|
volume.upload_to_image.return_value = (None, image)
|
||||||
self.clients("cinder").images.get.return_value = image
|
self.clients("cinder").images.get.return_value = image
|
||||||
|
|
||||||
self.scenario._generate_random_name = mock.Mock(
|
self.scenario.generate_random_name = mock.Mock(
|
||||||
return_value="test_vol")
|
return_value="test_vol")
|
||||||
self.scenario._upload_volume_to_image(volume, False,
|
self.scenario._upload_volume_to_image(volume, False,
|
||||||
"container", "disk")
|
"container", "disk")
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import ddt
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.plugins.openstack.scenarios.designate import utils
|
from rally.plugins.openstack.scenarios.designate import utils
|
||||||
@ -22,6 +23,7 @@ from tests.unit import test
|
|||||||
DESIGNATE_UTILS = "rally.plugins.openstack.scenarios.designate.utils."
|
DESIGNATE_UTILS = "rally.plugins.openstack.scenarios.designate.utils."
|
||||||
|
|
||||||
|
|
||||||
|
@ddt.ddt
|
||||||
class DesignateScenarioTestCase(test.ScenarioTestCase):
|
class DesignateScenarioTestCase(test.ScenarioTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -29,34 +31,25 @@ class DesignateScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self.domain = mock.Mock()
|
self.domain = mock.Mock()
|
||||||
self.server = mock.Mock()
|
self.server = mock.Mock()
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.generate_random_name")
|
@ddt.data(
|
||||||
def test_create_domain(self, mock_generate_random_name):
|
{},
|
||||||
scenario = utils.DesignateScenario()
|
{"email": "root@zone.name"})
|
||||||
|
def test_create_domain(self, domain_data):
|
||||||
random_name = "foo"
|
random_name = "foo"
|
||||||
explicit_name = "bar.io."
|
|
||||||
email = "root@zone.name"
|
|
||||||
|
|
||||||
mock_generate_random_name.return_value = random_name
|
|
||||||
scenario = utils.DesignateScenario(context=self.context)
|
scenario = utils.DesignateScenario(context=self.context)
|
||||||
|
scenario.generate_random_name = mock.Mock(return_value=random_name)
|
||||||
self.clients("designate").domains.create.return_value = self.domain
|
self.clients("designate").domains.create.return_value = self.domain
|
||||||
|
expected = {"email": "root@random.name"}
|
||||||
|
expected.update(domain_data)
|
||||||
|
expected["name"] = "%s.name." % random_name
|
||||||
|
|
||||||
# Check that the defaults / randoms are used if nothing is specified
|
domain = scenario._create_domain(domain_data)
|
||||||
domain = scenario._create_domain()
|
|
||||||
self.clients("designate").domains.create.assert_called_once_with(
|
self.clients("designate").domains.create.assert_called_once_with(
|
||||||
{"email": "root@random.name", "name": "%s.name." % random_name})
|
expected)
|
||||||
self.assertEqual(self.domain, domain)
|
self.assertEqual(self.domain, domain)
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"designate.create_domain")
|
"designate.create_domain")
|
||||||
|
|
||||||
self.clients("designate").domains.create.reset_mock()
|
|
||||||
|
|
||||||
# Check that when specifying zone defaults are not used...
|
|
||||||
data = {"email": email, "name": explicit_name}
|
|
||||||
domain = scenario._create_domain(data)
|
|
||||||
self.clients("designate").domains.create.assert_called_once_with(data)
|
|
||||||
self.assertEqual(self.domain, domain)
|
|
||||||
|
|
||||||
def test_list_domains(self):
|
def test_list_domains(self):
|
||||||
scenario = utils.DesignateScenario(context=self.context)
|
scenario = utils.DesignateScenario(context=self.context)
|
||||||
return_domains_list = scenario._list_domains()
|
return_domains_list = scenario._list_domains()
|
||||||
@ -73,36 +66,28 @@ class DesignateScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"designate.delete_domain")
|
"designate.delete_domain")
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.generate_random_name")
|
@ddt.data(
|
||||||
def test_create_record(self, mock_generate_random_name):
|
{},
|
||||||
scenario = utils.DesignateScenario()
|
{"data": "127.0.0.1"})
|
||||||
|
def test_create_record(self, record_data):
|
||||||
random_name = "foo"
|
random_name = "foo"
|
||||||
domain_name = "zone.name."
|
domain_name = "zone.name."
|
||||||
random_record_name = "%s.%s" % (random_name, domain_name)
|
|
||||||
|
|
||||||
mock_generate_random_name.return_value = random_name
|
|
||||||
scenario = utils.DesignateScenario(context=self.context)
|
|
||||||
|
|
||||||
domain = {"name": domain_name, "id": "123"}
|
domain = {"name": domain_name, "id": "123"}
|
||||||
|
record_name = "%s.%s" % (random_name, domain_name)
|
||||||
|
|
||||||
# Create with randoms (name and type)
|
scenario = utils.DesignateScenario(context=self.context)
|
||||||
scenario._create_record(domain)
|
scenario.generate_random_name = mock.Mock(return_value=random_name)
|
||||||
|
|
||||||
|
expected = {"type": "A", "data": "10.0.0.1"}
|
||||||
|
expected.update(record_data)
|
||||||
|
expected["name"] = record_name
|
||||||
|
|
||||||
|
scenario._create_record(domain, record=record_data)
|
||||||
self.clients("designate").records.create.assert_called_once_with(
|
self.clients("designate").records.create.assert_called_once_with(
|
||||||
domain["id"],
|
domain["id"], expected)
|
||||||
{"name": random_record_name, "type": "A", "data": "10.0.0.1"})
|
|
||||||
|
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"designate.create_record")
|
"designate.create_record")
|
||||||
|
|
||||||
self.clients("designate").records.create.reset_mock()
|
|
||||||
|
|
||||||
# Specify name
|
|
||||||
record = {"name": "www.zone.name.", "type": "ASD"}
|
|
||||||
scenario._create_record(domain, record)
|
|
||||||
self.clients("designate").records.create.assert_called_once_with(
|
|
||||||
domain["id"], record)
|
|
||||||
|
|
||||||
def test_list_records(self):
|
def test_list_records(self):
|
||||||
scenario = utils.DesignateScenario(context=self.context)
|
scenario = utils.DesignateScenario(context=self.context)
|
||||||
return_records_list = scenario._list_records("123")
|
return_records_list = scenario._list_records("123")
|
||||||
@ -127,14 +112,13 @@ class DesignateScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self.clients("designate").records.delete.assert_called_once_with(
|
self.clients("designate").records.delete.assert_called_once_with(
|
||||||
domain_id, record_id)
|
domain_id, record_id)
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.generate_random_name")
|
def test_create_server(self):
|
||||||
def test_create_server(self, mock_generate_random_name):
|
|
||||||
scenario = utils.DesignateScenario(context=self.context)
|
scenario = utils.DesignateScenario(context=self.context)
|
||||||
|
|
||||||
random_name = "foo"
|
random_name = "foo"
|
||||||
|
scenario.generate_random_name = mock.Mock(return_value=random_name)
|
||||||
|
|
||||||
explicit_name = "bar.io."
|
explicit_name = "bar.io."
|
||||||
|
|
||||||
mock_generate_random_name.return_value = random_name
|
|
||||||
self.admin_clients(
|
self.admin_clients(
|
||||||
"designate").servers.create.return_value = self.server
|
"designate").servers.create.return_value = self.server
|
||||||
|
|
||||||
|
@ -24,14 +24,14 @@ GLANCE_IMAGES = "rally.plugins.openstack.scenarios.glance.images.GlanceImages"
|
|||||||
|
|
||||||
class GlanceImagesTestCase(test.ScenarioTestCase):
|
class GlanceImagesTestCase(test.ScenarioTestCase):
|
||||||
|
|
||||||
@mock.patch(GLANCE_IMAGES + "._generate_random_name")
|
@mock.patch(GLANCE_IMAGES + ".generate_random_name")
|
||||||
@mock.patch(GLANCE_IMAGES + "._list_images")
|
@mock.patch(GLANCE_IMAGES + "._list_images")
|
||||||
@mock.patch(GLANCE_IMAGES + "._create_image")
|
@mock.patch(GLANCE_IMAGES + "._create_image")
|
||||||
def test_create_and_list_image(self, mock__create_image,
|
def test_create_and_list_image(self, mock__create_image,
|
||||||
mock__list_images,
|
mock__list_images,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
glance_scenario = images.GlanceImages(self.context)
|
glance_scenario = images.GlanceImages(self.context)
|
||||||
mock__generate_random_name.return_value = "test-rally-image"
|
mock_generate_random_name.return_value = "test-rally-image"
|
||||||
glance_scenario.create_and_list_image("cf", "url", "df",
|
glance_scenario.create_and_list_image("cf", "url", "df",
|
||||||
fakearg="f")
|
fakearg="f")
|
||||||
mock__create_image.assert_called_once_with(
|
mock__create_image.assert_called_once_with(
|
||||||
@ -44,16 +44,16 @@ class GlanceImagesTestCase(test.ScenarioTestCase):
|
|||||||
glance_scenario.list_images()
|
glance_scenario.list_images()
|
||||||
mock__list_images.assert_called_once_with()
|
mock__list_images.assert_called_once_with()
|
||||||
|
|
||||||
@mock.patch(GLANCE_IMAGES + "._generate_random_name")
|
@mock.patch(GLANCE_IMAGES + ".generate_random_name")
|
||||||
@mock.patch(GLANCE_IMAGES + "._delete_image")
|
@mock.patch(GLANCE_IMAGES + "._delete_image")
|
||||||
@mock.patch(GLANCE_IMAGES + "._create_image")
|
@mock.patch(GLANCE_IMAGES + "._create_image")
|
||||||
def test_create_and_delete_image(
|
def test_create_and_delete_image(
|
||||||
self, mock__create_image, mock__delete_image,
|
self, mock__create_image, mock__delete_image,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
glance_scenario = images.GlanceImages(self.context)
|
glance_scenario = images.GlanceImages(self.context)
|
||||||
fake_image = object()
|
fake_image = object()
|
||||||
mock__create_image.return_value = fake_image
|
mock__create_image.return_value = fake_image
|
||||||
mock__generate_random_name.return_value = "test-rally-image"
|
mock_generate_random_name.return_value = "test-rally-image"
|
||||||
glance_scenario.create_and_delete_image("cf", "url", "df",
|
glance_scenario.create_and_delete_image("cf", "url", "df",
|
||||||
fakearg="f")
|
fakearg="f")
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ class HeatStacksTestCase(test.ScenarioTestCase):
|
|||||||
self.default_files = ["dummy_file.yaml"]
|
self.default_files = ["dummy_file.yaml"]
|
||||||
self.default_environment = {"env": "dummy_env"}
|
self.default_environment = {"env": "dummy_env"}
|
||||||
|
|
||||||
@mock.patch(HEAT_STACKS + "._generate_random_name")
|
@mock.patch(HEAT_STACKS + ".generate_random_name")
|
||||||
@mock.patch(HEAT_STACKS + "._list_stacks")
|
@mock.patch(HEAT_STACKS + "._list_stacks")
|
||||||
@mock.patch(HEAT_STACKS + "._create_stack")
|
@mock.patch(HEAT_STACKS + "._create_stack")
|
||||||
def test_create_and_list_stack(self, mock__create_stack, mock__list_stacks,
|
def test_create_and_list_stack(self, mock__create_stack, mock__list_stacks,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
heat_scenario = stacks.HeatStacks(self.context)
|
heat_scenario = stacks.HeatStacks(self.context)
|
||||||
mock__generate_random_name.return_value = "test-rally-stack"
|
mock_generate_random_name.return_value = "test-rally-stack"
|
||||||
heat_scenario.create_and_list_stack(
|
heat_scenario.create_and_list_stack(
|
||||||
template_path=self.default_template,
|
template_path=self.default_template,
|
||||||
parameters=self.default_parameters,
|
parameters=self.default_parameters,
|
||||||
@ -68,16 +68,16 @@ class HeatStacksTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(
|
self._test_atomic_action_timer(
|
||||||
heat_scenario.atomic_actions(), "heat.list_events_of_1_stacks")
|
heat_scenario.atomic_actions(), "heat.list_events_of_1_stacks")
|
||||||
|
|
||||||
@mock.patch(HEAT_STACKS + "._generate_random_name")
|
@mock.patch(HEAT_STACKS + ".generate_random_name")
|
||||||
@mock.patch(HEAT_STACKS + "._delete_stack")
|
@mock.patch(HEAT_STACKS + "._delete_stack")
|
||||||
@mock.patch(HEAT_STACKS + "._create_stack")
|
@mock.patch(HEAT_STACKS + "._create_stack")
|
||||||
def test_create_and_delete_stack(
|
def test_create_and_delete_stack(
|
||||||
self, mock__create_stack, mock__delete_stack,
|
self, mock__create_stack, mock__delete_stack,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
heat_scenario = stacks.HeatStacks(self.context)
|
heat_scenario = stacks.HeatStacks(self.context)
|
||||||
fake_stack = object()
|
fake_stack = object()
|
||||||
mock__create_stack.return_value = fake_stack
|
mock__create_stack.return_value = fake_stack
|
||||||
mock__generate_random_name.return_value = "test-rally-stack"
|
mock_generate_random_name.return_value = "test-rally-stack"
|
||||||
heat_scenario.create_and_delete_stack(
|
heat_scenario.create_and_delete_stack(
|
||||||
template_path=self.default_template,
|
template_path=self.default_template,
|
||||||
parameters=self.default_parameters,
|
parameters=self.default_parameters,
|
||||||
@ -112,17 +112,17 @@ class HeatStacksTestCase(test.ScenarioTestCase):
|
|||||||
mock__delete_stack.assert_called_once_with(
|
mock__delete_stack.assert_called_once_with(
|
||||||
mock__create_stack.return_value)
|
mock__create_stack.return_value)
|
||||||
|
|
||||||
@mock.patch(HEAT_STACKS + "._generate_random_name")
|
@mock.patch(HEAT_STACKS + ".generate_random_name")
|
||||||
@mock.patch(HEAT_STACKS + "._delete_stack")
|
@mock.patch(HEAT_STACKS + "._delete_stack")
|
||||||
@mock.patch(HEAT_STACKS + "._update_stack")
|
@mock.patch(HEAT_STACKS + "._update_stack")
|
||||||
@mock.patch(HEAT_STACKS + "._create_stack")
|
@mock.patch(HEAT_STACKS + "._create_stack")
|
||||||
def test_create_update_delete_stack(
|
def test_create_update_delete_stack(
|
||||||
self, mock__create_stack, mock__update_stack, mock__delete_stack,
|
self, mock__create_stack, mock__update_stack, mock__delete_stack,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
heat_scenario = stacks.HeatStacks(self.context)
|
heat_scenario = stacks.HeatStacks(self.context)
|
||||||
fake_stack = object()
|
fake_stack = object()
|
||||||
mock__create_stack.return_value = fake_stack
|
mock__create_stack.return_value = fake_stack
|
||||||
mock__generate_random_name.return_value = "test-rally-stack"
|
mock_generate_random_name.return_value = "test-rally-stack"
|
||||||
heat_scenario.create_update_delete_stack(
|
heat_scenario.create_update_delete_stack(
|
||||||
template_path=self.default_template,
|
template_path=self.default_template,
|
||||||
parameters=self.default_parameters,
|
parameters=self.default_parameters,
|
||||||
|
@ -23,16 +23,16 @@ IRONIC_UTILS = "rally.plugins.openstack.scenarios.ironic.utils"
|
|||||||
|
|
||||||
class IronicScenarioTestCase(test.ScenarioTestCase):
|
class IronicScenarioTestCase(test.ScenarioTestCase):
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.generate_random_name")
|
def test__create_node(self):
|
||||||
def test__create_node(self, mock_generate_random_name):
|
|
||||||
mock_generate_random_name.return_value = "rally_fake_random_string"
|
|
||||||
self.admin_clients("ironic").node.create.return_value = "fake_node"
|
self.admin_clients("ironic").node.create.return_value = "fake_node"
|
||||||
scenario = utils.IronicScenario(self.context)
|
scenario = utils.IronicScenario(self.context)
|
||||||
|
scenario.generate_random_name = mock.Mock()
|
||||||
|
|
||||||
create_node = scenario._create_node(fake_param="foo")
|
create_node = scenario._create_node(fake_param="foo")
|
||||||
|
|
||||||
self.assertEqual("fake_node", create_node)
|
self.assertEqual("fake_node", create_node)
|
||||||
self.admin_clients("ironic").node.create.assert_called_once_with(
|
self.admin_clients("ironic").node.create.assert_called_once_with(
|
||||||
fake_param="foo", name="rally_fake_random_string")
|
fake_param="foo", name=scenario.generate_random_name.return_value)
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"ironic.create_node")
|
"ironic.create_node")
|
||||||
|
|
||||||
|
@ -65,13 +65,11 @@ class ManilaSharesTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
@ddt.data(
|
@ddt.data(
|
||||||
{},
|
{},
|
||||||
{"name": "foo_name"},
|
|
||||||
{"description": "foo_description"},
|
{"description": "foo_description"},
|
||||||
{"neutron_net_id": "foo_neutron_net_id"},
|
{"neutron_net_id": "foo_neutron_net_id"},
|
||||||
{"neutron_subnet_id": "foo_neutron_subnet_id"},
|
{"neutron_subnet_id": "foo_neutron_subnet_id"},
|
||||||
{"nova_net_id": "foo_nova_net_id"},
|
{"nova_net_id": "foo_nova_net_id"},
|
||||||
{"name": "foo_name",
|
{"description": "foo_description",
|
||||||
"description": "foo_description",
|
|
||||||
"neutron_net_id": "foo_neutron_net_id",
|
"neutron_net_id": "foo_neutron_net_id",
|
||||||
"neutron_subnet_id": "foo_neutron_subnet_id",
|
"neutron_subnet_id": "foo_neutron_subnet_id",
|
||||||
"nova_net_id": "foo_nova_net_id"},
|
"nova_net_id": "foo_nova_net_id"},
|
||||||
@ -82,7 +80,6 @@ class ManilaSharesTestCase(test.ScenarioTestCase):
|
|||||||
scenario._create_share_network = mock.MagicMock(return_value=fake_sn)
|
scenario._create_share_network = mock.MagicMock(return_value=fake_sn)
|
||||||
scenario._delete_share_network = mock.MagicMock()
|
scenario._delete_share_network = mock.MagicMock()
|
||||||
expected_params = {
|
expected_params = {
|
||||||
"name": None,
|
|
||||||
"description": None,
|
"description": None,
|
||||||
"neutron_net_id": None,
|
"neutron_net_id": None,
|
||||||
"neutron_subnet_id": None,
|
"neutron_subnet_id": None,
|
||||||
@ -98,13 +95,11 @@ class ManilaSharesTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
@ddt.data(
|
@ddt.data(
|
||||||
{},
|
{},
|
||||||
{"name": "foo_name"},
|
|
||||||
{"description": "foo_description"},
|
{"description": "foo_description"},
|
||||||
{"neutron_net_id": "foo_neutron_net_id"},
|
{"neutron_net_id": "foo_neutron_net_id"},
|
||||||
{"neutron_subnet_id": "foo_neutron_subnet_id"},
|
{"neutron_subnet_id": "foo_neutron_subnet_id"},
|
||||||
{"nova_net_id": "foo_nova_net_id"},
|
{"nova_net_id": "foo_nova_net_id"},
|
||||||
{"name": "foo_name",
|
{"description": "foo_description",
|
||||||
"description": "foo_description",
|
|
||||||
"neutron_net_id": "foo_neutron_net_id",
|
"neutron_net_id": "foo_neutron_net_id",
|
||||||
"neutron_subnet_id": "foo_neutron_subnet_id",
|
"neutron_subnet_id": "foo_neutron_subnet_id",
|
||||||
"nova_net_id": "foo_nova_net_id"},
|
"nova_net_id": "foo_nova_net_id"},
|
||||||
@ -114,7 +109,6 @@ class ManilaSharesTestCase(test.ScenarioTestCase):
|
|||||||
scenario._create_share_network = mock.MagicMock()
|
scenario._create_share_network = mock.MagicMock()
|
||||||
scenario._list_share_networks = mock.MagicMock()
|
scenario._list_share_networks = mock.MagicMock()
|
||||||
expected_create_params = {
|
expected_create_params = {
|
||||||
"name": params.get("name"),
|
|
||||||
"description": params.get("description"),
|
"description": params.get("description"),
|
||||||
"neutron_net_id": params.get("neutron_net_id"),
|
"neutron_net_id": params.get("neutron_net_id"),
|
||||||
"neutron_subnet_id": params.get("neutron_subnet_id"),
|
"neutron_subnet_id": params.get("neutron_subnet_id"),
|
||||||
@ -151,8 +145,7 @@ class ManilaSharesTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
@ddt.data(
|
@ddt.data(
|
||||||
{"security_service_type": "fake_type"},
|
{"security_service_type": "fake_type"},
|
||||||
{"name": "foo_name",
|
{"security_service_type": "fake_type",
|
||||||
"security_service_type": "fake_type",
|
|
||||||
"dns_ip": "fake_dns_ip",
|
"dns_ip": "fake_dns_ip",
|
||||||
"server": "fake_server",
|
"server": "fake_server",
|
||||||
"domain": "fake_domain",
|
"domain": "fake_domain",
|
||||||
@ -173,7 +166,6 @@ class ManilaSharesTestCase(test.ScenarioTestCase):
|
|||||||
"domain": params.get("domain"),
|
"domain": params.get("domain"),
|
||||||
"user": params.get("user"),
|
"user": params.get("user"),
|
||||||
"password": params.get("password"),
|
"password": params.get("password"),
|
||||||
"name": params.get("name"),
|
|
||||||
"description": params.get("description"),
|
"description": params.get("description"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ class ManilaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self.scenario = utils.ManilaScenario(self.context)
|
self.scenario = utils.ManilaScenario(self.context)
|
||||||
|
|
||||||
def test__create_share(self):
|
def test__create_share(self):
|
||||||
fake_name = "fake_name"
|
|
||||||
fake_share = mock.Mock()
|
fake_share = mock.Mock()
|
||||||
self.clients("manila").shares.create.return_value = fake_share
|
self.clients("manila").shares.create.return_value = fake_share
|
||||||
self.scenario.context = {
|
self.scenario.context = {
|
||||||
@ -43,12 +42,12 @@ class ManilaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
}
|
}
|
||||||
self.scenario.context["tenant"][consts.SHARE_NETWORKS_CONTEXT_NAME][
|
self.scenario.context["tenant"][consts.SHARE_NETWORKS_CONTEXT_NAME][
|
||||||
"sn_iterator"] = iter((0, ))
|
"sn_iterator"] = iter((0, ))
|
||||||
self.scenario._generate_random_name = mock.Mock(return_value=fake_name)
|
self.scenario.generate_random_name = mock.Mock()
|
||||||
|
|
||||||
self.scenario._create_share("nfs")
|
self.scenario._create_share("nfs")
|
||||||
|
|
||||||
self.clients("manila").shares.create.assert_called_once_with(
|
self.clients("manila").shares.create.assert_called_once_with(
|
||||||
"nfs", 1, name=fake_name,
|
"nfs", 1, name=self.scenario.generate_random_name.return_value,
|
||||||
share_network=self.scenario.context["tenant"][
|
share_network=self.scenario.context["tenant"][
|
||||||
consts.SHARE_NETWORKS_CONTEXT_NAME]["share_networks"][0])
|
consts.SHARE_NETWORKS_CONTEXT_NAME]["share_networks"][0])
|
||||||
|
|
||||||
@ -93,24 +92,24 @@ class ManilaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
detailed=params.get("detailed", True),
|
detailed=params.get("detailed", True),
|
||||||
search_opts=params.get("search_opts", None))
|
search_opts=params.get("search_opts", None))
|
||||||
|
|
||||||
@ddt.data(None, "", "SomeName")
|
def test__create_share_network(self):
|
||||||
def test__create_share_network(self, name):
|
|
||||||
fake_sn = mock.Mock()
|
fake_sn = mock.Mock()
|
||||||
self.scenario._generate_random_name = mock.Mock()
|
self.scenario.generate_random_name = mock.Mock()
|
||||||
self.clients("manila").share_networks.create.return_value = fake_sn
|
self.clients("manila").share_networks.create.return_value = fake_sn
|
||||||
data = {
|
data = {
|
||||||
"neutron_net_id": "fake_neutron_net_id",
|
"neutron_net_id": "fake_neutron_net_id",
|
||||||
"neutron_subnet_id": "fake_neutron_subnet_id",
|
"neutron_subnet_id": "fake_neutron_subnet_id",
|
||||||
"nova_net_id": "fake_nova_net_id",
|
"nova_net_id": "fake_nova_net_id",
|
||||||
"name": name or self.scenario._generate_random_name.return_value,
|
|
||||||
"description": "fake_description",
|
"description": "fake_description",
|
||||||
}
|
}
|
||||||
|
expected = dict(data)
|
||||||
|
expected["name"] = self.scenario.generate_random_name.return_value
|
||||||
|
|
||||||
result = self.scenario._create_share_network(**data)
|
result = self.scenario._create_share_network(**data)
|
||||||
|
|
||||||
self.assertEqual(fake_sn, result)
|
self.assertEqual(fake_sn, result)
|
||||||
self.clients("manila").share_networks.create.assert_called_once_with(
|
self.clients("manila").share_networks.create.assert_called_once_with(
|
||||||
**data)
|
**expected)
|
||||||
|
|
||||||
@mock.patch(BM_UTILS + "wait_for_status")
|
@mock.patch(BM_UTILS + "wait_for_status")
|
||||||
def test__delete_share_network(self, mock_wait_for_status):
|
def test__delete_share_network(self, mock_wait_for_status):
|
||||||
@ -166,6 +165,7 @@ class ManilaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
def test__create_security_service(self, ss_type):
|
def test__create_security_service(self, ss_type):
|
||||||
fake_ss = mock.Mock()
|
fake_ss = mock.Mock()
|
||||||
self.clients("manila").security_services.create.return_value = fake_ss
|
self.clients("manila").security_services.create.return_value = fake_ss
|
||||||
|
self.scenario.generate_random_name = mock.Mock()
|
||||||
data = {
|
data = {
|
||||||
"security_service_type": ss_type,
|
"security_service_type": ss_type,
|
||||||
"dns_ip": "fake_dns_ip",
|
"dns_ip": "fake_dns_ip",
|
||||||
@ -173,11 +173,11 @@ class ManilaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
"domain": "fake_domain",
|
"domain": "fake_domain",
|
||||||
"user": "fake_user",
|
"user": "fake_user",
|
||||||
"password": "fake_password",
|
"password": "fake_password",
|
||||||
"name": "fake_name",
|
|
||||||
"description": "fake_description",
|
"description": "fake_description",
|
||||||
}
|
}
|
||||||
expected = dict(data)
|
expected = dict(data)
|
||||||
expected["type"] = expected.pop("security_service_type")
|
expected["type"] = expected.pop("security_service_type")
|
||||||
|
expected["name"] = self.scenario.generate_random_name.return_value
|
||||||
|
|
||||||
result = self.scenario._create_security_service(**data)
|
result = self.scenario._create_security_service(**data)
|
||||||
|
|
||||||
|
@ -53,14 +53,14 @@ class MuranoEnvironmentsTestCase(test.ScenarioTestCase):
|
|||||||
@mock.patch(MURANO_SCENARIO + "._create_session")
|
@mock.patch(MURANO_SCENARIO + "._create_session")
|
||||||
@mock.patch(MURANO_SCENARIO + "._delete_environment")
|
@mock.patch(MURANO_SCENARIO + "._delete_environment")
|
||||||
@mock.patch(MURANO_SCENARIO + "._create_environment")
|
@mock.patch(MURANO_SCENARIO + "._create_environment")
|
||||||
@mock.patch(MURANO_SCENARIO + "._generate_random_name")
|
@mock.patch(MURANO_SCENARIO + ".generate_random_name")
|
||||||
def test_create_and_delete_environment(
|
def test_create_and_delete_environment(
|
||||||
self, mock__generate_random_name, mock__create_environment,
|
self, mock_generate_random_name, mock__create_environment,
|
||||||
mock__delete_environment, mock__create_session):
|
mock__delete_environment, mock__create_session):
|
||||||
scenario = environments.MuranoEnvironments(self.context)
|
scenario = environments.MuranoEnvironments(self.context)
|
||||||
fake_environment = mock.Mock(id="fake_id")
|
fake_environment = mock.Mock(id="fake_id")
|
||||||
mock__create_environment.return_value = fake_environment
|
mock__create_environment.return_value = fake_environment
|
||||||
mock__generate_random_name.return_value = "foo"
|
mock_generate_random_name.return_value = "foo"
|
||||||
scenario.create_and_delete_environment()
|
scenario.create_and_delete_environment()
|
||||||
mock__create_environment.assert_called_once_with()
|
mock__create_environment.assert_called_once_with()
|
||||||
mock__create_session.assert_called_once_with(fake_environment.id)
|
mock__create_session.assert_called_once_with(fake_environment.id)
|
||||||
|
@ -34,12 +34,16 @@ class MuranoScenarioTestCase(test.ScenarioTestCase):
|
|||||||
"murano.list_environments")
|
"murano.list_environments")
|
||||||
|
|
||||||
def test_create_environments(self):
|
def test_create_environments(self):
|
||||||
mock_create = mock.Mock(return_value="foo_env")
|
self.clients("murano").environments.create = mock.Mock()
|
||||||
self.clients("murano").environments.create = mock_create
|
|
||||||
scenario = utils.MuranoScenario(context=self.context)
|
scenario = utils.MuranoScenario(context=self.context)
|
||||||
create_env = scenario._create_environment("env_name")
|
scenario.generate_random_name = mock.Mock()
|
||||||
self.assertEqual("foo_env", create_env)
|
|
||||||
mock_create.assert_called_once_with({"name": "env_name"})
|
create_env = scenario._create_environment()
|
||||||
|
self.assertEqual(
|
||||||
|
create_env,
|
||||||
|
self.clients("murano").environments.create.return_value)
|
||||||
|
self.clients("murano").environments.create.assert_called_once_with(
|
||||||
|
{"name": scenario.generate_random_name.return_value})
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"murano.create_environment")
|
"murano.create_environment")
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ class NeutronNetworksTestCase(test.ScenarioTestCase):
|
|||||||
mock__delete_router.assert_has_calls(
|
mock__delete_router.assert_has_calls(
|
||||||
[mock.call(router)] * subnets_per_network)
|
[mock.call(router)] * subnets_per_network)
|
||||||
|
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._generate_random_name")
|
@mock.patch(NEUTRON_NETWORKS + ".generate_random_name")
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._list_ports")
|
@mock.patch(NEUTRON_NETWORKS + "._list_ports")
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._create_port")
|
@mock.patch(NEUTRON_NETWORKS + "._create_port")
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||||
@ -497,9 +497,9 @@ class NeutronNetworksTestCase(test.ScenarioTestCase):
|
|||||||
mock__create_network,
|
mock__create_network,
|
||||||
mock__create_port,
|
mock__create_port,
|
||||||
mock__list_ports,
|
mock__list_ports,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
scenario = network.NeutronNetworks(self.context)
|
scenario = network.NeutronNetworks(self.context)
|
||||||
mock__generate_random_name.return_value = "random-name"
|
mock_generate_random_name.return_value = "random-name"
|
||||||
net = {"network": {"id": "fake-id"}}
|
net = {"network": {"id": "fake-id"}}
|
||||||
mock__create_network.return_value = net
|
mock__create_network.return_value = net
|
||||||
ports_per_network = 10
|
ports_per_network = 10
|
||||||
@ -530,7 +530,7 @@ class NeutronNetworksTestCase(test.ScenarioTestCase):
|
|||||||
[mock.call(net, {"allocation_pools": []})] * ports_per_network)
|
[mock.call(net, {"allocation_pools": []})] * ports_per_network)
|
||||||
mock__list_ports.assert_called_once_with()
|
mock__list_ports.assert_called_once_with()
|
||||||
|
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._generate_random_name")
|
@mock.patch(NEUTRON_NETWORKS + ".generate_random_name")
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._update_port")
|
@mock.patch(NEUTRON_NETWORKS + "._update_port")
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._create_port", return_value={
|
@mock.patch(NEUTRON_NETWORKS + "._create_port", return_value={
|
||||||
"port": {
|
"port": {
|
||||||
@ -545,9 +545,9 @@ class NeutronNetworksTestCase(test.ScenarioTestCase):
|
|||||||
mock__create_network,
|
mock__create_network,
|
||||||
mock__create_port,
|
mock__create_port,
|
||||||
mock__update_port,
|
mock__update_port,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
scenario = network.NeutronNetworks(self.context)
|
scenario = network.NeutronNetworks(self.context)
|
||||||
mock__generate_random_name.return_value = "random-name"
|
mock_generate_random_name.return_value = "random-name"
|
||||||
ports_per_network = 10
|
ports_per_network = 10
|
||||||
|
|
||||||
port_update_args = {
|
port_update_args = {
|
||||||
@ -586,7 +586,7 @@ class NeutronNetworksTestCase(test.ScenarioTestCase):
|
|||||||
[mock.call(mock__create_port.return_value, port_update_args)
|
[mock.call(mock__create_port.return_value, port_update_args)
|
||||||
] * ports_per_network)
|
] * ports_per_network)
|
||||||
|
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._generate_random_name")
|
@mock.patch(NEUTRON_NETWORKS + ".generate_random_name")
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._delete_port")
|
@mock.patch(NEUTRON_NETWORKS + "._delete_port")
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._create_port")
|
@mock.patch(NEUTRON_NETWORKS + "._create_port")
|
||||||
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
@mock.patch(NEUTRON_NETWORKS + "._create_network")
|
||||||
@ -594,9 +594,9 @@ class NeutronNetworksTestCase(test.ScenarioTestCase):
|
|||||||
mock__create_network,
|
mock__create_network,
|
||||||
mock__create_port,
|
mock__create_port,
|
||||||
mock__delete_port,
|
mock__delete_port,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
scenario = network.NeutronNetworks(self.context)
|
scenario = network.NeutronNetworks(self.context)
|
||||||
mock__generate_random_name.return_value = "random-name"
|
mock_generate_random_name.return_value = "random-name"
|
||||||
net = {"network": {"id": "fake-id"}}
|
net = {"network": {"id": "fake-id"}}
|
||||||
mock__create_network.return_value = net
|
mock__create_network.return_value = net
|
||||||
ports_per_network = 10
|
ports_per_network = 10
|
||||||
|
@ -62,11 +62,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
neutron_scenario._list_networks.assert_called_once_with(
|
neutron_scenario._list_networks.assert_called_once_with(
|
||||||
atomic_action=False)
|
atomic_action=False)
|
||||||
|
|
||||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name")
|
def test_create_network(self):
|
||||||
def test_create_network(self, mock__generate_random_name):
|
|
||||||
neutron_scenario = utils.NeutronScenario(self.context)
|
neutron_scenario = utils.NeutronScenario(self.context)
|
||||||
random_name = "random_name"
|
random_name = "random_name"
|
||||||
mock__generate_random_name.return_value = random_name
|
neutron_scenario.generate_random_name = mock.Mock(
|
||||||
|
return_value=random_name)
|
||||||
self.clients("neutron").create_network.return_value = self.network
|
self.clients("neutron").create_network.return_value = self.network
|
||||||
|
|
||||||
network_data = {"admin_state_up": False}
|
network_data = {"admin_state_up": False}
|
||||||
@ -96,11 +96,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_update_network(self):
|
def test_update_network(self):
|
||||||
scenario = utils.NeutronScenario(context=self.context)
|
scenario = utils.NeutronScenario(context=self.context)
|
||||||
scenario._generate_random_name = mock.Mock()
|
scenario.generate_random_name = mock.Mock()
|
||||||
|
|
||||||
expected_network = {
|
expected_network = {
|
||||||
"network": {
|
"network": {
|
||||||
"name": scenario._generate_random_name.return_value,
|
"name": scenario.generate_random_name.return_value,
|
||||||
"admin_state_up": False,
|
"admin_state_up": False,
|
||||||
"fakearg": "fake"
|
"fakearg": "fake"
|
||||||
}
|
}
|
||||||
@ -128,10 +128,9 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"neutron.delete_network")
|
"neutron.delete_network")
|
||||||
|
|
||||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name",
|
def test_create_subnet(self):
|
||||||
return_value="test_subnet")
|
|
||||||
def test_create_subnet(self, mock__generate_random_name):
|
|
||||||
scenario = utils.NeutronScenario(self.context)
|
scenario = utils.NeutronScenario(self.context)
|
||||||
|
scenario.generate_random_name = mock.Mock(return_value="test_subnet")
|
||||||
network_id = "fake-id"
|
network_id = "fake-id"
|
||||||
start_cidr = "192.168.0.0/24"
|
start_cidr = "192.168.0.0/24"
|
||||||
|
|
||||||
@ -141,7 +140,7 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
"network_id": network_id,
|
"network_id": network_id,
|
||||||
"cidr": start_cidr,
|
"cidr": start_cidr,
|
||||||
"ip_version": scenario.SUBNET_IP_VERSION,
|
"ip_version": scenario.SUBNET_IP_VERSION,
|
||||||
"name": mock__generate_random_name.return_value
|
"name": scenario.generate_random_name.return_value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,10 +175,10 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_update_subnet(self):
|
def test_update_subnet(self):
|
||||||
scenario = utils.NeutronScenario(context=self.context)
|
scenario = utils.NeutronScenario(context=self.context)
|
||||||
scenario._generate_random_name = mock.Mock()
|
scenario.generate_random_name = mock.Mock()
|
||||||
expected_subnet = {
|
expected_subnet = {
|
||||||
"subnet": {
|
"subnet": {
|
||||||
"name": scenario._generate_random_name.return_value,
|
"name": scenario.generate_random_name.return_value,
|
||||||
"enable_dhcp": False,
|
"enable_dhcp": False,
|
||||||
"fakearg": "fake"
|
"fakearg": "fake"
|
||||||
}
|
}
|
||||||
@ -207,11 +206,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"neutron.delete_subnet")
|
"neutron.delete_subnet")
|
||||||
|
|
||||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name")
|
@mock.patch(NEUTRON_UTILS + "NeutronScenario.generate_random_name")
|
||||||
def test_create_router_default(self, mock__generate_random_name):
|
def test_create_router(self, mock_generate_random_name):
|
||||||
scenario = utils.NeutronScenario(self.context)
|
scenario = utils.NeutronScenario(self.context)
|
||||||
router = mock.Mock()
|
router = mock.Mock()
|
||||||
mock__generate_random_name.return_value = "random_name"
|
mock_generate_random_name.return_value = "random_name"
|
||||||
self.clients("neutron").create_router.return_value = router
|
self.clients("neutron").create_router.return_value = router
|
||||||
|
|
||||||
# Default options
|
# Default options
|
||||||
@ -222,13 +221,13 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"neutron.create_router")
|
"neutron.create_router")
|
||||||
|
|
||||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name")
|
@mock.patch(NEUTRON_UTILS + "NeutronScenario.generate_random_name")
|
||||||
def test_create_router_with_ext_gw(self, mock__generate_random_name):
|
def test_create_router_with_ext_gw(self, mock_generate_random_name):
|
||||||
scenario = utils.NeutronScenario()
|
scenario = utils.NeutronScenario()
|
||||||
router = mock.Mock()
|
router = mock.Mock()
|
||||||
external_network = [{"id": "ext-net", "router:external": True}]
|
external_network = [{"id": "ext-net", "router:external": True}]
|
||||||
scenario._list_networks = mock.Mock(return_value=external_network)
|
scenario._list_networks = mock.Mock(return_value=external_network)
|
||||||
mock__generate_random_name.return_value = "random_name"
|
mock_generate_random_name.return_value = "random_name"
|
||||||
self.clients("neutron").create_router.return_value = router
|
self.clients("neutron").create_router.return_value = router
|
||||||
|
|
||||||
# External_gw options
|
# External_gw options
|
||||||
@ -242,14 +241,14 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"neutron.create_router")
|
"neutron.create_router")
|
||||||
|
|
||||||
@mock.patch(NEUTRON_UTILS + "NeutronScenario._generate_random_name")
|
@mock.patch(NEUTRON_UTILS + "NeutronScenario.generate_random_name")
|
||||||
def test_create_router_with_ext_gw_but_no_ext_net(
|
def test_create_router_with_ext_gw_but_no_ext_net(
|
||||||
self, mock__generate_random_name):
|
self, mock_generate_random_name):
|
||||||
scenario = utils.NeutronScenario()
|
scenario = utils.NeutronScenario()
|
||||||
router = mock.Mock()
|
router = mock.Mock()
|
||||||
external_network = [{"id": "ext-net", "router:external": False}]
|
external_network = [{"id": "ext-net", "router:external": False}]
|
||||||
scenario._list_networks = mock.Mock(return_value=external_network)
|
scenario._list_networks = mock.Mock(return_value=external_network)
|
||||||
mock__generate_random_name.return_value = "random_name"
|
mock_generate_random_name.return_value = "random_name"
|
||||||
self.clients("neutron").create_router.return_value = router
|
self.clients("neutron").create_router.return_value = router
|
||||||
|
|
||||||
# External_gw options with no external networks in list_networks()
|
# External_gw options with no external networks in list_networks()
|
||||||
@ -285,11 +284,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_update_router(self):
|
def test_update_router(self):
|
||||||
scenario = utils.NeutronScenario(context=self.context)
|
scenario = utils.NeutronScenario(context=self.context)
|
||||||
scenario._generate_random_name = mock.Mock()
|
scenario.generate_random_name = mock.Mock()
|
||||||
|
|
||||||
expected_router = {
|
expected_router = {
|
||||||
"router": {
|
"router": {
|
||||||
"name": scenario._generate_random_name.return_value,
|
"name": scenario.generate_random_name.return_value,
|
||||||
"admin_state_up": False,
|
"admin_state_up": False,
|
||||||
"fakearg": "fake"
|
"fakearg": "fake"
|
||||||
}
|
}
|
||||||
@ -342,14 +341,14 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_create_port(self):
|
def test_create_port(self):
|
||||||
scenario = utils.NeutronScenario(self.context)
|
scenario = utils.NeutronScenario(self.context)
|
||||||
scenario._generate_random_name = mock.Mock()
|
scenario.generate_random_name = mock.Mock()
|
||||||
|
|
||||||
net_id = "network-id"
|
net_id = "network-id"
|
||||||
net = {"network": {"id": net_id}}
|
net = {"network": {"id": net_id}}
|
||||||
expected_port_args = {
|
expected_port_args = {
|
||||||
"port": {
|
"port": {
|
||||||
"network_id": net_id,
|
"network_id": net_id,
|
||||||
"name": scenario._generate_random_name.return_value
|
"name": scenario.generate_random_name.return_value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,11 +379,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_update_port(self):
|
def test_update_port(self):
|
||||||
scenario = utils.NeutronScenario(context=self.context)
|
scenario = utils.NeutronScenario(context=self.context)
|
||||||
scenario._generate_random_name = mock.Mock()
|
scenario.generate_random_name = mock.Mock()
|
||||||
|
|
||||||
expected_port = {
|
expected_port = {
|
||||||
"port": {
|
"port": {
|
||||||
"name": scenario._generate_random_name.return_value,
|
"name": scenario.generate_random_name.return_value,
|
||||||
"admin_state_up": False,
|
"admin_state_up": False,
|
||||||
"fakearg": "fake"
|
"fakearg": "fake"
|
||||||
}
|
}
|
||||||
@ -502,11 +501,11 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_update_pool(self):
|
def test_update_pool(self):
|
||||||
scenario = utils.NeutronScenario(context=self.context)
|
scenario = utils.NeutronScenario(context=self.context)
|
||||||
scenario._generate_random_name = mock.Mock()
|
scenario.generate_random_name = mock.Mock()
|
||||||
|
|
||||||
expected_pool = {
|
expected_pool = {
|
||||||
"pool": {
|
"pool": {
|
||||||
"name": scenario._generate_random_name.return_value,
|
"name": scenario.generate_random_name.return_value,
|
||||||
"admin_state_up": False,
|
"admin_state_up": False,
|
||||||
"fakearg": "fake"
|
"fakearg": "fake"
|
||||||
}
|
}
|
||||||
@ -557,10 +556,10 @@ class NeutronScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_update_v1_vip(self):
|
def test_update_v1_vip(self):
|
||||||
scenario = utils.NeutronScenario()
|
scenario = utils.NeutronScenario()
|
||||||
scenario._generate_random_name = mock.Mock(return_value="random_name")
|
scenario.generate_random_name = mock.Mock(return_value="random_name")
|
||||||
expected_vip = {
|
expected_vip = {
|
||||||
"vip": {
|
"vip": {
|
||||||
"name": scenario._generate_random_name.return_value,
|
"name": scenario.generate_random_name.return_value,
|
||||||
"admin_state_up": False
|
"admin_state_up": False
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,7 +655,7 @@ class NeutronLoadbalancerScenarioTestCase(test.ScenarioTestCase):
|
|||||||
pool = {"pool": {"id": "pool-id"}}
|
pool = {"pool": {"id": "pool-id"}}
|
||||||
pool_create_args = pool_create_args or {}
|
pool_create_args = pool_create_args or {}
|
||||||
if pool_create_args.get("name") is None:
|
if pool_create_args.get("name") is None:
|
||||||
neutron_scenario._generate_random_name = mock.Mock(
|
neutron_scenario.generate_random_name = mock.Mock(
|
||||||
return_value="random_name")
|
return_value="random_name")
|
||||||
self.clients("neutron").create_pool.return_value = pool
|
self.clients("neutron").create_pool.return_value = pool
|
||||||
args = {"lb_method": "ROUND_ROBIN", "protocol": "HTTP",
|
args = {"lb_method": "ROUND_ROBIN", "protocol": "HTTP",
|
||||||
@ -680,12 +679,12 @@ class NeutronLoadbalancerScenarioTestCase(test.ScenarioTestCase):
|
|||||||
)
|
)
|
||||||
@ddt.unpack
|
@ddt.unpack
|
||||||
def test__create_v1_vip(self, vip_create_args=None):
|
def test__create_v1_vip(self, vip_create_args=None):
|
||||||
neutron_scenario = utils.NeutronScenario()
|
neutron_scenario = utils.NeutronScenario(self.context)
|
||||||
vip = {"vip": {"id": "vip-id"}}
|
vip = {"vip": {"id": "vip-id"}}
|
||||||
pool = {"pool": {"id": "pool-id", "subnet_id": "subnet-id"}}
|
pool = {"pool": {"id": "pool-id", "subnet_id": "subnet-id"}}
|
||||||
vip_create_args = vip_create_args or {}
|
vip_create_args = vip_create_args or {}
|
||||||
if vip_create_args.get("name") is None:
|
if vip_create_args.get("name") is None:
|
||||||
neutron_scenario._generate_random_name = mock.Mock(
|
neutron_scenario.generate_random_name = mock.Mock(
|
||||||
return_value="random_name")
|
return_value="random_name")
|
||||||
self.clients("neutron").create_vip.return_value = vip
|
self.clients("neutron").create_vip.return_value = vip
|
||||||
args = {"protocol_port": 80, "protocol": "HTTP", "name": "random_name",
|
args = {"protocol_port": 80, "protocol": "HTTP", "name": "random_name",
|
||||||
|
@ -23,7 +23,7 @@ class NovaKeypairTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_create_and_list_keypairs(self):
|
def test_create_and_list_keypairs(self):
|
||||||
scenario = keypairs.NovaKeypair(self.context)
|
scenario = keypairs.NovaKeypair(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
|
scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
|
||||||
scenario._list_keypairs = mock.MagicMock()
|
scenario._list_keypairs = mock.MagicMock()
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class NovaKeypairTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_create_and_delete_keypair(self):
|
def test_create_and_delete_keypair(self):
|
||||||
scenario = keypairs.NovaKeypair(self.context)
|
scenario = keypairs.NovaKeypair(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
|
scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
|
||||||
scenario._delete_keypair = mock.MagicMock()
|
scenario._delete_keypair = mock.MagicMock()
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class NovaKeypairTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_boot_and_delete_server_with_keypair(self):
|
def test_boot_and_delete_server_with_keypair(self):
|
||||||
scenario = keypairs.NovaKeypair(self.context)
|
scenario = keypairs.NovaKeypair(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
|
scenario._create_keypair = mock.MagicMock(return_value="foo_keypair")
|
||||||
scenario._boot_server = mock.MagicMock(return_value="foo_server")
|
scenario._boot_server = mock.MagicMock(return_value="foo_server")
|
||||||
scenario._delete_server = mock.MagicMock()
|
scenario._delete_server = mock.MagicMock()
|
||||||
|
@ -32,7 +32,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_server = mock.MagicMock()
|
fake_server = mock.MagicMock()
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._rescue_server = mock.MagicMock()
|
scenario._rescue_server = mock.MagicMock()
|
||||||
scenario._unrescue_server = mock.MagicMock()
|
scenario._unrescue_server = mock.MagicMock()
|
||||||
scenario._delete_server = mock.MagicMock()
|
scenario._delete_server = mock.MagicMock()
|
||||||
@ -56,7 +56,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_server = mock.MagicMock()
|
fake_server = mock.MagicMock()
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._start_server = mock.MagicMock()
|
scenario._start_server = mock.MagicMock()
|
||||||
scenario._stop_server = mock.MagicMock()
|
scenario._stop_server = mock.MagicMock()
|
||||||
scenario._delete_server = mock.MagicMock()
|
scenario._delete_server = mock.MagicMock()
|
||||||
@ -85,7 +85,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
scenario._delete_server = mock.MagicMock()
|
scenario._delete_server = mock.MagicMock()
|
||||||
scenario._reboot_server = mock.MagicMock()
|
scenario._reboot_server = mock.MagicMock()
|
||||||
scenario._stop_and_start_server = mock.MagicMock()
|
scenario._stop_and_start_server = mock.MagicMock()
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
|
|
||||||
scenario.boot_and_bounce_server("img", 1, actions=actions)
|
scenario.boot_and_bounce_server("img", 1, actions=actions)
|
||||||
scenario._boot_server.assert_called_once_with("img", 1)
|
scenario._boot_server.assert_called_once_with("img", 1)
|
||||||
@ -158,7 +158,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
scenario._soft_reboot_server = mock.MagicMock()
|
scenario._soft_reboot_server = mock.MagicMock()
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._delete_server = mock.MagicMock()
|
scenario._delete_server = mock.MagicMock()
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
|
|
||||||
scenario.boot_and_bounce_server("img", 1, actions=actions)
|
scenario.boot_and_bounce_server("img", 1, actions=actions)
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_server = object()
|
fake_server = object()
|
||||||
|
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._delete_server = mock.MagicMock()
|
scenario._delete_server = mock.MagicMock()
|
||||||
scenario.sleep_between = mock.MagicMock()
|
scenario.sleep_between = mock.MagicMock()
|
||||||
@ -220,7 +220,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test_boot_and_list_server(self):
|
def test_boot_and_list_server(self):
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._boot_server = mock.MagicMock()
|
scenario._boot_server = mock.MagicMock()
|
||||||
scenario._list_servers = mock.MagicMock()
|
scenario._list_servers = mock.MagicMock()
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_server = object()
|
fake_server = object()
|
||||||
|
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._suspend_server = mock.MagicMock()
|
scenario._suspend_server = mock.MagicMock()
|
||||||
scenario._resume_server = mock.MagicMock()
|
scenario._resume_server = mock.MagicMock()
|
||||||
@ -254,7 +254,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_server = object()
|
fake_server = object()
|
||||||
|
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._pause_server = mock.MagicMock()
|
scenario._pause_server = mock.MagicMock()
|
||||||
scenario._unpause_server = mock.MagicMock()
|
scenario._unpause_server = mock.MagicMock()
|
||||||
@ -298,7 +298,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_server = object()
|
fake_server = object()
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario.sleep_between = mock.MagicMock()
|
scenario.sleep_between = mock.MagicMock()
|
||||||
scenario._delete_server = mock.MagicMock()
|
scenario._delete_server = mock.MagicMock()
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
|
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
|
|
||||||
kwargs = {"fakearg": "f"}
|
kwargs = {"fakearg": "f"}
|
||||||
expected_kwargs = {"fakearg": "f"}
|
expected_kwargs = {"fakearg": "f"}
|
||||||
@ -358,7 +358,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_image.id = "image_id"
|
fake_image.id = "image_id"
|
||||||
|
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._create_image = mock.MagicMock(return_value=fake_image)
|
scenario._create_image = mock.MagicMock(return_value=fake_image)
|
||||||
scenario._delete_server = mock.MagicMock()
|
scenario._delete_server = mock.MagicMock()
|
||||||
@ -383,7 +383,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
to_flavor = mock.MagicMock()
|
to_flavor = mock.MagicMock()
|
||||||
|
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._resize_confirm = mock.MagicMock()
|
scenario._resize_confirm = mock.MagicMock()
|
||||||
scenario._resize_revert = mock.MagicMock()
|
scenario._resize_revert = mock.MagicMock()
|
||||||
@ -410,7 +410,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_server = mock.MagicMock()
|
fake_server = mock.MagicMock()
|
||||||
|
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario.sleep_between = mock.MagicMock()
|
scenario.sleep_between = mock.MagicMock()
|
||||||
scenario._find_host_to_migrate = mock.MagicMock(
|
scenario._find_host_to_migrate = mock.MagicMock(
|
||||||
@ -437,7 +437,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_server = mock.MagicMock()
|
fake_server = mock.MagicMock()
|
||||||
|
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario.sleep_between = mock.MagicMock()
|
scenario.sleep_between = mock.MagicMock()
|
||||||
scenario._find_host_to_migrate = mock.MagicMock(
|
scenario._find_host_to_migrate = mock.MagicMock(
|
||||||
@ -517,7 +517,7 @@ class NovaServersTestCase(test.ScenarioTestCase):
|
|||||||
fake_server = mock.MagicMock()
|
fake_server = mock.MagicMock()
|
||||||
|
|
||||||
scenario = servers.NovaServers(self.context)
|
scenario = servers.NovaServers(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(return_value="name")
|
scenario.generate_random_name = mock.MagicMock(return_value="name")
|
||||||
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
scenario._boot_server = mock.MagicMock(return_value=fake_server)
|
||||||
scenario._stop_server = mock.MagicMock()
|
scenario._stop_server = mock.MagicMock()
|
||||||
scenario._migrate = mock.MagicMock()
|
scenario._migrate = mock.MagicMock()
|
||||||
|
@ -101,7 +101,7 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
context.setdefault("config", {})
|
context.setdefault("config", {})
|
||||||
|
|
||||||
nova_scenario = utils.NovaScenario(context=context)
|
nova_scenario = utils.NovaScenario(context=context)
|
||||||
nova_scenario._generate_random_name = mock.Mock()
|
nova_scenario.generate_random_name = mock.Mock()
|
||||||
nova_scenario._pick_random_nic = mock.Mock()
|
nova_scenario._pick_random_nic = mock.Mock()
|
||||||
if kwargs is None:
|
if kwargs is None:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
@ -134,7 +134,7 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
expected_kwargs["security_groups"] = list(expected_secgroups)
|
expected_kwargs["security_groups"] = list(expected_secgroups)
|
||||||
|
|
||||||
self.clients("nova").servers.create.assert_called_once_with(
|
self.clients("nova").servers.create.assert_called_once_with(
|
||||||
nova_scenario._generate_random_name.return_value,
|
nova_scenario.generate_random_name.return_value,
|
||||||
"image_id", "flavor_id", **expected_kwargs)
|
"image_id", "flavor_id", **expected_kwargs)
|
||||||
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
|
||||||
"nova.boot_server")
|
"nova.boot_server")
|
||||||
@ -440,22 +440,21 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
@ddt.data(
|
@ddt.data(
|
||||||
{"requests": 1},
|
{"requests": 1},
|
||||||
{"requests": 25},
|
{"requests": 25},
|
||||||
{"requests": 2, "name_prefix": "foo", "instances_amount": 100,
|
{"requests": 2, "instances_amount": 100, "auto_assign_nic": True,
|
||||||
"auto_assign_nic": True, "fakearg": "fake"},
|
"fakearg": "fake"},
|
||||||
{"auto_assign_nic": True, "nics": [{"net-id": "foo"}]},
|
{"auto_assign_nic": True, "nics": [{"net-id": "foo"}]},
|
||||||
{"auto_assign_nic": False, "nics": [{"net-id": "foo"}]})
|
{"auto_assign_nic": False, "nics": [{"net-id": "foo"}]})
|
||||||
@ddt.unpack
|
@ddt.unpack
|
||||||
def test__boot_servers(self, image_id="image", flavor_id="flavor",
|
def test__boot_servers(self, image_id="image", flavor_id="flavor",
|
||||||
requests=1, name_prefix=None, instances_amount=1,
|
requests=1, instances_amount=1,
|
||||||
auto_assign_nic=False, **kwargs):
|
auto_assign_nic=False, **kwargs):
|
||||||
servers = [mock.Mock() for i in range(instances_amount)]
|
servers = [mock.Mock() for i in range(instances_amount)]
|
||||||
self.clients("nova").servers.list.return_value = servers
|
self.clients("nova").servers.list.return_value = servers
|
||||||
scenario = utils.NovaScenario(context=self.context)
|
scenario = utils.NovaScenario(context=self.context)
|
||||||
scenario._generate_random_name = mock.Mock()
|
scenario.generate_random_name = mock.Mock()
|
||||||
scenario._pick_random_nic = mock.Mock()
|
scenario._pick_random_nic = mock.Mock()
|
||||||
|
|
||||||
scenario._boot_servers(image_id, flavor_id, requests,
|
scenario._boot_servers(image_id, flavor_id, requests,
|
||||||
name_prefix=name_prefix,
|
|
||||||
instances_amount=instances_amount,
|
instances_amount=instances_amount,
|
||||||
auto_assign_nic=auto_assign_nic,
|
auto_assign_nic=auto_assign_nic,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
@ -464,11 +463,10 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
if auto_assign_nic and "nics" not in kwargs:
|
if auto_assign_nic and "nics" not in kwargs:
|
||||||
expected_kwargs["nics"] = scenario._pick_random_nic.return_value
|
expected_kwargs["nics"] = scenario._pick_random_nic.return_value
|
||||||
|
|
||||||
if name_prefix is None:
|
|
||||||
name_prefix = scenario._generate_random_name.return_value
|
|
||||||
|
|
||||||
create_calls = [
|
create_calls = [
|
||||||
mock.call("%s_%d" % (name_prefix, i), image_id, flavor_id,
|
mock.call(
|
||||||
|
"%s_%d" % (scenario.generate_random_name.return_value, i),
|
||||||
|
image_id, flavor_id,
|
||||||
min_count=instances_amount, max_count=instances_amount,
|
min_count=instances_amount, max_count=instances_amount,
|
||||||
**expected_kwargs)
|
**expected_kwargs)
|
||||||
for i in range(requests)]
|
for i in range(requests)]
|
||||||
@ -661,7 +659,7 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test__create_security_groups(self):
|
def test__create_security_groups(self):
|
||||||
nova_scenario = utils.NovaScenario(context=self.context)
|
nova_scenario = utils.NovaScenario(context=self.context)
|
||||||
nova_scenario._generate_random_name = mock.MagicMock()
|
nova_scenario.generate_random_name = mock.MagicMock()
|
||||||
|
|
||||||
security_group_count = 5
|
security_group_count = 5
|
||||||
|
|
||||||
@ -670,7 +668,7 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
self.assertEqual(security_group_count, len(sec_groups))
|
self.assertEqual(security_group_count, len(sec_groups))
|
||||||
self.assertEqual(security_group_count,
|
self.assertEqual(security_group_count,
|
||||||
nova_scenario._generate_random_name.call_count)
|
nova_scenario.generate_random_name.call_count)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
security_group_count,
|
security_group_count,
|
||||||
self.clients("nova").security_groups.create.call_count)
|
self.clients("nova").security_groups.create.call_count)
|
||||||
@ -697,7 +695,7 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
(rules_per_security_group * len(fake_secgroups)))
|
(rules_per_security_group * len(fake_secgroups)))
|
||||||
|
|
||||||
def test__update_security_groups(self):
|
def test__update_security_groups(self):
|
||||||
nova_scenario = utils.NovaScenario()
|
nova_scenario = utils.NovaScenario(context=self.context)
|
||||||
fake_secgroups = [fakes.FakeSecurityGroup(None, None, 1, "uuid1"),
|
fake_secgroups = [fakes.FakeSecurityGroup(None, None, 1, "uuid1"),
|
||||||
fakes.FakeSecurityGroup(None, None, 2, "uuid2")]
|
fakes.FakeSecurityGroup(None, None, 2, "uuid2")]
|
||||||
nova_scenario._update_security_groups(fake_secgroups)
|
nova_scenario._update_security_groups(fake_secgroups)
|
||||||
@ -841,7 +839,7 @@ class NovaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self.admin_clients("nova").networks.create.return_value = (fake_net)
|
self.admin_clients("nova").networks.create.return_value = (fake_net)
|
||||||
|
|
||||||
nova_scenario = utils.NovaScenario()
|
nova_scenario = utils.NovaScenario()
|
||||||
nova_scenario._generate_random_name = mock.Mock(
|
nova_scenario.generate_random_name = mock.Mock(
|
||||||
return_value="rally_novanet_fake")
|
return_value="rally_novanet_fake")
|
||||||
|
|
||||||
return_netlabel = nova_scenario._create_network(fake_cidr,
|
return_netlabel = nova_scenario._create_network(fake_cidr,
|
||||||
|
@ -34,12 +34,8 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
CONF.set_override("sahara_cluster_check_interval", 0, "benchmark")
|
CONF.set_override("sahara_cluster_check_interval", 0, "benchmark")
|
||||||
CONF.set_override("sahara_job_check_interval", 0, "benchmark")
|
CONF.set_override("sahara_job_check_interval", 0, "benchmark")
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.generate_random_name",
|
|
||||||
return_value="job_42")
|
|
||||||
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
||||||
def test_create_launch_job_java(self, mock__run_job_execution,
|
def test_create_launch_job_java(self, mock__run_job_execution):
|
||||||
mock_generate_random_name):
|
|
||||||
|
|
||||||
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
||||||
id="42")
|
id="42")
|
||||||
|
|
||||||
@ -53,6 +49,7 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
jobs_scenario = jobs.SaharaJob(self.context)
|
jobs_scenario = jobs.SaharaJob(self.context)
|
||||||
|
jobs_scenario.generate_random_name = mock.Mock(return_value="job_42")
|
||||||
|
|
||||||
jobs_scenario.create_launch_job(
|
jobs_scenario.create_launch_job(
|
||||||
job_type="java",
|
job_type="java",
|
||||||
@ -60,7 +57,7 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
job_idx=0
|
job_idx=0
|
||||||
)
|
)
|
||||||
self.clients("sahara").jobs.create.assert_called_once_with(
|
self.clients("sahara").jobs.create.assert_called_once_with(
|
||||||
name=mock_generate_random_name.return_value,
|
name=jobs_scenario.generate_random_name.return_value,
|
||||||
type="java",
|
type="java",
|
||||||
description="",
|
description="",
|
||||||
mains=["main_42"],
|
mains=["main_42"],
|
||||||
@ -76,15 +73,11 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
job_idx=0
|
job_idx=0
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.generate_random_name",
|
|
||||||
return_value="job_42")
|
|
||||||
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
||||||
@mock.patch(SAHARA_JOB + "._create_output_ds",
|
@mock.patch(SAHARA_JOB + "._create_output_ds",
|
||||||
return_value=mock.MagicMock(id="out_42"))
|
return_value=mock.MagicMock(id="out_42"))
|
||||||
def test_create_launch_job_pig(self, mock__create_output_ds,
|
def test_create_launch_job_pig(self, mock__create_output_ds,
|
||||||
mock__run_job_execution,
|
mock__run_job_execution):
|
||||||
mock_generate_random_name):
|
|
||||||
|
|
||||||
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
||||||
id="42")
|
id="42")
|
||||||
|
|
||||||
@ -98,13 +91,15 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
jobs_scenario = jobs.SaharaJob(self.context)
|
jobs_scenario = jobs.SaharaJob(self.context)
|
||||||
|
jobs_scenario.generate_random_name = mock.Mock(return_value="job_42")
|
||||||
|
|
||||||
jobs_scenario.create_launch_job(
|
jobs_scenario.create_launch_job(
|
||||||
job_type="pig",
|
job_type="pig",
|
||||||
configs={"conf_key": "conf_val"},
|
configs={"conf_key": "conf_val"},
|
||||||
job_idx=0
|
job_idx=0
|
||||||
)
|
)
|
||||||
self.clients("sahara").jobs.create.assert_called_once_with(
|
self.clients("sahara").jobs.create.assert_called_once_with(
|
||||||
name=mock_generate_random_name.return_value,
|
name=jobs_scenario.generate_random_name.return_value,
|
||||||
type="pig",
|
type="pig",
|
||||||
description="",
|
description="",
|
||||||
mains=["main_42"],
|
mains=["main_42"],
|
||||||
@ -120,12 +115,8 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
job_idx=0
|
job_idx=0
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.generate_random_name",
|
|
||||||
return_value="job_42")
|
|
||||||
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
||||||
def test_create_launch_job_sequence(self, mock__run_job_execution,
|
def test_create_launch_job_sequence(self, mock__run_job_execution):
|
||||||
mock_generate_random_name):
|
|
||||||
|
|
||||||
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
||||||
id="42")
|
id="42")
|
||||||
|
|
||||||
@ -139,6 +130,8 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
jobs_scenario = jobs.SaharaJob(self.context)
|
jobs_scenario = jobs.SaharaJob(self.context)
|
||||||
|
jobs_scenario.generate_random_name = mock.Mock(return_value="job_42")
|
||||||
|
|
||||||
jobs_scenario.create_launch_job_sequence(
|
jobs_scenario.create_launch_job_sequence(
|
||||||
jobs=[
|
jobs=[
|
||||||
{
|
{
|
||||||
@ -150,7 +143,7 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
jobs_create_call = mock.call(
|
jobs_create_call = mock.call(
|
||||||
name=mock_generate_random_name.return_value,
|
name=jobs_scenario.generate_random_name.return_value,
|
||||||
type="java",
|
type="java",
|
||||||
description="",
|
description="",
|
||||||
mains=["main_42"],
|
mains=["main_42"],
|
||||||
@ -176,14 +169,11 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
job_idx=1)]
|
job_idx=1)]
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch("rally.common.utils.generate_random_name",
|
|
||||||
return_value="job_42")
|
|
||||||
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
@mock.patch(SAHARA_JOB + "._run_job_execution")
|
||||||
@mock.patch(SAHARA_JOB + "._scale_cluster")
|
@mock.patch(SAHARA_JOB + "._scale_cluster")
|
||||||
def test_create_launch_job_sequence_with_scaling(
|
def test_create_launch_job_sequence_with_scaling(self,
|
||||||
self, mock__scale_cluster, mock__run_job_execution,
|
mock__scale_cluster,
|
||||||
mock_generate_random_name):
|
mock__run_job_execution):
|
||||||
|
|
||||||
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
self.clients("sahara").jobs.create.return_value = mock.MagicMock(
|
||||||
id="42")
|
id="42")
|
||||||
self.clients("sahara").clusters.get.return_value = mock.MagicMock(
|
self.clients("sahara").clusters.get.return_value = mock.MagicMock(
|
||||||
@ -199,6 +189,8 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
jobs_scenario = jobs.SaharaJob(self.context)
|
jobs_scenario = jobs.SaharaJob(self.context)
|
||||||
|
jobs_scenario.generate_random_name = mock.Mock(return_value="job_42")
|
||||||
|
|
||||||
jobs_scenario.create_launch_job_sequence_with_scaling(
|
jobs_scenario.create_launch_job_sequence_with_scaling(
|
||||||
jobs=[
|
jobs=[
|
||||||
{
|
{
|
||||||
@ -211,7 +203,7 @@ class SaharaJobTestCase(test.ScenarioTestCase):
|
|||||||
deltas=[1, -1])
|
deltas=[1, -1])
|
||||||
|
|
||||||
jobs_create_call = mock.call(
|
jobs_create_call = mock.call(
|
||||||
name=mock_generate_random_name.return_value,
|
name=jobs_scenario.generate_random_name.return_value,
|
||||||
type="java",
|
type="java",
|
||||||
description="",
|
description="",
|
||||||
mains=["main_42"],
|
mains=["main_42"],
|
||||||
|
@ -55,12 +55,12 @@ class SaharaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"sahara.list_node_group_templates")
|
"sahara.list_node_group_templates")
|
||||||
|
|
||||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
@mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",
|
||||||
return_value="random_name")
|
return_value="random_name")
|
||||||
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
||||||
def test_create_node_group_templates(
|
def test_create_node_group_templates(
|
||||||
self, mock_sahara_consts,
|
self, mock_sahara_consts,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
|
|
||||||
scenario = utils.SaharaScenario(self.context)
|
scenario = utils.SaharaScenario(self.context)
|
||||||
mock_processes = {
|
mock_processes = {
|
||||||
@ -121,11 +121,11 @@ class SaharaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"sahara.delete_node_group_template")
|
"sahara.delete_node_group_template")
|
||||||
|
|
||||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
@mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",
|
||||||
return_value="random_name")
|
return_value="random_name")
|
||||||
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
||||||
def test_launch_cluster(self, mock_sahara_consts,
|
def test_launch_cluster(self, mock_sahara_consts,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
|
|
||||||
self.context.update({
|
self.context.update({
|
||||||
"tenant": {
|
"tenant": {
|
||||||
@ -226,11 +226,11 @@ class SaharaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"sahara.launch_cluster")
|
"sahara.launch_cluster")
|
||||||
|
|
||||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
@mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",
|
||||||
return_value="random_name")
|
return_value="random_name")
|
||||||
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
||||||
def test_launch_cluster_with_proxy(self, mock_sahara_consts,
|
def test_launch_cluster_with_proxy(self, mock_sahara_consts,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
"tenant": {
|
"tenant": {
|
||||||
@ -344,11 +344,11 @@ class SaharaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"sahara.launch_cluster")
|
"sahara.launch_cluster")
|
||||||
|
|
||||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
@mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",
|
||||||
return_value="random_name")
|
return_value="random_name")
|
||||||
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
@mock.patch(SAHARA_UTILS + ".sahara_consts")
|
||||||
def test_launch_cluster_error(self, mock_sahara_consts,
|
def test_launch_cluster_error(self, mock_sahara_consts,
|
||||||
mock__generate_random_name):
|
mock_generate_random_name):
|
||||||
|
|
||||||
scenario = utils.SaharaScenario(self.context)
|
scenario = utils.SaharaScenario(self.context)
|
||||||
mock_processes = {
|
mock_processes = {
|
||||||
@ -433,9 +433,9 @@ class SaharaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"sahara.delete_cluster")
|
"sahara.delete_cluster")
|
||||||
|
|
||||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
@mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",
|
||||||
return_value="42")
|
return_value="42")
|
||||||
def test_create_output_ds(self, mock__generate_random_name):
|
def test_create_output_ds(self, mock_generate_random_name):
|
||||||
self.context.update({
|
self.context.update({
|
||||||
"sahara_output_conf": {
|
"sahara_output_conf": {
|
||||||
"output_type": "hdfs",
|
"output_type": "hdfs",
|
||||||
@ -453,9 +453,9 @@ class SaharaScenarioTestCase(test.ScenarioTestCase):
|
|||||||
url="hdfs://test_out/42"
|
url="hdfs://test_out/42"
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch(SAHARA_UTILS + ".SaharaScenario._generate_random_name",
|
@mock.patch(SAHARA_UTILS + ".SaharaScenario.generate_random_name",
|
||||||
return_value="42")
|
return_value="42")
|
||||||
def test_create_output_ds_swift(self, mock__generate_random_name):
|
def test_create_output_ds_swift(self, mock_generate_random_name):
|
||||||
self.context.update({
|
self.context.update({
|
||||||
"sahara_output_conf": {
|
"sahara_output_conf": {
|
||||||
"output_type": "swift",
|
"output_type": "swift",
|
||||||
|
@ -88,7 +88,7 @@ class SwiftObjectsTestCase(test.ScenarioTestCase):
|
|||||||
names_list = ["AA", "BB", "CC", "DD"]
|
names_list = ["AA", "BB", "CC", "DD"]
|
||||||
|
|
||||||
scenario = objects.SwiftObjects(self.context)
|
scenario = objects.SwiftObjects(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(side_effect=names_list)
|
scenario.generate_random_name = mock.MagicMock(side_effect=names_list)
|
||||||
scenario._list_objects = mock.MagicMock()
|
scenario._list_objects = mock.MagicMock()
|
||||||
|
|
||||||
scenario.create_container_and_object_then_list_objects(
|
scenario.create_container_and_object_then_list_objects(
|
||||||
@ -104,7 +104,7 @@ class SwiftObjectsTestCase(test.ScenarioTestCase):
|
|||||||
names_list = ["111", "222", "333", "444", "555"]
|
names_list = ["111", "222", "333", "444", "555"]
|
||||||
|
|
||||||
scenario = objects.SwiftObjects(self.context)
|
scenario = objects.SwiftObjects(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(side_effect=names_list)
|
scenario.generate_random_name = mock.MagicMock(side_effect=names_list)
|
||||||
scenario._delete_object = mock.MagicMock()
|
scenario._delete_object = mock.MagicMock()
|
||||||
scenario._delete_container = mock.MagicMock()
|
scenario._delete_container = mock.MagicMock()
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ class SwiftObjectsTestCase(test.ScenarioTestCase):
|
|||||||
names_list = ["aaa", "bbb", "ccc", "ddd", "eee", "fff"]
|
names_list = ["aaa", "bbb", "ccc", "ddd", "eee", "fff"]
|
||||||
|
|
||||||
scenario = objects.SwiftObjects(self.context)
|
scenario = objects.SwiftObjects(self.context)
|
||||||
scenario._generate_random_name = mock.MagicMock(side_effect=names_list)
|
scenario.generate_random_name = mock.MagicMock(side_effect=names_list)
|
||||||
scenario._download_object = mock.MagicMock()
|
scenario._download_object = mock.MagicMock()
|
||||||
|
|
||||||
scenario.create_container_and_object_then_download_object(
|
scenario.create_container_and_object_then_download_object(
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import ddt
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.plugins.openstack.scenarios.swift import utils
|
from rally.plugins.openstack.scenarios.swift import utils
|
||||||
@ -38,62 +39,31 @@ class SwiftScenarioTestCase(test.ScenarioTestCase):
|
|||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"swift.list_containers")
|
"swift.list_containers")
|
||||||
|
|
||||||
def test__create_container(self):
|
@ddt.data(
|
||||||
container_name = mock.MagicMock()
|
{},
|
||||||
scenario = utils.SwiftScenario()
|
{"headers": {"X-fake-name": "fake-value"}},
|
||||||
|
{"public": False,
|
||||||
|
"headers": {"X-fake-name": "fake-value"}},
|
||||||
|
{"public": False})
|
||||||
|
@ddt.unpack
|
||||||
|
def test__create_container(self, public=True, kwargs=None, headers=None):
|
||||||
|
if kwargs is None:
|
||||||
|
kwargs = {"fakearg": "fake"}
|
||||||
|
if headers is None:
|
||||||
|
headers = {}
|
||||||
|
scenario = utils.SwiftScenario(self.context)
|
||||||
|
scenario.generate_random_name = mock.MagicMock()
|
||||||
|
|
||||||
# name + public=True + kw
|
container = scenario._create_container(public=public,
|
||||||
self.assertEqual(container_name,
|
headers=headers,
|
||||||
scenario._create_container(container_name,
|
**kwargs)
|
||||||
public=True, fargs="f"))
|
self.assertEqual(container,
|
||||||
kw = {"headers": {"X-Container-Read": ".r:*,.rlistings"}, "fargs": "f"}
|
scenario.generate_random_name.return_value)
|
||||||
|
kwargs["headers"] = headers
|
||||||
|
kwargs["headers"]["X-Container-Read"] = ".r:*,.rlistings"
|
||||||
self.clients("swift").put_container.assert_called_once_with(
|
self.clients("swift").put_container.assert_called_once_with(
|
||||||
container_name,
|
scenario.generate_random_name.return_value,
|
||||||
**kw)
|
**kwargs)
|
||||||
# name + public=True + additional header + kw
|
|
||||||
self.clients("swift").put_container.reset_mock()
|
|
||||||
self.assertEqual(container_name,
|
|
||||||
scenario._create_container(container_name,
|
|
||||||
public=True,
|
|
||||||
headers={"X-fake-name":
|
|
||||||
"fake-value"},
|
|
||||||
fargs="f"))
|
|
||||||
kw = {"headers": {"X-Container-Read": ".r:*,.rlistings",
|
|
||||||
"X-fake-name": "fake-value"}, "fargs": "f"}
|
|
||||||
self.clients("swift").put_container.assert_called_once_with(
|
|
||||||
container_name,
|
|
||||||
**kw)
|
|
||||||
# name + public=False + additional header + kw
|
|
||||||
self.clients("swift").put_container.reset_mock()
|
|
||||||
self.assertEqual(container_name,
|
|
||||||
scenario._create_container(container_name,
|
|
||||||
public=False,
|
|
||||||
headers={"X-fake-name":
|
|
||||||
"fake-value"},
|
|
||||||
fargs="f"))
|
|
||||||
kw = {"headers": {"X-fake-name": "fake-value"}, "fargs": "f"}
|
|
||||||
self.clients("swift").put_container.assert_called_once_with(
|
|
||||||
container_name,
|
|
||||||
**kw)
|
|
||||||
# name + kw
|
|
||||||
self.clients("swift").put_container.reset_mock()
|
|
||||||
self.assertEqual(container_name,
|
|
||||||
scenario._create_container(container_name, fargs="f"))
|
|
||||||
kw = {"fargs": "f"}
|
|
||||||
self.clients("swift").put_container.assert_called_once_with(
|
|
||||||
container_name,
|
|
||||||
**kw)
|
|
||||||
# kw
|
|
||||||
scenario._generate_random_name = mock.MagicMock(
|
|
||||||
return_value=container_name)
|
|
||||||
self.clients("swift").put_container.reset_mock()
|
|
||||||
self.assertEqual(container_name,
|
|
||||||
scenario._create_container(fargs="f"))
|
|
||||||
kw = {"fargs": "f"}
|
|
||||||
self.clients("swift").put_container.assert_called_once_with(
|
|
||||||
container_name,
|
|
||||||
**kw)
|
|
||||||
self.assertEqual(1, scenario._generate_random_name.call_count)
|
|
||||||
|
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"swift.create_container")
|
"swift.create_container")
|
||||||
@ -131,33 +101,21 @@ class SwiftScenarioTestCase(test.ScenarioTestCase):
|
|||||||
|
|
||||||
def test__upload_object(self):
|
def test__upload_object(self):
|
||||||
container_name = mock.MagicMock()
|
container_name = mock.MagicMock()
|
||||||
object_name = mock.MagicMock()
|
|
||||||
content = mock.MagicMock()
|
content = mock.MagicMock()
|
||||||
etag = mock.MagicMock()
|
etag = mock.MagicMock()
|
||||||
self.clients("swift").put_object.return_value = etag
|
self.clients("swift").put_object.return_value = etag
|
||||||
scenario = utils.SwiftScenario(self.context)
|
scenario = utils.SwiftScenario(self.context)
|
||||||
|
scenario.generate_random_name = mock.MagicMock()
|
||||||
|
|
||||||
# container + content + name + kw
|
|
||||||
self.assertEqual((etag, object_name),
|
|
||||||
scenario._upload_object(container_name, content,
|
|
||||||
object_name=object_name,
|
|
||||||
fargs="f"))
|
|
||||||
kw = {"fargs": "f"}
|
|
||||||
self.clients("swift").put_object.assert_called_once_with(
|
|
||||||
container_name, object_name,
|
|
||||||
content, **kw)
|
|
||||||
# container + content + kw
|
|
||||||
scenario._generate_random_name = mock.MagicMock(
|
|
||||||
return_value=object_name)
|
|
||||||
self.clients("swift").put_object.reset_mock()
|
self.clients("swift").put_object.reset_mock()
|
||||||
self.assertEqual((etag, object_name),
|
self.assertEqual((etag, scenario.generate_random_name.return_value),
|
||||||
scenario._upload_object(container_name, content,
|
scenario._upload_object(container_name, content,
|
||||||
fargs="f"))
|
fargs="f"))
|
||||||
kw = {"fargs": "f"}
|
kw = {"fargs": "f"}
|
||||||
self.clients("swift").put_object.assert_called_once_with(
|
self.clients("swift").put_object.assert_called_once_with(
|
||||||
container_name, object_name,
|
container_name, scenario.generate_random_name.return_value,
|
||||||
content, **kw)
|
content, **kw)
|
||||||
self.assertEqual(1, scenario._generate_random_name.call_count)
|
self.assertEqual(1, scenario.generate_random_name.call_count)
|
||||||
|
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"swift.upload_object")
|
"swift.upload_object")
|
||||||
|
@ -23,15 +23,15 @@ BASIC = BASE + "basic.ZaqarBasic."
|
|||||||
|
|
||||||
class ZaqarBasicTestCase(test.ScenarioTestCase):
|
class ZaqarBasicTestCase(test.ScenarioTestCase):
|
||||||
|
|
||||||
@mock.patch(BASIC + "_generate_random_name", return_value="fizbit")
|
@mock.patch(BASIC + "generate_random_name", return_value="fizbit")
|
||||||
def test_create_queue(self, mock__generate_random_name):
|
def test_create_queue(self, mock_generate_random_name):
|
||||||
scenario = basic.ZaqarBasic(self.context)
|
scenario = basic.ZaqarBasic(self.context)
|
||||||
scenario._queue_create = mock.MagicMock()
|
scenario._queue_create = mock.MagicMock()
|
||||||
scenario.create_queue(name_length=10)
|
scenario.create_queue(fakearg="fake")
|
||||||
scenario._queue_create.assert_called_once_with(name_length=10)
|
scenario._queue_create.assert_called_once_with(fakearg="fake")
|
||||||
|
|
||||||
@mock.patch(BASIC + "_generate_random_name", return_value="kitkat")
|
@mock.patch(BASIC + "generate_random_name", return_value="kitkat")
|
||||||
def test_producer_consumer(self, mock__generate_random_name):
|
def test_producer_consumer(self, mock_generate_random_name):
|
||||||
scenario = basic.ZaqarBasic(self.context)
|
scenario = basic.ZaqarBasic(self.context)
|
||||||
messages = [{"body": {"id": idx}, "ttl": 360} for idx
|
messages = [{"body": {"id": idx}, "ttl": 360} for idx
|
||||||
in range(20)]
|
in range(20)]
|
||||||
@ -42,10 +42,10 @@ class ZaqarBasicTestCase(test.ScenarioTestCase):
|
|||||||
scenario._messages_list = mock.MagicMock()
|
scenario._messages_list = mock.MagicMock()
|
||||||
scenario._queue_delete = mock.MagicMock()
|
scenario._queue_delete = mock.MagicMock()
|
||||||
|
|
||||||
scenario.producer_consumer(name_length=10, min_msg_count=20,
|
scenario.producer_consumer(min_msg_count=20, max_msg_count=20,
|
||||||
max_msg_count=20)
|
fakearg="fake")
|
||||||
|
|
||||||
scenario._queue_create.assert_called_once_with(name_length=10)
|
scenario._queue_create.assert_called_once_with(fakearg="fake")
|
||||||
scenario._messages_post.assert_called_once_with(queue, messages,
|
scenario._messages_post.assert_called_once_with(queue, messages,
|
||||||
20, 20)
|
20, 20)
|
||||||
scenario._messages_list.assert_called_once_with(queue)
|
scenario._messages_list.assert_called_once_with(queue)
|
||||||
|
@ -23,14 +23,15 @@ UTILS = "rally.plugins.openstack.scenarios.zaqar.utils."
|
|||||||
|
|
||||||
class ZaqarScenarioTestCase(test.ScenarioTestCase):
|
class ZaqarScenarioTestCase(test.ScenarioTestCase):
|
||||||
|
|
||||||
@mock.patch(UTILS + "ZaqarScenario._generate_random_name",
|
@mock.patch(UTILS + "ZaqarScenario.generate_random_name",
|
||||||
return_value="kitkat")
|
return_value="kitkat")
|
||||||
def test_queue_create(self, mock__generate_random_name):
|
def test_queue_create(self, mock_generate_random_name):
|
||||||
scenario = utils.ZaqarScenario(self.context)
|
scenario = utils.ZaqarScenario(self.context)
|
||||||
result = scenario._queue_create(name_length=10)
|
result = scenario._queue_create(fakearg="fakearg")
|
||||||
|
|
||||||
self.assertEqual(self.clients("zaqar").queue.return_value, result)
|
self.assertEqual(self.clients("zaqar").queue.return_value, result)
|
||||||
self.clients("zaqar").queue.assert_called_once_with("kitkat")
|
self.clients("zaqar").queue.assert_called_once_with("kitkat",
|
||||||
|
fakearg="fakearg")
|
||||||
self._test_atomic_action_timer(scenario.atomic_actions(),
|
self._test_atomic_action_timer(scenario.atomic_actions(),
|
||||||
"zaqar.create_queue")
|
"zaqar.create_queue")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user