未验证 提交 eb8c05fd 编写于 作者: X Xu Han 提交者: GitHub

Merge pull request #969 from vivianQizhu/live_snapshot

live_snapshot_integrity: Add integrity check test case for live snapshot.
......@@ -425,11 +425,15 @@ class BlockCopy(object):
"""
params = self.params
session = self.get_session()
file_create_cmd = params.get("create_cmd", "touch FILE")
file_create_cmd = params.get("create_command", "touch FILE")
test_exists_cmd = params.get("test_exists_cmd", "test -f FILE")
if session.cmd_status(test_exists_cmd.replace("FILE", file_name)):
session.cmd(file_create_cmd.replace("FILE", file_name))
session.cmd("md5sum %s > %s.md5" % (file_name, file_name))
session.cmd(file_create_cmd.replace("FILE", file_name), timeout=200)
session.cmd("md5sum %s > %s.md5" % (file_name, file_name), timeout=200)
sync_cmd = params.get("sync_cmd", "sync")
sync_cmd = utils_misc.set_winutils_letter(session, sync_cmd)
session.cmd(sync_cmd)
session.close()
def verify_md5(self, file_name):
"""
......@@ -437,7 +441,18 @@ class BlockCopy(object):
:param file_name: the file need to be verified.
"""
session = self.get_session()
status, output = session.cmd_status_output("md5sum -c %s.md5" % file_name)
status, output = session.cmd_status_output("md5sum -c %s.md5" % file_name,
timeout=200)
if status != 0:
raise error.TestFail("File %s changed, md5sum check output: %s" %
(file_name, output))
def reopen(self, reopen_image):
"""
Closing the vm and reboot it with the backup image.
:param reopen_image: the image that vm reopen with.
"""
self.vm.destroy()
self.params["image_name_%s" % self.tag] = reopen_image
self.vm.create(params=self.params)
self.vm.verify_alive()
......@@ -23,13 +23,18 @@
before_full_backup = "create_files reboot stop"
after_incremental += " verify_md5s verify_efficiency"
Linux:
create_cmd = "dd if=/dev/urandom of=FILE bs=128k count=100"
create_command = "dd if=/dev/urandom of=FILE bs=128k count=100"
file_names = "/home/test.img"
test_exists_cmd = "test -f FILE"
sync_cmd = "sync && echo 3 > /proc/sys/vm/drop_caches"
Windows:
create_cmd = "D:\coreutils\DummyCMD.exe FILE 1073741824 1"
create_command = "D:\coreutils\DummyCMD.exe FILE 1073741824 1"
file_names = "C:\live_backup_test"
test_exists_cmd = "dir FILE"
x86_64:
sync_cmd = "WIN_UTILS:\Sync\sync64.exe /accepteula"
i386, i686:
sync_cmd = "WIN_UTILS:\Sync\sync.exe /accepteula"
- granularity:
transaction = no
check_params = "granularity"
......
......@@ -60,31 +60,30 @@
copy_file_timeout = 600
- with_payload:
type = live_snapshot_stress
Windows:
timeout = 600
autostress = yes
stress_test = win_heavyload
config_cmd = 'setx -m path "%PATH%;${install_path};"'
install_cmd = "start /wait DRIVE:\HeavyLoadSetup.exe /verysilent"
check_cmd = 'tasklist | findstr /I "heavyload.exe"'
stop_cmd = "taskkill /T /F /IM heavyload.exe"
x86_64:
install_path = "C:\Program Files (x86)\JAM Software\HeavyLoad"
i386, i686:
install_path = "C:\Program Files\JAM Software\HeavyLoad"
Linux:
stress_test = autotest_control
test_control_file = stress.control
# Use a low stress to make sure guest can response during stress
control_args = "--cpu 4 --io 4 --vm 2 --vm-bytes 256M"
test_timeout = 1800
check_cmd = 'pgrep stress'
stop_cmd = "killall -g stress"
variants:
- with_stress:
backup_image_before_testing = yes
restore_image_after_testing = yes
Windows:
timeout = 600
autostress = yes
stress_test = win_heavyload
install_path = "C:\Program Files (x86)\JAM Software\HeavyLoad"
config_cmd = 'setx -m path "%PATH%;${install_path};"'
install_cmd = "start /wait DRIVE:\HeavyLoadSetup.exe /verysilent"
check_cmd = 'tasklist | findstr /I "heavyload.exe"'
stop_cmd = "taskkill /T /F /IM heavyload.exe"
x86_64:
install_path = "C:\Program Files (x86)\JAM Software\HeavyLoad"
i386, i686:
install_path = "C:\Program Files\JAM Software\HeavyLoad"
Linux:
stress_test = autotest_control
test_control_file = stress.control
# Use a low stress to make sure guest can response during stress
control_args = "--cpu 4 --io 4 --vm 2 --vm-bytes 256M"
test_timeout = 1800
check_cmd = 'pgrep stress'
stop_cmd = "killall -g stress"
before_start = "load_stress"
after_finished = "unload_stress reboot verify_alive"
- with_stop_cont:
......@@ -95,6 +94,30 @@
reboot_method = "system_reset"
when_start = "reboot"
after_finished = "verify_alive"
- data_integrity:
type = live_snapshot_integrity
#To make the integrity test innocent, use "writethrough" for cache
drive_cache = writethrough
before_start = "load_stress"
after_finished = "unload_stress"
backup_image_before_testing = yes
restore_image_after_testing = yes
Windows:
create_command = "D:\coreutils\DummyCMD.exe FILE 1073741824 1"
file_names = "C:\live_snapshot_base C:\live_snapshot_sn1"
test_exists_cmd = "dir FILE"
autostress = no
start_cmd = '"${install_path}\heavyload.exe" \CPU 1 \MEMORY 1024'
x86_64:
sync_cmd = "WIN_UTILS:\Sync\sync64.exe /accepteula"
i386, i686:
sync_cmd = "WIN_UTILS:\Sync\sync.exe /accepteula"
Linux:
create_command = "dd if=/dev/urandom of=FILE bs=128k count=100"
file_names = "/home/live_snapshot_base /home/live_snapshot_sn1"
test_exists_cmd = "test -f FILE"
control_args = "--cpu 1 --vm 1 --vm-bytes 16M"
sync_cmd = "sync"
- transaction:
type = live_snapshot_transaction
images += " sn1 sn2"
......
......@@ -159,16 +159,10 @@ class LiveBackup(block_copy.BlockCopy):
"""
Closing the vm and reboot it with the backup image.
"""
vm = self.vm
vm.destroy()
image_chain = self.image_chain
image_name = self.params.get("image_name_%s" %
image_chain[-1])
self.params["image_name_%s" % self.source_image] = image_name
vm.create(params=self.params)
self.vm = vm
session = self.get_session()
self.vm.verify_alive()
super(LiveBackup, self).reopen(image_name)
def before_full_backup(self):
"""
......
......@@ -51,7 +51,8 @@ class LiveSnapshot(block_copy.BlockCopy):
"""
Get path of snapshot file.
"""
snapshot_file = "images/%s" % self.snapshot_file
image_format = self.params["image_format"]
snapshot_file = "images/%s.%s" % (self.snapshot_file, image_format)
return utils_misc.get_path(data_dir.get_data_dir(), snapshot_file)
def create_snapshot(self):
......@@ -63,6 +64,7 @@ class LiveSnapshot(block_copy.BlockCopy):
self.snapshot_file = self.create_image()
else:
self.snapshot_file = self.get_snapshot_file()
self.trash_files.append(self.snapshot_file)
logging.info("Creating snapshot")
self.vm.monitor.live_snapshot(self.device, self.snapshot_file,
**self.snapshot_args)
......
from virttest import error_context
from qemu.tests import live_snapshot_stress
@error_context.context_aware
def run(test, params, env):
"""
live_snapshot_integrity test:
1). Boot up guest with cache=writethrough.
2). Load stress in guest.
3). dd file_base inside guest, record md5.
4). do snapshot;
5). dd file_sn1 inside guest, record md5.
6). Unload stress, reboot guest with snapshot.
7). Check file_base and file_sn1 md5.
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
tag = params.get("source_image", "image1")
stress_test = live_snapshot_stress.LiveSnapshotStress(test, params, env, tag)
try:
stress_test.action_before_start()
file_names = params["file_names"].split()
file_name_base = file_names[0]
file_name_sn1 = file_names[1]
stress_test.create_file(file_name_base)
stress_test.create_snapshot()
stress_test.create_file(file_name_sn1)
stress_test.action_after_finished()
format_postfix = ".%s" % params["image_format"]
snapshot = stress_test.snapshot_file.replace(format_postfix, '')
stress_test.reopen(snapshot)
map(stress_test.verify_md5, file_names)
finally:
stress_test.clean()
......@@ -2,7 +2,8 @@ import logging
from virttest import utils_misc
from virttest import utils_test
from autotest.client.shared import error
from virttest import error_context
from qemu.tests import live_snapshot_basic
......@@ -11,20 +12,21 @@ class LiveSnapshotStress(live_snapshot_basic.LiveSnapshot):
def __init__(self, test, params, env, tag):
super(LiveSnapshotStress, self).__init__(test, params, env, tag)
@error.context_aware
@error_context.context_aware
def load_stress(self):
"""
load IO/CPU/Memory stress in guest;
"""
error.context("launch stress app in guest", logging.info)
error_context.context("launch stress app in guest", logging.info)
args = (self.test, self.params, self.env, self.params["stress_test"])
bg_test = utils_test.BackgroundTest(utils_test.run_virt_sub_test, args)
bg_test.start()
if not utils_misc.wait_for(bg_test.is_alive, first=10, step=3, timeout=100):
raise error.TestFail("background test start failed")
self.test.fail("background test start failed")
if not utils_misc.wait_for(self.stress_app_running, timeout=360, step=5):
raise error.TestFail("stress app isn't running")
self.test.fail("stress app isn't running")
@error_context.context_aware
def unload_stress(self):
"""
stop stress app
......@@ -35,7 +37,7 @@ class LiveSnapshotStress(live_snapshot_basic.LiveSnapshot):
session.sendline(cmd)
return not self.stress_app_running()
error.context("stop stress app in guest", logging.info)
error_context.context("stop stress app in guest", logging.info)
utils_misc.wait_for(_unload_stress, first=2.0,
text="wait stress app quit", step=1.0, timeout=120)
......@@ -49,7 +51,7 @@ class LiveSnapshotStress(live_snapshot_basic.LiveSnapshot):
return status == 0
@error.context_aware
@error_context.context_aware
def run(test, params, env):
"""
live_snapshot_stress test:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册