Skip to content

Commit

Permalink
livemerge_test: fake prune_bitmaps errors
Browse files Browse the repository at this point in the history
Add support to fake errors in prune_bitmaps calls
to the IRS fake class.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
  • Loading branch information
aesteve-rh committed Dec 13, 2022
1 parent 05bdbe8 commit 9c9f881
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/virt/livemerge_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from vdsm.common.config import config
from vdsm.common.units import GiB, MiB

from vdsm.virt import errors
from vdsm.virt import metadata
from vdsm.virt import migration
from vdsm.virt import thinp
Expand Down Expand Up @@ -889,6 +890,23 @@ def test_internal_merge():
assert vm.volume_monitor.enabled


def test_internal_merge_prune_error():
config = Config('internal-merge')
merge_params = config.values["merge_params"]

vm = RunningVM(config)

assert vm.query_jobs() == {}

# Simulate prune_bitmaps error.
error_msg = "Failed to remove bitmap"
vm.cif.irs.errors["prune_bitmaps"] = exception.RemoveBitmapError(error_msg)

with pytest.raises(errors.StorageUnavailableError) as e:
vm.merge(**merge_params)
assert error_msg in str(e)


def test_extend_timeout_recover(fake_time):
config = Config('active-merge')
sd_id = config.values["drive"]["domainID"]
Expand Down
4 changes: 4 additions & 0 deletions tests/virt/vmfakelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self):
self.extend_requests = []
self.sd_types = {}
self.measure_info = {}
self.errors = {}

def getDeviceVisibility(self, guid):
pass
Expand All @@ -53,6 +54,9 @@ def inappropriateDevices(self, ident):

@recorded
def prune_bitmaps(self, sdUUID, imgUUID, volUUID, baseUUID):
error = self.errors.get("prune_bitmaps")
if error:
return response.error_raw(error.code, error.msg)
return response.success(result=None)

def measure(self, sdUUID, imgUUID, volUUID, dest_format, backing=True,
Expand Down

0 comments on commit 9c9f881

Please sign in to comment.