[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:
Spyros Trigazis 2016-09-24 14:50:49 +02:00
parent 446a0357aa
commit 72a329de9c
21 changed files with 1185 additions and 105 deletions

View File

@ -240,15 +240,15 @@
# Time(in sec) to sleep after creating a resource before polling for # Time(in sec) to sleep after creating a resource before polling for
# the status. (floating point value) # 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) # 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) # (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. # Delay between creating Manila share and polling for its status.
# (floating point value) # (floating point value)

View File

@ -1,5 +1,5 @@
--- ---
MagnumBaymodels.list_baymodels: MagnumClusterTemplates.list_cluster_templates:
- -
runner: runner:
type: "constant" type: "constant"
@ -9,7 +9,7 @@
users: users:
tenants: 1 tenants: 1
users_per_tenant: 1 users_per_tenant: 1
baymodels: cluster_templates:
image_id: "fedora-atomic-latest" image_id: "fedora-atomic-latest"
flavor_id: "m1.small" flavor_id: "m1.small"
master_flavor_id: "m1.small" master_flavor_id: "m1.small"
@ -33,7 +33,7 @@
users: users:
tenants: 1 tenants: 1
users_per_tenant: 1 users_per_tenant: 1
baymodels: cluster_templates:
image_id: "fedora-atomic-latest" image_id: "fedora-atomic-latest"
flavor_id: "m1.small" flavor_id: "m1.small"
master_flavor_id: "m1.small" master_flavor_id: "m1.small"
@ -48,7 +48,7 @@
failure_rate: failure_rate:
max: 0 max: 0
MagnumBays.create_and_list_bays: MagnumClusters.create_and_list_clusters:
- -
args: args:
node_count: 1 node_count: 1
@ -60,7 +60,7 @@
users: users:
tenants: 1 tenants: 1
users_per_tenant: 1 users_per_tenant: 1
baymodels: cluster_templates:
image_id: "fedora-atomic-latest" image_id: "fedora-atomic-latest"
flavor_id: "m1.small" flavor_id: "m1.small"
master_flavor_id: "m1.small" master_flavor_id: "m1.small"

View File

@ -90,16 +90,16 @@ class MagnumMixin(base.ResourceManager):
return result return result
@base.resource("magnum", "bays", order=next(_magnum_order), @base.resource("magnum", "clusters", order=next(_magnum_order),
tenant_resource=True) tenant_resource=True)
class MagnumBay(MagnumMixin): class MagnumCluster(MagnumMixin):
"""Resource class for Magnum bay.""" """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) tenant_resource=True)
class MagnumBaymodel(MagnumMixin): class MagnumClusterTemplate(MagnumMixin):
"""Resource class for Magnum baymodel.""" """Resource class for Magnum cluster_template."""
# HEAT # HEAT

View File

@ -0,0 +1,134 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from rally.common.i18n import _
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally.plugins.openstack.cleanup import manager as resource_manager
from rally.plugins.openstack.scenarios.magnum import utils as magnum_utils
from rally.plugins.openstack.scenarios.nova import utils as nova_utils
from rally.task import context
LOG = logging.getLogger(__name__)
@context.configure(name="cluster_templates", order=470)
class ClusterTemplateGenerator(context.Context):
"""Context class for generating temporary cluster model for benchmarks."""
CONFIG_SCHEMA = {
"type": "object",
"$schema": consts.JSON_SCHEMA,
"properties": {
"image_id": {
"type": "string"
},
"flavor_id": {
"type": "string"
},
"master_flavor_id": {
"type": "string"
},
"external_network_id": {
"type": "string"
},
"fixed_network": {
"type": "string"
},
"fixed_subnet": {
"type": "string"
},
"dns_nameserver": {
"type": "string"
},
"docker_volume_size": {
"type": "integer"
},
"labels": {
"type": ["string"]
},
"coe": {
"type": "string"
},
"http_proxy": {
"type": "string"
},
"https_proxy": {
"type": "string"
},
"no_proxy": {
"type": "string"
},
"network_driver": {
"type": "string"
},
"tls_disabled": {
"type": "boolean"
},
"public": {
"type": "boolean"
},
"registry_enabled": {
"type": "boolean"
},
"volume_driver": {
"type": "string"
},
"server_type": {
"type": "string"
},
"docker_storage_driver": {
"type": "string"
},
"master_lb_enabled": {
"type": "boolean"
}
},
"required": ["image_id", "external_network_id", "coe"],
"additionalProperties": False
}
@logging.log_task_wrapper(LOG.info, _("Enter context: `ClusterTemplate`"))
def setup(self):
for user, tenant_id in rutils.iterate_per_tenants(
self.context["users"]):
nova_scenario = nova_utils.NovaScenario({
"user": user,
"task": self.context["task"],
"config": {"api_versions": self.context["config"].get(
"api_versions", [])}
})
keypair = nova_scenario._create_keypair()
magnum_scenario = magnum_utils.MagnumScenario({
"user": user,
"task": self.context["task"],
"config": {"api_versions": self.context["config"].get(
"api_versions", [])}
})
cluster_template = magnum_scenario._create_cluster_template(
keypair_id=keypair, **self.config)
ct_uuid = cluster_template.uuid
self.context["tenants"][tenant_id]["cluster_template"] = ct_uuid
@logging.log_task_wrapper(LOG.info, _("Exit context: `ClusterTemplate`"))
def cleanup(self):
resource_manager.cleanup(
names=["magnum.cluster_templates", "nova.keypairs"],
users=self.context.get("users", []))

View File

@ -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.
from rally.common.i18n import _
from rally.common import logging
from rally.common import utils as rutils
from rally import consts
from rally.plugins.openstack.cleanup import manager as resource_manager
from rally.plugins.openstack.scenarios.magnum import utils as magnum_utils
from rally.task import context
LOG = logging.getLogger(__name__)
@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": {
"cluster_template_uuid": {
"type": "string"
},
"node_count": {
"type": "integer",
"minimum": 1,
"default": 1
},
},
"additionalProperties": False
}
@logging.log_task_wrapper(LOG.info, _("Enter context: `Cluster`"))
def setup(self):
for user, tenant_id in rutils.iterate_per_tenants(
self.context["users"]):
magnum_scenario = magnum_utils.MagnumScenario({
"user": user,
"task": self.context["task"],
"config": {"api_versions": self.context["config"].get(
"api_versions", [])}
})
# create a cluster
ct_uuid = self.config.get("cluster_template_uuid", None)
if ct_uuid is None:
ctx = self.context["tenants"][tenant_id]
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]["cluster"] = cluster.uuid
@logging.log_task_wrapper(LOG.info, _("Exit context: `Cluster`"))
def cleanup(self):
resource_manager.cleanup(
names=["magnum.clusters"],
users=self.context.get("users", []))

View File

@ -0,0 +1,45 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.magnum import utils
from rally.task import validation
"""Scenarios for Magnum cluster_templates."""
@validation.required_services(consts.Service.MAGNUM)
@validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["magnum"]},
name="MagnumClusterTemplates.list_cluster_templates")
class ListClusterTemplates(utils.MagnumScenario):
def run(self, **kwargs):
"""List all cluster_templates.
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 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 cluster_templates
listing
"""
self._list_cluster_templates(**kwargs)

View File

@ -0,0 +1,65 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from rally import consts
from rally.plugins.openstack import scenario
from rally.plugins.openstack.scenarios.magnum import utils
from rally.task import validation
"""Scenarios for Magnum clusters."""
@validation.required_services(consts.Service.MAGNUM)
@validation.required_openstack(users=True)
@scenario.configure(context={"cleanup": ["magnum.clusters"]},
name="MagnumClusters.list_clusters")
class ListClusters(utils.MagnumScenario):
def run(self, **kwargs):
"""List all clusters.
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 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 clusters listing
"""
self._list_clusters(**kwargs)
@validation.required_services(consts.Service.MAGNUM)
@validation.required_openstack(users=True)
@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 cluster and then list all clusters.
: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
"""
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)

