Only storage backend for RBD (RADOS Block Device), FS and directory have the resizeVol function, so only testing dir volume here. Flags 'allocate' and 'shrik' are with bug: https://bugzilla.redhat.com/show_bug.cgi?id=804516 they are not supported yet, so leave the case for later. * using volume resize API with flag VIR_STORAGE_VOL_RESIZE_DELTA * using volume info API to get volume info and check * add dir volume resize conf Signed-off-by: Wayne Sun <gsun@xxxxxxxxxx> --- cases/storage_dir_vol_resize_delta.conf | 47 +++++++++++++++++++ repos/storage/vol_resize_delta.py | 75 +++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 0 deletions(-) create mode 100644 cases/storage_dir_vol_resize_delta.conf create mode 100644 repos/storage/vol_resize_delta.py diff --git a/cases/storage_dir_vol_resize_delta.conf b/cases/storage_dir_vol_resize_delta.conf new file mode 100644 index 0000000..58e15bf --- /dev/null +++ b/cases/storage_dir_vol_resize_delta.conf @@ -0,0 +1,47 @@ +storage:create_dir_pool + poolname + $defaultpoolname + +storage:create_dir_volume + poolname + $defaultpoolname + volname + $defaultvolumename + volformat + $defaultvolumetype + capacity + $defaultvolumesize + +storage:vol_resize_delta + poolname + $defaultpoolname + volname + $defaultvolumename + capacity + 1M + +storage:vol_resize_delta + poolname + $defaultpoolname + volname + $defaultvolumename + capacity + 2G + +storage:vol_resize_delta + poolname + $defaultpoolname + volname + $defaultvolumename + capacity + 4096K + +storage:delete_dir_volume + poolname + $defaultpoolname + volname + $defaultvolumename + +storage:destroy_pool + poolname + $defaultpoolname diff --git a/repos/storage/vol_resize_delta.py b/repos/storage/vol_resize_delta.py new file mode 100644 index 0000000..a87941e --- /dev/null +++ b/repos/storage/vol_resize_delta.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# volume resize testing with delta flags, libvirt storage +# driver only support dir now + +import libvirt +from libvirt import libvirtError + +from src import sharedmod +from utils import utils + +required_params = ('poolname', 'volname', 'capacity',) +optional_params = {} + +def vol_resize_delta(params): + """test volume resize with delta flags""" + + global logger + logger = params['logger'] + poolname = params['poolname'] + volname = params['volname'] + capacity = params['capacity'] + + logger.info("the poolname is %s, volname is %s" % + (poolname, volname)) + + logger.info("the capacity given is %s" % capacity) + out = utils.get_capacity_suffix_size(capacity) + capacity_val = out['capacity_byte'] + logger.debug("the capacity to byte is %s" % capacity_val) + + conn = sharedmod.libvirtobj['conn'] + try: + poolobj = conn.storagePoolLookupByName(poolname) + vol = poolobj.storageVolLookupByName(volname) + + logger.info("get volume info before resize") + out = vol.info() + pre_capacity = out[1] + pre_allocation = out[2] + logger.info("volume capacity is %s bytes, allocation is %s bytes" % + (pre_capacity, pre_allocation)) + + flag = libvirt.VIR_STORAGE_VOL_RESIZE_DELTA + logger.info("resize %s with capacity %s in pool %s using flag: %s" + % (volname, capacity, poolname, flag)) + + vol.resize(capacity_val, flag) + + logger.info("get volume info after resize") + out = vol.info() + post_capacity = out[1] + post_allocation = out[2] + logger.info("volume capacity is %s bytes, allocation is %s bytes" % + (post_capacity, post_allocation)) + + logger.info("check resize effect") + if post_capacity - pre_capacity == capacity_val: + logger.info("increased size is expected") + else: + logger.error("increase size not equal to set, resize failed") + return 1 + + if pre_allocation == post_allocation: + logger.info("allocation is expected") + else: + logger.error("allocation changed, resize failed") + return 1 + + logger.info("resize succeed") + + except libvirtError, e: + logger.error("libvirt call failed: " + str(e)) + return 1 + + return 0 -- 1.7.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list