diff --git a/test/lvol/hotremove.sh b/test/lvol/hotremove.sh new file mode 100755 index 000000000..5803e3a32 --- /dev/null +++ b/test/lvol/hotremove.sh @@ -0,0 +1,42 @@ +#!/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 an lvol on lvs, then remove the lvs +function test_hotremove_lvol_store() { + # create lvs + lvol on top + malloc_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS) + lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test) + lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$LVS_DEFAULT_CAPACITY_MB") + + # remove lvs (with one lvol open) + rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid" + rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid" && false + lvolstores=$(rpc_cmd bdev_lvol_get_lvstores) + [ "$(jq length <<< "$lvolstores")" == "0" ] + + # make sure we can't destroy the lvs again + rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid" && false + + # make sure the lvol is also gone + rpc_cmd bdev_get_bdevs -b "$lvol_uuid" && false + lvols=$(rpc_cmd bdev_get_bdevs | jq -r '[ .[] | select(.product_name == "Logical Volume") ]') + [ "$(jq length <<< "$lvols")" == "0" ] + + # clean up + 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_hotremove_lvol_store" test_hotremove_lvol_store + +trap - SIGINT SIGTERM EXIT +killprocess $spdk_pid diff --git a/test/lvol/lvol.sh b/test/lvol/lvol.sh index 89874fba6..9e1ea87ff 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: - 252: 'bdev_lvol_delete_lvstore_with_lvol_bdev_positive', 253: 'destroy_multi_logical_volumes_positive', 254: 'destroy_after_bdev_lvol_resize_positive', 255: 'delete_lvol_store_persistent_positive', diff --git a/test/lvol/lvol2.sh b/test/lvol/lvol2.sh index 2419f1496..80e28db7a 100755 --- a/test/lvol/lvol2.sh +++ b/test/lvol/lvol2.sh @@ -9,6 +9,7 @@ timing_enter lvol timing_enter basic run_test "lvol_basic" test/lvol/basic.sh run_test "lvol_resize" test/lvol/resize.sh +run_test "lvol_hotremove" test/lvol/hotremove.sh timing_exit basic timing_exit lvol diff --git a/test/lvol/test_cases.py b/test/lvol/test_cases.py index dc86d9366..ac7058ef9 100644 --- a/test/lvol/test_cases.py +++ b/test/lvol/test_cases.py @@ -112,7 +112,6 @@ def case_message(func): def inner(*args, **kwargs): test_name = { # bdev_lvol_delete_lvstore - positive tests - 252: 'bdev_lvol_delete_lvstore_with_lvol_bdev_positive', 253: 'destroy_multi_logical_volumes_positive', 254: 'destroy_after_bdev_lvol_resize_positive', 255: 'delete_lvol_store_persistent_positive', @@ -292,47 +291,6 @@ class TestCases(object): lvs = self.c.bdev_lvol_get_lvstores(lvs_name)[0] return int(int(lvs['cluster_size']) / MEGABYTE) - @case_message - def test_case252(self): - """ - bdev_lvol_delete_lvstore_with_lvol_bdev_positive - - Positive test for destroying a logical volume store with lvol bdev - created on top. - Call bdev_lvol_delete_lvstore with correct logical_volumes name - """ - # Create malloc bdev - base_name = self.c.bdev_malloc_create(self.total_size, - self.block_size) - # Construct lvol store on created 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) - # Construct lvol bdev on correct lvs_uuid - # and size is equal to size malloc bdev - lvs_size = self.get_lvs_size() - uuid_bdev = self.c.bdev_lvol_create(uuid_store, - self.lbd_name, - lvs_size) - fail_count += self.c.check_bdev_get_bdevs_methods(uuid_bdev, - lvs_size) - # Destroy lvol store - if self.c.bdev_lvol_delete_lvstore(uuid_store) != 0: - fail_count += 1 - - # Check correct response bdev_lvol_get_lvstores command - if self.c.check_bdev_lvol_get_lvstores("", "", "") == 1: - fail_count += 1 - self.c.bdev_malloc_delete(base_name) - - # Expected result: - # - calls successful, return code = 0 - # - bdev_lvol_get_lvstores: response should be of no value after destroyed lvol store - # - no other operation fails - return fail_count - @case_message def test_case253(self): """