提交 448bc130 编写于 作者: N Nini Gu

balloon_service: Add linux guest into the guest-stats-polling-interval test

上级 ddee8193
...@@ -11,24 +11,27 @@ from avocado.core import exceptions ...@@ -11,24 +11,27 @@ from avocado.core import exceptions
from aexpect import ShellCmdError from aexpect import ShellCmdError
from virttest.utils_test.qemu import MemoryBaseTest from virttest.utils_test.qemu import MemoryBaseTest
from qemu.tests.balloon_check import BallooningTestWin from qemu.tests.balloon_check import BallooningTestWin
from qemu.tests.balloon_check import BallooningTestLinux
@error_context.context_aware @error_context.context_aware
def run(test, params, env): def run(test, params, env):
""" """
Balloon service test for windows guest. Balloon service test, i.e. guest-stats-polling-interval test.
1) boot a windows guest with balloon device. 1) boot a guest with balloon device.
2) enable and check driver verifier in guest. 2) enable and check driver verifier in guest(only for windows guest).
3) install balloon service in guest. 3) install balloon service in guest(only for windows guest).
4) enable polling in qmp. 4) enable polling in qmp.
5) evict and enlarge balloon. 5) evict / enlarge balloon.
6) get polling value in qmp. 6) get polling value in qmp, then do memory check if necessary.
7) uninstall balloon service and clear driver verifier. 7) repeat steps 5) and 6) for multi times
8) uninstall balloon service and clear driver verifier(only for
windows guest).
""" """
def get_disk_vol(session): def get_disk_vol(session):
""" """
Get virtio-win disk volume letter. Get virtio-win disk volume letter for windows guest.
:param session: VM session. :param session: VM session.
""" """
...@@ -41,7 +44,7 @@ def run(test, params, env): ...@@ -41,7 +44,7 @@ def run(test, params, env):
def config_balloon_service(session, drive_letter): def config_balloon_service(session, drive_letter):
""" """
Check / Install balloon service. Check / Install balloon service for windows guest.
:param session: VM session. :param session: VM session.
:param drive_letter: virtio-win disk volume letter. :param drive_letter: virtio-win disk volume letter.
...@@ -97,17 +100,21 @@ def run(test, params, env): ...@@ -97,17 +100,21 @@ def run(test, params, env):
(keyname, guest_mem, stat_memory_qmp, (keyname, guest_mem, stat_memory_qmp,
check_mem_ratio)) check_mem_ratio))
def balloon_memory(session, device_path): def balloon_memory(vm, device_path, mem_check):
""" """
Doing memory balloon in a loop and check memory status during balloon. Doing memory balloon in a loop and check memory status during balloon.
:param session: VM session. :param vm: VM object.
:param device_path: balloon polling path. :param device_path: balloon polling path.
:param mem_check: need to do memory check if param mem_check is 'yes'
""" """
repeat_times = int(params.get("repeat_times", 5)) repeat_times = int(params.get("repeat_times", 5))
logging.info("repeat times: %d" % repeat_times) logging.info("repeat times: %d" % repeat_times)
if params['os_type'] == 'windows':
balloon_test = BallooningTestWin(test, params, env) balloon_test = BallooningTestWin(test, params, env)
balloon_test = BallooningTestWin(test, params, env) else:
balloon_test = BallooningTestLinux(test, params, env)
min_sz, max_sz = balloon_test.get_memory_boundary() min_sz, max_sz = balloon_test.get_memory_boundary()
while repeat_times: while repeat_times:
for tag in params.objects('test_tags'): for tag in params.objects('test_tags'):
...@@ -115,9 +122,11 @@ def run(test, params, env): ...@@ -115,9 +122,11 @@ def run(test, params, env):
params_tag = params.object_params(tag) params_tag = params.object_params(tag)
balloon_type = params_tag['balloon_type'] balloon_type = params_tag['balloon_type']
if balloon_type == 'evict': if balloon_type == 'evict':
expect_mem = int(random.uniform(min_sz, balloon_test.get_ballooned_memory())) expect_mem = int(random.uniform(min_sz,
balloon_test.get_ballooned_memory()))
else: else:
expect_mem = int(random.uniform(balloon_test.get_ballooned_memory(), max_sz)) expect_mem = int(random.uniform(
balloon_test.get_ballooned_memory(), max_sz))
quit_after_test = balloon_test.run_ballooning_test(expect_mem, quit_after_test = balloon_test.run_ballooning_test(expect_mem,
tag) tag)
...@@ -125,6 +134,7 @@ def run(test, params, env): ...@@ -125,6 +134,7 @@ def run(test, params, env):
get_polling_output = vm.monitor.qom_get(device_path, get_polling_output = vm.monitor.qom_get(device_path,
get_balloon_property) get_balloon_property)
time.sleep(20) time.sleep(20)
if mem_check == "yes":
memory_check(vm, get_polling_output, 'stat-free-memory') memory_check(vm, get_polling_output, 'stat-free-memory')
if quit_after_test: if quit_after_test:
return return
...@@ -132,7 +142,7 @@ def run(test, params, env): ...@@ -132,7 +142,7 @@ def run(test, params, env):
repeat_times -= 1 repeat_times -= 1
timeout = int(params.get("login_timeout", 360)) timeout = int(params.get("login_timeout", 360))
driver_name = params.get("driver_name", "balloon") mem_check = params.get("mem_check", "yes")
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"])
...@@ -148,10 +158,13 @@ def run(test, params, env): ...@@ -148,10 +158,13 @@ def run(test, params, env):
polling_interval = int(params.get("polling_interval", 2)) polling_interval = int(params.get("polling_interval", 2))
try: try:
session = vm.wait_for_login(timeout=timeout)
if params['os_type'] == 'windows':
driver_name = params.get("driver_name", "balloon")
utils_test.qemu.setup_win_driver_verifier(driver_name, vm, timeout) utils_test.qemu.setup_win_driver_verifier(driver_name, vm, timeout)
error_context.context("Config balloon service in guest", logging.info) error_context.context("Config balloon service in guest",
session = vm.wait_for_login(timeout=timeout) logging.info)
drive_letter = get_disk_vol(session) drive_letter = get_disk_vol(session)
config_balloon_service(session, drive_letter) config_balloon_service(session, drive_letter)
...@@ -163,10 +176,12 @@ def run(test, params, env): ...@@ -163,10 +176,12 @@ def run(test, params, env):
memory_check(vm, get_polling_output, 'stat-total-memory') memory_check(vm, get_polling_output, 'stat-total-memory')
error_context.context("Balloon vm memory in loop", logging.info) error_context.context("Balloon vm memory in loop", logging.info)
balloon_memory(session, device_path) balloon_memory(vm, device_path, mem_check)
finally: finally:
error_context.context("Clear balloon service in guest", logging.info) if params['os_type'] == 'windows':
error_context.context("Clear balloon service in guest",
logging.info)
uninstall_cmd = params["uninstall_balloon_service"] % drive_letter uninstall_cmd = params["uninstall_balloon_service"] % drive_letter
session.cmd(uninstall_cmd, ignore_all_errors=True) session.cmd(uninstall_cmd, ignore_all_errors=True)
session.close() session.close()
- balloon_service: install setup image_copy unattended_install.cdrom - balloon_service: install setup image_copy unattended_install.cdrom
virt_test_type = qemu virt_test_type = qemu
type = balloon_service type = balloon_service
only Windows no Win2000, Fedora.8, Fedora.9, Fedora.10, RHEL.3, RHEL.4, Unix, livecd
no Host_RHEL.m5, Host_RHEL.m6 no Host_RHEL.m5, Host_RHEL.m6
monitor_type = "qmp" monitor_type = "qmp"
monitors = qmp1 monitors = qmp1
balloon = balloon0 balloon = balloon0
balloon_dev_devid = balloon0 balloon_dev_devid = balloon0
balloon_dev_add_bus = yes balloon_dev_add_bus = yes
Windows:
driver_name = "balloon" driver_name = "balloon"
cdroms = "cd1 winutils virtio" cdroms = "cd1 winutils virtio"
drive_index_virtio = 3 # Please change following cdrom_virtio to the right version
cdrom_virtio = isos/windows/virtio-win-1.8.0-4.iso # if necessary
cdrom_virtio = isos/windows/virtio-win-***.iso
# balloon service related cmd, which will be covered by different # balloon service related cmd, which will be covered by different
# guest's paths in guest-os cfg. # guest's paths in guest-os cfg.
install_balloon_service = "%s:\Balloon\GUEST_OS\amd64\blnsvr.exe -i" install_balloon_service = "%s:\Balloon\GUEST_OS\amd64\blnsvr.exe -i"
...@@ -22,11 +24,18 @@ ...@@ -22,11 +24,18 @@
base_path = "/machine/peripheral/" base_path = "/machine/peripheral/"
set_balloon_property = "guest-stats-polling-interval" set_balloon_property = "guest-stats-polling-interval"
get_balloon_property = "guest-stats" get_balloon_property = "guest-stats"
polling_interval = 2 polling_sleep_time = 20
polling_sleep_time = 10
free_mem_cmd = wmic os get FreePhysicalMemory
ratio = 0.1 ratio = 0.1
run_sub_test_after_balloon = no run_sub_test_after_balloon = no
test_tags = "evict enlarge" test_tags = "evict enlarge"
balloon_type_evict = evict balloon_type_evict = evict
balloon_type_enlarge = enlarge balloon_type_enlarge = enlarge
variants:
- small_polling_interval:
polling_interval = 2
- large_polling_interval:
polling_interval = 21474836
# No need to check the memory if set a large polling interval
# since qmp cmd 'qom-get' output for the balloon device won't
# change for a long time
mem_check = no
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册