test/lvol: rewrite delete_snapshot to bash

Change-Id: I9480cc329b76d4c4d89aa1ecc4bb2042487c7aab
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/697
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Michal Berger <michalx.berger@intel.com>
This commit is contained in:
Pawel Kaminski 2019-12-06 15:32:32 -05:00 committed by Tomasz Zawadzki
parent 97d7aa90b9
commit dbf5793576
3 changed files with 51 additions and 80 deletions

View File

@ -35,7 +35,6 @@ function usage() {
653: 'thin_provisioning_resize', 653: 'thin_provisioning_resize',
654: 'thin_overprovisioning', 654: 'thin_overprovisioning',
655: 'thin_provisioning_filling_disks_less_than_lvs_size', 655: 'thin_provisioning_filling_disks_less_than_lvs_size',
761: 'delete_snapshot',
762: 'delete_snapshot_with_snapshot', 762: 'delete_snapshot_with_snapshot',
800: 'rename_positive', 800: 'rename_positive',
801: 'rename_lvs_nonexistent', 801: 'rename_lvs_nonexistent',

View File

@ -407,6 +407,56 @@ function test_lvol_bdev_readonly() {
check_leftover_devices check_leftover_devices
} }
# Check if it is possible to delete snapshot with clone
function test_delete_snapshot_with_clone() {
malloc_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS)
lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test)
# Calculate size and create lvol bdev
lvol_size_mb=$( round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) )
lvol_size=$(( lvol_size_mb * 1024 * 1024 ))
lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb")
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
# Perform write operation on lvol
nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0
run_fio_test /dev/nbd0 0 $lvol_size "write" "0xcc"
# Create snapshots of lvol bdev
snapshot_uuid=$(rpc_cmd bdev_lvol_snapshot lvs_test/lvol_test lvol_snapshot)
# Fill first half of lvol bdev
half_size=$(( lvol_size / 2 - 1 ))
run_fio_test /dev/nbd0 0 $half_size "write" "0xee"
# Check if snapshot was unchanged
nbd_start_disks "$DEFAULT_RPC_ADDR" "$snapshot_uuid" /dev/nbd1
run_fio_test /dev/nbd1 0 $half_size "read" "0xcc"
# Verify lvol bdev
run_fio_test /dev/nbd0 0 $half_size "read" "0xee"
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
[ "$(jq '.[].driver_specific.lvol.clone' <<< "$lvol")" = "true" ]
# Delete snapshot - should succeed
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd1
rpc_cmd bdev_lvol_delete "$snapshot_uuid"
# Check data consistency
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
[ "$(jq '.[].driver_specific.lvol.clone' <<< "$lvol")" = "false" ]
run_fio_test /dev/nbd0 0 $half_size "read" "0xee"
run_fio_test /dev/nbd0 $(( half_size + 1 )) $half_size "read" "0xcc"
# Clean up
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0
rpc_cmd bdev_lvol_delete "$lvol_uuid"
rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid"
rpc_cmd bdev_malloc_delete "$malloc_name"
check_leftover_devices
}
$rootdir/app/spdk_tgt/spdk_tgt & $rootdir/app/spdk_tgt/spdk_tgt &
spdk_pid=$! spdk_pid=$!
trap 'killprocess "$spdk_pid"; exit 1' SIGINT SIGTERM EXIT trap 'killprocess "$spdk_pid"; exit 1' SIGINT SIGTERM EXIT
@ -420,6 +470,7 @@ run_test "test_clone_snapshot_relations" test_clone_snapshot_relations
run_test "test_clone_inflate" test_clone_inflate run_test "test_clone_inflate" test_clone_inflate
run_test "test_clone_decouple_parent" test_clone_decouple_parent run_test "test_clone_decouple_parent" test_clone_decouple_parent
run_test "test_lvol_bdev_readonly" test_lvol_bdev_readonly run_test "test_lvol_bdev_readonly" test_lvol_bdev_readonly
run_test "test_delete_snapshot_with_clone" test_delete_snapshot_with_clone
trap - SIGINT SIGTERM EXIT trap - SIGINT SIGTERM EXIT
killprocess $spdk_pid killprocess $spdk_pid

