提交 9134d237 编写于 作者: Y Yiqiao Pu 提交者: Lucas Meneghel Rodrigues

qemu.tests: Add qcow2 performance cases

Add 5 qcow2 performance cases:
  - write
  - read
  - convert
  - rebase
  - commit

These tests will records the time for 1G size data operations.

changes from v1:
  - Update the log format for the results
  - Update the qemu-io command line with option -n
Signed-off-by: NYiqiao Pu <ypu@redhat.com>
Acked-by: NSuqin Huang <shuang@redhat.com>

Support -t parameter in commit, rebase, convert function

Changes from v1:
Add cache_mode as a parameter of rebase, commit, convert function.
Signed-off-by: NFeng Yang <fyang@redhat.com>

Send one command to write image by qemu-io
Before testing qcow2 performace, drop cache
Use "time strace -c" to get the result of commit/convert/rebase
Use "time" to test write/read time

changes from v1:
    1: instead commands.get_output function with frame function
    2: skip write offset 0 step when write offset 1 to get a clean image
    3: rename fd as result_file
changes from v2:
    1: remove "'\'" in code
    2: use writecmd to replace cmd, use iocmd to replace writecmd.
Signed-off-by: NXiaomei Gao <xigao@redhat.com>
Acked-by: NFeng Yang <fyang@redhat.com>
上级 8f4e46fb
- qcow2perf:
virt_test_type = qemu
only qcow2
type = qcow2perf
image_chain = "base"
image_name_base = images/base
image_format_base = qcow2
start_vm = no
image_size_base = 8G
writecmd = "for i in $(seq 1 %s); do echo write $((%s + i * %s))%s %s%s; done"
iocmd = "time %s |qemu-io -%s %s > /dev/null 2>&1"
variants:
- writeoffset0:
op_type = writeoffset0
- writeoffset1:
op_type = writeoffset1
- read:
op_type = read
opcmd = "time echo read 0 1G | qemu-io -%s %s"
- convert:
op_type = convert
image_convert = "convert"
image_size_convert = 8G
image_name_convert = "images/base-qcow2"
image_format_convert = qcow2
opcmd = "time strace -c qemu-img convert -f qcow2 %s -O qcow2 -t %s %s"
variants:
- default_test:
only Host_RHEL.5
- cache_none:
no Host_RHEL.5
cache_mode = none
- cache_unsafe:
no Host_RHEL.5
cache_mode = unsafe
- cache_writeback:
no Host_RHEL.5
cache_mode = writeback
- cache_writethrough:
no Host_RHEL.5
cache_mode = writethrough
- rebase:
op_type = rebase
image_chain += " sn1 sn2 sn3"
test_image = 3
new_base = "base1"
image_name_sn1 = "images/sn1"
image_name_sn2 = "images/sn2"
image_name_sn3 = "images/sn3"
image_name_base1 = "images/base1"
image_size_sn1 = 8G
image_size_sn2 = 8G
image_size_sn3 = 8G
image_size_base1 = 8G
opcmd = "time strace -c qemu-img rebase -F qcow2 -b %s -f qcow2 -t %s %s"
variants:
- default_test:
only Host_RHEL.5
- cache_none:
no Host_RHEL.5
cache_mode = none
- cache_unsafe:
no Host_RHEL.5
cache_mode = unsafe
- cache_writeback:
no Host_RHEL.5
cache_mode = writeback
- cache_writethrough:
no Host_RHEL.5
cache_mode = writethrough
- commit:
op_type = commit
image_chain += " sn1"
image_name_sn1 = "images/sn1"
image_size_sn1 = 8G
test_image = 1
opcmd = "time strace -c qemu-img commit -f qcow2 -t %s %s"
variants:
- default_test:
only Host_RHEL.5
- cache_none:
no Host_RHEL.5
cache_mode = none
- cache_unsafe:
no Host_RHEL.5
cache_mode = unsafe
- cache_writeback:
no Host_RHEL.5
cache_mode = writeback
- cache_writethrough:
no Host_RHEL.5
cache_mode = writethrough
- summary_qcow2perf:
start_vm = yes
type = performance
test = qcow2perf
summary_results = yes
marks = "TIME:real\s+([\d\.]+)h([\d\.]+)m([\d\.]+)s|real\s+([\d\.]+)m([\d\.]+)s|real\s+([\d\.]+)s"
file_list = "qcow2perf.*results"
no_table_list = "read writeoffset0 writeoffset1"
thread_tag = " "
import re, logging, time
from autotest.client.shared import error
from virttest import qemu_io, data_dir
from virttest.qemu_storage import QemuImg
from autotest.client import utils
@error.context_aware
def run_qcow2perf(test, params, env):
"""
Run qcow2 performance tests:
1. Create image with given parameters
2. Write to the image to prepare a certain size image
3. Do one operations to the image and measure the time
4. Record the results
@param test: QEMU test object
@param params: Dictionary with the test parameters
@param env: Dictionary with test environment.
"""
image_chain = params.get("image_chain")
test_image = int(params.get("test_image", "0"))
interval_size = params.get("interval_szie", "64k")
write_round = int(params.get("write_round", "16384"))
op_type = params.get("op_type")
new_base = params.get("new_base")
writecmd = params.get("writecmd")
iocmd = params.get("iocmd")
opcmd = params.get("opcmd")
io_options = params.get("io_options", "n")
cache_mode = params.get("cache_mode")
image_dir = data_dir.get_data_dir()
if not re.match("\d+", interval_size[-1]):
write_unit = interval_size[-1]
interval_size = int(interval_size[:-1])
else:
interval_size = int(interval_size)
write_unit = ""
error.context("Init images for testing", logging.info)
sn_list = []
for img in re.split("\s+", image_chain.strip()):
image_params = params.object_params(img)
sn_tmp = QemuImg(image_params, image_dir, img)
sn_tmp.create(image_params)
sn_list.append((sn_tmp, image_params))
# Write to the test image
error.context("Prepare the image with write a certain size block",
logging.info)
dropcache = 'echo 3 > /proc/sys/vm/drop_caches && sleep 5'
snapshot_file = sn_list[test_image][0].image_filename
if op_type != "writeoffset1":
offset = 0
writecmd0 = writecmd % (write_round,offset,interval_size,
write_unit,interval_size,write_unit)
iocmd0 = iocmd % (writecmd0, io_options, snapshot_file)
logging.info("writecmd-offset-0: %s", writecmd0)
utils.run(dropcache)
output = utils.run(iocmd0)
else:
offset = 1
writecmd1 = writecmd % (write_round,offset,interval_size,
write_unit,interval_size,write_unit)
iocmd1 = iocmd % (writecmd1, io_options, snapshot_file)
logging.info("writecmd-offset-1: %s", writecmd1)
utils.run(dropcache)
output = utils.run(iocmd1)
error.context("Do one operations to the image and measure the time",
logging.info)
if op_type == "read":
readcmd = opcmd % (io_options, snapshot_file)
logging.info("read: %s", readcmd)
utils.run(dropcache)
output = utils.run(readcmd)
elif op_type == "commit":
commitcmd = opcmd % (cache_mode, snapshot_file)
logging.info("commit: %s", commitcmd)
utils.run(dropcache)
output = utils.run(commitcmd)
elif op_type == "rebase":
new_base_img = QemuImg(params.object_params(new_base), image_dir,
new_base)
new_base_img.create(params.object_params(new_base))
rebasecmd = opcmd % (new_base_img.image_filename,
cache_mode, snapshot_file)
logging.info ("rebase: %s", rebasecmd)
utils.run(dropcache)
output = utils.run(rebasecmd)
elif op_type == "convert":
convertname = sn_list[test_image][0].image_filename + "_convert"
convertcmd = opcmd % (snapshot_file, cache_mode, convertname)
logging.info("convert: %s", convertcmd)
utils.run(dropcache)
output = utils.run(convertcmd)
error.context("Result recording", logging.info)
result_file = open("%s/%s_%s_results" % (test.resultsdir, "qcow2perf", op_type), 'w')
result_file.write("%s:%s\n" % (op_type, output))
logging.info("%s takes %s" % (op_type, output))
result_file.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册