Skip to content

Commit

Permalink
Update event timeout for copy storage migration
Browse files Browse the repository at this point in the history
1. It takes longer to get the desired event in copy storage migration.
So update event timeout.
2. Add a function to check item multiple times by check_blockjob().

Signed-off-by: lcheng <[email protected]>
  • Loading branch information
cliping committed Dec 6, 2023
1 parent 291ae9f commit a03b41a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion virttest/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ def _run_complex_func(vm, one_func, virsh_event_session=None):
after_event = one_func.get('after_event')
before_event = one_func.get('before_event')
func = one_func.get('func')
wait_for_after_event_timeout = one_func.get('wait_for_after_event_timeout', '30')
if after_event and not virsh_event_session:
raise exceptions.TestError("virsh session for collecting domain "
"events is not provided")
Expand All @@ -417,7 +418,7 @@ def _run_complex_func(vm, one_func, virsh_event_session=None):
"%s", virsh_event_session.get_stripped_output())
if not utils_misc.wait_for(
lambda: re.findall(after_event,
virsh_event_session.get_stripped_output()), 30):
virsh_event_session.get_stripped_output()), wait_for_after_event_timeout):
raise exceptions.TestError("Unable to find "
"event {}".format(after_event))
LOG.debug("Receive the event '{}'".format(after_event))
Expand Down
25 changes: 25 additions & 0 deletions virttest/utils_libvirt/libvirt_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,3 +614,28 @@ def check_virtual_disk_io(vm, partition, path="/dev/%s"):
finally:
if session:
session.close()


def check_item_by_blockjob(params):
"""
Check item by blockjob, for example, bandwidth, progress.
:param params: dictionary with the test parameter
"""
vm_name = params.get("main_vm")
check_item = params.get("check_item")
check_item_value = params.get("check_item_value")
target_disk = params.get("target_disk", "vda")
wait_for_timeout = params.get("wait_for_timeout", "10")

if check_item == "none":
if not utils_misc.wait_for(
lambda: libvirt.check_blockjob(vm_name, target_disk),
wait_for_timeout):
raise exceptions.TestFail("Check failed.")
else:
if not utils_misc.wait_for(
lambda: libvirt.check_blockjob(vm_name,
target_disk, check_item, check_item_value),
wait_for_timeout):
raise exceptions.TestFail("Check '%s' failed." % check_item)

0 comments on commit a03b41a

Please sign in to comment.