diff options
-rw-r--r-- | samples/fio_volume.yaml | 74 | ||||
-rw-r--r-- | yardstick/benchmark/contexts/model.py | 19 | ||||
-rw-r--r-- | yardstick/common/openstack_utils.py | 24 | ||||
-rw-r--r-- | yardstick/orchestrator/heat.py | 34 |
4 files changed, 151 insertions, 0 deletions
diff --git a/samples/fio_volume.yaml b/samples/fio_volume.yaml new file mode 100644 index 000000000..edb3837e9 --- /dev/null +++ b/samples/fio_volume.yaml @@ -0,0 +1,74 @@ +############################################################################## +# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +--- +# Sample benchmark task config file +# measure storage performance using fio +# +# For this sample just like running the command below on the test vm and +# getting benchmark info back to the yardstick. +# +# sudo fio -filename=/home/ubuntu/data.raw -bs=4k -ipdepth=1 -rw=rw \ +# -ramp_time=10 -runtime=60 -name=yardstick-fio -ioengine=libaio \ +# -direct=1 -group_reporting -numjobs=1 -time_based \ +# --output-format=json + +schema: "yardstick:task:0.1" + +{% set rw = rw or "randrw" %} +{% set bs = bs or "8k" %} +{% set size = size or "100g" %} +{% set rwmixwrite = rwmixwrite or "50" %} +{% set numjobs = numjobs or "1" %} +{% set direct = direct or "1" %} + +scenarios: +- + type: Fio + options: + filename: /dev/vdb + bs: {{bs}} + rw: {{rw}} + size: {{size}} + rwmixwrite: {{rwmixwrite}} + numjobs: {{numjobs}} + direct: {{direct}} + ramp_time: 10 + + host: fio.fio_volume + + runner: + type: Duration + duration: 60 + interval: 1 + + sla: + read_bw: 6000 + read_iops: 1500 + read_lat: 500.1 + write_bw: 6000 + write_iops: 1500 + write_lat: 500.1 + action: monitor + +context: + name: fio_volume + image: yardstick-image + flavor: yardstick-flavor + user: ubuntu + servers: + fio: + volume: + name: fio-volume + size: 200 + volume_mountpoint: "/dev/vdb" + floating_ip: true + networks: + test: + cidr: "10.0.1.0/24" + port_security_enabled: true diff --git a/yardstick/benchmark/contexts/model.py b/yardstick/benchmark/contexts/model.py index ec474321f..0bf85d03d 100644 --- a/yardstick/benchmark/contexts/model.py +++ b/yardstick/benchmark/contexts/model.py @@ -184,6 +184,14 @@ class Server(Object): # pragma: no cover self.placement_groups.append(pg) pg.add_member(self.stack_name) + self.volume = None + if "volume" in attrs: + self.volume = attrs.get("volume") + + self.volume_mountpoint = None + if "volume_mountpoint" in attrs: + self.volume_mountpoint = attrs.get("volume_mountpoint") + # support servergroup attr self.server_group = None sg = attrs.get("server_group") @@ -283,6 +291,17 @@ class Server(Object): # pragma: no cover else: self.flavor_name = self.flavor + if self.volume: + if isinstance(self.volume, dict): + self.volume["name"] = \ + self.volume.setdefault("name", server_name + "-volume") + template.add_volume(**self.volume) + template.add_volume_attachment(server_name, self.volume["name"], + mountpoint=self.volume_mountpoint) + else: + template.add_volume_attachment(server_name, self.volume, + mountpoint=self.volume_mountpoint) + template.add_server(server_name, self.image, flavor=self.flavor_name, flavors=self.context.flavors, ports=port_name_list, diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py index 8787e605a..f027b7922 100644 --- a/yardstick/common/openstack_utils.py +++ b/yardstick/common/openstack_utils.py @@ -15,6 +15,7 @@ import logging from keystoneauth1 import loading from keystoneauth1 import session +from cinderclient import client as cinderclient from novaclient import client as novaclient from glanceclient import client as glanceclient from neutronclient.neutron import client as neutronclient @@ -108,6 +109,21 @@ def get_heat_api_version(): # pragma: no cover return api_version +def get_cinder_client_version(): # pragma: no cover + try: + api_version = os.environ['OS_VOLUME_API_VERSION'] + except KeyError: + return DEFAULT_API_VERSION + else: + log.info("OS_VOLUME_API_VERSION is set in env as '%s'", api_version) + return api_version + + +def get_cinder_client(): # pragma: no cover + sess = get_session() + return cinderclient.Client(get_cinder_client_version(), session=sess) + + def get_nova_client_version(): # pragma: no cover try: api_version = os.environ['OS_COMPUTE_API_VERSION'] @@ -430,3 +446,11 @@ def get_port_id_by_ip(neutron_client, ip_address): # pragma: no cover def get_image_id(glance_client, image_name): # pragma: no cover images = glance_client.images.list() return next((i.id for i in images if i.name == image_name), None) + + +# ********************************************* +# CINDER +# ********************************************* +def get_volume_id(volume_name): # pragma: no cover + volumes = get_cinder_client().volumes.list() + return next((v.id for v in volumes if v.name == volume_name), None) diff --git a/yardstick/orchestrator/heat.py b/yardstick/orchestrator/heat.py index 95ca0ad2e..05e359717 100644 --- a/yardstick/orchestrator/heat.py +++ b/yardstick/orchestrator/heat.py @@ -230,6 +230,40 @@ name (i.e. %s).\ 'value': {'get_resource': name} } + def add_volume(self, name, size=10): + """add to the template a volume description""" + log.debug("adding Cinder::Volume '%s' size '%d' ", name, size) + + self.resources[name] = { + 'type': 'OS::Cinder::Volume', + 'properties': {'name': name, + 'size': size} + } + + self._template['outputs'][name] = { + 'description': 'Volume %s ID' % name, + 'value': {'get_resource': name} + } + + def add_volume_attachment(self, server_name, volume_name, mountpoint=None): + """add to the template an association of volume to instance""" + log.debug("adding Cinder::VolumeAttachment server '%s' volume '%s' ", server_name, + volume_name) + + name = "%s-%s" % (server_name, volume_name) + + volume_id = op_utils.get_volume_id(volume_name) + if not volume_id: + volume_id = {'get_resource': volume_name} + self.resources[name] = { + 'type': 'OS::Cinder::VolumeAttachment', + 'properties': {'instance_uuid': {'get_resource': server_name}, + 'volume_id': volume_id} + } + + if mountpoint: + self.resources[name]['properties']['mountpoint'] = mountpoint + def add_network(self, name, physical_network='physnet1', provider=None, segmentation_id=None, port_security_enabled=None): """add to the template a Neutron Net""" |