Skip to content

Commit 7c0bf3e

Browse files
authored
Merge pull request #3810 from cliping/blockjob
Add a function to check item multiple times by blockjob
2 parents 7fd19b5 + 928bfa1 commit 7c0bf3e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

virttest/utils_libvirt/libvirt_disk.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,3 +614,28 @@ def check_virtual_disk_io(vm, partition, path="/dev/%s"):
614614
finally:
615615
if session:
616616
session.close()
617+
618+
619+
def check_item_by_blockjob(params):
620+
"""
621+
Check item by blockjob, for example, bandwidth, progress.
622+
623+
:param params: dictionary with the test parameter
624+
"""
625+
vm_name = params.get("main_vm")
626+
check_item = params.get("check_item")
627+
check_item_value = params.get("check_item_value")
628+
target_disk = params.get("target_disk", "vda")
629+
wait_for_timeout = params.get("wait_for_timeout", "10")
630+
631+
if check_item == "none":
632+
if not utils_misc.wait_for(
633+
lambda: libvirt.check_blockjob(vm_name, target_disk),
634+
wait_for_timeout):
635+
raise exceptions.TestFail("Check failed.")
636+
else:
637+
if not utils_misc.wait_for(
638+
lambda: libvirt.check_blockjob(vm_name,
639+
target_disk, check_item, check_item_value),
640+
wait_for_timeout):
641+
raise exceptions.TestFail("Check '%s' failed." % check_item)

0 commit comments

Comments
 (0)