提交 402cc057 编写于 作者: X Xu Tian 提交者: GitHub

Merge pull request #881 from suqinhuang/balloon_stress

Update video play code in balloon_stress
...@@ -78,9 +78,11 @@ class BallooningTest(MemoryBaseTest): ...@@ -78,9 +78,11 @@ class BallooningTest(MemoryBaseTest):
:param new_mem: New desired memory. :param new_mem: New desired memory.
:type new_mem: int :type new_mem: int
""" """
env["balloon_test"] = 0
error.context("Change VM memory to %s" % new_mem, logging.info) error.context("Change VM memory to %s" % new_mem, logging.info)
try: try:
self.vm.balloon(new_mem) self.vm.balloon(new_mem)
env["balloon_test"] = 1
except Exception, e: except Exception, e:
if self.params.get('illegal_value_check', 'no') == 'no' and new_mem != self.get_ballooned_memory(): if self.params.get('illegal_value_check', 'no') == 'no' and new_mem != self.get_ballooned_memory():
raise error.TestFail("Balloon memory fail with error message: %s" % e) raise error.TestFail("Balloon memory fail with error message: %s" % e)
......
import time
import logging import logging
import random import random
from autotest.client.shared import error
from virttest import utils_misc from virttest import utils_misc
from virttest import utils_test from virttest import utils_test
from virttest import error_context
from avocado.core import exceptions
from qemu.tests.balloon_check import BallooningTestWin from qemu.tests.balloon_check import BallooningTestWin
@error.context_aware @error_context.context_aware
def run(test, params, env): def run(test, params, env):
""" """
Qemu balloon device stress test: Qemu balloon device stress test:
...@@ -25,45 +25,38 @@ def run(test, params, env): ...@@ -25,45 +25,38 @@ def run(test, params, env):
:param env: Dictionary with test environment. :param env: Dictionary with test environment.
""" """
error.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"])
vm.verify_alive() vm.verify_alive()
default_memory = int(params.get("default_memory", params['mem']))
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)
# for media player configuration
if params.get("pre_cmd"):
session.cmd(params.get("pre_cmd"))
driver_name = params["driver_name"] driver_name = params["driver_name"]
utils_test.qemu.setup_win_driver_verifier(driver_name, vm, timeout) utils_test.qemu.setup_win_driver_verifier(driver_name, vm, timeout)
balloon_test = BallooningTestWin(test, params, env) balloon_test = BallooningTestWin(test, params, env)
error.context("Play video in guest", logging.info) video_play = utils_misc.InterruptedThread(
play_video_cmd = params["play_video_cmd"] utils_test.run_virt_sub_test, (test, params, env),
session.sendline(play_video_cmd) {"sub_type": params.get("sub_test")})
# need to wait for wmplayer loading remote video video_play.start()
time.sleep(float(params.get("loading_timeout", 60))) error_context.context("Run video background", logging.info)
check_playing_cmd = params["check_playing_cmd"] check_playing_cmd = params["check_playing_cmd"]
running = utils_misc.wait_for(lambda: utils_misc.get_guest_cmd_status_output( running = utils_misc.wait_for(
vm, check_playing_cmd)[0] == 0, first=5.0, timeout=600) lambda: utils_misc.get_guest_cmd_status_output(
vm, check_playing_cmd)[0] == 0, first=60, timeout=600)
if not running: if not running:
raise error.TestError("Video is not playing") raise exceptions.TestError("Video is not playing")
#for case:balloon_in_use to call error_context.context("balloon vm memory in loop", logging.info)
env["balloon_test"] = 0
error.context("balloon vm memory in loop", logging.info)
repeat_times = int(params.get("repeat_times", 10)) repeat_times = int(params.get("repeat_times", 10))
logging.info("repeat times: %d" % repeat_times) logging.info("repeat times: %d" % repeat_times)
min_sz, max_sz = balloon_test.get_memory_boundary() min_sz, max_sz = balloon_test.get_memory_boundary()
while repeat_times: while repeat_times:
balloon_test.balloon_memory(int(random.uniform(min_sz, max_sz))) balloon_test.balloon_memory(int(random.uniform(min_sz, max_sz)))
env["balloon_test"] = 1
repeat_times -= 1 repeat_times -= 1
error.context("verify guest still alive", logging.info) error_context.context("verify guest still alive", logging.info)
session.cmd(params["stop_player_cmd"])
vm.verify_alive() vm.verify_alive()
if session: if session:
session.close() session.close()
- balloon_stress: - balloon_stress:
type = balloon_stress type = balloon_stress
virt_test_type = qemu
only Windows only Windows
kill_vm = yes kill_vm = yes
repeat_times = 10000 repeat_times = 10000
virt_test_type = qemu sub_test = win_video_play
extra_params += " -balloon virtio" extra_params += " -balloon virtio"
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: x86_64:
program_files = "%ProgramFiles(x86)%" program_files = "%ProgramFiles(x86)%"
i386: i386:
program_files = "%ProgramFiles%" program_files = "%ProgramFiles%"
Windows: check_playing_cmd = "tasklist|findstr /I mplayer"
session_cmd_timeout = 240 driver_name = "balloon.sys"
# disable first startup guide for windows media player #Disable first startup guide for windows media player
pre_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001" wmplayer_reg_cmd = "reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer /v GroupPrivacyAcceptance /t REG_DWORD /f /d 00000001"
# enable repeat mode of windows media player wmplayer_path = "${program_files}\Windows Media Player\wmplayer.exe"
pre_cmd += " & reg add HKCU\Software\Microsoft\MediaPlayer\Preferences /v ModeLoop /t REG_DWORD /d 1 /f" #Install kmplayer if wmplayer is not installed default
play_video_cmd = taskkill /IM wmplayer.exe /F & "${program_files}\Windows Media Player\wmplayer.exe" "${video_url}" /play /fullscreen kmplayer_install_cmd = "start /wait WIN_UTILS:\kmplayer\%s\KMPlayer-setup.exe /SP- /VERYSILENT"
check_playing_cmd = "tasklist|findstr /I wmplayer" kmplayer_path = "${program_files}\KMPlayer\kmplayer.exe"
driver_name = "balloon.sys" play_video_cmd = '"%s" "%s" /play /fullscreen'
stop_player_cmd = "taskkill /IM wmplayer.exe /F" 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"
# reset media player play mode
post_cmd += "reg add HKCU\Software\Microsoft\MediaPlayer\Preferences /v ModeLoop /t REG_DWORD /d 0 /f"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册