42 lines
1.4 KiB
Bash
42 lines
1.4 KiB
Bash
|
#!/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
|
||
|
|
||
|
# create empty lvol store and verify its parameters
|
||
|
function test_construct_lvs() {
|
||
|
# create an lvol store
|
||
|
malloc_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS)
|
||
|
lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test)
|
||
|
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")" = "lvs_test" ]
|
||
|
[ "$(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")
|
||
|
[ "$(jq -r '.[0].free_clusters' <<< "$lvs")" = "$total_clusters" ]
|
||
|
[ "$(( total_clusters * cluster_size ))" = "$LVS_DEFAULT_CAPACITY" ]
|
||
|
|
||
|
# remove it and verify it's gone
|
||
|
rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid"
|
||
|
! rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid"
|
||
|
rpc_cmd bdev_malloc_delete "$malloc_name"
|
||
|
}
|
||
|
|
||
|
$rootdir/app/spdk_tgt/spdk_tgt &
|
||
|
spdk_pid=$!
|
||
|
trap 'killprocess "$spdk_pid"; exit 1' SIGINT SIGTERM EXIT
|
||
|
waitforlisten $spdk_pid
|
||
|
|
||
|
run_lvol_test test_construct_lvs
|
||
|
|
||
|
trap - SIGINT SIGTERM EXIT
|
||
|
killprocess $spdk_pid
|