diff --git a/autotest.sh b/autotest.sh index b97186772..a925f00c2 100755 --- a/autotest.sh +++ b/autotest.sh @@ -226,6 +226,7 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then if [ $SPDK_TEST_LVOL -eq 1 ]; then timing_enter lvol run_test suite ./test/lvol/lvol.sh --test-cases=all + run_test suite ./test/lvol/lvol2.sh run_test suite ./test/blobstore/blob_io_wait/blob_io_wait.sh report_test_completion "lvol" timing_exit lvol diff --git a/test/lvol/basic.sh b/test/lvol/basic.sh new file mode 100755 index 000000000..6d1182d6f --- /dev/null +++ b/test/lvol/basic.sh @@ -0,0 +1,41 @@ +#!/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 diff --git a/test/lvol/common.sh b/test/lvol/common.sh new file mode 100644 index 000000000..6bf4c842c --- /dev/null +++ b/test/lvol/common.sh @@ -0,0 +1,20 @@ +MALLOC_SIZE_MB=128 +MALLOC_BS=512 +LVS_DEFAULT_CLUSTER_SIZE_MB=4 +LVS_DEFAULT_CLUSTER_SIZE=$(( LVS_DEFAULT_CLUSTER_SIZE_MB * 1024 * 1024 )) +# reserve some MBs for lvolstore metadata +LVS_DEFAULT_CAPACITY_MB=$(( MALLOC_SIZE_MB - LVS_DEFAULT_CLUSTER_SIZE_MB )) +LVS_DEFAULT_CAPACITY=$(( LVS_DEFAULT_CAPACITY_MB * 1024 * 1024 )) + +function rpc_cmd() { + $rootdir/scripts/rpc.py $@ +} + +function run_lvol_test() { + run_test suite $@ + + leftover_bdevs=$(rpc_cmd bdev_get_bdevs) + [ "$(jq length <<< "$leftover_bdevs")" == "0" ] + leftover_lvs=$(rpc_cmd bdev_lvol_get_lvstores) + [ "$(jq length <<< "$leftover_lvs")" == "0" ] +} diff --git a/test/lvol/lvol.sh b/test/lvol/lvol.sh index 3b40f8fe5..521c8e484 100755 --- a/test/lvol/lvol.sh +++ b/test/lvol/lvol.sh @@ -21,7 +21,6 @@ function usage() { echo " --block-size Block size for this bdev" echo "-x set -x for script debug" echo " --test-cases= List test cases which will be run: - 1: 'construct_lvs_positive', 50: 'construct_logical_volume_positive', 51: 'construct_multi_logical_volumes_positive', 52: 'bdev_lvol_create_using_name_positive', diff --git a/test/lvol/lvol2.sh b/test/lvol/lvol2.sh new file mode 100755 index 000000000..881f8f1d5 --- /dev/null +++ b/test/lvol/lvol2.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +testdir=$(readlink -f $(dirname $0)) +rootdir=$(readlink -f $testdir/../..) +source $rootdir/test/common/autotest_common.sh + +timing_enter lvol + +timing_enter basic +run_test suite test/lvol/basic.sh +timing_exit basic + +timing_exit lvol diff --git a/test/lvol/test_cases.py b/test/lvol/test_cases.py index a5ecde24e..9bd347d1e 100644 --- a/test/lvol/test_cases.py +++ b/test/lvol/test_cases.py @@ -110,8 +110,6 @@ def test_counter(): def case_message(func): def inner(*args, **kwargs): test_name = { - # bdev_lvol_create_lvstore - positive tests - 1: 'construct_lvs_positive', # bdev_lvol_create - positive tests 50: 'construct_logical_volume_positive', 51: 'construct_multi_logical_volumes_positive', @@ -314,36 +312,6 @@ class TestCases(object): lvs = self.c.bdev_lvol_get_lvstores(lvs_name)[0] return int(int(lvs['cluster_size']) / MEGABYTE) - # positive tests - @case_message - def test_case1(self): - """ - construct_lvs_positive - - Positive test for constructing a new lvol store. - Call bdev_lvol_create_lvstore with correct base bdev name. - """ - # Create malloc bdev - base_name = self.c.bdev_malloc_create(self.total_size, - self.block_size) - # Construct_lvol_store on correct, exisitng malloc bdev - uuid_store = self.c.bdev_lvol_create_lvstore(base_name, - self.lvs_name) - # Check correct uuid values in response bdev_lvol_get_lvstores command - fail_count = self.c.check_bdev_lvol_get_lvstores(base_name, uuid_store, - self.cluster_size) - self.c.bdev_lvol_delete_lvstore(uuid_store) - self.c.bdev_malloc_delete(base_name) - if self.c.check_bdev_lvol_get_lvstores("", "", "") == 1: - fail_count += 1 - - # Expected result - # - call successful, return code = 0, uuid printed to stdout - # - bdev_lvol_get_lvstores: backend used for bdev_lvol_create_lvstore has uuid - # field set with the same uuid as returned from RPC call - # - no other operation fails - return fail_count - @case_message def test_case50(self): """