Commit 990d537e authored by Tomasz Zawadzki's avatar Tomasz Zawadzki Committed by Ben Walker
Browse files

test/lvol: add destroy_lvol_bdev tests



Change-Id: I60a00cdb2de543633bd3bd7d2d70537328a2f1f1
Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Signed-off-by: default avatarPawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/420232


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 18f53446
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -204,7 +204,8 @@ fi
if [ $SPDK_TEST_LVOL -eq 1 ]; then
	timing_enter lvol
	test_cases="1,50,51,52,53,100,101,102,150,200,201,250,251,252,253,254,255,"
	test_cases+="300,301,450,451,452,550,600,601,650,651,652,654,655,"
	test_cases+="300,301,450,451,452,550,551,552,553,"
	test_cases+="600,601,650,651,652,654,655,"
	test_cases+="700,701,750,751,752,753,754,755,756,757,758,759,"
	test_cases+="800,801,802,803,804,10000"
	run_test ./test/lvol/lvol.sh --test-cases=$test_cases
+4 −1
Original line number Diff line number Diff line
@@ -48,8 +48,11 @@ function usage() {
                                    452: 'construct_lvs_name_twice',
                                    500: 'nested_construct_lvol_bdev_on_full_lvol_store',
                                    550: 'delete_bdev_positive',
                                    551: 'delete_lvol_bdev',
                                    552: 'destroy_lvol_store_with_clones',
                                    553: 'unregister_lvol_bdev',
                                    600: 'construct_lvol_store_with_cluster_size_max',
                                    601 'construct_lvol_store_with_cluster_size_min',
                                    601: 'construct_lvol_store_with_cluster_size_min',
                                    650: 'thin_provisioning_check_space',
                                    651: 'thin_provisioning_read_empty_bdev',
                                    652: 'thin_provisionind_data_integrity_test',
+184 −0
Original line number Diff line number Diff line
@@ -117,6 +117,9 @@ def case_message(func):
            452: 'construct_lvs_name_twice',
            500: 'nested_construct_lvol_bdev_on_full_lvol_store',
            550: 'delete_bdev_positive',
            551: 'delete_lvol_bdev',
            552: 'destroy_lvol_store_with_clones',
            553: 'unregister_lvol_bdev',
            600: 'construct_lvol_store_with_cluster_size_max',
            601: 'construct_lvol_store_with_cluster_size_min',
            650: 'thin_provisioning_check_space',
@@ -796,6 +799,187 @@ class TestCases(object):
        # - no other operation fails
        return fail_count

    @case_message
    def test_case551(self):
        """
        destroy_lvol_bdev_ordering

        Test for destroying lvol bdevs in particular order.
        Check destroying wrong one is not possible and returns error.
        """

        fail_count = 0
        snapshot_name = "snapshot"
        clone_name = "clone"

        # Create malloc bdev
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        # Construct_lvol_store on correct, exisitng malloc bdev
        uuid_store = self.c.construct_lvol_store(base_name,
                                                 self.lvs_name,
                                                 self.cluster_size)
        # Check correct uuid values in response get_lvol_stores command
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        lvs = self.c.get_lvol_stores()
        size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 4 / MEGABYTE)

        # Construct thin provisioned lvol bdev
        uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store,
                                                self.lbd_name, size, thin=True)
        lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0)

        # Create snapshot of thin provisioned lvol bdev
        fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
        snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)

        # Create clone of snapshot and check if it ends with success
        fail_count += self.c.clone_lvol_bdev(self.lvs_name + "/" + snapshot_name, clone_name)
        clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name)

        # Try to destroy snapshot with clones and check if it fails
        ret_value = self.c.destroy_lvol_bdev(snapshot_bdev['name'])
        if ret_value == 0:
            print("ERROR: Delete snapshot should fail but didn't")
            fail_count += 1

        # Destroy clone and then snapshot
        fail_count += self.c.destroy_lvol_bdev(lvol_bdev['name'])
        fail_count += self.c.destroy_lvol_bdev(clone_bdev['name'])
        fail_count += self.c.destroy_lvol_bdev(snapshot_bdev['name'])

        # Destroy lvol store
        fail_count += self.c.destroy_lvol_store(uuid_store)

        #  Check response get_lvol_stores command
        if self.c.check_get_lvol_stores("", "", "") == 1:
            fail_count += 1

        # Delete malloc bdev
        self.c.delete_malloc_bdev(base_name)
        # Expected result:
        # - get_lvol_stores: response should be of no value after destroyed lvol store
        # - no other operation fails
        return fail_count

    @case_message
    def test_case552(self):
        """
        destroy_lvol_store_with_clones

        Test for destroying lvol store with clones present,
        without removing them first.
        """

        fail_count = 0
        snapshot_name = "snapshot"
        snapshot_name2 = "snapshot2"
        clone_name = "clone"

        # Create malloc bdev
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        # Construct_lvol_store on correct, exisitng malloc bdev
        uuid_store = self.c.construct_lvol_store(base_name,
                                                 self.lvs_name,
                                                 self.cluster_size)
        # Check correct uuid values in response get_lvol_stores command
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        lvs = self.c.get_lvol_stores()
        size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 4 / MEGABYTE)

        # Create lvol bdev, snapshot it, then clone it and then snapshot the clone
        uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, size, thin=True)
        lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0)

        fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
        snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)

        fail_count += self.c.clone_lvol_bdev(self.lvs_name + "/" + snapshot_name, clone_name)
        clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name)

        fail_count += self.c.snapshot_lvol_bdev(clone_bdev['name'], snapshot_name2)
        snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2)

        # Try to destroy snapshots with clones and check if it fails
        ret_value = self.c.destroy_lvol_bdev(snapshot_bdev['name'])
        if ret_value == 0:
            print("ERROR: Delete snapshot should fail but didn't")
            fail_count += 1
        ret_value = self.c.destroy_lvol_bdev(snapshot_bdev2['name'])
        if ret_value == 0:
            print("ERROR: Delete snapshot should fail but didn't")
            fail_count += 1

        # Destroy lvol store without deleting lvol bdevs
        fail_count += self.c.destroy_lvol_store(uuid_store)

        #  Check response get_lvol_stores command
        if self.c.check_get_lvol_stores("", "", "") == 1:
            fail_count += 1

        # Delete malloc bdev
        self.c.delete_malloc_bdev(base_name)
        # Expected result:
        # - get_lvol_stores: response should be of no value after destroyed lvol store
        # - no other operation fails
        return fail_count

    @case_message
    def test_case553(self):
        """
        unregister_lvol_bdev

        Test for unregistering the lvol bdevs.
        Removing malloc bdev under an lvol store triggers unregister of
        all lvol bdevs. Verify it with clones present.
        """

        fail_count = 0
        snapshot_name = "snapshot"
        snapshot_name2 = "snapshot2"
        clone_name = "clone"

        # Create malloc bdev
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        # Construct_lvol_store on correct, exisitng malloc bdev
        uuid_store = self.c.construct_lvol_store(base_name,
                                                 self.lvs_name,
                                                 self.cluster_size)
        # Check correct uuid values in response get_lvol_stores command
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        lvs = self.c.get_lvol_stores()
        size = int(int(lvs[0][u'free_clusters'] * lvs[0]['cluster_size']) / 4 / MEGABYTE)

        # Create lvol bdev, snapshot it, then clone it and then snapshot the clone
        uuid_bdev0 = self.c.construct_lvol_bdev(uuid_store, self.lbd_name, size, thin=True)
        lvol_bdev = self.c.get_lvol_bdev_with_name(uuid_bdev0)

        fail_count += self.c.snapshot_lvol_bdev(lvol_bdev['name'], snapshot_name)
        snapshot_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name)

        fail_count += self.c.clone_lvol_bdev(self.lvs_name + "/" + snapshot_name, clone_name)
        clone_bdev = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + clone_name)

        fail_count += self.c.snapshot_lvol_bdev(clone_bdev['name'], snapshot_name2)
        snapshot_bdev2 = self.c.get_lvol_bdev_with_name(self.lvs_name + "/" + snapshot_name2)

        # Delete malloc bdev
        self.c.delete_malloc_bdev(base_name)

        #  Check response get_lvol_stores command
        if self.c.check_get_lvol_stores("", "", "") == 1:
            fail_count += 1

        # Expected result:
        # - get_lvol_stores: response should be of no value after destroyed lvol store
        # - no other operation fails
        return fail_count

    @case_message
    def test_case600(self):
        """