test/lvol: Use AIO bdevs instead NVMe in lvol tasting

If lvol tasting test cases fails for some reason, lvol store
is keeped on on NVMe bdev making it problematic to remove.
Fails on AIO bdevs are easier to handle.
This also remove usage of .conf file in this test.

Change-Id: I58da80defa7a00e95084e34d6447b890272586ec
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/420898
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Pawel Niedzwiecki 2018-07-31 19:25:25 +02:00 committed by Jim Harris
parent a88b1371eb
commit 96ed6f24ba
3 changed files with 51 additions and 61 deletions

View File

@ -107,13 +107,7 @@ source $TEST_DIR/test/common/autotest_common.sh
function vhost_start()
{
modprobe nbd
touch $BASE_DIR/vhost.conf
# Use Split to make a bdev using just the first 1/4
# of the NVMe namespace
echo "[Split]" >> $BASE_DIR/vhost.conf
echo " Split Nvme0n1 4" >> $BASE_DIR/vhost.conf
$TEST_DIR/scripts/gen_nvme.sh >> $BASE_DIR/vhost.conf
$TEST_DIR/app/vhost/vhost -c $BASE_DIR/vhost.conf &
$TEST_DIR/app/vhost/vhost &
vhost_pid=$!
echo $vhost_pid > $BASE_DIR/vhost.pid
waitforlisten $vhost_pid
@ -127,14 +121,15 @@ function vhost_kill()
sleep 1
fi
rm $BASE_DIR/vhost.pid || true
rm $BASE_DIR/vhost.conf || true
rmmod nbd || true
}
trap "vhost_kill; exit 1" SIGINT SIGTERM EXIT
trap "vhost_kill; rm -f $BASE_DIR/aio_bdev_0; exit 1" SIGINT SIGTERM EXIT
truncate -s 400M $BASE_DIR/aio_bdev_0
vhost_start
$BASE_DIR/lvol_test.py $rpc_py $total_size $block_size $BASE_DIR $TEST_DIR/app/vhost "${test_cases[@]}"
vhost_kill
rm -rf $BASE_DIR/aio_bdev_0
trap - SIGINT SIGTERM EXIT

View File

@ -154,11 +154,6 @@ class Commands_Rpc(object):
output, rc = self.rpc.delete_malloc_bdev(base_name)
return rc
def delete_nvme_controller(self, controller_name):
print("INFO: RPC COMMAND delete_nvme_controller")
output, rc = self.rpc.delete_nvme_controller(controller_name)
return rc
def destroy_lvol_bdev(self, bdev_name):
print("INFO: RPC COMMAND destroy_lvol_bdev")
output, rc = self.rpc.destroy_lvol_bdev(bdev_name)
@ -204,10 +199,6 @@ class Commands_Rpc(object):
return None
def construct_nvme_bdev(self, nvme_name, trtype, traddr):
print("INFO: Add NVMe bdev {nvme}".format(nvme=nvme_name))
self.rpc.construct_nvme_bdev("-b", nvme_name, "-t", trtype, "-a", traddr)
def rename_lvol_store(self, old_name, new_name):
print("INFO: Renaming lvol store from {old} to {new}".format(old=old_name, new=new_name))
output, rc = self.rpc.rename_lvol_store(old_name, new_name)
@ -237,3 +228,13 @@ class Commands_Rpc(object):
print("INFO: RPC COMMAND decouple_parent_lvol_bdev")
output, rc = self.rpc.decouple_parent_lvol_bdev(clone_name)
return rc
def construct_aio_bdev(self, aio_path, aio_name, aio_bs=""):
print("INFO: RPC COMMAND construct_aio_bdev")
output, rc = self.rpc.construct_aio_bdev(aio_path, aio_name, aio_bs)
return rc
def delete_aio_bdev(self, aio_name):
print("INFO: RPC COMMAND delete_aio_bdev")
output, rc = self.rpc.delete_aio_bdev(aio_name)
return rc

View File

