Skip to content

Commit

Permalink
Merge pull request #5888 from liang-cong-red-hat/memory-balloon_perio…
Browse files Browse the repository at this point in the history
…d_change_verification_timeline

Change guest memory statistics checking timeline
  • Loading branch information
chloerh authored Sep 20, 2024
2 parents c46091b + 1a72e04 commit 23c9fb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
current_mem_unit = "KiB"
current_mem = "2097152"
mem_value = "2097152"
mem_operation = "swapoff -a; dd if=/dev/zero of=/tmp/temp bs=1024K count=10; memhog -r5 500M"
mem_operation = "swapoff -a && dd if=/dev/zero of=/tmp/temp bs=1024K count=10 && timeout 5s memhog -r5000 500M"
variants:
- virtio_model:
memballoon_model = "virtio"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import re

from virttest import utils_misc
from virttest import virsh

from virttest.libvirt_xml import vm_xml
Expand Down Expand Up @@ -45,20 +44,15 @@ def get_memory_statistics():
:return: usable mem, last_update, disk_caches value in result.
"""
def _get_response():
res = virsh.dommemstat(vm_name, ignore_status=False,
debug=True).stdout_text
return re.findall(r'usable (\d+)', res)

if utils_misc.wait_for(_get_response, 30, 5):
res = virsh.dommemstat(vm_name, ignore_status=False,
debug=True).stdout_text
res = virsh.dommemstat(vm_name, ignore_status=False,
debug=True).stdout_text
if re.findall(r'usable (\d+)', res):
usable_mem = re.findall(r'usable (\d+)', res)[0]
last_update = re.findall(r'last_update (\d+)', res)[0]
disk_caches = re.findall(r'disk_caches (\d+)', res)[0]
return usable_mem, last_update, disk_caches
else:
test.fail("Not get virsh dommemstat result in 25s")
test.fail("Fail to get virsh dommemstat result")

def check_vm_dommemstat(period_config, usable_mem, last_update,
disk_caches):
Expand Down Expand Up @@ -104,12 +98,12 @@ def check_xml_and_dommemstat(period_set):
vmxml, expect_xpath, ignore_status=True) == xpath_existed:
test.fail("Expect to get '%s' in xml " % expect_xpath)

guest_session = vm.wait_for_login()
usable_mem, last_update, disk_caches = get_memory_statistics()

guest_session = vm.wait_for_login()
status, stdout = guest_session.cmd_status_output(mem_operation)
guest_session.close()
if status:
if status != 0 and status != 124:
test.fail("Failed to consume memory: %s" % stdout)

check_vm_dommemstat(period_set, usable_mem, last_update, disk_caches)
Expand Down

0 comments on commit 23c9fb7

Please sign in to comment.