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

qemu.tests: Add stop continue with file copy case

Add a background process to copy file while do stop and continue.
Check the md5 value for the files.

changes from v1:
  - remove the blanks
Signed-off-by: NYiqiao Pu <ypu@redhat.com>
Acked-by: NFeng Yang <fyang@redhat.com>
上级 e5d0277c
import logging
from autotest.client.shared import error
from virttest import utils_test
def run_stop_continue(test, params, env):
......@@ -20,8 +21,21 @@ def run_stop_continue(test, params, env):
vm.verify_alive()
timeout = float(params.get("login_timeout", 240))
session = vm.wait_for_login(timeout=timeout)
session_bg = None
try:
if params.get("prepare_op"):
op_timeout = float(params.get("prepare_op_timeout", 60))
session.cmd(params.get("prepare_op"), timeout=op_timeout)
if params.get("start_bg_process"):
session_bg = vm.wait_for_login(timeout=login_timeout)
bg_cmd_timeout = float(params.get("bg_cmd_timeout", 240))
args = (bg_cmd, bg_cmd_timeout)
bg = utils_test.BackgroundTest(session_bg.cmd, args)
bg.start()
logging.info("Stop the VM")
vm.pause()
logging.info("Verifying the status of VM is 'paused'")
......@@ -39,5 +53,22 @@ def run_stop_continue(test, params, env):
logging.info("Try to re-log into guest")
session = vm.wait_for_login(timeout=timeout)
if params.get("start_bg_process"):
if bg:
bg.join()
if params.get("check_op"):
op_timeout = float(params.get("check_op_timeout", 60))
s, o = session.cmd_status_output(params.get("check_op"),
timeout=op_timeout)
if s != 0:
raise error.TestFail("Something wrong after stop continue, "
"check command report: %s" % o)
finally:
if params.get("clean_op"):
op_timeout = float(params.get("clean_op_timeout", 60))
session.cmd(params.get("clean_op"), timeout=op_timeout)
session.close()
if params.get("start_bg_process"):
if session_bg:
session_bg.close()
......@@ -2,3 +2,13 @@
virt_test_type = qemu libvirt
type = stop_continue
kill_vm_on_error = yes
variants:
- stop_cont_only:
- with_file_copy:
prepare_op = dd if=/dev/urandom of=/tmp/origin bs=1M count=1024
prepare_op_timeout = 240
start_bg_process = yes
bg_cmd = rm -rf /tmp/new; cp /tmp/origin /tmp/new
check_op = i=`md5sum /tmp/origin | awk '{print $1}'`; j=`md5sum /tmp/new | awk '{print $1}'`;echo $j|grep $i
clean_op = rm -rf /tmp/origin /tmp/new
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册