Merge "New optional_action_timer decorator"
This commit is contained in:
commit
27940131df
@ -49,13 +49,16 @@ class DesignateScenario(scenario.OpenStackScenario):
|
|||||||
"""
|
"""
|
||||||
self.clients("designate").domains.delete(domain_id)
|
self.clients("designate").domains.delete(domain_id)
|
||||||
|
|
||||||
def _create_record(self, domain, record=None, atomic_action=True):
|
@atomic.optional_action_timer("designate.create_record")
|
||||||
|
def _create_record(self, domain, record=None):
|
||||||
"""Create a record in a domain.
|
"""Create a record in a domain.
|
||||||
|
|
||||||
:param domain: domain dict
|
:param domain: domain dict
|
||||||
:param record: record dict
|
:param record: record dict
|
||||||
:param atomic_action: True if the record creation should be tracked
|
:param atomic_action: True if the record creation should be
|
||||||
as an atomic action
|
tracked as an atomic action. added and
|
||||||
|
handled by the optional_action_timer()
|
||||||
|
decorator
|
||||||
:returns: Designate record dict
|
:returns: Designate record dict
|
||||||
"""
|
"""
|
||||||
record = record or {}
|
record = record or {}
|
||||||
@ -66,10 +69,6 @@ class DesignateScenario(scenario.OpenStackScenario):
|
|||||||
|
|
||||||
client = self.clients("designate")
|
client = self.clients("designate")
|
||||||
|
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "designate.create_record"):
|
|
||||||
return client.records.create(domain["id"], record)
|
|
||||||
|
|
||||||
return client.records.create(domain["id"], record)
|
return client.records.create(domain["id"], record)
|
||||||
|
|
||||||
@atomic.action_timer("designate.list_records")
|
@atomic.action_timer("designate.list_records")
|
||||||
@ -81,21 +80,18 @@ class DesignateScenario(scenario.OpenStackScenario):
|
|||||||
"""
|
"""
|
||||||
return self.clients("designate").records.list(domain_id)
|
return self.clients("designate").records.list(domain_id)
|
||||||
|
|
||||||
def _delete_record(self, domain_id, record_id, atomic_action=True):
|
@atomic.optional_action_timer("designate.delete_record")
|
||||||
|
def _delete_record(self, domain_id, record_id):
|
||||||
"""Delete a domain record.
|
"""Delete a domain record.
|
||||||
|
|
||||||
:param domain_id: domain ID
|
:param domain_id: domain ID
|
||||||
:param record_id: record ID
|
:param record_id: record ID
|
||||||
:param atomic_action: True if the record creation should be tracked
|
:param atomic_action: True if the record creation should be
|
||||||
as an atomic action
|
tracked as an atomic action. added and
|
||||||
|
handled by the optional_action_timer()
|
||||||
|
decorator
|
||||||
"""
|
"""
|
||||||
client = self.clients("designate")
|
self.clients("designate").records.delete(domain_id, record_id)
|
||||||
|
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "designate.delete_record"):
|
|
||||||
client.records.delete(domain_id, record_id)
|
|
||||||
else:
|
|
||||||
client.records.delete(domain_id, record_id)
|
|
||||||
|
|
||||||
@atomic.action_timer("designate.create_server")
|
@atomic.action_timer("designate.create_server")
|
||||||
def _create_server(self, server=None):
|
def _create_server(self, server=None):
|
||||||
|
@ -97,9 +97,9 @@ class MuranoScenario(scenario.OpenStackScenario):
|
|||||||
"""
|
"""
|
||||||
return self.clients("murano").sessions.configure(environment_id)
|
return self.clients("murano").sessions.configure(environment_id)
|
||||||
|
|
||||||
|
@atomic.optional_action_timer("murano.create_service")
|
||||||
def _create_service(self, environment, session, full_package_name,
|
def _create_service(self, environment, session, full_package_name,
|
||||||
image_name=None, flavor_name=None,
|
image_name=None, flavor_name=None):
|
||||||
atomic_action=True):
|
|
||||||
"""Create Murano service.
|
"""Create Murano service.
|
||||||
|
|
||||||
:param environment: Environment instance
|
:param environment: Environment instance
|
||||||
@ -107,7 +107,9 @@ class MuranoScenario(scenario.OpenStackScenario):
|
|||||||
:param full_package_name: full name of the Murano package
|
:param full_package_name: full name of the Murano package
|
||||||
:param image_name: Image name
|
:param image_name: Image name
|
||||||
:param flavor_name: Flavor name
|
:param flavor_name: Flavor name
|
||||||
:param atomic_action: True if this is atomic action
|
:param atomic_action: True if this is atomic action. added and
|
||||||
|
handled by the optional_action_timer()
|
||||||
|
decorator
|
||||||
:returns: Service instance
|
:returns: Service instance
|
||||||
"""
|
"""
|
||||||
app_id = str(uuid.uuid4())
|
app_id = str(uuid.uuid4())
|
||||||
@ -115,12 +117,6 @@ class MuranoScenario(scenario.OpenStackScenario):
|
|||||||
"type": full_package_name},
|
"type": full_package_name},
|
||||||
"name": self._generate_random_name("rally_")}
|
"name": self._generate_random_name("rally_")}
|
||||||
|
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "murano.create_service"):
|
|
||||||
return self.clients("murano").services.post(
|
|
||||||
environment_id=environment.id, path="/", data=data,
|
|
||||||
session_id=session.id)
|
|
||||||
else:
|
|
||||||
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,
|
||||||
session_id=session.id)
|
session_id=session.id)
|
||||||
|
@ -93,16 +93,15 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
return self.clients("neutron").create_network(
|
return self.clients("neutron").create_network(
|
||||||
{"network": network_create_args})
|
{"network": network_create_args})
|
||||||
|
|
||||||
def _list_networks(self, atomic_action=True, **kwargs):
|
@atomic.optional_action_timer("neutron.list_networks")
|
||||||
|
def _list_networks(self, **kwargs):
|
||||||
"""Return user networks list.
|
"""Return user networks list.
|
||||||
|
|
||||||
:param atomic_action: True if this is an atomic action
|
:param atomic_action: True if this is an atomic action. added
|
||||||
|
and handled by the
|
||||||
|
optional_action_timer() decorator
|
||||||
:param kwargs: network list options
|
:param kwargs: network list options
|
||||||
"""
|
"""
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "neutron.list_networks"):
|
|
||||||
return self.clients("neutron").list_networks(
|
|
||||||
**kwargs)["networks"]
|
|
||||||
return self.clients("neutron").list_networks(**kwargs)["networks"]
|
return self.clients("neutron").list_networks(**kwargs)["networks"]
|
||||||
|
|
||||||
@atomic.action_timer("neutron.update_network")
|
@atomic.action_timer("neutron.update_network")
|
||||||
@ -311,13 +310,15 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
self.clients("neutron").remove_interface_router(
|
self.clients("neutron").remove_interface_router(
|
||||||
router["id"], {"subnet_id": subnet["id"]})
|
router["id"], {"subnet_id": subnet["id"]})
|
||||||
|
|
||||||
def _create_lb_pool(self, subnet_id, atomic_action=True,
|
@atomic.optional_action_timer("neutron.create_pool")
|
||||||
**pool_create_args):
|
def _create_lb_pool(self, subnet_id, **pool_create_args):
|
||||||
"""Create LB pool(v1)
|
"""Create LB pool(v1)
|
||||||
|
|
||||||
:param subnet_id: str, neutron subnet-id
|
:param subnet_id: str, neutron subnet-id
|
||||||
:param pool_create_args: dict, POST /lb/pools request options
|
:param pool_create_args: dict, POST /lb/pools request options
|
||||||
:param atomic_action: True if this is an atomic action
|
:param atomic_action: True if this is an atomic action. added
|
||||||
|
and handled by the
|
||||||
|
optional_action_timer() decorator
|
||||||
:returns: dict, neutron lb pool
|
:returns: dict, neutron lb pool
|
||||||
"""
|
"""
|
||||||
args = {"lb_method": self.LB_METHOD,
|
args = {"lb_method": self.LB_METHOD,
|
||||||
@ -325,9 +326,6 @@ class NeutronScenario(scenario.OpenStackScenario):
|
|||||||
"name": self._generate_random_name("rally_pool_"),
|
"name": self._generate_random_name("rally_pool_"),
|
||||||
"subnet_id": subnet_id}
|
"subnet_id": subnet_id}
|
||||||
args.update(pool_create_args)
|
args.update(pool_create_args)
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "neutron.create_pool"):
|
|
||||||
return self.clients("neutron").create_pool({"pool": args})
|
|
||||||
return self.clients("neutron").create_pool({"pool": args})
|
return self.clients("neutron").create_pool({"pool": args})
|
||||||
|
|
||||||
def _create_v1_pools(self, networks, **pool_create_args):
|
def _create_v1_pools(self, networks, **pool_create_args):
|
||||||
|
@ -32,14 +32,16 @@ class SwiftScenario(scenario.OpenStackScenario):
|
|||||||
return self.clients("swift").get_account(full_listing=full_listing,
|
return self.clients("swift").get_account(full_listing=full_listing,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
def _create_container(self, container_name=None, public=False,
|
@atomic.optional_action_timer("swift.create_container")
|
||||||
atomic_action=True, **kwargs):
|
def _create_container(self, container_name=None, public=False, **kwargs):
|
||||||
"""Create a new container with given name.
|
"""Create a new container with given name.
|
||||||
|
|
||||||
:param container_name: str, name of the container to create
|
: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 tracked as an
|
:param atomic_action: bool, enable create container to be
|
||||||
atomic action
|
tracked as an atomic action. added and
|
||||||
|
handled by the optional_action_timer()
|
||||||
|
decorator
|
||||||
:param kwargs: dict, other optional parameters to put_container
|
:param kwargs: dict, other optional parameters to put_container
|
||||||
|
|
||||||
:returns: container name
|
:returns: container name
|
||||||
@ -52,60 +54,51 @@ class SwiftScenario(scenario.OpenStackScenario):
|
|||||||
container_name = self._generate_random_name(
|
container_name = self._generate_random_name(
|
||||||
prefix="rally_container_")
|
prefix="rally_container_")
|
||||||
|
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "swift.create_container"):
|
|
||||||
self.clients("swift").put_container(container_name, **kwargs)
|
|
||||||
else:
|
|
||||||
self.clients("swift").put_container(container_name, **kwargs)
|
self.clients("swift").put_container(container_name, **kwargs)
|
||||||
return container_name
|
return container_name
|
||||||
|
|
||||||
def _delete_container(self, container_name, atomic_action=True, **kwargs):
|
@atomic.optional_action_timer("swift.delete_container")
|
||||||
|
def _delete_container(self, container_name, **kwargs):
|
||||||
"""Delete a container with given name.
|
"""Delete a container with given name.
|
||||||
|
|
||||||
:param container_name: str, name of the container to delete
|
:param container_name: str, name of the container to delete
|
||||||
:param atomic_action: bool, enable delete container to be tracked as an
|
:param atomic_action: bool, enable delete container to be
|
||||||
atomic action
|
tracked as an atomic action. added and
|
||||||
|
handled by the optional_action_timer()
|
||||||
|
decorator
|
||||||
:param kwargs: dict, other optional parameters to delete_container
|
:param kwargs: dict, other optional parameters to delete_container
|
||||||
"""
|
"""
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "swift.delete_container"):
|
|
||||||
self.clients("swift").delete_container(container_name,
|
|
||||||
**kwargs)
|
|
||||||
else:
|
|
||||||
self.clients("swift").delete_container(container_name, **kwargs)
|
self.clients("swift").delete_container(container_name, **kwargs)
|
||||||
|
|
||||||
def _list_objects(self, container_name, full_listing=True,
|
@atomic.optional_action_timer("swift.list_objects")
|
||||||
atomic_action=True, **kwargs):
|
def _list_objects(self, container_name, full_listing=True, **kwargs):
|
||||||
"""Return objects inside container.
|
"""Return objects inside container.
|
||||||
|
|
||||||
:param container_name: str, name of the container to make the list
|
:param container_name: str, name of the container to make the list
|
||||||
objects operation against
|
objects operation against
|
||||||
:param full_listing: bool, enable unlimit number of listing returned
|
:param full_listing: bool, enable unlimit number of listing returned
|
||||||
:param atomic_action: bool, enable list objects to be tracked as an
|
:param atomic_action: bool, enable list objects to be tracked
|
||||||
atomic action
|
as an atomic action. added and handled
|
||||||
|
by the optional_action_timer() decorator
|
||||||
:param kwargs: dict, other optional parameters to get_container
|
:param kwargs: dict, other optional parameters to get_container
|
||||||
|
|
||||||
:returns: tuple, (dict of response headers, a list of objects)
|
:returns: tuple, (dict of response headers, a list of objects)
|
||||||
"""
|
"""
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "swift.list_objects"):
|
|
||||||
return self.clients("swift").get_container(
|
|
||||||
container_name, full_listing=full_listing,
|
|
||||||
**kwargs)
|
|
||||||
|
|
||||||
return self.clients("swift").get_container(container_name,
|
return self.clients("swift").get_container(container_name,
|
||||||
full_listing=full_listing,
|
full_listing=full_listing,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
|
@atomic.optional_action_timer("swift.upload_object")
|
||||||
def _upload_object(self, container_name, content, object_name=None,
|
def _upload_object(self, container_name, content, object_name=None,
|
||||||
atomic_action=True, **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 object_name: str, name of the object to upload
|
||||||
:param atomic_action: bool, enable upload object to be tracked as an
|
:param atomic_action: bool, enable upload object to be tracked
|
||||||
atomic action
|
as an atomic action. added and handled
|
||||||
|
by the optional_action_timer() decorator
|
||||||
:param kwargs: dict, other optional parameters to put_object
|
:param kwargs: dict, other optional parameters to put_object
|
||||||
|
|
||||||
:returns: tuple, (etag and object name)
|
:returns: tuple, (etag and object name)
|
||||||
@ -113,52 +106,38 @@ class SwiftScenario(scenario.OpenStackScenario):
|
|||||||
if object_name is None:
|
if object_name is None:
|
||||||
object_name = self._generate_random_name(prefix="rally_object_")
|
object_name = self._generate_random_name(prefix="rally_object_")
|
||||||
|
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "swift.upload_object"):
|
|
||||||
return (self.clients("swift").put_object(container_name,
|
|
||||||
object_name, content,
|
|
||||||
**kwargs),
|
|
||||||
object_name)
|
|
||||||
|
|
||||||
return (self.clients("swift").put_object(container_name, object_name,
|
return (self.clients("swift").put_object(container_name, object_name,
|
||||||
content, **kwargs),
|
content, **kwargs),
|
||||||
object_name)
|
object_name)
|
||||||
|
|
||||||
def _download_object(self, container_name, object_name, atomic_action=True,
|
@atomic.optional_action_timer("swift.download_object")
|
||||||
**kwargs):
|
def _download_object(self, container_name, object_name, **kwargs):
|
||||||
"""Download object from container.
|
"""Download object from container.
|
||||||
|
|
||||||
:param container_name: str, name of the container to download object
|
:param container_name: str, name of the container to download object
|
||||||
from
|
from
|
||||||
:param object_name: str, name of the object to download
|
:param object_name: str, name of the object to download
|
||||||
:param atomic_action: bool, enable download object to be tracked as an
|
:param atomic_action: bool, enable download object to be
|
||||||
atomic action
|
tracked as an atomic action. added and
|
||||||
|
handled by the optional_action_timer()
|
||||||
|
decorator
|
||||||
:param kwargs: dict, other optional parameters to get_object
|
:param kwargs: dict, other optional parameters to get_object
|
||||||
|
|
||||||
:returns: tuple, (dict of response headers, the object's contents)
|
:returns: tuple, (dict of response headers, the object's contents)
|
||||||
"""
|
"""
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "swift.download_object"):
|
|
||||||
return self.clients("swift").get_object(container_name,
|
|
||||||
object_name, **kwargs)
|
|
||||||
|
|
||||||
return self.clients("swift").get_object(container_name, object_name,
|
return self.clients("swift").get_object(container_name, object_name,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
def _delete_object(self, container_name, object_name, atomic_action=True,
|
@atomic.optional_action_timer("swift.delete_object")
|
||||||
**kwargs):
|
def _delete_object(self, container_name, object_name, **kwargs):
|
||||||
"""Delete object from container.
|
"""Delete object from container.
|
||||||
|
|
||||||
:param container_name: str, name of the container to delete object from
|
:param container_name: str, name of the container to delete object from
|
||||||
:param object_name: str, name of the object to delete
|
:param object_name: str, name of the object to delete
|
||||||
:param atomic_action: bool, enable delete object to be tracked as an
|
:param atomic_action: bool, enable delete object to be tracked
|
||||||
atomic action
|
as an atomic action. added and handled
|
||||||
|
by the optional_action_timer() decorator
|
||||||
:param kwargs: dict, other optional parameters to delete_object
|
:param kwargs: dict, other optional parameters to delete_object
|
||||||
"""
|
"""
|
||||||
if atomic_action:
|
|
||||||
with atomic.ActionTimer(self, "swift.delete_object"):
|
|
||||||
self.clients("swift").delete_object(container_name,
|
|
||||||
object_name, **kwargs)
|
|
||||||
else:
|
|
||||||
self.clients("swift").delete_object(container_name, object_name,
|
self.clients("swift").delete_object(container_name, object_name,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user