Add pluging sample for glance gate
Recently we add support for plugins in gates, so now you are able to keep rally benchmarks in your source tree. It may be usefull in cases when you would like to check/debug in gates with benchmark that doens't exist in Rally but don't want to spend whole life to get in Rally source. As well we add extra/ directory that is just copy pasted in gates. So we can use absolute path in task configs, cause this directory will be copy pasted to ~/.rally/extra. This may be super usefull if you would like to test infrastracture on scale, creating images from empty files. Change-Id: I759ee8bf7a930169afd6076ec96f8fe3a3692866
This commit is contained in:
parent
ca6eb80ad4
commit
928004dec3
@ -1,5 +1,13 @@
|
||||
This directory contains rally benchmark scenarios to be run by OpenStack CI.
|
||||
|
||||
Structure:
|
||||
* glance.yaml is rally task that will be run in gates
|
||||
* plugins - directory where you can add rally plugins. So you don't need
|
||||
to merge benchmark in scenarios in rally to be able to run them in glance.
|
||||
* extra - all files from this directory will be copy pasted to gets, so you
|
||||
are able to use absolute path in rally tasks. Files will be in ~/.rally/extra/*
|
||||
|
||||
|
||||
* more about rally: https://wiki.openstack.org/wiki/Rally
|
||||
* how to add rally-gates: https://wiki.openstack.org/wiki/Rally/RallyGates
|
||||
* how to write plugins https://rally.readthedocs.org/en/latest/plugins.html
|
||||
|
0
rally-scenarios/extra/fake.img
Normal file
0
rally-scenarios/extra/fake.img
Normal file
@ -7,7 +7,7 @@
|
||||
disk_format: "qcow2"
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
times: 20
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
@ -22,9 +22,24 @@
|
||||
disk_format: "qcow2"
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 100
|
||||
times: 20
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 5
|
||||
users_per_tenant: 2
|
||||
|
||||
GlancePlugin.your_mega_benchmark:
|
||||
-
|
||||
args:
|
||||
image_location: "~/.rally/extra/fake.img"
|
||||
container_format: "bare"
|
||||
disk_format: "qcow2"
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 700
|
||||
concurrency: 7
|
||||
context:
|
||||
users:
|
||||
tenants: 1
|
||||
users_per_tenant: 1
|
||||
|
92
rally-scenarios/plugins/plugin_sample.py
Normal file
92
rally-scenarios/plugins/plugin_sample.py
Normal file
@ -0,0 +1,92 @@
|
||||
# Copyright 2014 Mirantis Inc.
|
||||
# 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.
|
||||
|
||||
""" Sample of plugin for Glance.
|
||||
|
||||
For more Glance related benchmarks take a look here:
|
||||
github.com/stackforge/rally/blob/master/rally/benchmark/scenarios/glance/
|
||||
|
||||
About plugins: https://rally.readthedocs.org/en/latest/plugins.html
|
||||
|
||||
Rally concepts https://wiki.openstack.org/wiki/Rally/Concepts
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from rally.benchmark.scenarios import base
|
||||
from rally.benchmark.scenarios import utils as scenario_utils
|
||||
from rally.benchmark import utils as bench_utils
|
||||
|
||||
|
||||
class GlancePlugin(base.Scenario):
|
||||
|
||||
@scenario_utils.atomic_action_timer("glance.create_image_label")
|
||||
def _create_image(self, image_name, container_format,
|
||||
image_location, disk_format, **kwargs):
|
||||
"""Create a new image.
|
||||
|
||||
:param image_name: String used to name the image
|
||||
:param container_format: Container format of image.
|
||||
Acceptable formats: ami, ari, aki, bare, and ovf.
|
||||
:param image_location: image file location used to upload
|
||||
:param disk_format: Disk format of image. Acceptable formats:
|
||||
ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso.
|
||||
:param **kwargs: optional parameters to create image
|
||||
|
||||
returns: object of image
|
||||
"""
|
||||
|
||||
kw = {
|
||||
"name": image_name,
|
||||
"container_format": container_format,
|
||||
"disk_format": disk_format,
|
||||
}
|
||||
|
||||
kw.update(kwargs)
|
||||
|
||||
try:
|
||||
if os.path.isfile(os.path.expanduser(image_location)):
|
||||
kw["data"] = open(os.path.expanduser(image_location))
|
||||
else:
|
||||
kw["copy_from"] = image_location
|
||||
|
||||
image = self.clients("glance").images.create(**kw)
|
||||
|
||||
image = bench_utils.wait_for(
|
||||
image,
|
||||
is_ready=bench_utils.resource_is("active"),
|
||||
update_resource=bench_utils.get_from_manager(),
|
||||
timeout=100,
|
||||
check_interval=0.5)
|
||||
|
||||
finally:
|
||||
if "data" in kw:
|
||||
kw["data"].close()
|
||||
|
||||
return image
|
||||
|
||||
@scenario_utils.atomic_action_timer("glance.list_images_label")
|
||||
def _list_images(self):
|
||||
return list(self.clients("glance").images.list())
|
||||
|
||||
@base.scenario(context={"cleanup": ["glance"]})
|
||||
def your_mega_benchmark(self, container_format,
|
||||
image_location, disk_format, **kwargs):
|
||||
self._create_image(self._generate_random_name(),
|
||||
container_format,
|
||||
image_location,
|
||||
disk_format,
|
||||
**kwargs)
|
||||
self._list_images()
|
Loading…
Reference in New Issue
Block a user