未验证 提交 1cfba46a 编写于 作者: B Balamuruhan S 提交者: GitHub

Merge pull request #1178 from huangyum/numa_1503402

numa_basic: Check node free memory before test
import logging import logging
from autotest.client.shared import error
from virttest import env_process from virttest import env_process
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 virttest.staging import utils_memory from virttest.staging import utils_memory
@error.context_aware @error_context.context_aware
def run(test, params, env): def run(test, params, env):
""" """
Qemu numa basic test: Qemu numa basic test:
...@@ -23,23 +22,27 @@ def run(test, params, env): ...@@ -23,23 +22,27 @@ def run(test, params, env):
: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.
""" """
error.context("Get host numa topological structure", logging.info) error_context.context("Get host numa topological structure", logging.info)
timeout = float(params.get("login_timeout", 240)) timeout = float(params.get("login_timeout", 240))
host_numa_node = utils_misc.NumaInfo() host_numa_node = utils_misc.NumaInfo()
node_list = host_numa_node.online_nodes node_list = host_numa_node.online_nodes
for node_id in node_list: for node_id in node_list:
error.base_context("Bind qemu process to numa node %s" % node_id, error_context.base_context("Bind qemu process to numa node %s" % node_id,
logging.info) logging.info)
vm = "vm_bind_to_%s" % node_id vm = "vm_bind_to_%s" % node_id
params['qemu_command_prefix'] = "numactl --cpunodebind=%s" % node_id params['qemu_command_prefix'] = "numactl --cpunodebind=%s" % node_id
utils_memory.drop_caches() utils_memory.drop_caches()
node_MemFree = int(host_numa_node.read_from_node_meminfo(node_id,
"MemFree"))
if node_MemFree < int(params["mem"]) * 1024:
test.cancel("No enough free memory in node %d." % node_id)
env_process.preprocess_vm(test, params, env, vm) env_process.preprocess_vm(test, params, env, vm)
vm = env.get_vm(vm) vm = env.get_vm(vm)
vm.verify_alive() vm.verify_alive()
session = vm.wait_for_login(timeout=timeout) session = vm.wait_for_login(timeout=timeout)
session.close() session.close()
error.context("Check the memory use status of qemu process", error_context.context("Check the memory use status of qemu process",
logging.info) logging.info)
memory_status, _ = utils_test.qemu.get_numa_status(host_numa_node, memory_status, _ = utils_test.qemu.get_numa_status(host_numa_node,
vm.get_pid()) vm.get_pid())
...@@ -52,9 +55,7 @@ def run(test, params, env): ...@@ -52,9 +55,7 @@ def run(test, params, env):
logging.debug("Qemu used %s pages in node" logging.debug("Qemu used %s pages in node"
" %s" % (memory_status[index], node_list[index])) " %s" % (memory_status[index], node_list[index]))
if node_used_most != node_id: if node_used_most != node_id:
raise error.TestFail("Qemu still use memory from other node." test.fail("Qemu still use memory from other node. "
" Expect: %s, used: %s" % (node_id, "Expect: %s, used: %s" % (node_id, node_used_most))
node_used_most)) error_context.context("Destroy guest.", logging.info)
error.context("Destroy guest.", logging.info)
vm.destroy() vm.destroy()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册