[magnum] Rename to cluster and cluster_template
Magnum renamed baymodels and bays to cluster_templates and clusters respectively [1]. [1] https://blueprints.launchpad.net/magnum/+spec/rename-bay-to-cluster Change-Id: I4390406d45a705cf93f8eb6522ebe4a65e468d2c Partially-Implements: blueprint benchmark-scenarios-for-magnum
This commit is contained in:
parent
7e22b0e15c
commit
316a14c633
@ -240,15 +240,15 @@
|
||||
|
||||
# Time(in sec) to sleep after creating a resource before polling for
|
||||
# the status. (floating point value)
|
||||
#magnum_bay_create_prepoll_delay = 5.0
|
||||
#magnum_cluster_create_prepoll_delay = 5.0
|
||||
|
||||
# Time(in sec) to wait for magnum bay to be created. (floating point
|
||||
# Time(in sec) to wait for magnum cluster to be created. (floating point
|
||||
# value)
|
||||
#magnum_bay_create_timeout = 1200.0
|
||||
#magnum_cluster_create_timeout = 1200.0
|
||||
|
||||
# Time interval(in sec) between checks when waiting for bay creation.
|
||||
# Time interval(in sec) between checks when waiting for cluster creation.
|
||||
# (floating point value)
|
||||
#magnum_bay_create_poll_interval = 1.0
|
||||
#magnum_cluster_create_poll_interval = 1.0
|
||||
|
||||
# Delay between creating Manila share and polling for its status.
|
||||
# (floating point value)
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
MagnumBaymodels.list_baymodels:
|
||||
MagnumClusterTemplates.list_cluster_templates:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
@ -9,7 +9,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "fedora-atomic-latest"
|
||||
flavor_id: "m1.small"
|
||||
master_flavor_id: "m1.small"
|
||||
@ -33,7 +33,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "fedora-atomic-latest"
|
||||
flavor_id: "m1.small"
|
||||
master_flavor_id: "m1.small"
|
||||
@ -48,7 +48,7 @@
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
MagnumBays.create_and_list_bays:
|
||||
MagnumClusters.create_and_list_clusters:
|
||||
-
|
||||
args:
|
||||
node_count: 1
|
||||
@ -60,7 +60,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "fedora-atomic-latest"
|
||||
flavor_id: "m1.small"
|
||||
master_flavor_id: "m1.small"
|
||||
|
@ -90,16 +90,16 @@ class MagnumMixin(base.ResourceManager):
|
||||
return result
|
||||
|
||||
|
||||
@base.resource("magnum", "bays", order=next(_magnum_order),
|
||||
@base.resource("magnum", "clusters", order=next(_magnum_order),
|
||||
tenant_resource=True)
|
||||
class MagnumBay(MagnumMixin):
|
||||
"""Resource class for Magnum bay."""
|
||||
class MagnumCluster(MagnumMixin):
|
||||
"""Resource class for Magnum cluster."""
|
||||
|
||||
|
||||
@base.resource("magnum", "baymodels", order=next(_magnum_order),
|
||||
@base.resource("magnum", "cluster_templates", order=next(_magnum_order),
|
||||
tenant_resource=True)
|
||||
class MagnumBaymodel(MagnumMixin):
|
||||
"""Resource class for Magnum baymodel."""
|
||||
class MagnumClusterTemplate(MagnumMixin):
|
||||
"""Resource class for Magnum cluster_template."""
|
||||
|
||||
|
||||
# HEAT
|
||||
|
@ -25,9 +25,9 @@ from rally.task import context
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@context.configure(name="baymodels", order=470)
|
||||
class BaymodelGenerator(context.Context):
|
||||
"""Context class for generating temporary bay model for benchmarks."""
|
||||
@context.configure(name="cluster_templates", order=470)
|
||||
class ClusterTemplateGenerator(context.Context):
|
||||
"""Context class for generating temporary cluster model for benchmarks."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
"type": "object",
|
||||
@ -101,7 +101,7 @@ class BaymodelGenerator(context.Context):
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
@logging.log_task_wrapper(LOG.info, _("Enter context: `Baymodel`"))
|
||||
@logging.log_task_wrapper(LOG.info, _("Enter context: `ClusterTemplate`"))
|
||||
def setup(self):
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
@ -121,13 +121,14 @@ class BaymodelGenerator(context.Context):
|
||||
"api_versions", [])}
|
||||
})
|
||||
|
||||
baymodel = magnum_scenario._create_baymodel(
|
||||
cluster_template = magnum_scenario._create_cluster_template(
|
||||
keypair_id=keypair, **self.config)
|
||||
|
||||
self.context["tenants"][tenant_id]["baymodel"] = baymodel.uuid
|
||||
ct_uuid = cluster_template.uuid
|
||||
self.context["tenants"][tenant_id]["cluster_template"] = ct_uuid
|
||||
|
||||
@logging.log_task_wrapper(LOG.info, _("Exit context: `Baymodel`"))
|
||||
@logging.log_task_wrapper(LOG.info, _("Exit context: `ClusterTemplate`"))
|
||||
def cleanup(self):
|
||||
resource_manager.cleanup(
|
||||
names=["magnum.baymodels", "nova.keypairs"],
|
||||
names=["magnum.cluster_templates", "nova.keypairs"],
|
||||
users=self.context.get("users", []))
|
@ -24,15 +24,15 @@ from rally.task import context
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@context.configure(name="bays", order=480)
|
||||
class BayGenerator(context.Context):
|
||||
"""Context class for generating temporary bay for benchmarks."""
|
||||
@context.configure(name="clusters", order=480)
|
||||
class ClusterGenerator(context.Context):
|
||||
"""Context class for generating temporary cluster for benchmarks."""
|
||||
|
||||
CONFIG_SCHEMA = {
|
||||
"type": "object",
|
||||
"$schema": consts.JSON_SCHEMA,
|
||||
"properties": {
|
||||
"baymodel_uuid": {
|
||||
"cluster_template_uuid": {
|
||||
"type": "string"
|
||||
},
|
||||
"node_count": {
|
||||
@ -44,7 +44,7 @@ class BayGenerator(context.Context):
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
@logging.log_task_wrapper(LOG.info, _("Enter context: `Bay`"))
|
||||
@logging.log_task_wrapper(LOG.info, _("Enter context: `Cluster`"))
|
||||
def setup(self):
|
||||
for user, tenant_id in rutils.iterate_per_tenants(
|
||||
self.context["users"]):
|
||||
@ -56,18 +56,18 @@ class BayGenerator(context.Context):
|
||||
"api_versions", [])}
|
||||
})
|
||||
|
||||
# create a bay
|
||||
baymodel_uuid = self.config.get("baymodel_uuid", None)
|
||||
if baymodel_uuid is None:
|
||||
# create a cluster
|
||||
ct_uuid = self.config.get("cluster_template_uuid", None)
|
||||
if ct_uuid is None:
|
||||
ctx = self.context["tenants"][tenant_id]
|
||||
baymodel_uuid = ctx.get("baymodel")
|
||||
bay = magnum_scenario._create_bay(
|
||||
baymodel=baymodel_uuid,
|
||||
ct_uuid = ctx.get("cluster_template")
|
||||
cluster = magnum_scenario._create_cluster(
|
||||
cluster_template=ct_uuid,
|
||||
node_count=self.config.get("node_count"))
|
||||
self.context["tenants"][tenant_id]["bay"] = bay.uuid
|
||||
self.context["tenants"][tenant_id]["cluster"] = cluster.uuid
|
||||
|
||||
@logging.log_task_wrapper(LOG.info, _("Exit context: `Bay`"))
|
||||
@logging.log_task_wrapper(LOG.info, _("Exit context: `Cluster`"))
|
||||
def cleanup(self):
|
||||
resource_manager.cleanup(
|
||||
names=["magnum.bays"],
|
||||
names=["magnum.clusters"],
|
||||
users=self.context.get("users", []))
|
@ -18,27 +18,28 @@ from rally.plugins.openstack.scenarios.magnum import utils
|
||||
from rally.task import validation
|
||||
|
||||
|
||||
"""Scenarios for Magnum baymodels."""
|
||||
"""Scenarios for Magnum cluster_templates."""
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.MAGNUM)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["magnum"]},
|
||||
name="MagnumBaymodels.list_baymodels")
|
||||
class ListBaymodels(utils.MagnumScenario):
|
||||
name="MagnumClusterTemplates.list_cluster_templates")
|
||||
class ListClusterTemplates(utils.MagnumScenario):
|
||||
|
||||
def run(self, **kwargs):
|
||||
"""List all baymodels.
|
||||
"""List all cluster_templates.
|
||||
|
||||
Measure the "magnum baymodel-list" command performance.
|
||||
Measure the "magnum cluster_template-list" command performance.
|
||||
|
||||
:param limit: (Optional) The maximum number of results to return
|
||||
per request, if:
|
||||
|
||||
1) limit > 0, the maximum number of baymodels to return.
|
||||
1) limit > 0, the maximum number of cluster_templates to return.
|
||||
2) limit param is NOT specified (None), the number of items
|
||||
returned respect the maximum imposed by the Magnum API
|
||||
(see Magnum's api.max_limit option).
|
||||
:param kwargs: optional additional arguments for baymodels listing
|
||||
:param kwargs: optional additional arguments for cluster_templates
|
||||
listing
|
||||
"""
|
||||
self._list_baymodels(**kwargs)
|
||||
self._list_cluster_templates(**kwargs)
|
@ -17,49 +17,49 @@ from rally.plugins.openstack import scenario
|
||||
from rally.plugins.openstack.scenarios.magnum import utils
|
||||
from rally.task import validation
|
||||
|
||||
"""Scenarios for Magnum bays."""
|
||||
"""Scenarios for Magnum clusters."""
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.MAGNUM)
|
||||
@validation.required_openstack(users=True)
|
||||
@scenario.configure(context={"cleanup": ["magnum.bays"]},
|
||||
name="MagnumBays.list_bays")
|
||||
class ListBays(utils.MagnumScenario):
|
||||
@scenario.configure(context={"cleanup": ["magnum.clusters"]},
|
||||
name="MagnumClusters.list_clusters")
|
||||
class ListClusters(utils.MagnumScenario):
|
||||
|
||||
def run(self, **kwargs):
|
||||
"""List all bays.
|
||||
"""List all clusters.
|
||||
|
||||
Measure the "magnum bays-list" command performance.
|
||||
Measure the "magnum clusters-list" command performance.
|
||||
:param limit: (Optional) The maximum number of results to return
|
||||
per request, if:
|
||||
|
||||
1) limit > 0, the maximum number of bays to return.
|
||||
1) limit > 0, the maximum number of clusters to return.
|
||||
2) limit param is NOT specified (None), the number of items
|
||||
returned respect the maximum imposed by the Magnum API
|
||||
(see Magnum's api.max_limit option).
|
||||
|
||||
:param kwargs: optional additional arguments for bays listing
|
||||
:param kwargs: optional additional arguments for clusters listing
|
||||
"""
|
||||
self._list_bays(**kwargs)
|
||||
self._list_clusters(**kwargs)
|
||||
|
||||
|
||||
@validation.required_services(consts.Service.MAGNUM)
|
||||
@validation.required_openstack(users=True)
|
||||
@validation.required_contexts("baymodels")
|
||||
@scenario.configure(context={"cleanup": ["magnum.bays"]},
|
||||
name="MagnumBays.create_and_list_bays")
|
||||
class CreateAndListBays(utils.MagnumScenario):
|
||||
@validation.required_contexts("cluster_templates")
|
||||
@scenario.configure(context={"cleanup": ["magnum.clusters"]},
|
||||
name="MagnumClusters.create_and_list_clusters")
|
||||
class CreateAndListClusters(utils.MagnumScenario):
|
||||
|
||||
def run(self, node_count, **kwargs):
|
||||
"""create bay and then list all bays.
|
||||
"""create cluster and then list all clusters.
|
||||
|
||||
:param node_count: the bay node count.
|
||||
:param baymodel_uuid: optional, if user want to use an existing
|
||||
baymodel
|
||||
:param kwargs: optional additional arguments for bay creation
|
||||
:param node_count: the cluster node count.
|
||||
:param cluster_template_uuid: optional, if user want to use an existing
|
||||
cluster_template
|
||||
:param kwargs: optional additional arguments for cluster creation
|
||||
"""
|
||||
baymodel_uuid = kwargs.get("baymodel_uuid", None)
|
||||
if baymodel_uuid is None:
|
||||
baymodel_uuid = self.context["tenant"]["baymodel"]
|
||||
self._create_bay(baymodel_uuid, node_count, **kwargs)
|
||||
self._list_bays(**kwargs)
|
||||
cluster_template_uuid = kwargs.get("cluster_template_uuid", None)
|
||||
if cluster_template_uuid is None:
|
||||
cluster_template_uuid = self.context["tenant"]["cluster_template"]
|
||||
self._create_cluster(cluster_template_uuid, node_count, **kwargs)
|
||||
self._list_clusters(**kwargs)
|
@ -20,17 +20,18 @@ from rally.task import atomic
|
||||
from rally.task import utils
|
||||
|
||||
MAGNUM_BENCHMARK_OPTS = [
|
||||
cfg.FloatOpt("magnum_bay_create_prepoll_delay",
|
||||
cfg.FloatOpt("magnum_cluster_create_prepoll_delay",
|
||||
default=5.0,
|
||||
help="Time(in sec) to sleep after creating a resource before "
|
||||
"polling for the status."),
|
||||
cfg.FloatOpt("magnum_bay_create_timeout",
|
||||
cfg.FloatOpt("magnum_cluster_create_timeout",
|
||||
default=1200.0,
|
||||
help="Time(in sec) to wait for magnum bay to be created."),
|
||||
cfg.FloatOpt("magnum_bay_create_poll_interval",
|
||||
help="Time(in sec) to wait for magnum cluster to be "
|
||||
"created."),
|
||||
cfg.FloatOpt("magnum_cluster_create_poll_interval",
|
||||
default=1.0,
|
||||
help="Time interval(in sec) between checks when waiting for "
|
||||
"bay creation."),
|
||||
"cluster creation."),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -41,76 +42,78 @@ CONF.register_opts(MAGNUM_BENCHMARK_OPTS, group=benchmark_group)
|
||||
class MagnumScenario(scenario.OpenStackScenario):
|
||||
"""Base class for Magnum scenarios with basic atomic actions."""
|
||||
|
||||
@atomic.action_timer("magnum.list_baymodels")
|
||||
def _list_baymodels(self, **kwargs):
|
||||
"""Return list of baymodels.
|
||||
@atomic.action_timer("magnum.list_cluster_templates")
|
||||
def _list_cluster_templates(self, **kwargs):
|
||||
"""Return list of cluster_templates.
|
||||
|
||||
:param limit: (Optional) The maximum number of results to return
|
||||
per request, if:
|
||||
|
||||
1) limit > 0, the maximum number of baymodels to return.
|
||||
1) limit > 0, the maximum number of cluster_templates to return.
|
||||
2) limit param is NOT specified (None), the number of items
|
||||
returned respect the maximum imposed by the Magnum API
|
||||
(see Magnum's api.max_limit option).
|
||||
:param kwargs: Optional additional arguments for baymodels listing
|
||||
:param kwargs: Optional additional arguments for cluster_templates
|
||||
listing
|
||||
|
||||
:returns: baymodels list
|
||||
:returns: cluster_templates list
|
||||
"""
|
||||
|
||||
return self.clients("magnum").baymodels.list(**kwargs)
|
||||
return self.clients("magnum").cluster_templates.list(**kwargs)
|
||||
|
||||
@atomic.action_timer("magnum.create_baymodel")
|
||||
def _create_baymodel(self, **kwargs):
|
||||
"""Create a baymodel
|
||||
@atomic.action_timer("magnum.create_cluster_template")
|
||||
def _create_cluster_template(self, **kwargs):
|
||||
"""Create a cluster_template
|
||||
|
||||
:param kwargs: optional additional arguments for baymodel creation
|
||||
:returns: magnum baymodel
|
||||
:param kwargs: optional additional arguments for cluster_template
|
||||
creation
|
||||
:returns: magnum cluster_template
|
||||
"""
|
||||
|
||||
kwargs["name"] = self.generate_random_name()
|
||||
|
||||
return self.clients("magnum").baymodels.create(**kwargs)
|
||||
return self.clients("magnum").cluster_templates.create(**kwargs)
|
||||
|
||||
@atomic.action_timer("magnum.list_bays")
|
||||
def _list_bays(self, limit=None, **kwargs):
|
||||
"""Return list of bays.
|
||||
@atomic.action_timer("magnum.list_clusters")
|
||||
def _list_clusters(self, limit=None, **kwargs):
|
||||
"""Return list of clusters.
|
||||
|
||||
:param limit: (Optional) the maximum number of results to return
|
||||
per request, if:
|
||||
|
||||
1) limit > 0, the maximum number of bays to return.
|
||||
1) limit > 0, the maximum number of clusters to return.
|
||||
2) limit param is NOT specified (None), the number of items
|
||||
returned respect the maximum imposed by the Magnum API
|
||||
(see Magnum's api.max_limit option).
|
||||
:param kwargs: Optional additional arguments for bays listing
|
||||
:param kwargs: Optional additional arguments for clusters listing
|
||||
|
||||
:returns: bays list
|
||||
:returns: clusters list
|
||||
"""
|
||||
return self.clients("magnum").bays.list(limit=limit, **kwargs)
|
||||
return self.clients("magnum").clusters.list(limit=limit, **kwargs)
|
||||
|
||||
@atomic.action_timer("magnum.create_bay")
|
||||
def _create_bay(self, baymodel, node_count, **kwargs):
|
||||
"""Create a bay
|
||||
@atomic.action_timer("magnum.create_cluster")
|
||||
def _create_cluster(self, cluster_template, node_count, **kwargs):
|
||||
"""Create a cluster
|
||||
|
||||
:param baymodel: baymodel for the bay
|
||||
:param node_count: the bay node count
|
||||
:param kwargs: optional additional arguments for bay creation
|
||||
:returns: magnum bay
|
||||
:param cluster_template: cluster_template for the cluster
|
||||
:param node_count: the cluster node count
|
||||
:param kwargs: optional additional arguments for cluster creation
|
||||
:returns: magnum cluster
|
||||
"""
|
||||
|
||||
name = self.generate_random_name()
|
||||
bay = self.clients("magnum").bays.create(
|
||||
name=name, baymodel_id=baymodel,
|
||||
cluster = self.clients("magnum").clusters.create(
|
||||
name=name, cluster_template_id=cluster_template,
|
||||
node_count=node_count, **kwargs)
|
||||
|
||||
common_utils.interruptable_sleep(
|
||||
CONF.benchmark.magnum_bay_create_prepoll_delay)
|
||||
bay = utils.wait_for_status(
|
||||
bay,
|
||||
CONF.benchmark.magnum_cluster_create_prepoll_delay)
|
||||
cluster = utils.wait_for_status(
|
||||
cluster,
|
||||
ready_statuses=["CREATE_COMPLETE"],
|
||||
update_resource=utils.get_from_manager(),
|
||||
timeout=CONF.benchmark.magnum_bay_create_timeout,
|
||||
check_interval=CONF.benchmark.magnum_bay_create_poll_interval,
|
||||
timeout=CONF.benchmark.magnum_cluster_create_timeout,
|
||||
check_interval=CONF.benchmark.magnum_cluster_create_poll_interval,
|
||||
id_attr="uuid"
|
||||
)
|
||||
return bay
|
||||
return cluster
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"MagnumBays.create_and_list_bays": [
|
||||
"MagnumClusters.create_and_list_clusters": [
|
||||
{
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
@ -10,7 +10,7 @@
|
||||
"node_count": 1
|
||||
},
|
||||
"context": {
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
||||
@ -35,7 +35,7 @@
|
||||
"node_count": 1
|
||||
},
|
||||
"context": {
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
||||
@ -60,7 +60,7 @@
|
||||
"node_count": 1
|
||||
},
|
||||
"context": {
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
MagnumBays.create_and_list_bays:
|
||||
MagnumClusters.create_and_list_clusters:
|
||||
-
|
||||
args:
|
||||
node_count: 1
|
||||
@ -11,7 +11,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "fedora-atomic-latest"
|
||||
external_network_id: "public"
|
||||
dns_nameserver: "8.8.8.8"
|
||||
@ -30,7 +30,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "fedora-atomic-latest"
|
||||
external_network_id: "public"
|
||||
dns_nameserver: "8.8.8.8"
|
||||
@ -49,7 +49,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "ubuntu-mesos"
|
||||
external_network_id: "public"
|
||||
dns_nameserver: "8.8.8.8"
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"MagnumBaymodels.list_baymodels": [
|
||||
"MagnumClusterTemplates.list_cluster_templates": [
|
||||
{
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
@ -7,7 +7,7 @@
|
||||
"times": 1
|
||||
},
|
||||
"context": {
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
||||
@ -29,7 +29,7 @@
|
||||
"times": 1
|
||||
},
|
||||
"context": {
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
||||
@ -51,7 +51,7 @@
|
||||
"times": 1
|
||||
},
|
||||
"context": {
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
MagnumBaymodels.list_baymodels:
|
||||
MagnumClusterTemplates.list_cluster_templates:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
@ -9,7 +9,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "fedora-atomic-latest"
|
||||
external_network_id: "public"
|
||||
dns_nameserver: "8.8.8.8"
|
||||
@ -26,7 +26,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "fedora-atomic-latest"
|
||||
external_network_id: "public"
|
||||
dns_nameserver: "8.8.8.8"
|
||||
@ -43,7 +43,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "ubuntu-mesos"
|
||||
external_network_id: "public"
|
||||
dns_nameserver: "8.8.8.8"
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"MagnumBays.list_bays": [
|
||||
"MagnumClusters.list_clusters": [
|
||||
{
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
@ -7,10 +7,10 @@
|
||||
"times": 1
|
||||
},
|
||||
"context": {
|
||||
"bays": {
|
||||
"clusters": {
|
||||
"node_count": 2
|
||||
},
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
||||
@ -32,10 +32,10 @@
|
||||
"times": 1
|
||||
},
|
||||
"context": {
|
||||
"bays": {
|
||||
"clusters": {
|
||||
"node_count": 2
|
||||
},
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
||||
@ -57,10 +57,10 @@
|
||||
"times": 1
|
||||
},
|
||||
"context": {
|
||||
"bays": {
|
||||
"clusters": {
|
||||
"node_count": 2
|
||||
},
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
MagnumBays.list_bays:
|
||||
MagnumClusters.list_clusters:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
@ -9,7 +9,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "fedora-atomic-latest"
|
||||
external_network_id: "public"
|
||||
dns_nameserver: "8.8.8.8"
|
||||
@ -17,7 +17,7 @@
|
||||
docker_volume_size: 5
|
||||
network_driver: "flannel"
|
||||
coe: "kubernetes"
|
||||
bays:
|
||||
clusters:
|
||||
node_count: 2
|
||||
-
|
||||
runner:
|
||||
@ -28,7 +28,7 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "fedora-atomic-latest"
|
||||
external_network_id: "public"
|
||||
dns_nameserver: "8.8.8.8"
|
||||
@ -36,7 +36,7 @@
|
||||
docker_volume_size: 5
|
||||
network_driver: "docker"
|
||||
coe: "swarm"
|
||||
bays:
|
||||
clusters:
|
||||
node_count: 2
|
||||
-
|
||||
runner:
|
||||
@ -47,12 +47,12 @@
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
baymodels:
|
||||
cluster_templates:
|
||||
image_id: "ubuntu-mesos"
|
||||
external_network_id: "public"
|
||||
dns_nameserver: "8.8.8.8"
|
||||
flavor_id: "m1.small"
|
||||
network_driver: "docker"
|
||||
coe: "mesos"
|
||||
bays:
|
||||
clusters:
|
||||
node_count: 2
|
@ -96,26 +96,26 @@ class Magnum(ResourceManager):
|
||||
|
||||
REQUIRED_SERVICE = consts.Service.MAGNUM
|
||||
|
||||
def list_baymodels(self):
|
||||
def list_cluster_templates(self):
|
||||
result = []
|
||||
marker = None
|
||||
while True:
|
||||
baymodels = self.client.baymodels.list(marker=marker)
|
||||
if not baymodels:
|
||||
ct_list = self.client.cluster_templates.list(marker=marker)
|
||||
if not ct_list:
|
||||
break
|
||||
result.extend(baymodels)
|
||||
marker = baymodels[-1].uuid
|
||||
result.extend(ct_list)
|
||||
marker = ct_list[-1].uuid
|
||||
return result
|
||||
|
||||
def list_bays(self):
|
||||
def list_clusters(self):
|
||||
result = []
|
||||
marker = None
|
||||
while True:
|
||||
bays = self.client.bays.list(marker=marker)
|
||||
if not bays:
|
||||
clusters = self.client.clusters.list(marker=marker)
|
||||
if not clusters:
|
||||
break
|
||||
result.extend(bays)
|
||||
marker = bays[-1].uuid
|
||||
result.extend(clusters)
|
||||
marker = clusters[-1].uuid
|
||||
return result
|
||||
|
||||
|
||||
|
@ -322,7 +322,7 @@ class FakeObject(FakeResource):
|
||||
pass
|
||||
|
||||
|
||||
class FakeBaymodel(FakeResource):
|
||||
class FakeClusterTemplate(FakeResource):
|
||||
pass
|
||||
|
||||
|
||||
@ -518,12 +518,12 @@ class FakeKeypairManager(FakeManager):
|
||||
self.resources_order.remove(resource)
|
||||
|
||||
|
||||
class FakeBaymodelManager(FakeManager):
|
||||
class FakeClusterTemplateManager(FakeManager):
|
||||
|
||||
def create(self, name):
|
||||
baymodel = FakeBaymodel(self)
|
||||
baymodel.name = name or baymodel.name
|
||||
return self._cache(baymodel)
|
||||
cluster_template = FakeClusterTemplate(self)
|
||||
cluster_template.name = name or cluster_template.name
|
||||
return self._cache(cluster_template)
|
||||
|
||||
def delete(self, resource):
|
||||
if not isinstance(resource, six.string_types):
|
||||
@ -1533,7 +1533,7 @@ class FakeSenlinClient(object):
|
||||
class FakeMagnumClient(object):
|
||||
|
||||
def __init__(self):
|
||||
self.baymodels = FakeBaymodelManager()
|
||||
self.cluster_templates = FakeClusterTemplateManager()
|
||||
|
||||
|
||||
class FakeWatcherClient(object):
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context.magnum import baymodels
|
||||
from rally.plugins.openstack.context.magnum import cluster_templates
|
||||
from tests.unit import fakes
|
||||
from tests.unit import test
|
||||
|
||||
@ -23,7 +23,7 @@ BASE_SCN = "rally.task.scenarios"
|
||||
SCN = "rally.plugins.openstack.scenarios"
|
||||
|
||||
|
||||
class BaymodelsGeneratorTestCase(test.ScenarioTestCase):
|
||||
class ClusterTemplatesGeneratorTestCase(test.ScenarioTestCase):
|
||||
|
||||
"""Generate tenants."""
|
||||
def _gen_tenants(self, count):
|
||||
@ -32,12 +32,13 @@ class BaymodelsGeneratorTestCase(test.ScenarioTestCase):
|
||||
tenants[str(id_)] = dict(name=str(id_))
|
||||
return tenants
|
||||
|
||||
@mock.patch("%s.magnum.utils.MagnumScenario._create_baymodel" % SCN,
|
||||
return_value=fakes.FakeBaymodel(id="uuid"))
|
||||
@mock.patch("%s.magnum.utils.MagnumScenario."
|
||||
"_create_cluster_template" % SCN,
|
||||
return_value=fakes.FakeClusterTemplate(id="uuid"))
|
||||
@mock.patch("%s.nova.utils.NovaScenario._create_keypair" % SCN,
|
||||
return_value="key1")
|
||||
def test_setup(self, mock_nova_scenario__create_keypair,
|
||||
mock_magnum_scenario__create_baymodel):
|
||||
mock__create_cluster_template):
|
||||
tenants_count = 2
|
||||
users_per_tenant = 5
|
||||
|
||||
@ -55,7 +56,7 @@ class BaymodelsGeneratorTestCase(test.ScenarioTestCase):
|
||||
"users_per_tenant": users_per_tenant,
|
||||
"concurrent": 10,
|
||||
},
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
||||
@ -69,18 +70,18 @@ class BaymodelsGeneratorTestCase(test.ScenarioTestCase):
|
||||
"tenants": tenants
|
||||
})
|
||||
|
||||
baymodel_ctx = baymodels.BaymodelGenerator(self.context)
|
||||
baymodel_ctx.setup()
|
||||
ct_ctx = cluster_templates.ClusterTemplateGenerator(self.context)
|
||||
ct_ctx.setup()
|
||||
|
||||
baymodel_ctx_config = self.context["config"]["baymodels"]
|
||||
image_id = baymodel_ctx_config.get("image_id")
|
||||
external_network_id = baymodel_ctx_config.get(
|
||||
ct_ctx_config = self.context["config"]["cluster_templates"]
|
||||
image_id = ct_ctx_config.get("image_id")
|
||||
external_network_id = ct_ctx_config.get(
|
||||
"external_network_id")
|
||||
dns_nameserver = baymodel_ctx_config.get("dns_nameserver")
|
||||
flavor_id = baymodel_ctx_config.get("flavor_id")
|
||||
docker_volume_size = baymodel_ctx_config.get("docker_volume_size")
|
||||
network_driver = baymodel_ctx_config.get("network_driver")
|
||||
coe = baymodel_ctx_config.get("coe")
|
||||
dns_nameserver = ct_ctx_config.get("dns_nameserver")
|
||||
flavor_id = ct_ctx_config.get("flavor_id")
|
||||
docker_volume_size = ct_ctx_config.get("docker_volume_size")
|
||||
network_driver = ct_ctx_config.get("network_driver")
|
||||
coe = ct_ctx_config.get("coe")
|
||||
mock_calls = [mock.call(image_id=image_id, keypair_id="key1",
|
||||
external_network_id=external_network_id,
|
||||
dns_nameserver=dns_nameserver,
|
||||
@ -88,19 +89,20 @@ class BaymodelsGeneratorTestCase(test.ScenarioTestCase):
|
||||
docker_volume_size=docker_volume_size,
|
||||
network_driver=network_driver, coe=coe)
|
||||
for i in range(tenants_count)]
|
||||
mock_magnum_scenario__create_baymodel.assert_has_calls(mock_calls)
|
||||
mock__create_cluster_template.assert_has_calls(mock_calls)
|
||||
|
||||
# check that stack ids have been saved in context
|
||||
for ten_id in self.context["tenants"].keys():
|
||||
self.assertIsNotNone(self.context["tenants"][ten_id]["baymodel"])
|
||||
self.assertIsNotNone(
|
||||
self.context["tenants"][ten_id]["cluster_template"])
|
||||
|
||||
@mock.patch("%s.magnum.baymodels.resource_manager.cleanup" % CTX)
|
||||
@mock.patch("%s.magnum.cluster_templates.resource_manager.cleanup" % CTX)
|
||||
def test_cleanup(self, mock_cleanup):
|
||||
self.context.update({
|
||||
"users": mock.MagicMock()
|
||||
})
|
||||
baymodel_ctx = baymodels.BaymodelGenerator(self.context)
|
||||
baymodel_ctx.cleanup()
|
||||
mock_cleanup.assert_called_once_with(names=["magnum.baymodels",
|
||||
ct_ctx = cluster_templates.ClusterTemplateGenerator(self.context)
|
||||
ct_ctx.cleanup()
|
||||
mock_cleanup.assert_called_once_with(names=["magnum.cluster_templates",
|
||||
"nova.keypairs"],
|
||||
users=self.context["users"])
|
@ -17,14 +17,14 @@ import copy
|
||||
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.context.magnum import bays
|
||||
from rally.plugins.openstack.context.magnum import clusters
|
||||
from tests.unit import test
|
||||
|
||||
CTX = "rally.plugins.openstack.context.magnum"
|
||||
SCN = "rally.plugins.openstack.scenarios"
|
||||
|
||||
|
||||
class BaysGeneratorTestCase(test.ScenarioTestCase):
|
||||
class ClustersGeneratorTestCase(test.ScenarioTestCase):
|
||||
|
||||
def _gen_tenants(self, count):
|
||||
tenants = {}
|
||||
@ -32,17 +32,16 @@ class BaysGeneratorTestCase(test.ScenarioTestCase):
|
||||
tenants[str(id_)] = {"name": str(id_)}
|
||||
return tenants
|
||||
|
||||
def _gen_tenants_with_baymodel(self, count):
|
||||
def _gen_tenants_with_cluster_template(self, count):
|
||||
tenants = {}
|
||||
for id_ in range(count):
|
||||
tenants[str(id_)] = {"name": str(id_)}
|
||||
tenants[str(id_)]["baymodel"] = "rally_baymodel_uuid"
|
||||
tenants[str(id_)]["cluster_template"] = "rally_ct_uuid"
|
||||
return tenants
|
||||
|
||||
@mock.patch("%s.magnum.utils.MagnumScenario._create_bay" % SCN,
|
||||
@mock.patch("%s.magnum.utils.MagnumScenario._create_cluster" % SCN,
|
||||
return_value=mock.Mock())
|
||||
def test_setup_using_existing_baymodel(self,
|
||||
mock_magnum_scenario__create_bay):
|
||||
def test_setup_using_existing_cluster_template(self, mock__create_cluster):
|
||||
tenants_count = 2
|
||||
users_per_tenant = 5
|
||||
|
||||
@ -60,8 +59,8 @@ class BaysGeneratorTestCase(test.ScenarioTestCase):
|
||||
"users_per_tenant": users_per_tenant,
|
||||
"concurrent": 10,
|
||||
},
|
||||
"bays": {
|
||||
"baymodel_uuid": "123456789",
|
||||
"clusters": {
|
||||
"cluster_template_uuid": "123456789",
|
||||
"node_count": 2
|
||||
}
|
||||
},
|
||||
@ -69,29 +68,30 @@ class BaysGeneratorTestCase(test.ScenarioTestCase):
|
||||
"tenants": tenants
|
||||
})
|
||||
|
||||
mock_bay = mock_magnum_scenario__create_bay.return_value
|
||||
mock_cluster = mock__create_cluster.return_value
|
||||
new_context = copy.deepcopy(self.context)
|
||||
for id_ in new_context["tenants"]:
|
||||
new_context["tenants"][id_]["bay"] = mock_bay.uuid
|
||||
new_context["tenants"][id_]["cluster"] = mock_cluster.uuid
|
||||
|
||||
bay_ctx = bays.BayGenerator(self.context)
|
||||
bay_ctx.setup()
|
||||
cluster_ctx = clusters.ClusterGenerator(self.context)
|
||||
cluster_ctx.setup()
|
||||
|
||||
self.assertEqual(new_context, self.context)
|
||||
bay_ctx_config = self.context["config"]["bays"]
|
||||
node_count = bay_ctx_config.get("node_count")
|
||||
baymodel_uuid = bay_ctx_config.get("baymodel_uuid")
|
||||
mock_calls = [mock.call(baymodel=baymodel_uuid, node_count=node_count)
|
||||
cluster_ctx_config = self.context["config"]["clusters"]
|
||||
node_count = cluster_ctx_config.get("node_count")
|
||||
cluster_template_uuid = cluster_ctx_config.get("cluster_template_uuid")
|
||||
mock_calls = [mock.call(cluster_template=cluster_template_uuid,
|
||||
node_count=node_count)
|
||||
for i in range(tenants_count)]
|
||||
mock_magnum_scenario__create_bay.assert_has_calls(mock_calls)
|
||||
mock__create_cluster.assert_has_calls(mock_calls)
|
||||
|
||||
@mock.patch("%s.magnum.utils.MagnumScenario._create_bay" % SCN,
|
||||
@mock.patch("%s.magnum.utils.MagnumScenario._create_cluster" % SCN,
|
||||
return_value=mock.Mock())
|
||||
def test_setup(self, mock_magnum_scenario__create_bay):
|
||||
def test_setup(self, mock__create_cluster):
|
||||
tenants_count = 2
|
||||
users_per_tenant = 5
|
||||
|
||||
tenants = self._gen_tenants_with_baymodel(tenants_count)
|
||||
tenants = self._gen_tenants_with_cluster_template(tenants_count)
|
||||
users = []
|
||||
for ten_id in tenants:
|
||||
for i in range(users_per_tenant):
|
||||
@ -105,7 +105,7 @@ class BaysGeneratorTestCase(test.ScenarioTestCase):
|
||||
"users_per_tenant": users_per_tenant,
|
||||
"concurrent": 10,
|
||||
},
|
||||
"baymodels": {
|
||||
"cluster_templates": {
|
||||
"dns_nameserver": "8.8.8.8",
|
||||
"external_network_id": "public",
|
||||
"flavor_id": "m1.small",
|
||||
@ -114,7 +114,7 @@ class BaysGeneratorTestCase(test.ScenarioTestCase):
|
||||
"image_id": "fedora-atomic-latest",
|
||||
"network_driver": "flannel"
|
||||
},
|
||||
"bays": {
|
||||
"clusters": {
|
||||
"node_count": 2
|
||||
}
|
||||
},
|
||||
@ -122,29 +122,29 @@ class BaysGeneratorTestCase(test.ScenarioTestCase):
|
||||
"tenants": tenants
|
||||
})
|
||||
|
||||
mock_bay = mock_magnum_scenario__create_bay.return_value
|
||||
mock_cluster = mock__create_cluster.return_value
|
||||
new_context = copy.deepcopy(self.context)
|
||||
for id_ in new_context["tenants"]:
|
||||
new_context["tenants"][id_]["bay"] = mock_bay.uuid
|
||||
new_context["tenants"][id_]["cluster"] = mock_cluster.uuid
|
||||
|
||||
bay_ctx = bays.BayGenerator(self.context)
|
||||
bay_ctx.setup()
|
||||
cluster_ctx = clusters.ClusterGenerator(self.context)
|
||||
cluster_ctx.setup()
|
||||
|
||||
self.assertEqual(new_context, self.context)
|
||||
bay_ctx_config = self.context["config"]["bays"]
|
||||
node_count = bay_ctx_config.get("node_count")
|
||||
mock_calls = [mock.call(baymodel="rally_baymodel_uuid",
|
||||
cluster_ctx_config = self.context["config"]["clusters"]
|
||||
node_count = cluster_ctx_config.get("node_count")
|
||||
mock_calls = [mock.call(cluster_template="rally_ct_uuid",
|
||||
node_count=node_count)
|
||||
for i in range(tenants_count)]
|
||||
mock_magnum_scenario__create_bay.assert_has_calls(mock_calls)
|
||||
mock__create_cluster.assert_has_calls(mock_calls)
|
||||
|
||||
@mock.patch("%s.baymodels.resource_manager.cleanup" % CTX)
|
||||
@mock.patch("%s.cluster_templates.resource_manager.cleanup" % CTX)
|
||||
def test_cleanup(self, mock_cleanup):
|
||||
self.context.update({
|
||||
"users": mock.MagicMock()
|
||||
})
|
||||
bays_ctx = bays.BayGenerator(self.context)
|
||||
bays_ctx.cleanup()
|
||||
clusters_ctx = clusters.ClusterGenerator(self.context)
|
||||
clusters_ctx.cleanup()
|
||||
mock_cleanup.assert_called_once_with(
|
||||
names=["magnum.bays"],
|
||||
names=["magnum.clusters"],
|
||||
users=self.context["users"])
|
@ -1,73 +0,0 @@
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.scenarios.magnum import bays
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class MagnumBaysTestCase(test.ScenarioTestCase):
|
||||
|
||||
@staticmethod
|
||||
def _get_context():
|
||||
context = test.get_test_context()
|
||||
context.update({
|
||||
"tenant": {
|
||||
"id": "rally_tenant_id",
|
||||
"baymodel": "rally_baymodel_uuid"
|
||||
}
|
||||
})
|
||||
return context
|
||||
|
||||
@ddt.data(
|
||||
{"kwargs": {}},
|
||||
{"kwargs": {"fakearg": "f"}})
|
||||
def test_list_bays(self, kwargs):
|
||||
scenario = bays.ListBays()
|
||||
scenario._list_bays = mock.Mock()
|
||||
|
||||
scenario.run(**kwargs)
|
||||
|
||||
scenario._list_bays.assert_called_once_with(**kwargs)
|
||||
|
||||
def test_create_bay_with_existing_baymodel_and_list_bays(self):
|
||||
scenario = bays.CreateAndListBays()
|
||||
kwargs = {"baymodel_uuid": "existing_baymodel_uuid",
|
||||
"fakearg": "f"}
|
||||
fake_bay = mock.Mock()
|
||||
scenario._create_bay = mock.Mock(return_value=fake_bay)
|
||||
scenario._list_bays = mock.Mock()
|
||||
|
||||
scenario.run(2, **kwargs)
|
||||
|
||||
scenario._create_bay.assert_called_once_with(
|
||||
"existing_baymodel_uuid", 2, **kwargs)
|
||||
scenario._list_bays.assert_called_once_with(**kwargs)
|
||||
|
||||
def test_create_and_list_bays(self):
|
||||
context = self._get_context()
|
||||
scenario = bays.CreateAndListBays(context)
|
||||
fake_bay = mock.Mock()
|
||||
kwargs = {"fakearg": "f"}
|
||||
scenario._create_bay = mock.Mock(return_value=fake_bay)
|
||||
scenario._list_bays = mock.Mock()
|
||||
|
||||
scenario.run(2, **kwargs)
|
||||
|
||||
scenario._create_bay.assert_called_once_with(
|
||||
"rally_baymodel_uuid", 2, **kwargs)
|
||||
scenario._list_bays.assert_called_once_with(**kwargs)
|
@ -15,21 +15,21 @@
|
||||
import ddt
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.scenarios.magnum import baymodels
|
||||
from rally.plugins.openstack.scenarios.magnum import cluster_templates
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class MagnumBaymodelsTestCase(test.TestCase):
|
||||
class MagnumClusterTemplatesTestCase(test.TestCase):
|
||||
|
||||
@ddt.data(
|
||||
{"kwargs": {}},
|
||||
{"kwargs": {"fakearg": "f"}})
|
||||
@ddt.unpack
|
||||
def test_list_baymodels(self, kwargs):
|
||||
scenario = baymodels.ListBaymodels()
|
||||
scenario._list_baymodels = mock.Mock()
|
||||
def test_list_cluster_templates(self, kwargs):
|
||||
scenario = cluster_templates.ListClusterTemplates()
|
||||
scenario._list_cluster_templates = mock.Mock()
|
||||
|
||||
scenario.run(**kwargs)
|
||||
|
||||
scenario._list_baymodels.assert_called_once_with(**kwargs)
|
||||
scenario._list_cluster_templates.assert_called_once_with(**kwargs)
|
@ -0,0 +1,73 @@
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
|
||||
from rally.plugins.openstack.scenarios.magnum import clusters
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class MagnumClustersTestCase(test.ScenarioTestCase):
|
||||
|
||||
@staticmethod
|
||||
def _get_context():
|
||||
context = test.get_test_context()
|
||||
context.update({
|
||||
"tenant": {
|
||||
"id": "rally_tenant_id",
|
||||
"cluster_template": "rally_cluster_template_uuid"
|
||||
}
|
||||
})
|
||||
return context
|
||||
|
||||
@ddt.data(
|
||||
{"kwargs": {}},
|
||||
{"kwargs": {"fakearg": "f"}})
|
||||
def test_list_clusters(self, kwargs):
|
||||
scenario = clusters.ListClusters()
|
||||
scenario._list_clusters = mock.Mock()
|
||||
|
||||
scenario.run(**kwargs)
|
||||
|
||||
scenario._list_clusters.assert_called_once_with(**kwargs)
|
||||
|
||||
def test_create_cluster_with_existing_ct_and_list_clusters(self):
|
||||
scenario = clusters.CreateAndListClusters()
|
||||
kwargs = {"cluster_template_uuid": "existing_cluster_template_uuid",
|
||||
"fakearg": "f"}
|
||||
fake_cluster = mock.Mock()
|
||||
scenario._create_cluster = mock.Mock(return_value=fake_cluster)
|
||||
scenario._list_clusters = mock.Mock()
|
||||
|
||||
scenario.run(2, **kwargs)
|
||||
|
||||
scenario._create_cluster.assert_called_once_with(
|
||||
"existing_cluster_template_uuid", 2, **kwargs)
|
||||
scenario._list_clusters.assert_called_once_with(**kwargs)
|
||||
|
||||
def test_create_and_list_clusters(self):
|
||||
context = self._get_context()
|
||||
scenario = clusters.CreateAndListClusters(context)
|
||||
fake_cluster = mock.Mock()
|
||||
kwargs = {"fakearg": "f"}
|
||||
scenario._create_cluster = mock.Mock(return_value=fake_cluster)
|
||||
scenario._list_clusters = mock.Mock()
|
||||
|
||||
scenario.run(2, **kwargs)
|
||||
|
||||
scenario._create_cluster.assert_called_once_with(
|
||||
"rally_cluster_template_uuid", 2, **kwargs)
|
||||
scenario._list_clusters.assert_called_once_with(**kwargs)
|
@ -23,28 +23,28 @@ CONF = utils.CONF
|
||||
class MagnumScenarioTestCase(test.ScenarioTestCase):
|
||||
def setUp(self):
|
||||
super(MagnumScenarioTestCase, self).setUp()
|
||||
self.baymodel = mock.Mock()
|
||||
self.bay = mock.Mock()
|
||||
self.cluster_template = mock.Mock()
|
||||
self.cluster = mock.Mock()
|
||||
self.scenario = utils.MagnumScenario(self.context)
|
||||
|
||||
def test_list_baymodels(self):
|
||||
fake_baymodel_list = [self.baymodel]
|
||||
def test_list_cluster_templates(self):
|
||||
fake_list = [self.cluster_template]
|
||||
|
||||
self.clients("magnum").baymodels.list.return_value = fake_baymodel_list
|
||||
return_baymodels_list = self.scenario._list_baymodels()
|
||||
self.assertEqual(fake_baymodel_list, return_baymodels_list)
|
||||
self.clients("magnum").cluster_templates.list.return_value = fake_list
|
||||
return_ct_list = self.scenario._list_cluster_templates()
|
||||
self.assertEqual(fake_list, return_ct_list)
|
||||
|
||||
self.clients("magnum").baymodels.list.assert_called_once_with()
|
||||
self.clients("magnum").cluster_templates.list.assert_called_once_with()
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"magnum.list_baymodels")
|
||||
"magnum.list_cluster_templates")
|
||||
|
||||
def test_create_baymodel(self):
|
||||
def test_create_cluster_template(self):
|
||||
self.scenario.generate_random_name = mock.Mock(
|
||||
return_value="generated_name")
|
||||
fake_baymodel = self.baymodel
|
||||
self.clients("magnum").baymodels.create.return_value = fake_baymodel
|
||||
fake_ct = self.cluster_template
|
||||
self.clients("magnum").cluster_templates.create.return_value = fake_ct
|
||||
|
||||
return_baymodel = self.scenario._create_baymodel(
|
||||
return_cluster_template = self.scenario._create_cluster_template(
|
||||
image="test_image",
|
||||
keypair="test_key",
|
||||
external_network="public",
|
||||
@ -54,40 +54,41 @@ class MagnumScenarioTestCase(test.ScenarioTestCase):
|
||||
network_driver="docker",
|
||||
coe="swarm")
|
||||
|
||||
self.assertEqual(fake_baymodel, return_baymodel)
|
||||
args, kwargs = self.clients("magnum").baymodels.create.call_args
|
||||
self.assertEqual(fake_ct, return_cluster_template)
|
||||
_, kwargs = self.clients("magnum").cluster_templates.create.call_args
|
||||
self.assertEqual("generated_name", kwargs["name"])
|
||||
|
||||
self._test_atomic_action_timer(self.scenario.atomic_actions(),
|
||||
"magnum.create_baymodel")
|
||||
"magnum.create_cluster_template")
|
||||
|
||||
def test_list_bays(self):
|
||||
return_bays_list = self.scenario._list_bays(limit="foo1")
|
||||
self.clients("magnum").bays.list.assert_called_once_with(limit="foo1")
|
||||
self.assertEqual(self.clients("magnum").bays.list.return_value,
|
||||
return_bays_list)
|
||||
def test_list_clusters(self):
|
||||
return_clusters_list = self.scenario._list_clusters(limit="foo1")
|
||||
client = self.clients("magnum")
|
||||
client.clusters.list.assert_called_once_with(limit="foo1")
|
||||
self.assertEqual(client.clusters.list.return_value,
|
||||
return_clusters_list)
|
||||
self._test_atomic_action_timer(
|
||||
self.scenario.atomic_actions(), "magnum.list_bays")
|
||||
self.scenario.atomic_actions(), "magnum.list_clusters")
|
||||
|
||||
def test_create_bay(self):
|
||||
def test_create_cluster(self):
|
||||
self.scenario.generate_random_name = mock.Mock(
|
||||
return_value="generated_name")
|
||||
self.clients("magnum").bays.create.return_value = self.bay
|
||||
return_bay = self.scenario._create_bay(
|
||||
baymodel="generated_uuid", node_count=2)
|
||||
self.clients("magnum").clusters.create.return_value = self.cluster
|
||||
return_cluster = self.scenario._create_cluster(
|
||||
cluster_template="generated_uuid", node_count=2)
|
||||
self.mock_wait_for_status.mock.assert_called_once_with(
|
||||
self.bay,
|
||||
self.cluster,
|
||||
ready_statuses=["CREATE_COMPLETE"],
|
||||
update_resource=self.mock_get_from_manager.mock.return_value,
|
||||
check_interval=CONF.benchmark.
|
||||
magnum_bay_create_poll_interval,
|
||||
timeout=CONF.benchmark.magnum_bay_create_timeout,
|
||||
magnum_cluster_create_poll_interval,
|
||||
timeout=CONF.benchmark.magnum_cluster_create_timeout,
|
||||
id_attr="uuid")
|
||||
args, kwargs = self.clients("magnum").bays.create.call_args
|
||||
_, kwargs = self.clients("magnum").clusters.create.call_args
|
||||
self.assertEqual("generated_name", kwargs["name"])
|
||||
self.assertEqual("generated_uuid", kwargs["baymodel_id"])
|
||||
self.assertEqual("generated_uuid", kwargs["cluster_template_id"])
|
||||
self.mock_get_from_manager.mock.assert_called_once_with()
|
||||
self.assertEqual(
|
||||
self.mock_wait_for_status.mock.return_value, return_bay)
|
||||
self.mock_wait_for_status.mock.return_value, return_cluster)
|
||||
self._test_atomic_action_timer(
|
||||
self.scenario.atomic_actions(), "magnum.create_bay")
|
||||
self.scenario.atomic_actions(), "magnum.create_cluster")
|
||||
|
Loading…
Reference in New Issue
Block a user