test/lvol: rewrite bdev_lvol_rename_nonexistent and bdev_lvol_rename_EEXIST to bash

Change-Id: I47c8cf085556e7ce1df5384c27ab513a8808b3c0
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/701
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Michal Berger <michalx.berger@intel.com>
This commit is contained in:
Pawel Kaminski 2019-12-11 09:53:55 -05:00 committed by Tomasz Zawadzki
parent 35db02d253
commit 99a89f83a9
3 changed files with 38 additions and 77 deletions

View File

@ -35,8 +35,6 @@ function usage() {
653: 'thin_provisioning_resize',
654: 'thin_overprovisioning',
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
803: 'bdev_lvol_rename_nonexistent',
804: 'bdev_lvol_rename_EEXIST',
850: 'clear_method_none',
851: 'clear_method_unmap',
10000: 'SIGTERM'

View File

@ -169,6 +169,43 @@ function test_rename_lvs_negative() {
check_leftover_devices
}
# Negative test case for lvol bdev rename.
# Check that error is returned when trying to rename not existing lvol bdev
# Check that error is returned when trying to rename to a name which is already
# used by another lvol bdev.
function test_lvol_rename_negative() {
# Call bdev_lvol_rename with name pointing to not existing lvol bdev
rpc_cmd bdev_lvol_rename NOTEXIST WHATEVER && false
malloc_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS)
lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test)
# Calculate lvol bdev size
lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) )
lvol_size=$(( lvol_size_mb * 1024 * 1024 ))
# Create two lvol bdevs on top of previously created lvol store
lvol_uuid1=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test1 "$lvol_size_mb")
lvol_uuid2=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test2 "$lvol_size_mb")
# Call bdev_lvol_rename on first lvol bdev and try to change its name to
# the same name as used by second lvol bdev
rpc_cmd bdev_lvol_rename lvol_test1 lvol_test2 && false
# Verify that lvol bdev still have the same names as before
lvol=$(rpc_cmd bdev_get_bdevs -b $lvol_uuid1)
[ "$(jq -r '.[0].driver_specific.lvol.lvol_store_uuid' <<< "$lvol")" = "$lvs_uuid" ]
[ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$MALLOC_BS" ]
[ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / MALLOC_BS ))" ]
[ "$(jq -r '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["lvs_test/lvol_test1"]')" ]
rpc_cmd bdev_lvol_delete lvs_test/lvol_test1
rpc_cmd bdev_lvol_delete lvs_test/lvol_test2
rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid"
rpc_cmd bdev_malloc_delete "$malloc_name"
check_leftover_devices
}
$rootdir/app/spdk_tgt/spdk_tgt &
spdk_pid=$!
trap 'killprocess "$spdk_pid"; exit 1' SIGINT SIGTERM EXIT
@ -176,6 +213,7 @@ waitforlisten $spdk_pid
run_test "test_rename_positive" test_rename_positive
run_test "test_rename_lvs_negative" test_rename_lvs_negative
run_test "test_lvol_rename_negative" test_lvol_rename_negative
trap - SIGINT SIGTERM EXIT
killprocess $spdk_pid

View File

@ -125,9 +125,6 @@ def case_message(func):
653: 'thin_provisioning_resize',
654: 'thin_overprovisioning',
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
# logical volume rename tests
803: 'bdev_lvol_rename_nonexistent',
804: 'bdev_lvol_rename_EEXIST',
# logical volume clear_method test
850: 'clear_method_none',
851: 'clear_method_unmap',
@ -971,78 +968,6 @@ class TestCases(object):
# - no other operation fails
return fail_count
@case_message
def test_case803(self):
"""
bdev_lvol_rename_nonexistent
Negative test case for lvol bdev rename.
Check that error is returned when trying to rename not existing lvol bdev.
"""
fail_count = 0
# Call bdev_lvol_rename with name pointing to not existing lvol bdev
if self.c.bdev_lvol_rename("NOTEXIST", "WHATEVER") == 0:
fail_count += 1
# Expected results:
# - bdev_lvol_rename return code != 0
# - no other operation fails
return fail_count
@case_message
def test_case804(self):
"""
bdev_lvol_rename_EEXIST
Negative test case for lvol bdev rename.
Check that error is returned when trying to rename to a name which is already
used by another lvol bdev.
"""
fail_count = 0
# Construt malloc bdev
base_bdev = self.c.bdev_malloc_create(self.total_size,
self.block_size)
# Create lvol store on created malloc bdev
lvs_uuid = self.c.bdev_lvol_create_lvstore(base_bdev,
self.lvs_name)
fail_count += self.c.check_bdev_lvol_get_lvstores(base_bdev,
lvs_uuid,
self.cluster_size,
self.lvs_name)
# Construct 2 lvol bdevs on lvol store
bdev_size = self.get_lvs_divided_size(2)
bdev_uuid_1 = self.c.bdev_lvol_create(lvs_uuid,
self.lbd_name + "1",
bdev_size)
fail_count += self.c.check_bdev_get_bdevs_methods(bdev_uuid_1,
bdev_size)
bdev_uuid_2 = self.c.bdev_lvol_create(lvs_uuid,
self.lbd_name + "2",
bdev_size)
fail_count += self.c.check_bdev_get_bdevs_methods(bdev_uuid_2,
bdev_size)
# Call bdev_lvol_rename on first lvol bdev and try to change its name to
# the same name as used by second lvol bdev
if self.c.bdev_lvol_rename(self.lbd_name + "1", self.lbd_name + "2") == 0:
fail_count += 1
# Verify that lvol bdev still have the same names as before
fail_count += self.c.check_bdev_get_bdevs_methods(bdev_uuid_1,
bdev_size,
"/".join([self.lvs_name, self.lbd_name + "1"]))
fail_count += self.c.bdev_lvol_delete(bdev_uuid_1)
fail_count += self.c.bdev_lvol_delete(bdev_uuid_2)
fail_count += self.c.bdev_lvol_delete_lvstore(lvs_uuid)
fail_count += self.c.bdev_malloc_delete(base_bdev)
# Expected results:
# - bdev_lvol_rename return code != 0; not possible to rename to already
# used name
# - no other operation fails
return fail_count
@case_message
def test_case850(self):
""""