Skip to content

Commit

Permalink
Merge pull request #3810 from cliping/blockjob
Browse files Browse the repository at this point in the history
Add a function to check item multiple times by blockjob
  • Loading branch information
chloerh authored Dec 7, 2023
2 parents 7fd19b5 + 928bfa1 commit 7c0bf3e
Showing 1 changed file with 25 additions and 0 deletions.
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 7c0bf3e

Please sign in to comment.