提交 4c43136a 编写于 作者: X Xu Tian 提交者: GitHub

Merge pull request #611 from xutian/hotplug_repeat

Add hotplug/unplug memory in loop test
# Notes:
# Before start testing, please ensure systemd is your guest OS
# is support memory hotplug;
- hotplug_memory_repeat:
type = hotplug_mem_repeat
only Linux
no Host_RHEL.m6
no RHEL.5 RHEL.6
threshold = 210
slots_mem = 4
size_mem = 128M
mem_fixed = 1024
maxmem_mem = 32G
target_mem = mem1
login_timeout = 600
variants:
- policy_default:
policy_mem = default
- policy_bind:
policy_mem = bind
host-nodes = 0
- policy_interleave:
policy_mem = interleave
host-nodes = 0
- policy_preferred:
policy_mem = preferred
host-nodes = 0
- no_policy:
del policy_mem
variants:
- backend_ram:
backend_mem = memory-backend-ram
- backend_file:
backend_mem = memory-backend-file
setup_hugepages = yes
mem-path = /mnt/kvm_hugepage
target_hugepages = 2058
pre_command = "echo 3 > /proc/sys/vm/drop_caches"
pre_command_noncritical = yes
variants:
- @repeat_256:
repeats = 256
scalability_test = no
- scalability_test:
scalability_test = yes
slots_mem = 256
import time
import logging
from virttest.utils_test.qemu import MemoryHotplugTest
try:
from virttest import error_context as step_engine
except ImportError:
from autotest.client.shared.error import step_engine
class MemoryHotplugRepeat(MemoryHotplugTest):
def start_test(self):
"""
Prepare reqired test params, then start memory
hotplug/unplug tests in turn. And this is test entry.
"""
target_mem = self.params["target_mem"]
vm = self.env.get_vm(self.params["main_vm"])
max_slots = int(self.params.get("slots_mem", 4))
scalability_test = self.params.get("scalability_test") == "yes"
repeats = scalability_test and max_slots or self.params["repeats"]
original_mem = self.get_guest_total_mem(vm)
for repeat in xrange(int(repeats)):
extra_params = (scalability_test and
[{'slot_dimm': repeat}] or [None])[0]
step_engine.context(
"Hotplug/unplug loop '%d'" %
repeat, logging.info)
self.turn(vm, target_mem, extra_params)
current_mem = self.get_guest_total_mem(vm)
if current_mem != original_mem:
raise error.TestFailed("Guest memory changed about repeat "
"hotpug/unplug memory %d times" % repeat)
time.sleep(1.5)
vm.verify_alive()
vm.reboot()
def turn(self, vm, target_mem, extra_params=None):
"""
Hotplug/Unplug memory in turn
:param vm: qemu target VM object
:param target_mem: memory name of target VM object
:param extra_params: params dict, that you want to update
"""
memorys = self.get_all_memorys(vm)
if extra_params:
self.params.update(extra_params)
self.hotplug_memory(vm, target_mem)
memorys_added = self.get_all_memorys(vm) - memorys
offline_memorys = self.get_offline_memorys(vm)
time.sleep(1.5)
for memory in offline_memorys:
# Online memory to movable zone maybe failed, see details
# in redhat Bug 1314306
self.memory_operate(vm, memory, 'online_movable')
for memory in memorys_added:
self.memory_operate(vm, memory, 'offline')
time.sleep(1.5)
self.unplug_memory(vm, target_mem)
@step_engine.context_aware
def run(test, params, env):
"""
Qemu memory hotplug test:
1) Boot guest with -m option
2) Hotplug/unplug memory in turn
3) Reboot VM
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment.
"""
hotplug_test = MemoryHotplugRepeat(test, params, env)
hotplug_test.start_test()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册