Refactor rally plugin
This patch refactors rally plugin for senlin. Since the plugin for basic cluster and profile operations has been merged into rally repo, we can remove duplicated util functions and test scenarios from senlin repo. Related test jobs are also changed accordingly. Change-Id: Ic8ac5acac17bd013c25089a7db58d32ac0dfa5ba
This commit is contained in:
parent
e5a9c8065d
commit
82d390a7a8
@ -12,28 +12,17 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from rally.common import logging
|
||||
from rally import consts
|
||||
from rally import exceptions
|
||||
from rally.plugins.openstack import scenario
|
||||
from rally.plugins.openstack.scenarios.senlin import utils as senlin_utils
|
||||
from rally.task import atomic
|
||||
from rally.task import utils
|
||||
from rally.task import validation
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
SENLIN_BENCHMARK_OPTS = [
|
||||
cfg.FloatOpt("senlin_action_timeout",
|
||||
default=3600,
|
||||
help="Time in seconds to wait for senlin action to finish."),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
benchmark_group = cfg.OptGroup(name="benchmark", title="benchmark options")
|
||||
CONF.register_opts(SENLIN_BENCHMARK_OPTS, group=benchmark_group)
|
||||
|
||||
|
||||
class SenlinScenario(scenario.OpenStackScenario):
|
||||
class SenlinPlugin(senlin_utils.SenlinScenario):
|
||||
"""Base class for Senlin scenarios with basic atomic actions."""
|
||||
|
||||
@atomic.action_timer("senlin.get_action")
|
||||
@ -46,63 +35,6 @@ class SenlinScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
return self.admin_clients("senlin").get_action(action_id)
|
||||
|
||||
@atomic.action_timer("senlin.list_clusters")
|
||||
def _list_clusters(self):
|
||||
"""Return user cluster list."""
|
||||
|
||||
return list(self.admin_clients("senlin").clusters())
|
||||
|
||||
@atomic.action_timer("senlin.create_cluster")
|
||||
def _create_cluster(self, profile_id, desired_capacity=0, min_size=0,
|
||||
max_size=-1, timeout=None, metadata=None):
|
||||
"""Create a new cluster from attributes.
|
||||
|
||||
:param profile_id: ID of profile used to create cluster
|
||||
:param desired_capacity: The capacity or initial number of nodes
|
||||
owned by the cluster
|
||||
:param min_size: The minimum number of nodes owned by the cluster
|
||||
:param max_size: The maximum number of nodes owned by the cluster.
|
||||
-1 means no limit
|
||||
:param timeout: The timeout value in minutes for cluster creation
|
||||
:param metadata: A set of key value pairs to associate with the cluster
|
||||
|
||||
:returns: object of cluster created.
|
||||
"""
|
||||
attrs = {}
|
||||
attrs["profile_id"] = profile_id
|
||||
attrs["name"] = self.generate_random_name()
|
||||
attrs["desired_capacity"] = desired_capacity
|
||||
attrs["min_size"] = min_size
|
||||
attrs["max_size"] = max_size
|
||||
attrs["metadata"] = metadata
|
||||
if timeout:
|
||||
attrs["timeout"] = timeout
|
||||
|
||||
cluster = self.admin_clients("senlin").create_cluster(**attrs)
|
||||
cluster = utils.wait_for_status(
|
||||
cluster,
|
||||
ready_statuses=["ACTIVE"],
|
||||
failure_statuses=["ERROR"],
|
||||
update_resource=self._get_cluster,
|
||||
timeout=CONF.benchmark.senlin_action_timeout)
|
||||
|
||||
return cluster
|
||||
|
||||
@atomic.action_timer("senlin.get_cluster")
|
||||
def _get_cluster(self, cluster):
|
||||
"""Get cluster details.
|
||||
|
||||
:param cluster: cluster to get
|
||||
|
||||
:returns: object of cluster
|
||||
"""
|
||||
try:
|
||||
return self.admin_clients("senlin").get_cluster(cluster.id)
|
||||
except Exception as e:
|
||||
if getattr(e, "code", getattr(e, "http_status", 400)) == 404:
|
||||
raise exceptions.GetResourceNotFound(resource=cluster.id)
|
||||
raise exceptions.GetResourceFailure(resource=cluster.id, err=e)
|
||||
|
||||
@atomic.action_timer("senlin.resize_cluster")
|
||||
def _resize_cluster(self, cluster, adj_type=None, number=None,
|
||||
min_size=None, max_size=None, min_step=None,
|
||||
@ -147,93 +79,7 @@ class SenlinScenario(scenario.OpenStackScenario):
|
||||
ready_statuses=["SUCCEEDED"],
|
||||
failure_statuses=["FAILED"],
|
||||
update_resource=self._get_action,
|
||||
timeout=CONF.benchmark.senlin_action_timeout)
|
||||
|
||||
@atomic.action_timer("senlin.delete_cluster")
|
||||
def _delete_cluster(self, cluster):
|
||||
"""Delete given cluster.
|
||||
|
||||
Returns after the cluster is successfully deleted.
|
||||
|
||||
:param cluster: cluster object to delete
|
||||
"""
|
||||
cluster = self.admin_clients("senlin").delete_cluster(cluster)
|
||||
utils.wait_for_status(
|
||||
cluster,
|
||||
# FIXME(Yanyan Hu): ready_statuses is actually useless
|
||||
# for deleting Senlin cluster since cluster db item will
|
||||
# be removed once cluster is deleted successfully.
|
||||
ready_statuses=["DELETED"],
|
||||
failure_statuses=["ERROR"],
|
||||
check_deletion=True,
|
||||
update_resource=self._get_cluster,
|
||||
timeout=CONF.benchmark.senlin_action_timeout)
|
||||
|
||||
@atomic.action_timer("senlin.create_profile")
|
||||
def _create_profile(self, spec, metadata=None):
|
||||
"""Create a new profile from attributes.
|
||||
|
||||
:param spec: spec dictionary used to create profile
|
||||
:param metadata: A set of key value pairs to associate with the
|
||||
profile
|
||||
|
||||
:returns: object of profile created
|
||||
"""
|
||||
attrs = {}
|
||||
attrs["spec"] = spec
|
||||
attrs["name"] = self.generate_random_name()
|
||||
if metadata:
|
||||
attrs["metadata"] = metadata
|
||||
|
||||
return self.admin_clients("senlin").create_profile(**attrs)
|
||||
|
||||
@atomic.action_timer("senlin.get_profile")
|
||||
def _get_profile(self, profile_id):
|
||||
"""Get profile details.
|
||||
|
||||
:param profile_id: ID of profile to get
|
||||
|
||||
:returns: object of profile
|
||||
"""
|
||||
return self.admin_clients("senlin").get_profile(profile_id)
|
||||
|
||||
@atomic.action_timer("senlin.delete_profile")
|
||||
def _delete_profile(self, profile):
|
||||
"""Delete given profile.
|
||||
|
||||
Returns after the profile is successfully deleted.
|
||||
|
||||
:param profile: profile object to be deleted
|
||||
"""
|
||||
self.admin_clients("senlin").delete_profile(profile)
|
||||
|
||||
@validation.required_openstack(admin=True)
|
||||
@validation.required_services(consts.Service.SENLIN)
|
||||
@scenario.configure(context={"cleanup": ["senlin"]})
|
||||
def create_and_delete_profile_cluster(self, profile_spec,
|
||||
desired_capacity=0, min_size=0,
|
||||
max_size=-1, timeout=3600,
|
||||
metadata=None):
|
||||
"""Create a profile and a cluster and then delete them.
|
||||
|
||||
Measure the "senlin profile-create", "senlin profile-delete",
|
||||
"senlin cluster-create" and "senlin cluster-delete" commands
|
||||
performance.
|
||||
|
||||
:param profile_spec: spec dictionary used to create profile
|
||||
:param desired_capacity: The capacity or initial number of nodes
|
||||
owned by the cluster
|
||||
:param min_size: The minimum number of nodes owned by the cluster
|
||||
:param max_size: The maximum number of nodes owned by the cluster.
|
||||
-1 means no limit
|
||||
:param timeout: The timeout value in seconds for cluster creation
|
||||
:param metadata: A set of key value pairs to associate with the cluster
|
||||
"""
|
||||
profile = self._create_profile(profile_spec)
|
||||
cluster = self._create_cluster(profile.id, desired_capacity,
|
||||
min_size, max_size, timeout, metadata)
|
||||
self._delete_cluster(cluster)
|
||||
self._delete_profile(profile)
|
||||
timeout=senlin_utils.CONF.benchmark.senlin_action_timeout)
|
||||
|
||||
@validation.required_openstack(admin=True)
|
||||
@validation.required_services(consts.Service.SENLIN)
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
|
||||
SenlinScenario.create_and_delete_profile_cluster:
|
||||
SenlinClusters.create_and_delete_profile_cluster:
|
||||
-
|
||||
args:
|
||||
profile_spec:
|
||||
@ -12,22 +12,22 @@
|
||||
image: cirros-0.3.4-x86_64-uec
|
||||
networks:
|
||||
- network: private
|
||||
desired_capacity: 2
|
||||
desired_capacity: 3
|
||||
min_size: 0
|
||||
max_size: 3
|
||||
max_size: 5
|
||||
runner:
|
||||
type: constant
|
||||
times: 2
|
||||
type: "constant"
|
||||
times: 3
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
SenlinScenario.create_resize_delete_cluster:
|
||||
SenlinPlugin.create_resize_delete_cluster:
|
||||
-
|
||||
args:
|
||||
profile_spec:
|
||||
@ -51,12 +51,12 @@
|
||||
strict: false
|
||||
runner:
|
||||
type: constant
|
||||
times: 2
|
||||
times: 3
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
Loading…
Reference in New Issue
Block a user