View File

@ -20,17 +20,18 @@ from rally.task import atomic
from rally.task import utils from rally.task import utils
MAGNUM_BENCHMARK_OPTS = [ MAGNUM_BENCHMARK_OPTS = [
cfg.FloatOpt("magnum_bay_create_prepoll_delay", cfg.FloatOpt("magnum_cluster_create_prepoll_delay",
default=5.0, default=5.0,
help="Time(in sec) to sleep after creating a resource before " help="Time(in sec) to sleep after creating a resource before "
"polling for the status."), "polling for the status."),
cfg.FloatOpt("magnum_bay_create_timeout", cfg.FloatOpt("magnum_cluster_create_timeout",
default=1200.0, default=1200.0,
help="Time(in sec) to wait for magnum bay to be created."), help="Time(in sec) to wait for magnum cluster to be "
cfg.FloatOpt("magnum_bay_create_poll_interval", "created."),
cfg.FloatOpt("magnum_cluster_create_poll_interval",
default=1.0, default=1.0,
help="Time interval(in sec) between checks when waiting for " help="Time interval(in sec) between checks when waiting for "
"bay creation."), "cluster creation."),
] ]
CONF = cfg.CONF CONF = cfg.CONF
@ -41,76 +42,78 @@ CONF.register_opts(MAGNUM_BENCHMARK_OPTS, group=benchmark_group)
class MagnumScenario(scenario.OpenStackScenario): class MagnumScenario(scenario.OpenStackScenario):
"""Base class for Magnum scenarios with basic atomic actions.""" """Base class for Magnum scenarios with basic atomic actions."""
@atomic.action_timer("magnum.list_baymodels") @atomic.action_timer("magnum.list_cluster_templates")
def _list_baymodels(self, **kwargs): def _list_cluster_templates(self, **kwargs):
"""Return list of baymodels. """Return list of cluster_templates.
:param limit: (Optional) The maximum number of results to return :param limit: (Optional) The maximum number of results to return
per request, if: 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 2) limit param is NOT specified (None), the number of items
returned respect the maximum imposed by the Magnum API returned respect the maximum imposed by the Magnum API
(see Magnum's api.max_limit option). (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") @atomic.action_timer("magnum.create_cluster_template")
def _create_baymodel(self, **kwargs): def _create_cluster_template(self, **kwargs):
"""Create a baymodel """Create a cluster_template
:param kwargs: optional additional arguments for baymodel creation :param kwargs: optional additional arguments for cluster_template
:returns: magnum baymodel creation
:returns: magnum cluster_template
""" """
kwargs["name"] = self.generate_random_name() 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") @atomic.action_timer("magnum.list_clusters")
def _list_bays(self, limit=None, **kwargs): def _list_clusters(self, limit=None, **kwargs):
"""Return list of bays. """Return list of clusters.
:param limit: (Optional) the maximum number of results to return :param limit: (Optional) the maximum number of results to return
per request, if: 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 2) limit param is NOT specified (None), the number of items
returned respect the maximum imposed by the Magnum API returned respect the maximum imposed by the Magnum API
(see Magnum's api.max_limit option). (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") @atomic.action_timer("magnum.create_cluster")
def _create_bay(self, baymodel, node_count, **kwargs): def _create_cluster(self, cluster_template, node_count, **kwargs):
"""Create a bay """Create a cluster
:param baymodel: baymodel for the bay :param cluster_template: cluster_template for the cluster
:param node_count: the bay node count :param node_count: the cluster node count
:param kwargs: optional additional arguments for bay creation :param kwargs: optional additional arguments for cluster creation
:returns: magnum bay :returns: magnum cluster
""" """
name = self.generate_random_name() name = self.generate_random_name()
bay = self.clients("magnum").bays.create( cluster = self.clients("magnum").clusters.create(
name=name, baymodel_id=baymodel, name=name, cluster_template_id=cluster_template,
node_count=node_count, **kwargs) node_count=node_count, **kwargs)
common_utils.interruptable_sleep( common_utils.interruptable_sleep(
CONF.benchmark.magnum_bay_create_prepoll_delay) CONF.benchmark.magnum_cluster_create_prepoll_delay)
bay = utils.wait_for_status( cluster = utils.wait_for_status(
bay, cluster,
ready_statuses=["CREATE_COMPLETE"], ready_statuses=["CREATE_COMPLETE"],
update_resource=utils.get_from_manager(), update_resource=utils.get_from_manager(),
timeout=CONF.benchmark.magnum_bay_create_timeout, timeout=CONF.benchmark.magnum_cluster_create_timeout,
check_interval=CONF.benchmark.magnum_bay_create_poll_interval, check_interval=CONF.benchmark.magnum_cluster_create_poll_interval,
id_attr="uuid" id_attr="uuid"
) )
return bay return cluster

View File

@ -0,0 +1,78 @@
{
"MagnumClusters.create_and_list_clusters": [
{
"runner": {
"type": "constant",
"concurrency": 1,
"times": 1
},
"args": {
"node_count": 1
},
"context": {
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"docker_volume_size": 5,
"coe": "kubernetes",
"image_id": "fedora-atomic-latest",
"network_driver": "flannel"
},
"users": {
"users_per_tenant": 1,
"tenants": 1
}
}
},
{
"runner": {
"type": "constant",
"concurrency": 1,
"times": 1
},
"args": {
"node_count": 1
},
"context": {
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"docker_volume_size": 5,
"coe": "swarm",
"image_id": "fedora-atomic-latest",
"network_driver": "docker"
},
"users": {
"users_per_tenant": 1,
"tenants": 1
}
}
},
{
"runner": {
"type": "constant",
"concurrency": 1,
"times": 1
},
"args": {
"node_count": 1
},
"context": {
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"coe": "mesos",
"image_id": "ubuntu-mesos",
"network_driver": "docker"
},
"users": {
"users_per_tenant": 1,
"tenants": 1
}
}
}
]
}

