Commit c96cefbf authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Tomasz Zawadzki
Browse files

test/lvol: rewrite construct_lvol_bdev_name_twice to bash

parent c997d126
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -218,6 +218,29 @@ function test_construct_lvol_full_lvs() {
	check_leftover_devices
}

# try to create two lvols with conflicting aliases
function test_construct_lvol_alias_conflict() {
	# create an lvol store
	malloc_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS)
	lvs_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc_name" lvs_test)

	# create valid lvol
	lvol_size_mb=$(round_down $(( LVS_DEFAULT_CAPACITY_MB / 2 )) )
	lvol1_uuid=$(rpc_cmd bdev_lvol_create -l lvs_test lvol_test "$lvol_size_mb")
	lvol1=$(rpc_cmd bdev_get_bdevs -b "$lvol1_uuid")

	# try to create another lvol with a name that's already taken
	rpc_cmd bdev_lvol_create -l lvs_test lvol_test "$lvol_size_mb" && false

	# clean up
	rpc_cmd bdev_lvol_delete_lvstore -u "$lvs_uuid"
	rpc_cmd bdev_lvol_get_lvstores -u "$lvs_uuid" && false
	rpc_cmd bdev_malloc_delete "$malloc_name"
	rpc_cmd bdev_get_bdevs -b "$malloc_name" && false
	check_leftover_devices
}


$rootdir/app/spdk_tgt/spdk_tgt &
spdk_pid=$!
trap 'killprocess "$spdk_pid"; exit 1' SIGINT SIGTERM EXIT
@@ -229,6 +252,7 @@ run_test "test_construct_multi_lvols" test_construct_multi_lvols
run_test "test_construct_lvols_conflict_alias" test_construct_lvols_conflict_alias
run_test "test_construct_lvol_inexistent_lvs" test_construct_lvol_inexistent_lvs
run_test "test_construct_lvol_full_lvs" test_construct_lvol_full_lvs
run_test "test_construct_lvol_alias_conflict" test_construct_lvol_alias_conflict

trap - SIGINT SIGTERM EXIT
killprocess $spdk_pid
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ function usage() {
    echo "    --block-size          Block size for this bdev"
    echo "-x                        set -x for script debug"
    echo "    --test-cases=         List test cases which will be run:
                                    102: 'bdev_lvol_create_name_twice',
                                    150: 'bdev_lvol_resize_positive',
                                    200: 'resize_logical_volume_nonexistent_logical_volume',
                                    201: 'resize_logical_volume_with_size_out_of_range',
+0 −44
Original line number Diff line number Diff line
@@ -110,8 +110,6 @@ def test_counter():
def case_message(func):
    def inner(*args, **kwargs):
        test_name = {
            # bdev_lvol_create - negative tests
            102: 'bdev_lvol_create_name_twice',
            # resize_lvol_store - positive tests
            150: 'bdev_lvol_resize_positive',
            # resize lvol store - negative tests
@@ -305,48 +303,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_case102(self):
        """
        bdev_lvol_create_name_twice

        Negative test for constructing lvol bdev using the same
        friendly name twice on the same logical volume store.
        """
        # Construct malloc bdev
        base_name = self.c.bdev_malloc_create(self.total_size,
                                              self.block_size)
        # Create logical volume store on malloc bdev
        uuid_store = self.c.bdev_lvol_create_lvstore(base_name,
                                                     self.lvs_name)
        # Using bdev_lvol_get_lvstores verify that logical volume store was correctly created
        fail_count = self.c.check_bdev_lvol_get_lvstores(base_name, uuid_store,
                                                         self.cluster_size)
        size = self.get_lvs_size()
        # Construct logical volume on lvol store and verify it was correctly created
        uuid_bdev = self.c.bdev_lvol_create(uuid_store,
                                            self.lbd_name,
                                            size)
        fail_count += self.c.check_bdev_get_bdevs_methods(uuid_bdev,
                                                          size)
        # Try to create another logical volume on the same lvol store using
        # the same friendly name as in previous step
        # This step should fail
        if self.c.bdev_lvol_create(uuid_store,
                                   self.lbd_name,
                                   size) == 0:
            fail_count += 1

        self.c.bdev_lvol_delete(uuid_bdev)
        self.c.bdev_lvol_delete_lvstore(uuid_store)
        self.c.bdev_malloc_delete(base_name)

        # Expected results:
        # - creating two logical volumes with the same friendly name within the same
        #   lvol store should not be possible
        # - no other operation fails
        return fail_count

    @case_message
    def test_case150(self):
        """