提交 116fb16f 编写于 作者: C Cong Li

qemu.tests: Add new case of live snapshot under stress.

Signed-off-by: NCong Li <coli@redhat.com>
上级 610c0a4a
......@@ -42,3 +42,30 @@
dd_cmd = "dd if=/dev/zero of=%s bs=4K count=1024 oflag=dsync"
dd_timeout = 600
copy_file_timeout = 600
- with_payload:
type = live_snapshot_stress
variants:
- stress:
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"
import logging
from virttest import utils_misc
from virttest import utils_test
from autotest.client.shared import error
from qemu.tests import live_snapshot_basic
class LiveSnapshotStress(live_snapshot_basic.LiveSnapshot):
def __init__(self, test, params, env, tag):
super(LiveSnapshotStress, self).__init__(test, params, env, tag)
@error.context_aware
def load_stress(self):
"""
load IO/CPU/Memory stress in guest;
"""
error.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")
if not utils_misc.wait_for(self.stress_app_running, timeout=360, step=5):
raise error.TestFail("stress app isn't running")
def unload_stress(self):
"""
stop stress app
"""
def _unload_stress():
session = self.get_session()
cmd = self.params.get("stop_cmd")
session.sendline(cmd)
return not self.stress_app_running()
error.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)
def stress_app_running(self):
"""
check stress app really run in background;
"""
session = self.get_session()
cmd = self.params.get("check_cmd")
status = session.cmd_status(cmd, timeout=120)
return status == 0
@error.context_aware
def run(test, params, env):
"""
live_snapshot_stress test:
1). load stress in guest.
2). do live snapshot during stress.
3). quit stress app, reboot guest(optional);
4). verify guest can response correctly.
: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 = LiveSnapshotStress(test, params, env, tag)
try:
stress_test.action_before_start()
stress_test.create_snapshot()
stress_test.action_after_finished()
finally:
stress_test.clean()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册