View File

@ -0,0 +1,58 @@
---
MagnumClusters.create_and_list_clusters:
-
args:
node_count: 1
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
cluster_templates:
image_id: "fedora-atomic-latest"
external_network_id: "public"
dns_nameserver: "8.8.8.8"
flavor_id: "m1.small"
docker_volume_size: 5
network_driver: "flannel"
coe: "kubernetes"
-
args:
node_count: 1
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
cluster_templates:
image_id: "fedora-atomic-latest"
external_network_id: "public"
dns_nameserver: "8.8.8.8"
flavor_id: "m1.small"
docker_volume_size: 5
network_driver: "docker"
coe: "swarm"
-
args:
node_count: 1
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
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"

View File

@ -0,0 +1,69 @@
{
"MagnumClusterTemplates.list_cluster_templates": [
{
"runner": {
"type": "constant",
"concurrency": 1,
"times": 1
},
"context": {
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"docker_volume_size": 5,
"coe": "kubernetes",
"image_id": "fedora-atomic-latest",
"network_driver": "flannel"
},
"users": {
"users_per_tenant": 1,
"tenants": 1
}
}
},
{
"runner": {
"type": "constant",
"concurrency": 1,
"times": 1
},
"context": {
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"docker_volume_size": 5,
"coe": "swarm",
"image_id": "fedora-atomic-latest",
"network_driver": "docker"
},
"users": {
"users_per_tenant": 1,
"tenants": 1
}
}
},
{
"runner": {
"type": "constant",
"concurrency": 1,
"times": 1
},
"context": {
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"coe": "mesos",
"image_id": "ubuntu-mesos",
"network_driver": "docker"
},
"users": {
"users_per_tenant": 1,
"tenants": 1
}
}
}
]
}

