test/lvol: make tests python3 compatible

There needed to ba a couple of changes made with respect to integer
rounding and handling raw binary strings from subprocess calls that were
handled by default in the last version.

Change-Id: Ie0e664a577e0b0fb690058842c5dbe95b2794a26
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/409776
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Seth Howell 2018-05-02 14:25:23 -07:00 committed by Daniel Verkamp
parent e8ddb060f8
commit 142221987e
2 changed files with 16 additions and 16 deletions

View File

@ -14,13 +14,13 @@ class Spdk_Rpc(object):
cmd += " {}".format(arg)
try:
output = check_output(cmd, shell=True)
return output.rstrip('\n'), 0
return output.decode('ascii').rstrip('\n'), 0
except CalledProcessError as e:
print("ERROR: RPC Command {cmd} "
"execution failed:". format(cmd=cmd))
print("Failed command output:")
print(e.output)
return e.output, e.returncode
return e.output.decode('ascii'), e.returncode
return call

View File

@ -309,7 +309,7 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
size = ((self.total_size - 1) / 4)
size = int((self.total_size - 1) / 4)
for j in range(2):
uuid_bdevs = []
@ -420,7 +420,7 @@ class TestCases(object):
@case_message
def test_case102(self):
size = (self.total_size / 2) - 1
size = int((self.total_size / 2) - 1)
base_name = self.c.construct_malloc_bdev(self.total_size,
self.block_size)
uuid_store = self.c.construct_lvol_store(base_name,
@ -453,12 +453,12 @@ 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 = self.total_size / 4
size = int(self.total_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 = self.total_size / 2
size = int(self.total_size / 2)
self.c.resize_lvol_bdev(uuid_bdev, size)
fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size)
@ -567,7 +567,7 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
size = ((self.total_size - 1) / 4)
size = int((self.total_size - 1) / 4)
for i in range(4):
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
@ -590,7 +590,7 @@ class TestCases(object):
self.cluster_size)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
size = ((self.total_size - 1) / 4)
size = int((self.total_size - 1) / 4)
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
self.lbd_name,
size)
@ -792,7 +792,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(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE
bdev_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
# 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)
@ -875,7 +875,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(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE
bdev_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
# 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)
@ -930,7 +930,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(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE
bdev_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
# 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)
@ -1006,7 +1006,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(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE
bdev_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
# 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,
@ -1077,7 +1077,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(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE
lvs_size = int(int(lvs['cluster_size']) * int(lvs['free_clusters']) / MEGABYTE)
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
@ -1620,7 +1620,7 @@ class TestCases(object):
def test_case800(self):
fail_count = 0
bdev_size = (self.total_size - 1) / 4
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]
@ -1709,7 +1709,7 @@ 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 = (self.total_size - 1) / 4
bdev_size = int((self.total_size - 1) / 4)
base_bdev_1 = self.c.construct_malloc_bdev(self.total_size,
self.block_size)
@ -1794,7 +1794,7 @@ class TestCases(object):
@case_message
def test_case804(self):
fail_count = 0
bdev_size = (self.total_size - 1) / 2
bdev_size = int((self.total_size - 1) / 2)
base_bdev = self.c.construct_malloc_bdev(self.total_size,
self.block_size)