test/lvol: rewrite rename_positive to bash

Change-Id: I54df8b70c644291062d582f11f4da3aecc9dd9c9
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/699
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>
This commit is contained in:
Pawel Kaminski 2019-12-10 10:12:32 -05:00 committed by Tomasz Zawadzki
parent 051a6902d8
commit 48a373f483
4 changed files with 93 additions and 87 deletions

View File

@ -35,7 +35,6 @@ function usage() {
653: 'thin_provisioning_resize',
654: 'thin_overprovisioning',
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
800: 'rename_positive',
801: 'rename_lvs_nonexistent',
802: 'rename_lvs_EEXIST',
803: 'bdev_lvol_rename_nonexistent',

View File

@ -12,6 +12,7 @@ run_test "lvol_resize" test/lvol/resize.sh
run_test "lvol_hotremove" test/lvol/hotremove.sh
run_test "lvol_tasting" test/lvol/tasting.sh
run_test "lvol_snapshot_clone" test/lvol/snapshot_clone.sh
run_test "lvol_rename" test/lvol/rename.sh
timing_exit basic
timing_exit lvol

92
test/lvol/rename.sh Executable file
View File

@ -0,0 +1,92 @@
#!/usr/bin/env bash
testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../..)
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/lvol/common.sh
# Positive test for lvol store and lvol bdev rename.
function test_rename_positive() {
malloc_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS)
lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test)
bdev_name=("lvol_test"{0..3})
bdev_aliases=("lvs_test/lvol_test"{0..3})
# Calculate size and create two lvol bdevs on top
lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 4 )) )
lvol_size=$(( lvol_size_mb * 1024 * 1024 ))
# Create 4 lvol bdevs on top of previously created lvol store
bdev_uuids=()
for i in "${!bdev_name[@]}"; do
lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" "${bdev_name[i]}" "$lvol_size_mb")
lvol=$(rpc_cmd bdev_get_bdevs -b $lvol_uuid)
[ "$(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 '.[0].aliases|sort' <<< "$lvol")" = "$(jq '.|sort' <<< '["'${bdev_aliases[i]}'"]')" ]
bdev_uuids+=("$lvol_uuid")
done
# Rename lvol store and check if lvol store name and
# lvol bdev aliases were updated properly
new_lvs_name="lvs_new"
bdev_aliases=("$new_lvs_name/lvol_test"{0..3})
rpc_cmd bdev_lvol_rename_lvstore lvs_test "$new_lvs_name"
lvs=$(rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid")
# verify it's there
[ "$(jq -r '.[0].uuid' <<< "$lvs")" = "$lvs_uuid" ]
[ "$(jq -r '.[0].name' <<< "$lvs")" = "$new_lvs_name" ]
[ "$(jq -r '.[0].base_bdev' <<< "$lvs")" = "$malloc_name" ]
# verify some of its parameters
cluster_size=$(jq -r '.[0].cluster_size' <<< "$lvs")
[ "$cluster_size" = "$LVS_DEFAULT_CLUSTER_SIZE" ]
total_clusters=$(jq -r '.[0].total_data_clusters' <<< "$lvs")
[ "$(( total_clusters * cluster_size ))" = "$LVS_DEFAULT_CAPACITY" ]
for i in "${!bdev_uuids[@]}"; do
lvol=$(rpc_cmd bdev_get_bdevs -b "${bdev_uuids[i]}")
[ "$(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' <<< '["'${bdev_aliases[i]}'"]')" ]
done
# Now try to rename the bdevs using their uuid as "old_name"
# Verify that all bdev names were successfully updated
bdev_names=("lbd_new"{0..3})
new_bdev_aliases=()
for bdev_name in "${bdev_names[@]}"; do
new_bdev_aliases+=("$new_lvs_name/$bdev_name")
done
for i in "${!bdev_names[@]}"; do
rpc_cmd bdev_lvol_rename "${bdev_aliases[i]}" "${bdev_names[i]}"
lvol=$(rpc_cmd bdev_get_bdevs -b "${bdev_uuids[i]}")
[ "$(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' <<< '["'${new_bdev_aliases[i]}'"]')" ]
done
# Clean up
for bdev in "${new_bdev_aliases[@]}"; do
rpc_cmd bdev_lvol_delete "$bdev"
done
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
waitforlisten $spdk_pid
run_test "test_rename_positive" test_rename_positive
trap - SIGINT SIGTERM EXIT
killprocess $spdk_pid

View File

@ -126,7 +126,6 @@ def case_message(func):
654: 'thin_overprovisioning',
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
# logical volume rename tests
800: 'rename_positive',
801: 'rename_lvs_nonexistent',
802: 'rename_lvs_EEXIST',
803: 'bdev_lvol_rename_nonexistent',
@ -974,91 +973,6 @@ class TestCases(object):
# - no other operation fails
return fail_count
@case_message
def test_case800(self):
"""
rename_positive
Positive test for lvol store and lvol bdev rename.
"""
fail_count = 0
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]
# Create malloc bdev
base_name = self.c.bdev_malloc_create(self.total_size,
self.block_size)
# Construct lvol store on created malloc bdev
lvs_uuid = self.c.bdev_lvol_create_lvstore(base_name,
self.lvs_name)
fail_count += self.c.check_bdev_lvol_get_lvstores(base_name,
lvs_uuid,
self.cluster_size,
self.lvs_name)
# Create 4 lvol bdevs on top of previously created lvol store
bdev_size = self.get_lvs_divided_size(4)
for name, alias in zip(bdev_names, bdev_aliases):
uuid = self.c.bdev_lvol_create(lvs_uuid,
name,
bdev_size)
fail_count += self.c.check_bdev_get_bdevs_methods(uuid,
bdev_size,
alias)
bdev_uuids.append(uuid)
# Rename lvol store and check if lvol store name and
# lvol bdev aliases were updated properly
new_lvs_name = "lvs_new"
bdev_aliases = [alias.replace(self.lvs_name, new_lvs_name) for alias in bdev_aliases]
fail_count += self.c.bdev_lvol_rename_lvstore(self.lvs_name, new_lvs_name)
fail_count += self.c.check_bdev_lvol_get_lvstores(base_name,
lvs_uuid,
self.cluster_size,
new_lvs_name)
for uuid, alias in zip(bdev_uuids, bdev_aliases):
fail_count += self.c.check_bdev_get_bdevs_methods(uuid,
bdev_size,
alias)
# Now try to rename the bdevs using their uuid as "old_name"
# Verify that all bdev names were successfully updated
bdev_names = ["lbd_new" + str(i) for i in range(4)]
bdev_aliases = ["/".join([new_lvs_name, name]) for name in bdev_names]
print(bdev_aliases)
for uuid, new_name, new_alias in zip(bdev_uuids, bdev_names, bdev_aliases):
fail_count += self.c.bdev_lvol_rename(uuid, new_name)
fail_count += self.c.check_bdev_get_bdevs_methods(uuid,
bdev_size,
new_alias)
# Rename lvol bdevs. Use lvols alias name to point which lvol bdev name to change
# Verify that all bdev names were successfully updated
bdev_names = ["lbd_even_newer" + str(i) for i in range(4)]
new_bdev_aliases = ["/".join([new_lvs_name, name]) for name in bdev_names]
print(bdev_aliases)
for uuid, old_alias, new_alias, new_name in zip(bdev_uuids, bdev_aliases, new_bdev_aliases, bdev_names):
fail_count += self.c.bdev_lvol_rename(old_alias, new_name)
fail_count += self.c.check_bdev_get_bdevs_methods(uuid,
bdev_size,
new_alias)
# Delete configuration using names after rename operation
for bdev in new_bdev_aliases:
fail_count += self.c.bdev_lvol_delete(bdev)
fail_count += self.c.bdev_lvol_delete_lvstore(new_lvs_name)
fail_count += self.c.bdev_malloc_delete(base_name)
# Expected results:
# - lvol store and lvol bdevs correctly created
# - lvol store and lvol bdevs names updated after renaming operation
# - lvol store and lvol bdevs possible to delete using new names
# - no other operation fails
return fail_count
@case_message
def test_case801(self):
"""