Skip to content

Commit

Permalink
zfs-vol: add a test for VDI resize
Browse files Browse the repository at this point in the history
Signed-off-by: Yann Dirson <[email protected]>
  • Loading branch information
ydirson committed Apr 4, 2024
1 parent dd75e38 commit cd35610
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/vdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def __init__(self, sr, uuid, snapshot_of=None):
# TODO: use a different approach when migration is possible
self.sr = sr

def resize(self, size):
return self.sr.pool.master.xe('vdi-resize', {'uuid': self.uuid,
'disk-size': str(size)})

def snapshot(self):
logging.info(f"Create snapshot of {self}")
return VDI(self.sr,
Expand Down
14 changes: 14 additions & 0 deletions tests/storage/zfsvol/test_zfsvol_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ def test_create_and_destroy_sr(self, host, sr_disk_wiped):

@pytest.mark.usefixtures("zfsvol_sr")
class TestZfsvolSrBasics:
def test_vdi_resize(self, vdi_on_zfsvol_sr):
logging.info("Resize up")
vdi_on_zfsvol_sr.resize(1024 * 1024)
logging.info("Attempt to resize down")
try:
vdi_on_zfsvol_sr.resize(64 * 1024)
except Exception as e:
if "shrinking not allowed" in str(e):
# properly refused
pass
else:
logging.error("unexpected error on downsize attempt: %s", e)
raise

@pytest.mark.xfail # needs support for cloning non-snapshots
def test_vdi_clone(self, vdi_on_zfsvol_sr):
clone = vdi_on_zfsvol_sr.clone()
Expand Down

0 comments on commit cd35610

Please sign in to comment.