diff --git a/test/lvol/hotremove.sh b/test/lvol/hotremove.sh index aa4cc3547f..1670d533e2 100755 --- a/test/lvol/hotremove.sh +++ b/test/lvol/hotremove.sh @@ -97,6 +97,58 @@ function test_hotremove_lvol_store_base_with_lvols() { check_leftover_devices } +function test_bdev_lvol_delete_lvstore_with_clones() { + local snapshot_name1=snapshot1 snapshot_uuid1 + local snapshot_name2=snapshot2 snapshot_uuid2 + local clone_name=clone clone_uuid + local lbd_name=lbd_test + + local bdev_uuid + local lvstore_name=lvs_name lvstore_uuid + local malloc_dev + + malloc_dev=$(rpc_cmd bdev_malloc_create 256 "$MALLOC_BS") + lvstore_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_dev" "$lvstore_name") + + get_lvs_jq bdev_lvol_get_lvstores -u "$lvstore_uuid" + [[ ${jq_out["uuid"]} == "$lvstore_uuid" ]] + [[ ${jq_out["name"]} == "$lvstore_name" ]] + [[ ${jq_out["base_bdev"]} == "$malloc_dev" ]] + + size=$(( jq_out["free_clusters"] * jq_out["cluster_size"] / 4 / 1024**2 )) + + bdev_uuid=$(rpc_cmd bdev_lvol_create -u "$lvstore_uuid" "$lbd_name" "$size") + + get_bdev_jq bdev_get_bdevs -b "$bdev_uuid" + + snapshot_uuid1=$(rpc_cmd bdev_lvol_snapshot "${jq_out["name"]}" "$snapshot_name1") + + get_bdev_jq bdev_get_bdevs -b "$lvstore_name/$snapshot_name1" + [[ ${jq_out["name"]} == "$snapshot_uuid1" ]] + [[ ${jq_out["product_name"]} == "Logical Volume" ]] + [[ ${jq_out["aliases[0]"]} == "$lvstore_name/$snapshot_name1" ]] + + clone_uuid=$(rpc_cmd bdev_lvol_clone "$lvstore_name/$snapshot_name1" "$clone_name") + + get_bdev_jq bdev_get_bdevs -b "$lvstore_name/$clone_name" + [[ ${jq_out["name"]} == "$clone_uuid" ]] + [[ ${jq_out["product_name"]} == "Logical Volume" ]] + [[ ${jq_out["aliases[0]"]} == "$lvstore_name/$clone_name" ]] + + snapshot_uuid2=$(rpc_cmd bdev_lvol_snapshot "${jq_out["name"]}" "$snapshot_name2") + + get_bdev_jq bdev_get_bdevs -b "$lvstore_name/$snapshot_name2" + [[ ${jq_out["name"]} == "$snapshot_uuid2" ]] + [[ ${jq_out["product_name"]} == "Logical Volume" ]] + [[ ${jq_out["aliases[0]"]} == "$lvstore_name/$snapshot_name2" ]] + + rpc_cmd bdev_lvol_delete "$snapshot_uuid1" && false + rpc_cmd bdev_lvol_delete_lvstore -u "$lvstore_uuid" + rpc_cmd bdev_malloc_delete "$malloc_dev" + + check_leftover_devices +} + $rootdir/app/spdk_tgt/spdk_tgt & spdk_pid=$! trap 'killprocess "$spdk_pid"; exit 1' SIGINT SIGTERM EXIT @@ -106,6 +158,7 @@ run_test "test_hotremove_lvol_store" test_hotremove_lvol_store run_test "test_hotremove_lvol_store_multiple_lvols" test_hotremove_lvol_store_multiple_lvols run_test "test_hotremove_lvol_store_base" test_hotremove_lvol_store_base run_test "test_hotremove_lvol_store_base_with_lvols" test_hotremove_lvol_store_base_with_lvols +run_test "test_bdev_lvol_delete_lvstore_with_clones" test_bdev_lvol_delete_lvstore_with_clones trap - SIGINT SIGTERM EXIT killprocess $spdk_pid diff --git a/test/lvol/lvol.sh b/test/lvol/lvol.sh index 2799af414c..3353b4b424 100755 --- a/test/lvol/lvol.sh +++ b/test/lvol/lvol.sh @@ -23,7 +23,6 @@ function usage() { echo " --test-cases= List test cases which will be run: 350: 'nested_destroy_logical_volume_negative', 400: 'nested_construct_logical_volume_positive', - 552: 'bdev_lvol_delete_lvstore_with_clones', 553: 'unregister_lvol_bdev', 850: 'clear_method_none', 851: 'clear_method_unmap', diff --git a/test/lvol/test_cases.py b/test/lvol/test_cases.py index 858b4d56d8..db970a214b 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 - 552: 'bdev_lvol_delete_lvstore_with_clones', 553: 'unregister_lvol_bdev', # logical volume clear_method test 850: 'clear_method_none', @@ -249,66 +248,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_case552(self): - """ - bdev_lvol_delete_lvstore_with_clones - - Test for destroying lvol store with clones present, - without removing them first. - """ - - fail_count = 0 - snapshot_name = "snapshot" - snapshot_name2 = "snapshot2" - clone_name = "clone" - - # 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, - self.cluster_size) - # 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) - lvs = self.c.bdev_lvol_get_lvstores() - size = int(int(lvs[0]['free_clusters'] * lvs[0]['cluster_size']) / 4 / MEGABYTE) - - # Create lvol bdev, snapshot it, then clone it and then snapshot the clone - uuid_bdev0 = self.c.bdev_lvol_create(uuid_store, self.lbd_name, size, thin=True) - lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0) - - fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name) - snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name) - - fail_count += self.c.bdev_lvol_clone(self.lvs_name + "/" + snapshot_name, clone_name) - clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name) - - fail_count += self.c.bdev_lvol_snapshot(clone_bdev['name'], snapshot_name2) - snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2) - - # Try to destroy snapshot with 2 clones and check if it fails - ret_value = self.c.bdev_lvol_delete(snapshot_bdev['name']) - if ret_value == 0: - print("ERROR: Delete snapshot should fail but didn't") - fail_count += 1 - - # Destroy lvol store without deleting lvol bdevs - fail_count += self.c.bdev_lvol_delete_lvstore(uuid_store) - - # Check response bdev_lvol_get_lvstores command - if self.c.check_bdev_lvol_get_lvstores("", "", "") == 1: - fail_count += 1 - - # Delete malloc bdev - self.c.bdev_malloc_delete(base_name) - # Expected result: - # - 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_case553(self): """