test/lvol: get proper size for construct_lvol_bdev

Change-Id: I7c4686ffc3800867227cac6e2b9a04bf1be05970
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/420652
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Pawel Niedzwiecki 2018-07-27 20:53:01 +02:00 committed by Jim Harris
parent d3995f6eca
commit 9ead0e506c

View File

@ -272,6 +272,18 @@ class TestCases(object):
print("INFO: Traddr not found for Nvme {nvme}".format(nvme=nvme_name))
return -1
def get_lvs_size(self):
lvs = self.c.get_lvol_stores()
return int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / MEGABYTE)
def get_lvol_bdev_split_size(self, split_num):
lvs = self.c.get_lvol_stores()
return int(int(lvs[0][u'free_clusters'] / split_num) * lvs[0]['cluster_size'] / MEGABYTE)
def get_lvs_cluster_size(self):
lvs = self.c.get_lvol_stores()
return int(int(lvs[0]['cluster_size']) / MEGABYTE)
# positive tests
@case_message
def test_case1(self):
@ -297,11 +309,13 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs_size = self.get_lvs_size()
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
self.lbd_name,
self.total_size - 1)
lvs_size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
self.total_size - 1)
lvs_size)
self.c.destroy_lvol_bdev(uuid_bdev)
self.c.destroy_lvol_store(uuid_store)
self.c.delete_malloc_bdev(base_name)
@ -316,7 +330,7 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
size = int((self.total_size - 1) / 4)
size = self.get_lvol_bdev_split_size(4)
for j in range(2):
uuid_bdevs = []
@ -345,12 +359,12 @@ class TestCases(object):
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs_size = self.get_lvs_size()
uuid_bdev = self.c.construct_lvol_bdev(self.lvs_name,
self.lbd_name,
self.total_size - 1)
lvs_size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
self.total_size - 1)
lvs_size)
fail_count += self.c.destroy_lvol_bdev(uuid_bdev)
fail_count += self.c.destroy_lvol_store(uuid_store)
@ -375,14 +389,15 @@ class TestCases(object):
fail_count = self.c.check_get_lvol_stores(base_name_2, uuid_store_2,
self.cluster_size)
lvs_size = self.get_lvs_size()
uuid_bdev_1 = self.c.construct_lvol_bdev(uuid_store_1,
self.lbd_name,
self.total_size - 1)
lvs_size)
uuid_bdev_2 = self.c.construct_lvol_bdev(uuid_store_2,
self.lbd_name,
self.total_size - 1)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev_1, self.total_size - 1)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev_2, self.total_size - 1)
lvs_size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev_1, lvs_size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev_2, lvs_size)
fail_count += self.c.destroy_lvol_bdev(uuid_bdev_1)
fail_count += self.c.destroy_lvol_bdev(uuid_bdev_2)
@ -410,14 +425,15 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs_size = self.get_lvs_size()
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
self.lbd_name,
self.total_size - 1)
lvs_size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
self.total_size - 1)
lvs_size)
if self.c.construct_lvol_bdev(uuid_store,
self.lbd_name + "_1",
self.total_size - 1) == 0:
lvs_size) == 0:
fail_count += 1
self.c.destroy_lvol_bdev(uuid_bdev)
@ -435,6 +451,7 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
size = self.get_lvs_size()
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
self.lbd_name,
size)
@ -460,17 +477,18 @@ class TestCases(object):
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
# size is equal to one quarter of size malloc bdev
size = int(self.total_size / 4)
size = self.get_lvol_bdev_split_size(4)
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size)
# size is equal to half of size malloc bdev
size = int(self.total_size / 2)
size = self.get_lvol_bdev_split_size(2)
self.c.resize_lvol_bdev(uuid_bdev, size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size)
# size is smaller by 1 MB
size = self.total_size - 1
# size is smaller by 1 cluster
size = (self.get_lvs_size() - self.get_lvs_cluster_size())
self.c.resize_lvol_bdev(uuid_bdev, size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size)
@ -500,11 +518,12 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs_size = self.get_lvs_size()
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
self.lbd_name,
self.total_size - 1)
lvs_size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
self.total_size - 1)
lvs_size)
if self.c.resize_lvol_bdev(uuid_bdev, self.total_size + 1) == 0:
fail_count += 1
@ -552,11 +571,12 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs_size = self.get_lvs_size()
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
self.lbd_name,
self.total_size - 1)
lvs_size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
self.total_size - 1)
lvs_size)
if self.c.destroy_lvol_store(uuid_store) != 0:
fail_count += 1
@ -574,7 +594,7 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
size = int((self.total_size - 1) / 4)
size = self.get_lvol_bdev_split_size(4)
for i in range(4):
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
@ -597,7 +617,7 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
size = int((self.total_size - 1) / 4)
size = self.get_lvol_bdev_split_size(4)
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
self.lbd_name,
size)
@ -1049,7 +1069,7 @@ class TestCases(object):
self.cluster_size)
lvs = self.c.get_lvol_stores(self.lvs_name)[0]
free_clusters_start = int(lvs['free_clusters'])
bdev_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
bdev_size = self.get_lvs_size()
# create thin provisioned lvol bdev with size equals to lvol store free space
bdev_name = self.c.construct_lvol_bdev(uuid_store, self.lbd_name,
bdev_size, thin=True)
@ -1132,7 +1152,7 @@ class TestCases(object):
lbd_name0 = self.lbd_name + str("0")
lbd_name1 = self.lbd_name + str("1")
# calculate bdev size in megabytes
bdev_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
bdev_size = self.get_lvs_size()
# create thick provisioned lvol bvdev with size equal to lvol store
bdev_name0 = self.c.construct_lvol_bdev(uuid_store, lbd_name0,
bdev_size, thin=False)
@ -1187,7 +1207,7 @@ class TestCases(object):
self.cluster_size)
lvs = self.c.get_lvol_stores(self.lvs_name)[0]
free_clusters_start = int(lvs['free_clusters'])
bdev_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
bdev_size = self.get_lvs_size()
# construct thin provisioned lvol bdev with size equal to lvol store
bdev_name = self.c.construct_lvol_bdev(uuid_store, self.lbd_name,
bdev_size, thin=True)
@ -1263,7 +1283,7 @@ class TestCases(object):
free_clusters_start = int(lvs['free_clusters'])
lbd_name0 = self.lbd_name + str("0")
lbd_name1 = self.lbd_name + str("1")
bdev_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
bdev_size = self.get_lvs_size()
# construct two thin provisioned lvol bdevs on created lvol store
# with size equals to free lvs size
bdev_name0 = self.c.construct_lvol_bdev(uuid_store, lbd_name0,
@ -1334,7 +1354,7 @@ class TestCases(object):
free_clusters_start = int(lvs['free_clusters'])
lbd_name0 = self.lbd_name + str("0")
lbd_name1 = self.lbd_name + str("1")
lvs_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
lvs_size = self.get_lvs_size()
bdev_size = int(lvs_size * 0.7)
# construct two thin provisioned lvol bdevs on created lvol store
# with size equal to 70% of lvs size
@ -1403,8 +1423,7 @@ class TestCases(object):
self.cluster_size)
# size = approx 2% of total NVMe disk size
_ = self.c.get_lvol_stores()[0]
size = int(_["free_clusters"] / 50)
size = self.get_lvol_bdev_split_size(50)
for i in range(5):
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
@ -1545,7 +1564,7 @@ class TestCases(object):
lvs = self.c.get_lvol_stores()[0]
free_clusters_start = int(lvs['free_clusters'])
bdev_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE / 3)
bdev_size = self.get_lvol_bdev_split_size(3)
# Create lvol bdev with 33% of lvol store space
bdev_name = self.c.construct_lvol_bdev(uuid_store, self.lbd_name,
bdev_size)
@ -1597,8 +1616,7 @@ class TestCases(object):
self.cluster_size)
fail_count += self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs = self.c.get_lvol_stores()
size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 6 / MEGABYTE)
size = self.get_lvol_bdev_split_size(6)
lbd_name0 = self.lbd_name + str(0)
lbd_name1 = self.lbd_name + str(1)
# Create thin provisioned lvol bdev with size less than 25% of lvs
@ -1674,9 +1692,8 @@ class TestCases(object):
self.cluster_size)
fail_count += self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs = self.c.get_lvol_stores()
# Create thin provisioned lvol bdev with size equal to 50% of lvs space
size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 2 / MEGABYTE)
size = self.get_lvol_bdev_split_size(2)
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.lbd_name,
size, thin=True)
@ -1731,9 +1748,8 @@ class TestCases(object):
self.cluster_size)
fail_count += self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs = self.c.get_lvol_stores()
# Create thick provisioned lvol bdev
size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 2 / MEGABYTE)
size = self.get_lvol_bdev_split_size(2)
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.lbd_name,
size, thin=False)
@ -1782,7 +1798,7 @@ class TestCases(object):
self.cluster_size)
lvs = self.c.get_lvol_stores()
# Create thick provisioned lvol bdev with size equal to 50% of lvs space
size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 2 / MEGABYTE)
size = self.get_lvol_bdev_split_size(2)
uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.lbd_name,
size, thin=False)
@ -1844,8 +1860,7 @@ class TestCases(object):
self.cluster_size)
fail_count += self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs = self.c.get_lvol_stores()
size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 6 / MEGABYTE)
size = self.get_lvol_bdev_split_size(6)
lbd_name0 = self.lbd_name + str(0)
# Construct thick provisioned lvol bdev
uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store,
@ -1919,8 +1934,7 @@ class TestCases(object):
self.cluster_size)
fail_count += self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs = self.c.get_lvol_stores()
size = int(int(lvs[0]['free_clusters'] * lvs[0]['cluster_size']) / 6 / MEGABYTE)
size = self.get_lvol_bdev_split_size(6)
# Construct thick provisioned lvol bdev
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
@ -2011,8 +2025,7 @@ class TestCases(object):
self.cluster_size)
fail_count += self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs = self.c.get_lvol_stores()
size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 4 / MEGABYTE)
size = self.get_lvol_bdev_split_size(4)
# Construct thick provisioned lvol bdev
uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store,
@ -2104,8 +2117,7 @@ class TestCases(object):
self.cluster_size)
fail_count += self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
lvs = self.c.get_lvol_stores()
size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 4 / MEGABYTE)
size = self.get_lvol_bdev_split_size(4)
# Construct thin provisioned lvol bdev
uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store,
@ -2273,7 +2285,6 @@ class TestCases(object):
def test_case800(self):
fail_count = 0
bdev_size = int((self.total_size - 1) / 4)
bdev_uuids = []
bdev_names = [self.lbd_name + str(i) for i in range(4)]
bdev_aliases = ["/".join([self.lvs_name, name]) for name in bdev_names]
@ -2288,6 +2299,7 @@ class TestCases(object):
lvs_uuid,
self.cluster_size,
self.lvs_name)
bdev_size = self.get_lvol_bdev_split_size(4)
for name, alias in zip(bdev_names, bdev_aliases):
uuid = self.c.construct_lvol_bdev(lvs_uuid,
name,
@ -2362,7 +2374,6 @@ class TestCases(object):
bdev_names_2 = ["lvol_2_" + str(i) for i in range(4)]
bdev_aliases_2 = ["/".join([lvs_name_2, name]) for name in bdev_names_2]
bdev_uuids_2 = []
bdev_size = int((self.total_size - 1) / 4)
base_bdev_1 = self.c.construct_malloc_bdev(self.total_size,
self.block_size)
@ -2386,6 +2397,7 @@ class TestCases(object):
lvs_name_2)
# Create 4 lvol bdevs on top of each lvol store
bdev_size = self.get_lvol_bdev_split_size(4)
for name, alias in zip(bdev_names_1, bdev_aliases_1):
uuid = self.c.construct_lvol_bdev(lvs_uuid_1,
name,
@ -2447,7 +2459,6 @@ class TestCases(object):
@case_message
def test_case804(self):
fail_count = 0
bdev_size = int((self.total_size - 1) / 2)
base_bdev = self.c.construct_malloc_bdev(self.total_size,
self.block_size)
@ -2458,6 +2469,7 @@ class TestCases(object):
lvs_uuid,
self.cluster_size,
self.lvs_name)
bdev_size = self.get_lvol_bdev_split_size(2)
bdev_uuid_1 = self.c.construct_lvol_bdev(lvs_uuid,
self.lbd_name + "1",
bdev_size)