提交 838cbbbd 编写于 作者: X Xu Tian 提交者: Lucas Meneghel Rodrigues

qemu.tests: new test to check image backingfile after stream done

new test to verify image file no backingfile after stream done;

changes from v1:
    update test steps in doc string;
Signed-off-by: NXu Tian <xutian@redhat.com>
上级 8ff472c3
import logging
from autotest.client.shared import error
from qemu.tests import blk_stream
class BlockStreamCheckBackingfile(blk_stream.BlockStream):
def __init__(self, test, params, env, tag):
super(BlockStreamCheckBackingfile, self).__init__(test,
params, env, tag)
@error.context_aware
def check_backingfile(self):
"""
check no backingfile found after stream job done via qemu-img info;
"""
fail = False
error.context("Check image file backing-file", logging.info)
backingfile = self.get_backingfile("qemu-img")
if backingfile:
img_file = self.get_image_file()
logging.debug("Got backing-file: %s" % backingfile +
"by 'qemu-img info %s'" % img_file)
fail |= bool(backingfile)
backingfile = self.get_backingfile("monitor")
if backingfile:
logging.debug("Got backing-file: %s" % backingfile +
"by 'info/query block' " +
"in %s monitor" % self.vm.monitor.protocol)
fail |= bool(backingfile)
if fail:
msg = ("Unexpected backing file found, there should be "
"no backing file")
raise error.TestFail(msg)
@error.context_aware
def check_imagefile(self):
"""
verify current image file is expected image file
"""
params = self.parser_test_args()
exp_img_file = params["expected_image_file"]
error.context("Check image file is '%s'" % exp_img_file, logging.info)
img_file = self.get_image_file()
if exp_img_file != img_file:
msg = "Excepted image file: %s," % exp_img_file
msg += "Actual image file: %s" % img_file
raise error.TestFail(msg)
def run_block_stream_check_backingfile(test, params, env):
"""
block_stream.check_backingfile test:
1). boot up vm and create snapshots;
2). start block steam job, then wait block job done;
3). check backing-file in monitor and qemu-img command;
4). verify image file is excepted image file;
5). vierfy guest is alive;
@param test: QEMU test object
@param params: Dictionary with the test parameters
@param env: Dictionary with test environment.
"""
tag = params.get("source_images", "image1")
backingfile_test = BlockStreamCheckBackingfile(test, params, env, tag)
try:
backingfile_test.create_snapshots()
backingfile_test.start()
backingfile_test.action_after_finished()
finally:
backingfile_test.clean()
......@@ -48,6 +48,11 @@
# set limited_speed to 10MB/s eq 10485760B/s
limited_speed = 10485760
snapshot_check_cmd = "lsof -p %s|awk '{print $9}'|grep ^/"
- check_backingfile:
type = block_stream_check_backingfile
snapshot_chain = "/tmp/sn1"
expected_image_file = "/tmp/sn1"
after_finished = "check_backingfile check_imagefile verify_alive"
- with_stress:
type = block_stream_stress
wait_timeout = 3600
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册