@ -222,10 +222,9 @@ class TestCases(object):
return 1
return 0
def _start_vhost(self, vhost_path, config_path, pid_path):
subprocess.call("{app} -c {config} -f "
def _start_vhost(self, vhost_path, pid_path):
subprocess.call("{app} -f "
"{pid} &".format(app=vhost_path,
config=config_path,
pid=pid_path), shell=True)
for timeo in range(10):
if timeo == 9:
@ -261,17 +260,6 @@ class TestCases(object):
return 1
return 0
def _find_traddress_for_nvme(self, nvme_name):
with open(self.vhost_config_path) as file:
for line in file:
if nvme_name in line and "TransportID" in line:
for word in line.split(" "):
if word.startswith("traddr"):
return word.split(":", 1)[1].replace("\"", "")
print("INFO: Traddr not found for Nvme {nvme}".format(nvme=nvme_name))
return -1
def get_lvs_size(self, lvs_name="lvs_test"):
lvs = self.c.get_lvol_stores(lvs_name)[0]
return int(int(lvs[u'free_clusters'] * lvs['cluster_size']) / MEGABYTE)
@ -635,25 +623,26 @@ class TestCases(object):
@case_message
def test_case255(self):
base_path = path.dirname(sys.argv[0])
base_name = "Nvme0n1p0"
base_name = "aio_bdev0"
aio_bdev0 = path.join(base_path, "aio_bdev_0")
self.c.construct_aio_bdev(aio_bdev0, base_name, 4096)
uuid_store = self.c.construct_lvol_store(base_name,
self.lvs_name)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
if self.c.destroy_lvol_store(self.lvs_name) != 0:
fail_count += 1
traddr = self._find_traddress_for_nvme("Nvme0")
if traddr != -1:
self.c.delete_nvme_controller("Nvme0")
self.c.construct_nvme_bdev("Nvme0", "PCIe", traddr)
# wait 1 second to allow time for lvolstore tasting
sleep(1)
else:
fail_count += 1
self.c.delete_aio_bdev(base_name)
self.c.construct_aio_bdev(aio_bdev0, base_name, 4096)
# wait 1 second to allow time for lvolstore tasting
sleep(1)
ret_value = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
if ret_value == 0:
fail_count += 1
self.c.delete_aio_bdev(base_name)
return fail_count
@case_message
@ -1378,20 +1367,21 @@ class TestCases(object):
tasting_positive
Positive test for tasting a multi lvol bdev configuration.
Create a lvol store with some lvol bdevs on NVMe drive and restart vhost app.
Create a lvol store with some lvol bdevs on aio bdev and restart vhost app.
After restarting configuration should be automatically loaded and should be exactly
the same as before restarting.
Check that running configuration can be modified after restarting and tasting.
"""
fail_count = 0
uuid_bdevs = []
base_name = "Nvme0n1p0"
base_name = "aio_bdev0"
base_path = path.dirname(sys.argv[0])
vhost_path = path.join(self.app_path, 'vhost')
config_path = path.join(base_path, 'vhost.conf')
pid_path = path.join(base_path, 'vhost.pid')
aio_bdev0 = path.join(base_path, 'aio_bdev_0')
self.c.construct_aio_bdev(aio_bdev0, base_name, 4096)
# Create initial configuration on running vhost instance
# create lvol store, create 5 bdevs
# save info of all lvs and lvol bdevs
@ -1401,8 +1391,7 @@ class TestCases(object):
uuid_store,
self.cluster_size)
# size = approx 2% of total NVMe disk size
size = self.get_lvs_divided_size(50)
size = self.get_lvs_divided_size(10)
for i in range(5):
uuid_bdev = self.c.construct_lvol_bdev(uuid_store,
@ -1418,10 +1407,11 @@ class TestCases(object):
# Shut down vhost instance and restart with new instance
fail_count += self._stop_vhost(pid_path)
remove(pid_path)
if self._start_vhost(vhost_path, config_path, pid_path) != 0:
if self._start_vhost(vhost_path, pid_path) != 0:
fail_count += 1
return fail_count
self.c.construct_aio_bdev(aio_bdev0, base_name, 4096)
# Check if configuration was properly loaded after tasting
# get all info all lvs and lvol bdevs, compare with previous info
new_bdevs = sorted(self.c.get_lvol_bdevs(), key=lambda x: x["name"])
@ -1446,6 +1436,7 @@ class TestCases(object):
pprint.pprint([o, n])
if fail_count != 0:
self.c.delete_aio_bdev(aio_bdev0)
return fail_count
# Try modifying loaded configuration
@ -1466,7 +1457,7 @@ class TestCases(object):
uuid_bdevs = []
# Create lvol store on NVMe bdev, create ten lvol bdevs on lvol store and
# Create lvol store on aio bdev, create ten lvol bdevs on lvol store and
# verify all configuration call results
uuid_store = self.c.construct_lvol_store(base_name,
self.lvs_name)
@ -1485,6 +1476,8 @@ class TestCases(object):
if self.c.destroy_lvol_store(uuid_store) != 0:
fail_count += 1
self.c.delete_aio_bdev(base_name)
return fail_count
@case_message
@ -1494,29 +1487,30 @@ class TestCases(object):
Positive test for tasting lvol store.
"""
base_name = "Nvme0n1p0"
# construct lvol store on NVMe bdev
base_path = path.dirname(sys.argv[0])
aio_bdev0 = path.join(base_path, 'aio_bdev_0')
base_name = "aio_bdev0"
self.c.construct_aio_bdev(aio_bdev0, base_name, 4096)
# construct lvol store on aio bdev
uuid_store = self.c.construct_lvol_store(base_name,
self.lvs_name)
fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size)
traddr = self._find_traddress_for_nvme("Nvme0")
if traddr != -1:
# delete NVMe bdev
self.c.delete_nvme_controller("Nvme0")
# add NVMe bdev
self.c.construct_nvme_bdev("Nvme0", "PCIe", traddr)
# wait 1 second to allow time for lvolstore tasting
sleep(1)
else:
fail_count += 1
self.c.delete_aio_bdev(base_name)
self.c.construct_aio_bdev(aio_bdev0, base_name, 4096)
# wait 1 second to allow time for lvolstore tasting
sleep(1)
# check if lvol store still exists in vhost configuration
if self.c.check_get_lvol_stores(base_name, uuid_store,
self.cluster_size) != 0:
fail_count += 1
# destroy lvol store from NVMe bdev
# destroy lvol store from aio bdev
if self.c.destroy_lvol_store(uuid_store) != 0:
fail_count += 1
self.c.delete_aio_bdev(base_name)
return fail_count
@case_message