Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add consume memory repeat times #3996

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions virttest/utils_libvirt/libvirt_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,20 @@ def normalize_mem_size(mem_size, mem_unit):
return int(mem_size * 1024**mem_unit_idx)


def consume_vm_freememory(vm_session, consume_value=100000):
def consume_vm_freememory(vm_session, consume_value=100000, repeat_times=1):
"""
Verify the free memory of the vm can be consumed normally

:param vm_session: vm session
:param consume_value: consume value , default 100000
:param repeat_times: consume memory times, default 1
"""
vm_session.cmd_status("swapoff -a")
free_mem = utils_memory.freememtotal(vm_session)
if not utils_package.package_install("numactl", vm_session):
raise exceptions.TestError(
"Fail to install package 'numactl' which provides command 'memhog'"
)
cmd = "memhog %dk" % (free_mem - consume_value)
cmd = "memhog -r%d %dk" % (repeat_times, (free_mem - consume_value))
status, stdout = vm_session.cmd_status_output(cmd, timeout=60)
return (status, stdout)
Loading