The main purpose of this case is to expand the qcow2 file to its max size. Currently we only support Linux guest and write specified size /dev/zero to files under /tmp.
Signed-off-by: Feng Yang <[email protected]> Signed-off-by: Cao, Chen Signed-off-by: Yolkfull Chow Signed-off-by: Qingtang Zhou <[email protected]> --- client/tests/kvm/tests_base.cfg.sample | 17 ++++++++++ client/virt/tests/fillup_disk.py | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 0 deletions(-) create mode 100644 client/virt/tests/fillup_disk.py diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 78c84c6..0d72d29 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -866,6 +866,15 @@ variants: profilers = '' take_regular_screendumps = no + - fillup_disk: + only Linux + only qcow2 + type = fillup_disk + fillup_timeout = 120 + fillup_size = 200 + fillup_cmd = "dd if=/dev/zero of=/%s/fillup.%d bs=%dM count=1 oflag=direct" + kill_vm = yes + - ioquit: only Linux type = ioquit @@ -1641,6 +1650,8 @@ variants: cdrom_cd1 = isos/linux/RHEL-4.7-i386-DVD.iso md5sum_cd1 = ee5092653732a88ddbaf8eef2484c500 md5sum_1m_cd1 = 127081cbed825d7232331a2083975528 + fillup_disk: + fillup_cmd = "dd if=/dev/zero of=/%s/fillup.%d bs=%dM count=1" - 4.7.x86_64: no setup autotest @@ -1660,6 +1671,8 @@ variants: cdrom_cd1 = isos/linux/RHEL-4.7-x86_64-DVD.iso md5sum_cd1 = ea9dae16dd86f7d94092d0e672333292 md5sum_1m_cd1 = 58fa63eaee68e269f4cb1d2edf479792 + fillup_disk: + fillup_cmd = "dd if=/dev/zero of=/%s/fillup.%d bs=%dM count=1" - 4.8.i386: no setup autotest @@ -1677,6 +1690,8 @@ variants: nicdriver_unload: readlink_command = readlink -f sys_path = "/sys/class/net/%s/driver" + fillup_disk: + fillup_cmd = "dd if=/dev/zero of=/%s/fillup.%d bs=%dM count=1" - 4.8.x86_64: @@ -1695,6 +1710,8 @@ variants: nicdriver_unload: readlink_command = readlink -f sys_path = "/sys/class/net/%s/driver" + fillup_disk: + fillup_cmd = "dd if=/dev/zero of=/%s/fillup.%d bs=%dM count=1" - 5.3.i386: diff --git a/client/virt/tests/fillup_disk.py b/client/virt/tests/fillup_disk.py new file mode 100644 index 0000000..25aade2 --- /dev/null +++ b/client/virt/tests/fillup_disk.py @@ -0,0 +1,56 @@ +import logging +from autotest_lib.client.common_lib import error + +def run_fillup_disk(test, params, env): + """ + Fillup guest disk (root mount point) using dd if=/dev/zero, + and then clean up (rm the big file). The main purpose of this case is to + expand the qcow2 file to its max size. + + Suggest to test rebooting vm after this test. + + @param test: kvm test object + @param params: Dictionary with the test parameters + @param env: Dictionary with test environment. + """ + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + timeout = int(params.get("login_timeout", 360)) + session = vm.wait_for_login(timeout=timeout) + + fillup_timeout = int(params.get("fillup_timeout")) + fillup_size = int(params.get("fillup_size")) + fill_dir = params.get("guest_testdir","/tmp") + filled = False + number = 0 + + try: + logging.info("Start filling the disk in %s" % fill_dir) + cmd = params.get("fillup_cmd") + while not filled: + # As we want to test the backing file, so bypass the cache + tmp_cmd = cmd % (fill_dir, number, fillup_size) + logging.debug(tmp_cmd) + s, o = session.cmd_status_output(tmp_cmd, timeout=fillup_timeout) + if "No space left on device" in o: + logging.debug("Successfully fill up the disk") + filled = True; + elif s != 0: + logging.error(o) + raise error.TestFail("Unexpected results got from dd command") + number += 1 + finally: + logging.info("Cleaning the temporary files...") + while number >= 0: + cmd = "rm -f /%s/fillup.%d" % (fill_dir, number) + logging.debug(cmd) + s, o = session.cmd_status_output(cmd) + if s != 0: + logging.error(o) + raise error.TestFail("Failed to remove file %s: %s;" + "guest may be unresponsive or " + "command timeout" % (number, o)) + number -= 1 + session.close() + + logging.info("Test finish successfully") -- 1.7.4.1 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