View File

@ -0,0 +1,52 @@
---
MagnumClusterTemplates.list_cluster_templates:
-
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
cluster_templates:
image_id: "fedora-atomic-latest"
external_network_id: "public"
dns_nameserver: "8.8.8.8"
flavor_id: "m1.small"
docker_volume_size: 5
network_driver: "flannel"
coe: "kubernetes"
-
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
cluster_templates:
image_id: "fedora-atomic-latest"
external_network_id: "public"
dns_nameserver: "8.8.8.8"
flavor_id: "m1.small"
docker_volume_size: 5
network_driver: "docker"
coe: "swarm"
-
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
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"

View File

@ -0,0 +1,78 @@
{
"MagnumClusters.list_clusters": [
{
"runner": {
"type": "constant",
"concurrency": 1,
"times": 1
},
"context": {
"clusters": {
"node_count": 2
},
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"docker_volume_size": 5,
"coe": "kubernetes",
"image_id": "fedora-atomic-latest",
"network_driver": "flannel"
},
"users": {
"users_per_tenant": 1,
"tenants": 1
}
}
},
{
"runner": {
"type": "constant",
"concurrency": 1,
"times": 1
},
"context": {
"clusters": {
"node_count": 2
},
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"docker_volume_size": 5,
"coe": "swarm",
"image_id": "fedora-atomic-latest",
"network_driver": "docker"
},
"users": {
"users_per_tenant": 1,
"tenants": 1
}
}
},
{
"runner": {
"type": "constant",
"concurrency": 1,
"times": 1
},
"context": {
"clusters": {
"node_count": 2
},
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"coe": "mesos",
"image_id": "ubuntu-mesos",
"network_driver": "docker"
},
"users": {
"users_per_tenant": 1,
"tenants": 1
}
}
}
]
}

