test/lvol: rewrite clone_inflate to bash

Change-Id: If479b610c6349e0394122bd6a87d38037d199bca
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/688
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Pawel Kaminski 2019-12-04 17:49:04 -05:00 committed by Tomasz Zawadzki
parent 053c15b32b
commit 4c8066a32b
3 changed files with 55 additions and 92 deletions

View File

@ -35,7 +35,6 @@ function usage() {
653: 'thin_provisioning_resize',
654: 'thin_overprovisioning',
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
757: 'clone_inflate',
758: 'clone_decouple_parent',
759: 'clone_decouple_parent_rw',
760: 'set_read_only',

View File

@ -223,6 +223,60 @@ function test_clone_snapshot_relations() {
check_leftover_devices
}
# Testing usage of bdev_lvol_inflate
function test_clone_inflate() {
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 / 4 )) )
lvol_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb")
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
# Fill lvol bdev with 100% of its space
nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0
run_fio_test /dev/nbd0 0 $(( lvol_size_mb * 1024 * 1024 )) "write" "0xcc"
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0
# Create snapshots of lvol bdev
snapshot_uuid=$(rpc_cmd bdev_lvol_snapshot lvs_test/lvol_test lvol_snapshot)
# Create clone of snapshot
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
[ "$(jq '.[].driver_specific.lvol.thin_provision' <<< "$lvol")" = "true" ]
# Fill part of clone with data of known pattern
nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0
first_fill=0
second_fill=$(( lvol_size_mb * 1024 * 1024 * 3 / 4 ))
run_fio_test /dev/nbd0 $first_fill $(( 1024 * 1024 )) "write" "0xdd"
run_fio_test /dev/nbd0 $second_fill $(( 1024 * 1024 )) "write" "0xdd"
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0
# Do inflate
rpc_cmd bdev_lvol_inflate lvs_test/lvol_test
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
[ "$(jq '.[].driver_specific.lvol.thin_provision' <<< "$lvol")" = "false" ]
# Delete snapshot
rpc_cmd bdev_lvol_delete "$snapshot_uuid"
# Check data consistency
nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0
run_fio_test /dev/nbd0 $first_fill $(( 1024 * 1024 )) "read" "0xdd"
run_fio_test /dev/nbd0 $(( (first_fill + 1) * 1024 * 1024 )) $(( second_fill - 1024 * 1024 )) "read" "0xcc"
run_fio_test /dev/nbd0 $second_fill $(( 1024 * 1024 )) "read" "0xdd"
run_fio_test /dev/nbd0 $(( second_fill + 1024 * 1024 )) $(( lvol_size_mb * 1024 * 1024 - ( second_fill + 1024 * 1024 ) )) "read" "0xcc"
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0
# Clean up
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 &
spdk_pid=$!
trap 'killprocess "$spdk_pid"; exit 1' SIGINT SIGTERM EXIT
@ -233,6 +287,7 @@ run_test "test_snapshot_compare_with_lvol_bdev" test_snapshot_compare_with_lvol_
run_test "test_create_snapshot_with_io" test_create_snapshot_with_io
run_test "test_create_snapshot_of_snapshot" test_create_snapshot_of_snapshot
run_test "test_clone_snapshot_relations" test_clone_snapshot_relations
run_test "test_clone_inflate" test_clone_inflate
trap - SIGINT SIGTERM EXIT
killprocess $spdk_pid

View File

@ -126,7 +126,6 @@ def case_message(func):
654: 'thin_overprovisioning',
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
# snapshot and clone
757: 'clone_inflate',
758: 'decouple_parent',
759: 'decouple_parent_rw',
760: 'set_read_only',
@ -981,96 +980,6 @@ class TestCases(object):
# - no other operation fails
return fail_count
@case_message
def test_case757(self):
"""
clone_inflate
Test inflate rpc method
"""
fail_count = 0
snapshot_name = "snapshot"
nbd_name = "/dev/nbd0"
# Create malloc bdev
base_name = self.c.bdev_malloc_create(self.total_size,
self.block_size)
# Create lvol store
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)
size = self.get_lvs_divided_size(4)
# Construct thick provisioned lvol bdev
uuid_bdev0 = self.c.bdev_lvol_create(uuid_store,
self.lbd_name, size, thin=False)
lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0)
# Fill bdev with data of knonw pattern
fail_count += self.c.nbd_start_disk(lvol_bdev['name'], nbd_name)
fill_size = size * MEGABYTE
fail_count += self.run_fio_test(nbd_name, 0, fill_size, "write", "0xcc", 0)
self.c.nbd_stop_disk(nbd_name)
# Create snapshot of thick 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 two clones of created snapshot
lvol_clone = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + self.lbd_name)
if lvol_clone['driver_specific']['lvol']['thin_provision'] is not True:
fail_count += 1
# Fill part of clone with data of known pattern
fail_count += self.c.nbd_start_disk(lvol_clone['name'], nbd_name)
first_fill = 0
second_fill = int(size * 3 / 4)
fail_count += self.run_fio_test(nbd_name, first_fill * MEGABYTE,
MEGABYTE, "write", "0xdd", 0)
fail_count += self.run_fio_test(nbd_name, second_fill * MEGABYTE,
MEGABYTE, "write", "0xdd", 0)
self.c.nbd_stop_disk(nbd_name)
# Do inflate
fail_count += self.c.bdev_lvol_inflate(lvol_clone['name'])
lvol_clone = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + self.lbd_name)
if lvol_clone['driver_specific']['lvol']['thin_provision'] is not False:
fail_count += 1
# Delete snapshot
fail_count += self.c.bdev_lvol_delete(snapshot_bdev['name'])
# Check data consistency
fail_count += self.c.nbd_start_disk(lvol_clone['name'], nbd_name)
fail_count += self.run_fio_test(nbd_name, first_fill * MEGABYTE,
MEGABYTE, "read", "0xdd")
fail_count += self.run_fio_test(nbd_name, (first_fill + 1) * MEGABYTE,
(second_fill - first_fill - 1) * MEGABYTE,
"read", "0xcc")
fail_count += self.run_fio_test(nbd_name, (second_fill) * MEGABYTE,
MEGABYTE, "read", "0xdd")
fail_count += self.run_fio_test(nbd_name, (second_fill + 1) * MEGABYTE,
(size - second_fill - 1) * MEGABYTE,
"read", "0xcc")
self.c.nbd_stop_disk(nbd_name)
# Destroy lvol bdev
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
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
def test_case758(self):
"""