View File

@ -126,7 +126,6 @@ def case_message(func):
654: 'thin_overprovisioning', 654: 'thin_overprovisioning',
655: 'thin_provisioning_filling_disks_less_than_lvs_size', 655: 'thin_provisioning_filling_disks_less_than_lvs_size',
# snapshot and clone # snapshot and clone
761: 'delete_snapshot',
762: 'delete_snapshot_with_snapshot', 762: 'delete_snapshot_with_snapshot',
# logical volume rename tests # logical volume rename tests
800: 'rename_positive', 800: 'rename_positive',
@ -977,84 +976,6 @@ class TestCases(object):
# - no other operation fails # - no other operation fails
return fail_count return fail_count
@case_message
def test_case761(self):
"""
delete_snapshot
Check if it is possible to delete snapshot with clone
"""
fail_count = 0
nbd_name0 = "/dev/nbd0"
nbd_name1 = "/dev/nbd1"
snapshot_name = "snapshot"
# Construct malloc bdev
base_name = self.c.bdev_malloc_create(self.total_size,
self.block_size)
# Construct lvol store on malloc bdev
uuid_store = self.c.bdev_lvol_create_lvstore(base_name,
self.lvs_name)
fail_count += self.c.check_bdev_lvol_get_lvstores(base_name, uuid_store,
self.cluster_size)
# Create lvol bdev with 50% of lvol store space
lvs = self.c.bdev_lvol_get_lvstores()[0]
bdev_size = self.get_lvs_divided_size(2)
bdev_name = self.c.bdev_lvol_create(uuid_store, self.lbd_name,
bdev_size)
lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name)
# Perform write operation on lvol
fail_count += self.c.nbd_start_disk(lvol_bdev['name'], nbd_name0)
size = bdev_size * MEGABYTE
fail_count += self.run_fio_test(nbd_name0, 0, size, "write", "0xcc")
# Create snapshot of 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)
if snapshot_bdev['driver_specific']['lvol']['clone'] is not False\
or snapshot_bdev['driver_specific']['lvol']['snapshot'] is not True:
fail_count += 1
# Fill first half of lvol bdev
half_size = bdev_size * MEGABYTE / 2
lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name)
fail_count += self.run_fio_test(nbd_name0, 0, half_size-1, "write", "0xee")
# Check if snapshot was unchanged
fail_count += self.c.nbd_start_disk(snapshot_bdev['name'], nbd_name1)
fail_count += self.run_fio_test(nbd_name1, 0, half_size-1, "read", "0xcc")
# Verify lvol bdev
fail_count += self.run_fio_test(nbd_name0, 0, half_size-1, "read", "0xee")
if lvol_bdev['driver_specific']['lvol']['clone'] is not True:
fail_count += 1
# Delete snapshot - should succeed
fail_count += self.c.nbd_stop_disk(nbd_name1)
fail_count += self.c.bdev_lvol_delete(snapshot_bdev['name'])
# Check data consistency
lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name)
if lvol_bdev['driver_specific']['lvol']['clone'] is not False:
fail_count += 1
fail_count += self.run_fio_test(nbd_name0, 0, half_size-1, "read", "0xee")
fail_count += self.run_fio_test(nbd_name0, half_size, size-1, "read", "0xcc")
# Destroy lvol bdev
fail_count += self.c.nbd_stop_disk(nbd_name0)
fail_count += self.c.bdev_lvol_delete(lvol_bdev['name'])
# Destroy lvol store
fail_count += self.c.bdev_lvol_delete_lvstore(uuid_store)
# Delete malloc bdev
fail_count += self.c.bdev_malloc_delete(base_name)
# Expected result:
# - calls successful, return code = 0
# - no other operation fails
return fail_count
@case_message @case_message
def test_case762(self): def test_case762(self):
""" """