提交 d6dbc9a8 编写于 作者: X Xiaoling Gao

qemu-guest-agent: gagent snapshot test case support windows guest

1. windows guest support for qemu_guest_agent_snapshot
2. delete redundant parameter for gagent snapshot
3. enlarge the transfer data size
Signed-off-by: NXiaoling Gao <xiagao@redhat.com>
上级 2f89966d
......@@ -140,12 +140,8 @@
- check_reboot_shutdown_fsfreeze:
gagent_check_type = reboot_shutdown
- check_snapshot:
# fsfreeze series commands can't run on windows guest.
no Windows
type = qemu_guest_agent_snapshot
gagent_check_type = fsfreeze
gagent_fs_test_cmd = "rm -f /tmp/foo; echo foo > /tmp/foo"
gagent_fs_check_cmd = "grep foo /tmp/foo"
- check_suspend:
type = qemu_guest_agent_suspend
services_up_timeout = 30
......
......@@ -1310,7 +1310,7 @@ class QemuGuestAgentBasicCheck(QemuGuestAgentTest):
error_context.context("Check guest agent command "
"'guest-fsfreeze-freeze/thaw'",
logging.info)
write_cmd = params["gagent_fs_test_cmd"]
write_cmd = params.get("gagent_fs_test_cmd", "")
write_cmd_timeout = int(params.get("write_cmd_timeout", 60))
try:
expect_status = self.gagent.FSFREEZE_STATUS_THAWED
......@@ -1646,8 +1646,8 @@ class QemuGuestAgentBasicCheckWin(QemuGuestAgentBasicCheck):
"""
def __init__(self, test, params, env):
QemuGuestAgentBasicCheck.__init__(self, test, params, env)
self.gagent_guest_dir = params["gagent_guest_dir"]
self.qemu_ga_pkg = params["qemu_ga_pkg"]
self.gagent_guest_dir = params.get("gagent_guest_dir", "")
self.qemu_ga_pkg = params.get("qemu_ga_pkg", "")
self.gagent_src_type = params.get("gagent_src_type", "url")
@error_context.context_aware
......
......@@ -7,15 +7,23 @@ from virttest import error_context
from virttest import utils_misc
from qemu.tests.live_snapshot_basic import LiveSnapshot
from qemu.tests.qemu_guest_agent import QemuGuestAgentBasicCheck
from qemu.tests.qemu_guest_agent import QemuGuestAgentBasicCheckWin
class QemuGuestAgentSnapshotTest(QemuGuestAgentBasicCheck):
class QemuGuestAgentSnapshotTest(QemuGuestAgentBasicCheckWin):
@error_context.context_aware
def setup(self, test, params, env):
# pylint: disable=E1003
if params["os_type"] == "windows":
super(QemuGuestAgentSnapshotTest, self).setup(test, params, env)
else:
super(QemuGuestAgentBasicCheckWin, self).setup(test, params, env)
@error_context.context_aware
def _action_before_fsfreeze(self, *args):
copy_timeout = int(self.params.get("copy_timeoout", 600))
file_size = int(self.params.get("file_size", "500"))
file_size = int(self.params.get("file_size", "1024"))
tmp_name = utils_misc.generate_random_string(5)
self.host_path = self.guest_path = "/tmp/%s" % tmp_name
if self.params.get("os_type") != "linux":
......@@ -55,18 +63,25 @@ class QemuGuestAgentSnapshotTest(QemuGuestAgentBasicCheck):
if self.bg:
self.bg.join()
# Make sure the returned file is identical to the original one
self.host_path_returned = "%s-returned" % self.host_path
self.vm.copy_files_from(self.guest_path, self.host_path_returned)
error_context.context("comparing hashes", logging.info)
self.curr_hash = crypto.hash_file(self.host_path_returned)
if self.orig_hash != self.curr_hash:
self.test.fail("Current file hash (%s) differs from "
"original one (%s)" % (self.curr_hash,
self.orig_hash))
error_context.context("Reboot and shutdown guest.")
self.vm.reboot()
self.vm.destroy()
try:
self.host_path_returned = "%s-returned" % self.host_path
self.vm.copy_files_from(self.guest_path, self.host_path_returned)
error_context.context("comparing hashes", logging.info)
self.curr_hash = crypto.hash_file(self.host_path_returned)
if self.orig_hash != self.curr_hash:
self.test.fail("Current file hash (%s) differs from "
"original one (%s)" % (self.curr_hash,
self.orig_hash))
finally:
error_context.context("Delete the created files.", logging.info)
process.run("rm -rf %s %s" % (self.host_path,
self.host_path_returned))
session = self._get_session(self.params, None)
self._open_session_list.append(session)
cmd_del_file = "rm -rf %s" % self.guest_path
if self.params.get("os_type") == "windows":
cmd_del_file = r"del /f /q %s" % self.guest_path
session.cmd(cmd_del_file)
def run(test, params, env):
......@@ -81,7 +96,6 @@ def run(test, params, env):
5) Thaw guest.
6) Scp the file from guest to host.
7) Compare hash of those 2 files.
8) Reboot and shutdown guest.
:param test: kvm test object
:param params: Dictionary with the test parameters
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册