提交 4efe2e1c 编写于 作者: S suqinhuang 提交者: GitHub

Merge pull request #704 from CongLi/live_snapshot_reboot

qemu.tests: Re-write live snapshot reboot case with existing class and func.
......@@ -35,6 +35,7 @@ class BlockCopy(object):
"default_speed": 0}
trash_files = []
opening_sessions = []
processes = []
def __init__(self, test, params, env, tag):
self.tag = tag
......@@ -287,6 +288,18 @@ class BlockCopy(object):
"""
return self.do_steps("before_start")
def action_when_start(self):
"""
start pre-action in new threads;
"""
for test in self.params.get("when_start").split():
if hasattr(self, test):
fun = getattr(self, test)
bg = utils.InterruptedThread(fun)
bg.start()
if bg.isAlive():
self.processes.append(bg)
def action_before_cleanup(self):
"""
run steps before job in steady status;
......@@ -297,6 +310,8 @@ class BlockCopy(object):
"""
close opening connections and clean trash files;
"""
for bg in self.processes:
bg.join()
while self.opening_sessions:
session = self.opening_sessions.pop()
if session:
......@@ -305,4 +320,4 @@ class BlockCopy(object):
self.vm.destroy()
while self.trash_files:
tmp_file = self.trash_files.pop()
utils.system("rm -f %s" % tmp_file)
utils.system("rm -f %s" % tmp_file, ignore_status=True)
......@@ -24,10 +24,6 @@
no Host_RHEL.m5, Host_RHEL.m6
node_name = node1
snapshot_node_name = node2
- with_reboot:
subcommand = reboot
sleep_time = 10
reboot_timeout = 900
- with_runtime:
subcommand = runtime
- with_file_transfer:
......@@ -63,7 +59,7 @@
- with_payload:
type = live_snapshot_stress
variants:
- stress:
- with_stress:
Windows:
timeout = 600
autostress = yes
......@@ -87,9 +83,14 @@
stop_cmd = "killall -g stress"
before_start = "load_stress"
after_finished = "unload_stress reboot verify_alive"
- stop_cont:
- with_stop_cont:
before_start = "stop"
after_finished = "resume reboot verify_alive"
- with_reboot:
type = live_snapshot_runtime
reboot_method = "system_reset"
when_start = "reboot"
after_finished = "verify_alive"
- negative_test:
type = live_snapshot_negative_test
variants:
......
......@@ -75,19 +75,6 @@ def run(test, params, env):
finally:
session.close()
def reboot_test():
try:
reboot_timeout = int(params.get("reboot_timeout", 900))
bg = utils_test.BackgroundTest(vm.reboot, (session, "shell", 0,
reboot_timeout, False,))
logging.info("Rebooting guest ...")
bg.start()
sleep_time = int(params.get("sleep_time"))
time.sleep(sleep_time)
create_snapshot(vm)
finally:
bg.join()
def file_transfer_test():
try:
bg_cmd = utils_test.run_file_transfer
......
from autotest.client.shared import error
from qemu.tests import live_snapshot_basic
class LiveSnapshotRuntime(live_snapshot_basic.LiveSnapshot):
def __init__(self, test, params, env, tag):
super(LiveSnapshotRuntime, self).__init__(test, params, env, tag)
@error.context_aware
def reboot(self):
"""
Reset guest with system_reset;
"""
method = self.params.get("reboot_method", "system_reset")
return super(LiveSnapshotRuntime, self).reboot(method=method)
def run(test, params, env):
"""
live_snapshot runtime test:
1). boot guest;
2). do some operations, like reboot;
3). create snapshots during the operations in step 2;
4). waiting operations done and check guest is alive;
:param test: Kvm test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
tag = params.get("source_image", "image1")
runtime_test = LiveSnapshotRuntime(test, params, env, tag)
try:
runtime_test.action_when_start()
runtime_test.create_snapshot()
runtime_test.action_after_finished()
finally:
try:
runtime_test.clean()
except Exception:
pass
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册