diff --git a/qemu/tests/cfg/remote_image_snapshot.cfg b/qemu/tests/cfg/remote_image_snapshot.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c7d32a233ae384d44f498a91b13eb3408942b329 --- /dev/null +++ b/qemu/tests/cfg/remote_image_snapshot.cfg @@ -0,0 +1,41 @@ +# These tcs only focus on the following scenarios: +# remote image -> local snapshot +# remote image -> remote snapshot + +- remote_image_snapshot: + only iscsi_direct ceph + virt_test_type = qemu + type = qemu_disk_img_info + image_chain= "image1 snA" + kill_vm = yes + start_vm = no + image_size = 20G + md5sum_bin = "md5sum" + tmp_dir = /var/tmp + tmp_file_name = ${tmp_dir}/test.img + force_create_image = no + dd_bs_val = 1 + dd_bs_count = 256 + file_create_cmd = "dd if=/dev/urandom of=%s bs=${dd_bs_val}M count=${dd_bs_count}" + guest_file_name_image1 = "${tmp_dir}/test.img" + image_name_snA = "images/snA" + image_format_snA = "qcow2" + guest_file_name_snA = "${tmp_dir}/snA" + backing_chain = yes + iscsi_direct: + # Never set size for the whole block is used + image_size_snA = "" + variants: + - to_local: + enable_iscsi_snA = no + enable_ceph_snA = no + image_raw_device_snA = no + storage_type_snA = filesystem + - to_remote: + iscsi_direct: + # make sure size of lun_snA equals to size of lun_image1 + # hard code here for avocado-vt cannot select luns by now + lun_snA = 1 + ceph: + # qcow2 is supported since 4.1.0 on ceph + required_qemu = [4.1.0,) diff --git a/qemu/tests/qemu_disk_img.py b/qemu/tests/qemu_disk_img.py index ba86021ee3f80902cd1f8f85b4a3927e51fcbc3f..db88da7762ffd33d03e20c2212d2eab7c0e2e9c4 100644 --- a/qemu/tests/qemu_disk_img.py +++ b/qemu/tests/qemu_disk_img.py @@ -1,4 +1,3 @@ -import os import re import logging @@ -40,8 +39,7 @@ class QemuImgTest(qemu_storage.QemuImg): if len(params.get("image_chain", "").split()) < 2: return {} snapshot = storage.get_image_filename(params, self.data_dir) - if os.path.exists(snapshot): - process.run("rm -f %s" % snapshot) + storage.file_remove(params, snapshot) super(QemuImgTest, self).create(params) self.trash.append(snapshot) return params diff --git a/qemu/tests/qemu_disk_img_info.py b/qemu/tests/qemu_disk_img_info.py index b8be5bcf132376262c5f5c5545fcfb93f2624d57..2530a6f25158e766685c7b85d1fe802e04a51c99 100644 --- a/qemu/tests/qemu_disk_img_info.py +++ b/qemu/tests/qemu_disk_img_info.py @@ -4,7 +4,6 @@ from virttest import env_process from virttest import error_context from virttest import storage -from avocado.utils import process from qemu.tests import qemu_disk_img @@ -38,7 +37,7 @@ class InfoTest(qemu_disk_img.QemuImgTest): for sn in params.get("image_chain").split()[1:]: _params = params.object_params(sn) _image = storage.get_image_filename(_params, self.data_dir) - process.run("rm -f %s" % _image) + storage.file_remove(_params, _image) def run(test, params, env): @@ -50,9 +49,38 @@ def run(test, params, env): :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"]}) + + update_params = { + "image_name_%s" % base_image: params["image_name"], + "image_format_%s" % base_image: params["image_format"] + } + + optval = (lambda opt, img, p, default: p.get('%s_%s' % (opt, img), + p.get(opt, default))) + enable_ceph = params.get("enable_ceph") == "yes" + enable_iscsi = params.get("enable_iscsi") == "yes" + if enable_ceph: + update_params.update({ + "enable_ceph_%s" % base_image: optval("enable_ceph", + base_image, + params, "no"), + "storage_type_%s" % base_image: optval("storage_type", + base_image, + params, "filesystem")}) + elif enable_iscsi: + update_params.update({ + "enable_iscsi_%s" % base_image: optval("enable_iscsi", + base_image, + params, "no"), + "storage_type_%s" % base_image: optval("storage_type", + base_image, + params, "filesystem"), + "image_raw_device_%s" % base_image: optval("image_raw_device", + base_image, + params, "no"), + "lun_%s" % base_image: optval("lun", base_image, params, "0")}) + params.update(update_params) + image_chain = params.get("image_chain", "").split() check_files = [] md5_dict = {} @@ -78,4 +106,4 @@ def run(test, params, env): # get the disk image information info_test.check_backingfile() - info_test.clean() + info_test.clean()