Commit 5d2881c6 authored by Karol Latecki's avatar Karol Latecki Committed by Jim Harris
Browse files

test/lvol: Fix test cases for lvol store cluster size



rpc_commands_lib.py: make cluster size optional argument as
sometimes we only need to check if lvol store exists and not
care about details.

Test cases 600 and 601 fix: add missing delete_bdev() at the end,
add using get_lvol_stores to check if lvol store was created.

Test case 601 modified:
Change test case to check if creating a lvol store with cluster
size less than 8192 is disallowed.
Previous check for cluster size of 0 was incorrect as 0 is an
allowed value for that operation and results in setting default
cluster size.

Change-Id: I8bcbed9a7dff3e81fcc0ca4b525da3a1d0627495
Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/398370


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 6336217e
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -52,31 +52,36 @@ class Commands_Rpc(object):
                                    json_value=json_value))
        return 1

    def check_get_lvol_stores(self, base_name, uuid, cluster_size):
    def check_get_lvol_stores(self, base_name, uuid, cluster_size=None):
        print("INFO: RPC COMMAND get_lvol_stores")
        json_value = self.get_lvol_stores()
        if json_value:
            for i in range(len(json_value)):
                uuid_json_response = json_value[i]['uuid']
                cluster_size_response = json_value[i]['cluster_size']
                base_bdev_json_reponse = json_value[i]['base_bdev']
                if base_name in [base_bdev_json_reponse] \
                        and uuid in [uuid_json_response] \
                        and cluster_size in [cluster_size_response]:
                json_uuid = json_value[i]['uuid']
                json_cluster = json_value[i]['cluster_size']
                json_base_name = json_value[i]['base_bdev']

                if base_name in json_base_name \
                        and uuid in json_uuid:
                    print("INFO: base_name:{base_name} is found in RPC "
                          "Command: get_lvol_stores "
                          "response".format(base_name=base_name))
                    print("INFO: UUID:{uuid} is found in RPC Command: "
                          "get_lvol_stores response".format(uuid=uuid))
                    print("INFO: Cluster size :{cluster_size} is found in RPC "
                          "Commnad: get_lvol_stores "
                    if cluster_size:
                        if str(cluster_size) in str(json_cluster):
                            print("Info: Cluster size :{cluster_size} is found in RPC "
                                  "Command: get_lvol_stores "
                                  "response".format(cluster_size=cluster_size))
                        else:
                            print("ERROR: Wrong cluster size in lvol store")
                            print("Expected:".format(cluster_size))
                            print("Actual:".format(json_cluster))
                            return 1
                    return 0
            print("FAILED: UUID: {uuid} or base_name: {base_name} or "
                  "cluster size: {cluster_size} not found in RPC COMMAND "
                  "get_bdevs: {json_value}".format(uuid=uuid,
                                                   base_name=base_name,
                                                   json_value=json_value))
            print("FAILED: UUID: lvol store {uuid} on base_bdev: "
                  "{base_name} not found in get_lvol_stores()".format(uuid=uuid,
                                                                      base_name=base_name))
            return 1
        else:
            print("INFO: Lvol store not exist")
+9 −7
Original line number Diff line number Diff line
@@ -656,22 +656,24 @@ class TestCases(object):
        fail_count = 0
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        if self.c.construct_lvol_store(base_name,
        lvol_uuid = self.c.construct_lvol_store(base_name,
                                                self.lvs_name,
                                       (self.total_size * 1024 * 1024) + 1) == 0:
                                                (self.total_size * 1024 * 1024) + 1) == 0
        if self.c.check_get_lvol_stores(base_name, lvol_uuid) == 0:
            fail_count += 1
        fail_count += self.c.delete_bdev(base_name)
        footer(600)
        return fail_count

    def test_case601(self):
        header(601)
        fail_count = 0
        # Create malloc bdev smaller than default lvol cluster size
        base_name = self.c.construct_malloc_bdev(1,
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        if self.c.construct_lvol_store(base_name,
                                       self.lvs_name, 0) == 0:
        lvol_uuid = self.c.construct_lvol_store(base_name, self.lvs_name, 8191)
        if self.c.check_get_lvol_stores(base_name, lvol_uuid) == 0:
            fail_count += 1
        fail_count += self.c.delete_bdev(base_name)
        footer(601)
        return fail_count

+4 −3
Original line number Diff line number Diff line
@@ -544,13 +544,14 @@ Expected result:

#### TEST CASE 601 - Name: construct_lvol_store_with_cluster_size_min
Negative test for constructing a new lvol store.
Call construct_lvol_store with cluster size = 0.
Call construct_lvol_store with cluster size smaller than minimal value of 8192.
Steps:
- create a malloc bdev
- construct_lvol_store on correct, exisitng malloc bdev and cluster size 0
- try construct lvol store on malloc bdev with cluster size 8191
- verify that lvol store was not created

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

### Provisioning