test/lvol: rewrite set_read_only to bash
Change-Id: I6540067b2ca8ffc0255e1222e3203922432d0b34 Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/696 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:
parent
45088e0c60
commit
97d7aa90b9
@ -35,7 +35,6 @@ function usage() {
|
||||
653: 'thin_provisioning_resize',
|
||||
654: 'thin_overprovisioning',
|
||||
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
|
||||
760: 'set_read_only',
|
||||
761: 'delete_snapshot',
|
||||
762: 'delete_snapshot_with_snapshot',
|
||||
800: 'rename_positive',
|
||||
|
@ -372,6 +372,41 @@ function test_clone_decouple_parent() {
|
||||
check_leftover_devices
|
||||
}
|
||||
|
||||
# Set lvol bdev as read only and perform clone on it.
|
||||
function test_lvol_bdev_readonly() {
|
||||
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_uuid=$(rpc_cmd bdev_lvol_create -u "$lvs_uuid" lvol_test "$lvol_size_mb")
|
||||
lvol=$(rpc_cmd bdev_get_bdevs -b "$lvol_uuid")
|
||||
|
||||
# Set lvol bdev as read only
|
||||
rpc_cmd bdev_lvol_set_read_only lvs_test/lvol_test
|
||||
|
||||
# Try to perform write operation on lvol marked as read only
|
||||
nbd_start_disks "$DEFAULT_RPC_ADDR" "$lvol_uuid" /dev/nbd0
|
||||
run_fio_test /dev/nbd0 0 lvol_size "write" "0xcc" && false
|
||||
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0
|
||||
|
||||
# Create clone of lvol set to read only
|
||||
clone_uuid=$(rpc_cmd bdev_lvol_clone lvs_test/lvol_test clone_test)
|
||||
|
||||
# Try to perform write operation on lvol clone
|
||||
nbd_start_disks "$DEFAULT_RPC_ADDR" "$clone_uuid" /dev/nbd0
|
||||
run_fio_test /dev/nbd0 0 lvol_size "write" "0xcc"
|
||||
nbd_stop_disks "$DEFAULT_RPC_ADDR" /dev/nbd0
|
||||
|
||||
# Clean up
|
||||
rpc_cmd bdev_lvol_delete "$clone_uuid"
|
||||
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
|
||||
@ -384,6 +419,7 @@ 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
|
||||
run_test "test_clone_decouple_parent" test_clone_decouple_parent
|
||||
run_test "test_lvol_bdev_readonly" test_lvol_bdev_readonly
|
||||
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
killprocess $spdk_pid
|
||||
|
@ -126,7 +126,6 @@ def case_message(func):
|
||||
654: 'thin_overprovisioning',
|
||||
655: 'thin_provisioning_filling_disks_less_than_lvs_size',
|
||||
# snapshot and clone
|
||||
760: 'set_read_only',
|
||||
761: 'delete_snapshot',
|
||||
762: 'delete_snapshot_with_snapshot',
|
||||
# logical volume rename tests
|
||||
@ -978,70 +977,6 @@ class TestCases(object):
|
||||
# - no other operation fails
|
||||
return fail_count
|
||||
|
||||
@case_message
|
||||
def test_case760(self):
|
||||
"""
|
||||
set read only
|
||||
|
||||
Set lvol bdev as read only and perform clone on it.
|
||||
"""
|
||||
fail_count = 0
|
||||
nbd_name0 = "/dev/nbd0"
|
||||
nbd_name1 = "/dev/nbd1"
|
||||
clone_name = "clone0"
|
||||
# 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]
|
||||
free_clusters_start = int(lvs['free_clusters'])
|
||||
bdev_size = self.get_lvs_divided_size(2)
|
||||
bdev_name = self.c.bdev_lvol_create(uuid_store, self.lbd_name,
|
||||
bdev_size)
|
||||
# Set lvol bdev as read only
|
||||
lvol_bdev = self.c.get_lvol_bdev_with_name(bdev_name)
|
||||
fail_count += self.c.bdev_lvol_set_read_only(lvol_bdev['name'])
|
||||
|
||||
# Try to perform write operation on lvol marked as read only
|
||||
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", 1)
|
||||
|
||||
# Create clone of lvol set to read only
|
||||
rv = self.c.bdev_lvol_clone(lvol_bdev['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)
|
||||
|
||||
# Try to perform write operation on lvol clone
|
||||
fail_count += self.c.nbd_start_disk(clone_bdev['name'], nbd_name1)
|
||||
size = bdev_size * MEGABYTE
|
||||
fail_count += self.run_fio_test(nbd_name1, 0, size, "write", "0xcc", 0)
|
||||
|
||||
# Stop nbd disks
|
||||
fail_count += self.c.nbd_stop_disk(nbd_name0)
|
||||
fail_count += self.c.nbd_stop_disk(nbd_name1)
|
||||
# Destroy clone lvol bdev
|
||||
fail_count += self.c.bdev_lvol_delete(clone_bdev['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 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
|
||||
def test_case761(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user