diff --git a/rally-scenarios/ec2-api-fakevirt.yaml b/rally-scenarios/ec2-api-fakevirt.yaml index 4aee2427..ae4a705c 100644 --- a/rally-scenarios/ec2-api-fakevirt.yaml +++ b/rally-scenarios/ec2-api-fakevirt.yaml @@ -3,7 +3,7 @@ - runner: type: "constant" - times: 20 + times: 2 concurrency: 1 context: users: @@ -14,7 +14,7 @@ name: "m1.nano" image: name: "^cirros.*uec$" - servers_per_tenant: 500 + servers_per_tenant: 1 prepare_ec2_client: EC2APIPlugin.describe_regions: @@ -28,3 +28,19 @@ tenants: 1 users_per_tenant: 1 prepare_ec2_client: + + EC2APIPlugin.describe_images: + - + runner: + type: "constant" + times: 20 + concurrency: 1 + context: + users: + tenants: 1 + users_per_tenant: 1 + fake_images: + disk_format: "ami" + container_format: "ami" + images_per_tenant: 1000 + prepare_ec2_client: diff --git a/rally-scenarios/plugins/context_plugin.py b/rally-scenarios/plugins/context_plugin_ec2.py similarity index 100% rename from rally-scenarios/plugins/context_plugin.py rename to rally-scenarios/plugins/context_plugin_ec2.py diff --git a/rally-scenarios/plugins/context_plugin_images.py b/rally-scenarios/plugins/context_plugin_images.py new file mode 100644 index 00000000..1df7a118 --- /dev/null +++ b/rally-scenarios/plugins/context_plugin_images.py @@ -0,0 +1,83 @@ +# 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.benchmark.context import base +from rally.benchmark.scenarios import base as scenario_base +from rally.common.i18n import _ +from rally.common import log as logging +from rally.common import utils as rutils +from rally import consts +from rally import osclients + + +LOG = logging.getLogger(__name__) + + +@base.context(name="fake_images", order=411) +class FakeImageGenerator(base.Context): + """Context class for adding images to each user for benchmarks.""" + + CONFIG_SCHEMA = { + "type": "object", + "$schema": consts.JSON_SCHEMA, + "properties": { + "disk_format": { + "enum": ["qcow2", "raw", "vhd", "vmdk", "vdi", "iso", "aki", + "ari", "ami"], + }, + "container_format": { + "type": "string", + }, + "images_per_tenant": { + "type": "integer", + "minimum": 1 + }, + }, + "required": ["disk_format", "container_format", "images_per_tenant"], + "additionalProperties": False + } + + @rutils.log_task_wrapper(LOG.info, _("Enter context: `Images`")) + def setup(self): + disk_format = self.config["disk_format"] + container_format = self.config["container_format"] + images_per_tenant = self.config["images_per_tenant"] + + for user, tenant_id in rutils.iterate_per_tenants( + self.context["users"]): + glance = osclients.Clients(user["endpoint"]).glance().images + current_images = [] + for i in range(images_per_tenant): + kw = { + "name": scenario_base.Scenario._generate_random_name(), + "container_format": container_format, + "disk_format": disk_format, + "size": 1000000, + } + image = glance.create(**kw) + current_images.append(image.id) + + self.context["tenants"][tenant_id]["images"] = current_images + + @rutils.log_task_wrapper(LOG.info, _("Exit context: `Images`")) + def cleanup(self): + for user, tenant_id in rutils.iterate_per_tenants( + self.context["users"]): + glance = osclients.Clients(user["endpoint"]).glance().images + for image in self.context["tenants"][tenant_id].get("images", []): + with logging.ExceptionLogger( + LOG, + _("Failed to delete network for tenant %s") + % tenant_id): + glance.delete(image) diff --git a/rally-scenarios/plugins/ec2api_plugin.py b/rally-scenarios/plugins/ec2api_plugin.py index 7d877486..c2af09f5 100644 --- a/rally-scenarios/plugins/ec2api_plugin.py +++ b/rally-scenarios/plugins/ec2api_plugin.py @@ -57,3 +57,9 @@ class EC2APIPlugin(base.Scenario): def describe_regions(self, client): resp, data = client.DescribeRegions() assert 200 == resp.status_code + + @base.scenario() + @_both_api_runner() + def describe_images(self, client): + resp, data = client.DescribeImages() + assert 200 == resp.status_code