2342070e07
Rewriting test cases: - tasting_positive - tasting_lvol_store_positive - tasting_positive_with_different_lvol_store_cluster_size These three python test cases were merged into one test, as there was a lot of similarity between them. Change-Id: Ie68568e2b6b9e574917b6b350e96b0f42c999c95 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/+/683 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
135 lines
5.1 KiB
Bash
Executable File
135 lines
5.1 KiB
Bash
Executable File
#!/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
|
|
|
|
# Make sure lvol stores are automatically detected after base bdev detach and subsequent attach
|
|
function test_tasting() {
|
|
# Create two aio bdevs
|
|
rpc_cmd bdev_aio_create $testdir/aio_bdev_0 aio_bdev0 "$AIO_BS"
|
|
rpc_cmd bdev_aio_create $testdir/aio_bdev_1 aio_bdev1 "$AIO_BS"
|
|
# Create a valid lvs
|
|
lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore aio_bdev0 lvs_test)
|
|
# Destroy lvol store
|
|
rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid"
|
|
# Remove the lvol stores and make sure it's not being automatically detected after base
|
|
# bdev re-attach.
|
|
rpc_cmd bdev_aio_delete aio_bdev0
|
|
# Create aio bdev on the same file
|
|
rpc_cmd bdev_aio_create $testdir/aio_bdev_0 aio_bdev0 "$AIO_BS"
|
|
sleep 1
|
|
# Check if destroyed lvol store does not exist on aio bdev
|
|
rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid" && false
|
|
|
|
# Create a valid lvs
|
|
lvs1_cluster_size=$(( 1 * 1024 * 1024 ))
|
|
lvs2_cluster_size=$(( 32 * 1024 * 1024 ))
|
|
lvs_uuid1=$(rpc_cmd bdev_lvol_create_lvstore aio_bdev0 lvs_test1 -c $lvs1_cluster_size)
|
|
lvs_uuid2=$(rpc_cmd bdev_lvol_create_lvstore aio_bdev1 lvs_test2 -c $lvs2_cluster_size)
|
|
|
|
# Create 5 lvols on first lvs
|
|
lvol_size_mb=$(round_down $(( LVS_DEFAULT_CAPACITY_MB / 10 )))
|
|
lvol_size=$(( lvol_size_mb * 1024 * 1024 ))
|
|
|
|
for i in $(seq 1 5); do
|
|
lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid1" "lvol_test${i}" "$lvol_size_mb")
|
|
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
|
|
|
|
[ "$(jq -r '.[0].name' <<< "$lvol")" = "$lvol_uuid" ]
|
|
[ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ]
|
|
[ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test1/lvol_test${i}" ]
|
|
[ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$AIO_BS" ]
|
|
[ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / AIO_BS ))" ]
|
|
done
|
|
|
|
# Create 5 lvols on second lvs
|
|
lvol2_size_mb=$(round_down $(( ( AIO_SIZE_MB - 16 ) / 5 )) 32)
|
|
lvol2_size=$(( lvol2_size_mb * 1024 * 1024 ))
|
|
|
|
for i in $(seq 1 5); do
|
|
lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid2" "lvol_test${i}" "$lvol2_size_mb")
|
|
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
|
|
|
|
[ "$(jq -r '.[0].name' <<< "$lvol")" = "$lvol_uuid" ]
|
|
[ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ]
|
|
[ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test2/lvol_test${i}" ]
|
|
[ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$AIO_BS" ]
|
|
[ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol2_size / AIO_BS ))" ]
|
|
done
|
|
|
|
old_lvols=$(rpc_cmd bdev_get_bdevs | jq -r '[ .[] | select(.product_name == "Logical Volume") ]')
|
|
[ "$(jq length <<< "$old_lvols")" == "10" ]
|
|
old_lvs=$(rpc_cmd bdev_lvol_get_lvstores | jq .)
|
|
|
|
# Restart spdk app
|
|
killprocess $spdk_pid
|
|
$rootdir/app/spdk_tgt/spdk_tgt &
|
|
spdk_pid=$!
|
|
waitforlisten $spdk_pid
|
|
|
|
# Create aio bdevs
|
|
rpc_cmd bdev_aio_create $testdir/aio_bdev_0 aio_bdev0 "$AIO_BS"
|
|
rpc_cmd bdev_aio_create $testdir/aio_bdev_1 aio_bdev1 "$AIO_BS"
|
|
sleep 1
|
|
|
|
# Check tasting feature
|
|
new_lvols=$(rpc_cmd bdev_get_bdevs | jq -r '[ .[] | select(.product_name == "Logical Volume") ]')
|
|
[ "$(jq length <<< "$new_lvols")" == "10" ]
|
|
new_lvs=$(rpc_cmd bdev_lvol_get_lvstores | jq .)
|
|
if ! diff <(jq -S . <<<"$old_lvs") <(jq -S . <<<"$new_lvs"); then
|
|
echo "ERROR: old and loaded lvol store is not the same"
|
|
return 1
|
|
fi
|
|
if ! diff <(jq -S . <<<"$old_lvols") <(jq -S . <<<"$new_lvols"); then
|
|
echo "ERROR: old and loaded lvols are not the same"
|
|
return 1
|
|
fi
|
|
|
|
# Check if creation and deletion lvol bdevs on lvs is possible
|
|
for i in $(seq 6 10); do
|
|
lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid1" "lvol_test${i}" "$lvol_size_mb")
|
|
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
|
|
|
|
[ "$(jq -r '.[0].name' <<< "$lvol")" = "$lvol_uuid" ]
|
|
[ "$(jq -r '.[0].uuid' <<< "$lvol")" = "$lvol_uuid" ]
|
|
[ "$(jq -r '.[0].aliases[0]' <<< "$lvol")" = "lvs_test1/lvol_test${i}" ]
|
|
[ "$(jq -r '.[0].block_size' <<< "$lvol")" = "$AIO_BS" ]
|
|
[ "$(jq -r '.[0].num_blocks' <<< "$lvol")" = "$(( lvol_size / AIO_BS ))" ]
|
|
done
|
|
|
|
for i in $(seq 1 10); do
|
|
rpc_cmd bdev_lvol_delete "lvs_test1/lvol_test${i}"
|
|
done
|
|
|
|
rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid1"
|
|
|
|
# Create an lvstore and 10 lvol on top to see if deletion of such struct works as it should.
|
|
lvs_uuid1=$(rpc_cmd bdev_lvol_create_lvstore aio_bdev0 lvs_test1)
|
|
for i in $(seq 1 10); do
|
|
rpc_cmd bdev_lvol_create -u "$lvs_uuid1" "lvol_test${i}" "$lvol_size_mb"
|
|
done
|
|
|
|
# Clean up
|
|
rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid1"
|
|
rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid1" && false
|
|
rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid2"
|
|
rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid2" && false
|
|
rpc_cmd bdev_aio_delete aio_bdev0
|
|
rpc_cmd bdev_aio_delete aio_bdev1
|
|
check_leftover_devices
|
|
}
|
|
|
|
$rootdir/app/spdk_tgt/spdk_tgt &
|
|
spdk_pid=$!
|
|
trap 'killprocess "$spdk_pid"; rm -f $testdir/aio_bdev_0 $testdir/aio_bdev_1; exit 1' SIGINT SIGTERM EXIT
|
|
waitforlisten $spdk_pid
|
|
truncate -s "${AIO_SIZE_MB}M" $testdir/aio_bdev_0 $testdir/aio_bdev_1
|
|
|
|
run_test "test_tasting" test_tasting
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
killprocess $spdk_pid
|
|
rm -f $testdir/aio_bdev_0 $testdir/aio_bdev_1
|