提交 367e858d 编写于 作者: Y Yumei Huang

balloon_stress: improve test steps for background stress test

1. To avoid linux guest hang due to run infinite stress
2. Replace video player to mplayer to support playing video in a
continuous loop
Signed-off-by: NYumei Huang <yuhuang@redhat.com>
上级 d049472b
import logging import logging
import random import random
import re
from virttest import utils_misc from virttest import utils_misc
from virttest import utils_test from virttest import utils_test
...@@ -22,17 +23,18 @@ def run(test, params, env): ...@@ -22,17 +23,18 @@ def run(test, params, env):
:param env: Dictionary with test environment. :param env: Dictionary with test environment.
""" """
def run_stress(test, params, env, vm): def check_bg_running():
""" """
Run stress in background Check the background test status in guest.
:return: return True if find the process name; otherwise False
""" """
while True: if params['os_type'] == 'windows':
if params['os_type'] == 'windows': list_cmd = params.get("list_cmd", "wmic process get name")
utils_test.run_virt_sub_test(test, params, env, output = session.cmd_output_safe(list_cmd, timeout=60)
params.get("stress_test")) process = re.findall("mplayer", output, re.M | re.I)
else: return bool(process)
stress_bg = utils_test.VMStress(vm, "stress", params) else:
stress_bg.load_stress_tool() return stress_bg.app_running()
error_context.context("Boot guest with balloon device", logging.info) error_context.context("Boot guest with balloon device", logging.info)
vm = env.get_vm(params["main_vm"]) vm = env.get_vm(params["main_vm"])
...@@ -51,8 +53,16 @@ def run(test, params, env): ...@@ -51,8 +53,16 @@ def run(test, params, env):
balloon_test = BallooningTestLinux(test, params, env) balloon_test = BallooningTestLinux(test, params, env)
error_context.context("Run stress background", logging.info) error_context.context("Run stress background", logging.info)
bg = utils_misc.InterruptedThread(run_stress, (test, params, env, vm)) stress_test = params.get("stress_test")
bg.start() if params['os_type'] == 'windows':
utils_test.run_virt_sub_test(test, params, env, stress_test)
if not utils_misc.wait_for(check_bg_running, first=2.0,
text="wait for stress app to start",
step=1.0, timeout=60):
test.error("Run stress background failed")
else:
stress_bg = utils_test.VMStress(vm, "stress", params)
stress_bg.load_stress_tool()
repeat_times = int(params.get("repeat_times", 1000)) repeat_times = int(params.get("repeat_times", 1000))
min_sz, max_sz = balloon_test.get_memory_boundary() min_sz, max_sz = balloon_test.get_memory_boundary()
...@@ -62,7 +72,7 @@ def run(test, params, env): ...@@ -62,7 +72,7 @@ def run(test, params, env):
for i in range(1, int(repeat_times+1)): for i in range(1, int(repeat_times+1)):
logging.info("repeat times: %d" % i) logging.info("repeat times: %d" % i)
balloon_test.balloon_memory(int(random.uniform(min_sz, max_sz))) balloon_test.balloon_memory(int(random.uniform(min_sz, max_sz)))
if not bg.is_alive(): if not check_bg_running():
test.error("Background stress process is not alive") test.error("Background stress process is not alive")
finally: finally:
if session: if session:
......
...@@ -14,22 +14,12 @@ ...@@ -14,22 +14,12 @@
balloon_timeout = 240 balloon_timeout = 240
check_setup_events = balloon_test_setup_ready check_setup_events = balloon_test_setup_ready
Windows: Windows:
x86_64:
program_files = "%ProgramFiles(x86)%"
i386:
program_files = "%ProgramFiles%"
stress_test = win_video_play stress_test = win_video_play
#Disable first startup guide for windows media player mplayer_path = "WIN_UTILS:\mplayer.exe"
wmplayer_reg_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001" play_video_cmd = "start /MIN %s %s -loop 0 -fs"
wmplayer_path = "${program_files}\Windows Media Player\wmplayer.exe" target_process = mplayer.exe
#Install kmplayer if wmplayer is not installed default
kmplayer_install_cmd = "start /wait WIN_UTILS:\kmplayer\%s\KMPlayer-setup.exe /SP- /VERYSILENT"
kmplayer_path = "${program_files}\KMPlayer\kmplayer.exe"
video_url = http://fileshare.com/Peppa_Pig_39_The_Tree_House.avi video_url = http://fileshare.com/Peppa_Pig_39_The_Tree_House.avi
play_video_cmd = '"%s" "%s" /play /fullscreen'
guest_alias = "Win2008-sp2-32:2k8\x86,Win2008-sp2-64:2k8\amd64,Win2008-r2-64:2k8\amd64,Win2012-64:2k12\amd64,Win2012-64r2:2k12\amd64"
driver_name = "balloon" driver_name = "balloon"
time_for_video = 600
free_mem_cmd = wmic os get FreePhysicalMemory free_mem_cmd = wmic os get FreePhysicalMemory
default_memory = ${mem} default_memory = ${mem}
check_guest_bsod = yes check_guest_bsod = yes
......
...@@ -8,22 +8,11 @@ ...@@ -8,22 +8,11 @@
balloon_dev_devid = balloon0 balloon_dev_devid = balloon0
balloon_dev_add_bus = yes balloon_dev_add_bus = yes
Windows: Windows:
driver_name = "balloon"
stress_test = win_video_play stress_test = win_video_play
mplayer_path = "WIN_UTILS:\mplayer.exe"
play_video_cmd = "start /MIN %s %s -loop 0 -fs"
video_url = http://FILESHARE.COM/pub/section2/kvmauto/video/big_buck_bunny_480p_stereo.avi video_url = http://FILESHARE.COM/pub/section2/kvmauto/video/big_buck_bunny_480p_stereo.avi
x86_64:
program_files = "%ProgramFiles(x86)%"
i386:
program_files = "%ProgramFiles%"
driver_name = "balloon"
#Disable first startup guide for windows media player
wmplayer_reg_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001"
wmplayer_path = "${program_files}\Windows Media Player\wmplayer.exe"
#Install kmplayer if wmplayer is not installed default
kmplayer_install_cmd = "start /wait WIN_UTILS:\kmplayer\%s\KMPlayer-setup.exe /SP- /VERYSILENT"
kmplayer_path = "${program_files}\KMPlayer\kmplayer.exe"
play_video_cmd = '"%s" "%s" /play /fullscreen'
time_for_video = 1200
guest_alias = "Win2008-sp2-32:2k8\x86,Win2008-sp2-64:2k8\amd64,Win2008-r2-64:2k8\amd64,Win2012-64:2k12\amd64,Win2012-64r2:2k12\amd64"
Linux: Linux:
# Use a low stress to make sure guest can response during stress # Use a low stress to make sure guest can response during stress
stress_args = "--cpu 4 --io 4 --vm 2 --vm-bytes 256M" stress_args = "--cpu 4 --io 4 --vm 2 --vm-bytes 256M"
...@@ -107,20 +107,10 @@ ...@@ -107,20 +107,10 @@
free_mem_cmd = wmic os get FreePhysicalMemory free_mem_cmd = wmic os get FreePhysicalMemory
session_cmd_timeout = 240 session_cmd_timeout = 240
stress_test = win_video_play stress_test = win_video_play
x86_64: mplayer_path = "WIN_UTILS:\mplayer.exe"
program_files = "%ProgramFiles(x86)%" play_video_cmd = "start /MIN %s %s -loop 0 -fs"
i386:
program_files = "%ProgramFiles%"
#Disable first startup guide for windows media player
wmplayer_reg_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001"
wmplayer_path = "${program_files}\Windows Media Player\wmplayer.exe"
#Install kmplayer if wmplayer is not installed default
kmplayer_install_cmd = "start /wait WIN_UTILS:\kmplayer\%s\KMPlayer-setup.exe /SP- /VERYSILENT"
kmplayer_path = "${program_files}\KMPlayer\kmplayer.exe"
video_url = http://fileshare.com/Peppa_Pig_39_The_Tree_House.avi video_url = http://fileshare.com/Peppa_Pig_39_The_Tree_House.avi
play_video_cmd = '"%s" "%s" /play /fullscreen' target_process = mplayer.exe
target_process = \w+mplayer.exe
guest_alias = "Win2008-sp2-32:2k8\x86,Win2008-sp2-64:2k8\amd64,Win2008-r2-64:2k8\amd64,Win2012-64:2k12\amd64,Win2012-64r2:2k12\amd64"
- with_viorng: - with_viorng:
no no_virtio_rng no no_virtio_rng
driver_name = viorng driver_name = viorng
......
...@@ -2,16 +2,7 @@ ...@@ -2,16 +2,7 @@
type = win_video_play type = win_video_play
only Windows only Windows
image_snapshot = yes image_snapshot = yes
x86_64: mplayer_path = "WIN_UTILS:\mplayer.exe"
program_files = "%ProgramFiles(x86)%" play_video_cmd = "start /MIN %s %s -loop 0 -fs"
i386:
program_files = "%ProgramFiles%"
#Disable first startup guide for windows media player
wmplayer_reg_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001"
wmplayer_path = "${program_files}\Windows Media Player\wmplayer.exe"
#Install kmplayer if wmplayer is not installed default
kmplayer_install_cmd = "start /wait WIN_UTILS:\kmplayer\%s\KMPlayer-setup.exe /SP- /VERYSILENT"
kmplayer_path = "${program_files}\KMPlayer\kmplayer.exe"
video_url = http://fileshare.com/Peppa_Pig_39_The_Tree_House.avi video_url = http://fileshare.com/Peppa_Pig_39_The_Tree_House.avi
play_video_cmd = '"%s" "%s" /play /fullscreen' play_video_duration = 300
guest_alias = "Win2008-sp2-32:2k8\x86,Win2008-sp2-64:2k8\amd64,Win2008-r2-64:2k8\amd64,Win2012-64:2k12\amd64,Win2012-64r2:2k12\amd64"
...@@ -11,87 +11,30 @@ def run(test, params, env): ...@@ -11,87 +11,30 @@ def run(test, params, env):
""" """
Run video in Windows guest Run video in Windows guest
1) Boot guest with the device. 1) Boot guest with the device.
2) Check if wmplayer is installed default 2) Run video by mplayer
3) Install kmplayer if wmplayer is not installed
4) Run video
:param test: QEMU test object :param test: QEMU test object
:param params: Dictionary with the test parameters :param params: Dictionary with the test parameters
:param env: Dictionary with test environment. :param env: Dictionary with test environment.
""" """
def check_wmplayer_installed(session):
"""
Check if wmplayer is installed
:param session: VM session
:return: return wmplayer.exe path
"""
error_context.context("Check if wmplayer is installed", logging.info)
install_path = params.get("wmplayer_path")
check_cmd = 'dir "%s"|findstr /I wmplayer'
check_cmd = params.get("wmplayer_check_cmd", check_cmd) % install_path
if session.cmd_status(check_cmd) == 0:
return install_path
def check_kmplayer_installed(session):
"""
Check if kmplayer is installed
:param session: VM session
:return: return kmplayer.exe path
"""
error_context.context("Check if kmplayer is installed", logging.info)
install_path = params.get("kmplayer_path")
check_cmd = 'dir "%s"|findstr /I kmplayer'
check_cmd = params.get("kmplayer_check_cmd", check_cmd) % install_path
if session.cmd_status(check_cmd) != 0:
kmplayer_install(session)
return install_path
def kmplayer_install(session):
"""
Install kmplayer
:param session: VM session
"""
error_context.context("Install kmplayer ...", logging.info)
guest_name = params["guest_name"]
alias_map = params["guest_alias"]
guest_list = dict([x.split(":") for x in alias_map.split(",")])
guest_name = guest_list[guest_name]
install_cmd = params["kmplayer_install_cmd"] % guest_name
install_cmd = utils_misc.set_winutils_letter(session, install_cmd)
s, o = session.cmd_status_output(install_cmd, timeout=240)
if s != 0:
raise exceptions.TestError("Failed to install kmplayer %s" % o)
vm = env.get_vm(params["main_vm"]) vm = env.get_vm(params["main_vm"])
vm.verify_alive() vm.verify_alive()
timeout = float(params.get("login_timeout", 360)) timeout = float(params.get("login_timeout", 360))
session = vm.wait_for_login(timeout=timeout) session = vm.wait_for_login(timeout=timeout)
video_player = utils_misc.set_winutils_letter(session,
wmplayer = check_wmplayer_installed(session) params["mplayer_path"])
if wmplayer:
video_player = wmplayer
if params.get("wmplayer_reg_cmd"):
logging.info("Update regedit")
session.cmd(params.get("wmplayer_reg_cmd"))
else:
kmplayer = check_kmplayer_installed(session)
video_player = kmplayer
video_url = params["video_url"] video_url = params["video_url"]
play_video_cmd = params["play_video_cmd"] % (video_player, video_url) play_video_cmd = params["play_video_cmd"] % (video_player, video_url)
error_context.context("Play video", logging.info) error_context.context("Play video", logging.info)
try: try:
session.cmd(play_video_cmd, timeout=240) session.cmd(play_video_cmd, timeout=240)
time.sleep(float(params.get("time_for_video", 240)))
except Exception as details: except Exception as details:
raise exceptions.TestFail(details) raise exceptions.TestFail(details)
finally:
logging.info("Stop video") play_video_duration = params.get("play_video_duration")
if play_video_duration:
time.sleep(int(play_video_duration))
session.cmd("taskkill /IM %s /F" % video_player, session.cmd("taskkill /IM %s /F" % video_player,
ignore_all_errors=True) ignore_all_errors=True)
session.close() session.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册