View File

@ -0,0 +1,58 @@
---
MagnumClusters.list_clusters:
-
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
cluster_templates:
image_id: "fedora-atomic-latest"
external_network_id: "public"
dns_nameserver: "8.8.8.8"
flavor_id: "m1.small"
docker_volume_size: 5
network_driver: "flannel"
coe: "kubernetes"
clusters:
node_count: 2
-
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
cluster_templates:
image_id: "fedora-atomic-latest"
external_network_id: "public"
dns_nameserver: "8.8.8.8"
flavor_id: "m1.small"
docker_volume_size: 5
network_driver: "docker"
coe: "swarm"
clusters:
node_count: 2
-
runner:
type: "constant"
times: 1
concurrency: 1
context:
users:
tenants: 1
users_per_tenant: 1
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"
clusters:
node_count: 2

View File

@ -96,26 +96,26 @@ class Magnum(ResourceManager):
REQUIRED_SERVICE = consts.Service.MAGNUM REQUIRED_SERVICE = consts.Service.MAGNUM
def list_baymodels(self): def list_cluster_templates(self):
result = [] result = []
marker = None marker = None
while True: while True:
baymodels = self.client.baymodels.list(marker=marker) ct_list = self.client.cluster_templates.list(marker=marker)
if not baymodels: if not ct_list:
break break
result.extend(baymodels) result.extend(ct_list)
marker = baymodels[-1].uuid marker = ct_list[-1].uuid
return result return result
def list_bays(self): def list_clusters(self):
result = [] result = []
marker = None marker = None
while True: while True:
bays = self.client.bays.list(marker=marker) clusters = self.client.clusters.list(marker=marker)
if not bays: if not clusters:
break break
result.extend(bays) result.extend(clusters)
marker = bays[-1].uuid marker = clusters[-1].uuid
return result return result

View File

@ -322,7 +322,7 @@ class FakeObject(FakeResource):
pass pass
class FakeBaymodel(FakeResource): class FakeClusterTemplate(FakeResource):
pass pass
@ -518,12 +518,12 @@ class FakeKeypairManager(FakeManager):
self.resources_order.remove(resource) self.resources_order.remove(resource)
class FakeBaymodelManager(FakeManager): class FakeClusterTemplateManager(FakeManager):
def create(self, name): def create(self, name):
baymodel = FakeBaymodel(self) cluster_template = FakeClusterTemplate(self)
baymodel.name = name or baymodel.name cluster_template.name = name or cluster_template.name
return self._cache(baymodel) return self._cache(cluster_template)
def delete(self, resource): def delete(self, resource):
if not isinstance(resource, six.string_types): if not isinstance(resource, six.string_types):
@ -1533,7 +1533,7 @@ class FakeSenlinClient(object):
class FakeMagnumClient(object): class FakeMagnumClient(object):
def __init__(self): def __init__(self):
self.baymodels = FakeBaymodelManager() self.cluster_templates = FakeClusterTemplateManager()
class FakeWatcherClient(object): class FakeWatcherClient(object):

View File

@ -0,0 +1,108 @@
# 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 mock
from rally.plugins.openstack.context.magnum import cluster_templates
from tests.unit import fakes
from tests.unit import test
BASE_CTX = "rally.task.context"
CTX = "rally.plugins.openstack.context"
BASE_SCN = "rally.task.scenarios"
SCN = "rally.plugins.openstack.scenarios"
class ClusterTemplatesGeneratorTestCase(test.ScenarioTestCase):
"""Generate tenants."""
def _gen_tenants(self, count):
tenants = {}
for id_ in range(count):
tenants[str(id_)] = dict(name=str(id_))
return tenants
@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__create_cluster_template):
tenants_count = 2
users_per_tenant = 5
tenants = self._gen_tenants(tenants_count)
users = []
for ten_id in tenants:
for i in range(users_per_tenant):
users.append({"id": i, "tenant_id": ten_id,
"credential": mock.MagicMock()})
self.context.update({
"config": {
"users": {
"tenants": tenants_count,
"users_per_tenant": users_per_tenant,
"concurrent": 10,
},
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"docker_volume_size": 5,
"coe": "kubernetes",
"image_id": "fedora-atomic-latest",
"network_driver": "flannel"
}
},
"users": users,
"tenants": tenants
})
ct_ctx = cluster_templates.ClusterTemplateGenerator(self.context)
ct_ctx.setup()
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 = 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,
flavor_id=flavor_id,
docker_volume_size=docker_volume_size,
network_driver=network_driver, coe=coe)
for i in range(tenants_count)]
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]["cluster_template"])
@mock.patch("%s.magnum.cluster_templates.resource_manager.cleanup" % CTX)
def test_cleanup(self, mock_cleanup):
self.context.update({
"users": mock.MagicMock()
})
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"])

