test/lvol: Rewrite delete_lvol_bdev to Bash
This test case covers proper order of lvol snapshot, clone removal ( test case no. 551). Change-Id: I0faccaba0c2a097e2b6d03bc0446d1fbc1ef1891 Signed-off-by: Michal Berger <michalx.berger@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/870 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>
This commit is contained in:
parent
100339aaf6
commit
a0d55c607a
@ -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',
|
||||
551: 'delete_lvol_bdev',
|
||||
552: 'bdev_lvol_delete_lvstore_with_clones',
|
||||
553: 'unregister_lvol_bdev',
|
||||
850: 'clear_method_none',
|
||||
|
@ -542,6 +542,62 @@ function test_delete_snapshot_with_snapshot() {
|
||||
check_leftover_devices
|
||||
}
|
||||
|
||||
# Test for destroying lvol bdevs in particular order.
|
||||
function test_bdev_lvol_delete_ordering() {
|
||||
local snapshot_name=snapshot snapshot_uuid
|
||||
local clone_name=clone clone_uuid
|
||||
|
||||
local bdev_uuid
|
||||
local lbd_name=lbd_test
|
||||
local lvstore_uuid lvstore_name=lvs_name
|
||||
local malloc_dev
|
||||
local size
|
||||
|
||||
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 -t -u "$lvstore_uuid" "$lbd_name" "$size")
|
||||
|
||||
get_bdev_jq bdev_get_bdevs -b "$bdev_uuid"
|
||||
|
||||
snapshot_uuid=$(rpc_cmd bdev_lvol_snapshot "${jq_out["name"]}" "$snapshot_name")
|
||||
|
||||
get_bdev_jq bdev_get_bdevs -b "$lvstore_name/$snapshot_name"
|
||||
[[ ${jq_out["name"]} == "$snapshot_uuid" ]]
|
||||
[[ ${jq_out["product_name"]} == "Logical Volume" ]]
|
||||
[[ ${jq_out["aliases[0]"]} == "$lvstore_name/$snapshot_name" ]]
|
||||
|
||||
clone_uuid=$(rpc_cmd bdev_lvol_clone "$lvstore_name/$snapshot_name" "$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" ]]
|
||||
|
||||
# Try to destroy snapshot with clones and check if it fails
|
||||
rpc_cmd bdev_lvol_delete "$snapshot_uuid" && false
|
||||
|
||||
# cleanup logical volumes
|
||||
rpc_cmd bdev_lvol_delete "$bdev_uuid"
|
||||
rpc_cmd bdev_lvol_delete "$clone_uuid"
|
||||
rpc_cmd bdev_lvol_delete "$snapshot_uuid"
|
||||
|
||||
# cleanup lvstore
|
||||
rpc_cmd bdev_lvol_delete_lvstore -u "$lvstore_uuid"
|
||||
|
||||
# cleanup malloc dev
|
||||
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
|
||||
@ -557,6 +613,7 @@ run_test "test_clone_decouple_parent" test_clone_decouple_parent
|
||||
run_test "test_lvol_bdev_readonly" test_lvol_bdev_readonly
|
||||
run_test "test_delete_snapshot_with_clone" test_delete_snapshot_with_clone
|
||||
run_test "test_delete_snapshot_with_snapshot" test_delete_snapshot_with_snapshot
|
||||
run_test "test_bdev_lvol_delete_ordering" test_bdev_lvol_delete_ordering
|
||||
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
killprocess $spdk_pid
|
||||
|
@ -112,7 +112,6 @@ def case_message(func):
|
||||
def inner(*args, **kwargs):
|
||||
test_name = {
|
||||
# bdev_lvol_delete_lvstore - positive tests
|
||||
551: 'delete_lvol_bdev',
|
||||
552: 'bdev_lvol_delete_lvstore_with_clones',
|
||||
553: 'unregister_lvol_bdev',
|
||||
# logical volume clear_method test
|
||||
@ -250,70 +249,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_case551(self):
|
||||
"""
|
||||
bdev_lvol_delete_ordering
|
||||
|
||||
Test for destroying lvol bdevs in particular order.
|
||||
Check destroying wrong one is not possible and returns error.
|
||||
"""
|
||||
|
||||
fail_count = 0
|
||||
snapshot_name = "snapshot"
|
||||
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)
|
||||
|
||||
# Construct thin provisioned lvol bdev
|
||||
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)
|
||||
|
||||
# Create snapshot of thin provisioned lvol bdev
|
||||
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)
|
||||
|
||||
# Create clone of snapshot and check if it ends with success
|
||||
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)
|
||||
|
||||
# Try to destroy snapshot with 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 clone and then snapshot
|
||||
fail_count += self.c.bdev_lvol_delete(lvol_bdev['name'])
|
||||
fail_count += self.c.bdev_lvol_delete(clone_bdev['name'])
|
||||
fail_count += self.c.bdev_lvol_delete(snapshot_bdev['name'])
|
||||
|
||||
# Destroy lvol store
|
||||
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_case552(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user