test/lvol: rewrite clone_bdev_only, clone_writing_clone and clone_and_snapshot_consistency to bash
Change-Id: I6a705557d621b758e35efd929a013918e969b91d 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/+/687 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
9010c464da
commit
f139b86f45
@ -35,9 +35,6 @@ function usage() {
|
||||
653: 'thin_provisioning_resize',
|
||||
654: 'thin_overprovisioning',
|
||||
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
|
||||
754: 'clone_bdev_only',
|
||||
755: 'clone_writing_clone',
|
||||
756: 'clone_and_snapshot_consistency',
|
||||
757: 'clone_inflate',
|
||||
758: 'clone_decouple_parent',
|
||||
759: 'clone_decouple_parent_rw',
|
||||
|
@ -141,6 +141,88 @@ function test_create_snapshot_of_snapshot() {
|
||||
check_leftover_devices
|
||||
}
|
||||
|
||||
# Check if only clone of snapshot can be created.
|
||||
# Check if writing to one clone doesn't affect other clone
|
||||
# Check if relations between clones and snapshots are properly set in configuration
|
||||
function test_clone_snapshot_relations() {
|
||||
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 / 6 )) )
|
||||
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")
|
||||
|
||||
# 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 "write" "0xcc"
|
||||
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0
|
||||
|
||||
# An attempt to create a clone from lvol that is rw capable should fail
|
||||
rpc_cmd bdev_lvol_clone lvs_test/lvol_test clone_test && false
|
||||
|
||||
# Create snapshots of lvol bdev
|
||||
snapshot_uuid=$(rpc_cmd bdev_lvol_snapshot lvs_test/lvol_test lvol_snapshot)
|
||||
|
||||
# Create again clone of lvol bdev and check if it fails
|
||||
rpc_cmd bdev_lvol_clone lvs_test/lvol_test clone_test && false
|
||||
|
||||
# Create two clones of snapshot and check if it ends with success
|
||||
clone_uuid1=$(rpc_cmd bdev_lvol_clone lvs_test/lvol_snapshot clone_test1)
|
||||
clone_uuid2=$(rpc_cmd bdev_lvol_clone lvs_test/lvol_snapshot clone_test2)
|
||||
|
||||
# Perform write operation to first clone
|
||||
# Change first half of its space
|
||||
nbd_start_disks "$DEFAULT_RPC_ADDR" "$clone_uuid1" /dev/nbd0
|
||||
fill_size=$(( lvol_size / 2 ))
|
||||
run_fio_test /dev/nbd0 0 $fill_size "write" "0xaa"
|
||||
|
||||
# Compare snapshot with second clone. Data on both bdevs should be the same
|
||||
nbd_start_disks "$DEFAULT_RPC_ADDR" "$snapshot_uuid" /dev/nbd1
|
||||
nbd_start_disks "$DEFAULT_RPC_ADDR" "$clone_uuid2" /dev/nbd2
|
||||
sleep 1
|
||||
cmp /dev/nbd1 /dev/nbd2
|
||||
# Compare snapshot with first clone
|
||||
cmp /dev/nbd0 /dev/nbd1 && false
|
||||
|
||||
snapshot_bdev=$(rpc_cmd bdev_get_bdevs -b "lvs_test/lvol_snapshot")
|
||||
clone_bdev1=$(rpc_cmd bdev_get_bdevs -b "lvs_test/clone_test1")
|
||||
clone_bdev2=$(rpc_cmd bdev_get_bdevs -b "lvs_test/lvol_test")
|
||||
|
||||
# Check snapshot consistency
|
||||
[ "$(jq '.[].driver_specific.lvol.snapshot' <<< "$snapshot_bdev")" = "true" ]
|
||||
[ "$(jq '.[].driver_specific.lvol.clone' <<< "$snapshot_bdev")" = "false" ]
|
||||
[ "$(jq '.[].driver_specific.lvol.clones|sort' <<< "$snapshot_bdev")" = "$(jq '.|sort' <<< '["lvol_test", "clone_test1", "clone_test2"]')" ]
|
||||
|
||||
# Check first clone consistency
|
||||
[ "$(jq '.[].driver_specific.lvol.snapshot' <<< "$clone_bdev1")" = "false" ]
|
||||
[ "$(jq '.[].driver_specific.lvol.clone' <<< "$clone_bdev1")" = "true" ]
|
||||
[ "$(jq '.[].driver_specific.lvol.base_snapshot' <<< "$clone_bdev1")" = '"lvol_snapshot"' ]
|
||||
|
||||
# Check second clone consistency
|
||||
[ "$(jq '.[].driver_specific.lvol.snapshot' <<< "$clone_bdev2")" = "false" ]
|
||||
[ "$(jq '.[].driver_specific.lvol.clone' <<< "$clone_bdev2")" = "true" ]
|
||||
[ "$(jq '.[].driver_specific.lvol.base_snapshot' <<< "$clone_bdev2")" = '"lvol_snapshot"' ]
|
||||
|
||||
# Destroy first clone and check if it is deleted from snapshot
|
||||
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0
|
||||
rpc_cmd bdev_lvol_delete "$clone_uuid1"
|
||||
snapshot_bdev=$(rpc_cmd bdev_get_bdevs -b "lvs_test/lvol_snapshot")
|
||||
[ "$(jq '.[].driver_specific.lvol.clones|sort' <<< "$snapshot_bdev")" = "$(jq '.|sort' <<< '["lvol_test", "clone_test2"]')" ]
|
||||
|
||||
# Clean up
|
||||
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd1
|
||||
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd2
|
||||
rpc_cmd bdev_lvol_delete "$lvol_uuid"
|
||||
rpc_cmd bdev_lvol_delete "$clone_uuid2"
|
||||
rpc_cmd bdev_lvol_delete "$snapshot_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
|
||||
@ -150,6 +232,7 @@ modprobe nbd
|
||||
run_test "test_snapshot_compare_with_lvol_bdev" test_snapshot_compare_with_lvol_bdev
|
||||
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
|
||||
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
killprocess $spdk_pid
|
||||
|
@ -126,9 +126,6 @@ def case_message(func):
|
||||
654: 'thin_overprovisioning',
|
||||
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
|
||||
# snapshot and clone
|
||||
754: 'clone_bdev_only',
|
||||
755: 'clone_writing_clone',
|
||||
756: 'clone_and_snapshot_consistency',
|
||||
757: 'clone_inflate',
|
||||
758: 'decouple_parent',
|
||||
759: 'decouple_parent_rw',
|
||||
@ -984,230 +981,6 @@ class TestCases(object):
|
||||
# - no other operation fails
|
||||
return fail_count
|
||||
|
||||
@case_message
|
||||
def test_case754(self):
|
||||
"""
|
||||
clone_bdev_only
|
||||
|
||||
Check that only clone of snapshot can be created.
|
||||
Creating clone of lvol bdev should fail.
|
||||
"""
|
||||
fail_count = 0
|
||||
clone_name = "clone"
|
||||
snapshot_name = "snapshot"
|
||||
# Create malloc bdev
|
||||
base_name = self.c.bdev_malloc_create(self.total_size,
|
||||
self.block_size)
|
||||
# Construct 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)
|
||||
lvs = self.c.bdev_lvol_get_lvstores()
|
||||
# Create thick provisioned lvol bdev with size equal to 50% of lvs space
|
||||
size = self.get_lvs_divided_size(2)
|
||||
uuid_bdev = self.c.bdev_lvol_create(uuid_store, self.lbd_name,
|
||||
size, thin=False)
|
||||
|
||||
lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev)
|
||||
# Create clone of lvol bdev and check if it fails
|
||||
rv = self.c.bdev_lvol_clone(lvol_bdev['name'], clone_name)
|
||||
if rv == 0:
|
||||
print("ERROR: Creating clone of lvol bdev ended with unexpected success")
|
||||
fail_count += 1
|
||||
# Create snapshot of lvol bdev
|
||||
fail_count += self.c.bdev_lvol_snapshot(lvol_bdev['name'], snapshot_name)
|
||||
# Create again clone of lvol bdev and check if it fails
|
||||
rv = self.c.bdev_lvol_clone(lvol_bdev['name'], clone_name)
|
||||
if rv == 0:
|
||||
print("ERROR: Creating clone of lvol bdev ended with unexpected success")
|
||||
fail_count += 1
|
||||
# Create clone of snapshot and check if it ends with success
|
||||
rv = self.c.bdev_lvol_clone(self.lvs_name + "/" + snapshot_name, clone_name)
|
||||
if rv != 0:
|
||||
print("ERROR: Creating clone of snapshot ended with unexpected failure")
|
||||
fail_count += 1
|
||||
clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name)
|
||||
|
||||
# Delete lvol bdev
|
||||
fail_count += self.c.bdev_lvol_delete(lvol_bdev['name'])
|
||||
# Destroy clone
|
||||
fail_count += self.c.bdev_lvol_delete(clone_bdev['name'])
|
||||
# Delete snapshot
|
||||
fail_count += self.c.bdev_lvol_delete(self.lvs_name + "/" + snapshot_name)
|
||||
# Delete lvol store
|
||||
fail_count += self.c.bdev_lvol_delete_lvstore(uuid_store)
|
||||
# Destroy malloc bdev
|
||||
fail_count += self.c.bdev_malloc_delete(base_name)
|
||||
|
||||
# Expected result:
|
||||
# - calls successful, return code = 0
|
||||
# - cloning thick provisioned lvol bdev should fail
|
||||
# - no other operation fails
|
||||
return fail_count
|
||||
|
||||
@case_message
|
||||
def test_case755(self):
|
||||
"""
|
||||
clone_writing_to_clone
|
||||
|
||||
|
||||
"""
|
||||
fail_count = 0
|
||||
nbd_name = ["/dev/nbd0", "/dev/nbd1", "/dev/nbd2", "/dev/nbd3"]
|
||||
snapshot_name = "snapshot"
|
||||
clone_name0 = "clone0"
|
||||
clone_name1 = "clone1"
|
||||
# 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(6)
|
||||
lbd_name0 = self.lbd_name + str(0)
|
||||
# Construct thick provisioned lvol bdev
|
||||
uuid_bdev0 = self.c.bdev_lvol_create(uuid_store,
|
||||
lbd_name0, size, thin=False)
|
||||
lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0)
|
||||
# Install lvol bdev on /dev/nbd0
|
||||
fail_count += self.c.nbd_start_disk(lvol_bdev['name'], nbd_name[0])
|
||||
fill_size = size * MEGABYTE
|
||||
# Fill lvol bdev with 100% of its space
|
||||
fail_count += self.run_fio_test(nbd_name[0], 0, fill_size, "write", "0xcc", 0)
|
||||
|
||||
# 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
|
||||
fail_count += self.c.bdev_lvol_clone(snapshot_bdev['name'], clone_name0)
|
||||
fail_count += self.c.bdev_lvol_clone(snapshot_bdev['name'], clone_name1)
|
||||
|
||||
lvol_clone0 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name0)
|
||||
fail_count += self.c.nbd_start_disk(lvol_clone0['name'], nbd_name[1])
|
||||
fill_size = int(size * MEGABYTE / 2)
|
||||
# Perform write operation to first clone
|
||||
# Change first half of its space
|
||||
fail_count += self.run_fio_test(nbd_name[1], 0, fill_size, "write", "0xaa", 0)
|
||||
fail_count += self.c.nbd_start_disk(self.lvs_name + "/" + snapshot_name, nbd_name[2])
|
||||
lvol_clone1 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name1)
|
||||
fail_count += self.c.nbd_start_disk(lvol_clone1['name'], nbd_name[3])
|
||||
# Compare snapshot with second clone. Data on both bdevs should be the same
|
||||
time.sleep(1)
|
||||
fail_count += self.compare_two_disks(nbd_name[2], nbd_name[3], 0)
|
||||
|
||||
for nbd in nbd_name:
|
||||
fail_count += self.c.nbd_stop_disk(nbd)
|
||||
# Destroy lvol bdev
|
||||
fail_count += self.c.bdev_lvol_delete(lvol_bdev['name'])
|
||||
# Destroy two clones
|
||||
fail_count += self.c.bdev_lvol_delete(lvol_clone0['name'])
|
||||
fail_count += self.c.bdev_lvol_delete(lvol_clone1['name'])
|
||||
# Delete snapshot
|
||||
fail_count += self.c.bdev_lvol_delete(snapshot_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_case756(self):
|
||||
"""
|
||||
clone_and_snapshot_relations
|
||||
|
||||
Check if relations between clones and snapshots
|
||||
are properly set in configuration
|
||||
"""
|
||||
fail_count = 0
|
||||
snapshot_name = 'snapshot'
|
||||
clone_name0 = 'clone1'
|
||||
clone_name1 = 'clone2'
|
||||
lbd_name = clone_name1
|
||||
|
||||
# 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(6)
|
||||
|
||||
# Construct thick provisioned lvol bdev
|
||||
uuid_bdev = self.c.bdev_lvol_create(uuid_store,
|
||||
lbd_name, size, thin=False)
|
||||
lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev)
|
||||
|
||||
# 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 clone of created snapshot
|
||||
fail_count += self.c.bdev_lvol_clone(snapshot_bdev['name'], clone_name0)
|
||||
|
||||
# Get current bdevs configuration
|
||||
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
|
||||
lvol_clone0 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name0)
|
||||
lvol_clone1 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name1)
|
||||
|
||||
# Check snapshot consistency
|
||||
snapshot_lvol = snapshot_bdev['driver_specific']['lvol']
|
||||
if snapshot_lvol['snapshot'] is not True:
|
||||
fail_count += 1
|
||||
if snapshot_lvol['clone'] is not False:
|
||||
fail_count += 1
|
||||
if sorted([clone_name0, clone_name1]) != sorted(snapshot_lvol['clones']):
|
||||
fail_count += 1
|
||||
|
||||
# Check first clone consistency
|
||||
lvol_clone0_lvol = lvol_clone0['driver_specific']['lvol']
|
||||
if lvol_clone0_lvol['snapshot'] is not False:
|
||||
fail_count += 1
|
||||
if lvol_clone0_lvol['clone'] is not True:
|
||||
fail_count += 1
|
||||
if lvol_clone0_lvol['base_snapshot'] != 'snapshot':
|
||||
fail_count += 1
|
||||
|
||||
# Check second clone consistency
|
||||
lvol_clone1_lvol = lvol_clone1['driver_specific']['lvol']
|
||||
if lvol_clone1_lvol['snapshot'] is not False:
|
||||
fail_count += 1
|
||||
if lvol_clone1_lvol['clone'] is not True:
|
||||
fail_count += 1
|
||||
if lvol_clone1_lvol['base_snapshot'] != 'snapshot':
|
||||
fail_count += 1
|
||||
|
||||
# Destroy first clone and check if it is deleted from snapshot
|
||||
fail_count += self.c.bdev_lvol_delete(lvol_clone0['name'])
|
||||
snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)
|
||||
if [clone_name1] != snapshot_bdev['driver_specific']['lvol']['clones']:
|
||||
fail_count += 1
|
||||
|
||||
# Destroy second clone
|
||||
fail_count += self.c.bdev_lvol_delete(lvol_clone1['name'])
|
||||
|
||||
# Delete snapshot
|
||||
fail_count += self.c.bdev_lvol_delete(snapshot_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_case757(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user