Commit 67ab15d6 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Jim Harris
Browse files

test/lvol: rewrite construct_lvs_with_cluster_size_min/max to bash

parent c6e13991
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -76,6 +76,49 @@ function test_construct_lvs_conflict_alias() {
	check_leftover_devices
}

# call bdev_lvol_create_lvstore with cluster size equals to malloc bdev size + 1B
# call bdev_lvol_create_lvstore with cluster size smaller than minimal value of 8192
function test_construct_lvs_different_cluster_size() {
	# create the first lvs
	malloc1_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS)
	lvs1_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc1_name" lvs_test)

	# make sure we've got 1 lvs
	lvol_stores=$(rpc_cmd bdev_lvol_get_lvstores)
	[ "$(jq length <<< "$lvol_stores")" == "1" ]

	# use the second malloc for some more lvs creation negative tests
	malloc2_name=$(rpc_cmd bdev_malloc_create $MALLOC_SIZE_MB $MALLOC_BS)
	# capacity bigger than malloc's
	rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c $(( MALLOC_SIZE + 1 )) && false
	# capacity equal to malloc's (no space left for metadata)
	rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c $MALLOC_SIZE && false
	# capacity smaller than malloc's, but still no space left for metadata
	rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c $(( MALLOC_SIZE - 1 )) && false
	# cluster size smaller than the minimum (8192)
	rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c 8191 && false

	# no additional lvol stores should have been created
	lvol_stores=$(rpc_cmd bdev_lvol_get_lvstores)
	[ "$(jq length <<< "$lvol_stores")" == "1" ]

	# this one should be fine
	lvs2_uuid=$(rpc_cmd bdev_lvol_create_lvstore "$malloc2_name" lvs2_test -c 8192)
	# we should have one more lvs
	lvol_stores=$(rpc_cmd bdev_lvol_get_lvstores)
	[ "$(jq length <<< "$lvol_stores")" == "2" ]

	# clean up
	rpc_cmd bdev_lvol_delete_lvstore -u "$lvs1_uuid"
	rpc_cmd bdev_lvol_get_lvstores -u "$lvs1_uuid" && false
	rpc_cmd bdev_lvol_delete_lvstore -u "$lvs2_uuid"
	rpc_cmd bdev_lvol_get_lvstores -u "$lvs2_uuid" && false

	rpc_cmd bdev_malloc_delete "$malloc1_name"
	rpc_cmd bdev_malloc_delete "$malloc2_name"
	check_leftover_devices
}

# create lvs + lvol on top, verify lvol's parameters
function test_construct_lvol() {
	# create an lvol store
@@ -335,6 +378,7 @@ run_test "test_construct_lvs" test_construct_lvs
run_test "test_construct_lvs_nonexistent_bdev" test_construct_lvs_nonexistent_bdev
run_test "test_construct_two_lvs_on_the_same_bdev" test_construct_two_lvs_on_the_same_bdev
run_test "test_construct_lvs_conflict_alias" test_construct_lvs_conflict_alias
run_test "test_construct_lvs_different_cluster_size" test_construct_lvs_different_cluster_size
run_test "test_construct_lvol" test_construct_lvol
run_test "test_construct_multi_lvols" test_construct_multi_lvols
run_test "test_construct_lvols_conflict_alias" test_construct_lvols_conflict_alias
+0 −2
Original line number Diff line number Diff line
@@ -38,8 +38,6 @@ function usage() {
                                    551: 'delete_lvol_bdev',
                                    552: 'bdev_lvol_delete_lvstore_with_clones',
                                    553: 'unregister_lvol_bdev',
                                    600: 'bdev_lvol_create_lvstore_with_cluster_size_max',
                                    601: 'bdev_lvol_create_lvstore_with_cluster_size_min',
                                    602: 'bdev_lvol_create_lvstore_with_all_clear_methods',
                                    650: 'thin_provisioning_check_space',
                                    651: 'thin_provisioning_read_empty_bdev',
+0 −52
Original line number Diff line number Diff line
@@ -130,8 +130,6 @@ def case_message(func):
            551: 'delete_lvol_bdev',
            552: 'bdev_lvol_delete_lvstore_with_clones',
            553: 'unregister_lvol_bdev',
            600: 'bdev_lvol_create_lvstore_with_cluster_size_max',
            601: 'bdev_lvol_create_lvstore_with_cluster_size_min',
            602: 'bdev_lvol_create_lvstore_with_all_clear_methods',
            # Provisioning
            650: 'thin_provisioning_check_space',
@@ -926,56 +924,6 @@ class TestCases(object):
        # - no other operation fails
        return fail_count

    @case_message
    def test_case600(self):
        """
        bdev_lvol_create_lvstore_with_cluster_size_max

        Negative test for constructing a new lvol store.
        Call bdev_lvol_create_lvstore with cluster size is equal malloc bdev size + 1B.
        """
        fail_count = 0
        # Create malloc bdev
        base_name = self.c.bdev_malloc_create(self.total_size,
                                              self.block_size)
        # Construct_lvol_store on correct, exisitng malloc bdev and cluster size equal
        # malloc bdev size in bytes + 1B
        lvol_uuid = self.c.bdev_lvol_create_lvstore(base_name,
                                                    self.lvs_name,
                                                    (self.total_size * 1024 * 1024) + 1) == 0
        if self.c.check_bdev_lvol_get_lvstores(base_name, lvol_uuid) == 0:
            fail_count += 1
        fail_count += self.c.bdev_malloc_delete(base_name)

        # Expected result:
        # - return code != 0
        # - Error code response printed to stdout
        return fail_count

    @case_message
    def test_case601(self):
        """
        bdev_lvol_create_lvstore_with_cluster_size_min

        Negative test for constructing a new lvol store.
        Call bdev_lvol_create_lvstore with cluster size smaller than minimal value of 8192.
        """
        fail_count = 0
        # Create malloc bdev
        base_name = self.c.bdev_malloc_create(self.total_size,
                                              self.block_size)
        # Try construct lvol store on malloc bdev with cluster size 8191
        lvol_uuid = self.c.bdev_lvol_create_lvstore(base_name, self.lvs_name, 8191)
        # Verify that lvol store was not created
        if self.c.check_bdev_lvol_get_lvstores(base_name, lvol_uuid) == 0:
            fail_count += 1
        fail_count += self.c.bdev_malloc_delete(base_name)

        # Expected result:
        # - construct lvol store return code != 0
        # - Error code response printed to stdout
        return fail_count

    @case_message
    def test_case602(self):
        """