View File

@ -0,0 +1,150 @@
# 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 copy
import mock
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 ClustersGeneratorTestCase(test.ScenarioTestCase):
def _gen_tenants(self, count):
tenants = {}
for id_ in range(count):
tenants[str(id_)] = {"name": str(id_)}
return tenants
def _gen_tenants_with_cluster_template(self, count):
tenants = {}
for id_ in range(count):
tenants[str(id_)] = {"name": str(id_)}
tenants[str(id_)]["cluster_template"] = "rally_ct_uuid"
return tenants
@mock.patch("%s.magnum.utils.MagnumScenario._create_cluster" % SCN,
return_value=mock.Mock())
def test_setup_using_existing_cluster_template(self, mock__create_cluster):
tenants_count = 2
users_per_tenant = 5
tenants = self._gen_tenants(tenants_count)
users = []
for ten_id in tenants:
for i in range(users_per_tenant):
users.append({"id": i, "tenant_id": ten_id,
"credential": mock.MagicMock()})
self.context.update({
"config": {
"users": {
"tenants": tenants_count,
"users_per_tenant": users_per_tenant,
"concurrent": 10,
},
"clusters": {
"cluster_template_uuid": "123456789",
"node_count": 2
}
},
"users": users,
"tenants": tenants
})
mock_cluster = mock__create_cluster.return_value
new_context = copy.deepcopy(self.context)
for id_ in new_context["tenants"]:
new_context["tenants"][id_]["cluster"] = mock_cluster.uuid
cluster_ctx = clusters.ClusterGenerator(self.context)
cluster_ctx.setup()
self.assertEqual(new_context, self.context)
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__create_cluster.assert_has_calls(mock_calls)
@mock.patch("%s.magnum.utils.MagnumScenario._create_cluster" % SCN,
return_value=mock.Mock())
def test_setup(self, mock__create_cluster):
tenants_count = 2
users_per_tenant = 5
tenants = self._gen_tenants_with_cluster_template(tenants_count)
users = []
for ten_id in tenants:
for i in range(users_per_tenant):
users.append({"id": i, "tenant_id": ten_id,
"credential": mock.MagicMock()})
self.context.update({
"config": {
"users": {
"tenants": tenants_count,
"users_per_tenant": users_per_tenant,
"concurrent": 10,
},
"cluster_templates": {
"dns_nameserver": "8.8.8.8",
"external_network_id": "public",
"flavor_id": "m1.small",
"docker_volume_size": 5,
"coe": "kubernetes",
"image_id": "fedora-atomic-latest",
"network_driver": "flannel"
},
"clusters": {
"node_count": 2
}
},
"users": users,
"tenants": tenants
})
mock_cluster = mock__create_cluster.return_value
new_context = copy.deepcopy(self.context)
for id_ in new_context["tenants"]:
new_context["tenants"][id_]["cluster"] = mock_cluster.uuid
cluster_ctx = clusters.ClusterGenerator(self.context)
cluster_ctx.setup()
self.assertEqual(new_context, self.context)
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__create_cluster.assert_has_calls(mock_calls)
@mock.patch("%s.cluster_templates.resource_manager.cleanup" % CTX)
def test_cleanup(self, mock_cleanup):
self.context.update({
"users": mock.MagicMock()
})
clusters_ctx = clusters.ClusterGenerator(self.context)
clusters_ctx.cleanup()
mock_cleanup.assert_called_once_with(
names=["magnum.clusters"],
users=self.context["users"])

View File

@ -0,0 +1,35 @@
# 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 cluster_templates
from tests.unit import test
@ddt.ddt
class MagnumClusterTemplatesTestCase(test.TestCase):
@ddt.data(
{"kwargs": {}},
{"kwargs": {"fakearg": "f"}})
@ddt.unpack
def test_list_cluster_templates(self, kwargs):
scenario = cluster_templates.ListClusterTemplates()
scenario._list_cluster_templates = mock.Mock()
scenario.run(**kwargs)
scenario._list_cluster_templates.assert_called_once_with(**kwargs)

