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

qemu.tests: add qemu_disk_img_commit test

Implement new test to check qemu-img commit function;

Changes from V1:
    replace params.get() with params[] to avoid missing param errors.
Signed-off-by: NXu Tian <xutian@redhat.com>
上级 166a69c5
......@@ -36,3 +36,10 @@
image_format_sn1 = "qcow2"
convert_name_sn1 = "images/sn1_to_qcow2"
convert_format_sn1 = "qcow2"
- commit:
type = qemu_disk_img_commit
guest_file_name = /tmp/test.img
image_commit = "sn1"
image_chain += " sn1"
image_name_sn1 = "images/sn1"
image_format_sn1 = "qcow2"
import logging
from autotest.client.shared import error
from qemu.tests import qemu_disk_img
class CommitTest(qemu_disk_img.QemuImgTest):
def __init__(self, test, params, env):
self.tag = params.get("image_commit", "image1")
t_params = params.object_params(self.tag)
super(CommitTest, self).__init__(test, t_params, env, self.tag)
@error.context_aware
def commit(self, t_params={}):
"""
commit snapshot to backing file;
"""
error.context("commit snapshot to backingfile", logging.info)
params = self.params.object_params(self.tag)
params.update(t_params)
cache_mode = params.get("cache_mode")
return super(CommitTest, self).commit(params, cache_mode)
def run_qemu_disk_img_commit(test, params, env):
"""
'qemu-img' commit functions test:
@param test: Qemu test object
@param params: Dictionary with the test parameters
@param env: Dictionary with test environment.
"""
base_image = params.get("images", "image1").split()[0]
params.update(
{"image_name_%s" % base_image: params["image_name"],
"image_format_%s" % base_image: params["image_format"]})
t_file = params["guest_file_name"]
commit_test = CommitTest(test, params, env)
n_params = commit_test.create_snapshot()
commit_test.start_vm(n_params)
# save file md5sum before commit
ret = commit_test.save_file(t_file)
if not ret:
raise error.TestError("Fail to save tmp file")
commit_test.destroy_vm()
commit_test.commit()
commit_test.start_vm(params)
# check md5sum after commit
ret = commit_test.check_file(t_file)
if not ret:
raise error.TestError("image content changed after commit")
commit_test.clean()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册