View File

@ -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)

View File

@ -23,28 +23,28 @@ CONF = utils.CONF
class MagnumScenarioTestCase(test.ScenarioTestCase): class MagnumScenarioTestCase(test.ScenarioTestCase):
def setUp(self): def setUp(self):
super(MagnumScenarioTestCase, self).setUp() super(MagnumScenarioTestCase, self).setUp()
self.baymodel = mock.Mock() self.cluster_template = mock.Mock()
self.bay = mock.Mock() self.cluster = mock.Mock()
self.scenario = utils.MagnumScenario(self.context) self.scenario = utils.MagnumScenario(self.context)
def test_list_baymodels(self): def test_list_cluster_templates(self):
fake_baymodel_list = [self.baymodel] fake_list = [self.cluster_template]
self.clients("magnum").baymodels.list.return_value = fake_baymodel_list self.clients("magnum").cluster_templates.list.return_value = fake_list
return_baymodels_list = self.scenario._list_baymodels() return_ct_list = self.scenario._list_cluster_templates()
self.assertEqual(fake_baymodel_list, return_baymodels_list) 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(), 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( self.scenario.generate_random_name = mock.Mock(
return_value="generated_name") return_value="generated_name")
fake_baymodel = self.baymodel fake_ct = self.cluster_template
self.clients("magnum").baymodels.create.return_value = fake_baymodel 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", image="test_image",
keypair="test_key", keypair="test_key",
external_network="public", external_network="public",
@ -54,40 +54,41 @@ class MagnumScenarioTestCase(test.ScenarioTestCase):
network_driver="docker", network_driver="docker",
coe="swarm") coe="swarm")
self.assertEqual(fake_baymodel, return_baymodel) self.assertEqual(fake_ct, return_cluster_template)
args, kwargs = self.clients("magnum").baymodels.create.call_args _, kwargs = self.clients("magnum").cluster_templates.create.call_args
self.assertEqual("generated_name", kwargs["name"]) self.assertEqual("generated_name", kwargs["name"])
self._test_atomic_action_timer(self.scenario.atomic_actions(), self._test_atomic_action_timer(self.scenario.atomic_actions(),
"magnum.create_baymodel") "magnum.create_cluster_template")
def test_list_bays(self): def test_list_clusters(self):
return_bays_list = self.scenario._list_bays(limit="foo1") return_clusters_list = self.scenario._list_clusters(limit="foo1")
self.clients("magnum").bays.list.assert_called_once_with(limit="foo1") client = self.clients("magnum")
self.assertEqual(self.clients("magnum").bays.list.return_value, client.clusters.list.assert_called_once_with(limit="foo1")
return_bays_list) self.assertEqual(client.clusters.list.return_value,
return_clusters_list)
self._test_atomic_action_timer( 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( self.scenario.generate_random_name = mock.Mock(
return_value="generated_name") return_value="generated_name")
self.clients("magnum").bays.create.return_value = self.bay self.clients("magnum").clusters.create.return_value = self.cluster
return_bay = self.scenario._create_bay( return_cluster = self.scenario._create_cluster(
baymodel="generated_uuid", node_count=2) cluster_template="generated_uuid", node_count=2)
self.mock_wait_for_status.mock.assert_called_once_with( self.mock_wait_for_status.mock.assert_called_once_with(
self.bay, self.cluster,
ready_statuses=["CREATE_COMPLETE"], ready_statuses=["CREATE_COMPLETE"],
update_resource=self.mock_get_from_manager.mock.return_value, update_resource=self.mock_get_from_manager.mock.return_value,
check_interval=CONF.benchmark. check_interval=CONF.benchmark.
magnum_bay_create_poll_interval, magnum_cluster_create_poll_interval,
timeout=CONF.benchmark.magnum_bay_create_timeout, timeout=CONF.benchmark.magnum_cluster_create_timeout,
id_attr="uuid") 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_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.mock_get_from_manager.mock.assert_called_once_with()
self.assertEqual( 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._test_atomic_action_timer(
self.scenario.atomic_actions(), "magnum.create_bay") self.scenario.atomic_actions(), "magnum.create_cluster")