Commit 9fb50ad8 authored by Lukasz Galka's avatar Lukasz Galka Committed by Daniel Verkamp
Browse files

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



Added "-c" argument for construct_lvol_store calls in tests.
Added 2 additional test cases for checking cluster_size=0
and cluster_size>base_bdev_size.

Commit also includes small PEP8 fixes for additional empty lines
between class and function definitions.

Change-Id: Ibdfb3312a61828ad4aa0f79327b648b6ea67899b
Signed-off-by: default avatarLukasz Galka <lukaszx.galka@intel.com>
Reviewed-on: https://review.gerrithub.io/381294


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>
parent 392fdc8a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ if [ $SPDK_TEST_VHOST -eq 1 ]; then
	run_test ./test/vhost/spdk_vhost.sh --integrity
	run_test ./test/vhost/spdk_vhost.sh --integrity-lvol-scsi
	run_test ./test/vhost/spdk_vhost.sh --integrity-lvol-blk
	run_test ./test/lvol/lvol.sh --test-cases=1,2,3,5,6,7,10,11,12,13,16,17,21
	run_test ./test/lvol/lvol.sh --test-cases=1,2,3,5,6,7,10,11,12,13,16,17,21,22,23
	timing_exit vhost
fi

+7 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ BASE_DIR=$(readlink -f $(dirname $0))

total_size=64
block_size=512
cluster_sz=1048576 #1MiB
test_cases=all
x=""

@@ -19,6 +20,7 @@ function usage() {
    echo "-h, --help                print help and exit"
    echo "    --total-size          Size of malloc bdev in MB (int > 0)"
    echo "    --block-size          Block size for this bdev"
    echo "    --cluster-sz          size of cluster (in bytes)"
    echo "-x                        set -x for script debug"
    echo "    --test-cases=         List test cases which will be run:
                                    1: 'construct_lvs_positive',
@@ -41,7 +43,9 @@ function usage() {
                                    18: 'nested construct_logical_volume_on_busy_bdev',
                                    19: 'nested destroy_logical_volume_positive',
                                    20: 'delete_bdev_positive',
                                    21: 'SIGTERM_on_lvol_store',
                                    21: 'construct_lvs_with_cluster_sz_out_of_range_max',
                                    22: 'construct_lvs_with_cluster_sz_out_of_range_min',
                                    23: 'SIGTERM'
                                    or
                                    all: This parameter runs all tests
                                    Ex: \"1,2,19,20\", default: all"
@@ -57,6 +61,7 @@ while getopts 'xh-:' optchar; do
            help) usage $0 ;;
            total-size=*) total_size="${OPTARG#*=}" ;;
            block-size=*) block_size="${OPTARG#*=}" ;;
            cluster-sz=*) cluster_sz="${OPTARG#*=}" ;;
            test-cases=*) test_cases="${OPTARG#*=}" ;;
            *) usage $0 "Invalid argument '$OPTARG'" ;;
        esac
@@ -94,7 +99,7 @@ trap "vhost_kill; exit 1" SIGINT SIGTERM EXIT

vhost_start

$BASE_DIR/lvol_test.py $rpc_py $total_size $block_size $BASE_DIR "${test_cases[@]}"
$BASE_DIR/lvol_test.py $rpc_py $total_size $block_size $cluster_sz $BASE_DIR "${test_cases[@]}"

trap - SIGINT SIGTERM EXIT
vhost_kill
+5 −3
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
import sys
from test_cases import *


def check_fail_count(fail_count, num_test):
    if not fail_count:
        print("Test: {num_test} - PASS".format(num_test=num_test))
@@ -12,7 +13,7 @@ if __name__ == "__main__":
    rpc_py = None
    total_size = None
    block_size = None
    cluster_size = "-c 1048576"  # 1MB cluster size for tests
    cluster_size = None
    num_test = None
    fail_count = 0
    tc_failed = []
@@ -22,8 +23,9 @@ if __name__ == "__main__":
        rpc_py = sys.argv[1]
        total_size = int(sys.argv[2])
        block_size = int(sys.argv[3])
        base_dir_path = sys.argv[4]
        tc_list = sys.argv[5].split(',')
        cluster_size = int(sys.argv[4])
        base_dir_path = sys.argv[5]
        tc_list = sys.argv[6].split(',')
    else:
        print("Invalid argument")
    try:
+16 −7
Original line number Diff line number Diff line
import json
from subprocess import check_output, CalledProcessError


class Spdk_Rpc(object):
    def __init__(self, rpc_py):
        self.rpc_py = rpc_py
@@ -21,6 +22,7 @@ class Spdk_Rpc(object):
                return e.output, e.returncode
        return call


class Commands_Rpc(object):
    def __init__(self, rpc_py):
        self.rpc = Spdk_Rpc(rpc_py)
@@ -49,25 +51,31 @@ class Commands_Rpc(object):
                                    json_value=json_value))
        return 1

    def check_get_lvol_stores(self, base_name, uuid):
    def check_get_lvol_stores(self, base_name, uuid, cluster_size):
        print("INFO: RPC COMMAND get_lvol_stores")
        output = self.rpc.get_lvol_stores()[0]
        json_value = json.loads(output)
        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 uuid in [uuid_json_response] \
                        and cluster_size in [cluster_size_response]:
                    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 Commnad: "
                          "get_lvol_stores response".format(uuid=uuid))
                    print("INFO: Cluster size :{cluster_size} is found in RPC "
                          "Commnad: get_lvol_stores "
                          "response".format(cluster_size=cluster_size))
                    return 0
            print("FAILED: UUID: {uuid} or base_name: {base_name} not found "
                  "in RPC COMMAND get_bdevs:"
                  "{json_value}".format(uuid=uuid, base_name=base_name,
            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))
            return 1
        else:
@@ -81,7 +89,8 @@ class Commands_Rpc(object):

    def construct_lvol_store(self, base_name, cluster_size):
        print("INFO: RPC COMMAND construct_lvol_store")
        output = self.rpc.construct_lvol_store(base_name, cluster_size)[0]
        output = self.rpc.construct_lvol_store(
            base_name, "-c {cluster_sz}".format(cluster_sz=cluster_size))[0]
        return output.rstrip('\n')

    def construct_lvol_bdev(self, uuid, size):
+66 −29
Original line number Diff line number Diff line
@@ -9,11 +9,12 @@ from rpc_commands_lib import Commands_Rpc
from time import sleep
from uuid import uuid4


def test_counter():
    '''
    :return: the number of tests
    '''
    return 21
    return 23

def header(num):
    test_name = {
@@ -37,7 +38,9 @@ def header(num):
        18: 'nested_construct_lvol_bdev_on_full_lvol_store',
        19: 'nested_destroy_logical_volume_positive',
        20: 'delete_bdev_positive',
        21: 'SIGTERM_on_lvol_store',
        21: 'construct_lvs_with_cluster_sz_out_of_range_max',
        22: 'construct_lvs_with_cluster_sz_out_of_range_min',
        23: 'SIGTERM',
    }
    print("========================================================")
    print("Test Case {num}: Start".format(num=num))
@@ -48,6 +51,7 @@ def footer(num):
    print("Test Case {num}: END\n".format(num=num))
    print("========================================================")


class TestCases(object):
    def __init__(self, rpc_py, total_size, block_size, cluster_size, base_dir_path):
        self.c = Commands_Rpc(rpc_py)
@@ -68,10 +72,11 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        self.c.destroy_lvol_store(uuid_store)
        self.c.delete_bdev(base_name)
        fail_count += self.c.check_get_lvol_stores("", "")
        fail_count += self.c.check_get_lvol_stores("", "", "")
        footer(1)
        return fail_count

@@ -80,7 +85,8 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size - 1)
        fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
                                                     self.total_size - 1)
@@ -95,7 +101,8 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        size = ((self.total_size - 1) / 4)

        uuid_bdevs = []
@@ -117,7 +124,8 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        # size is equal to one quarter of size malloc bdev
        uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size / 4)
        fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
@@ -145,9 +153,10 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        self.c.destroy_lvol_store(uuid_store)
        fail_count += self.c.check_get_lvol_stores("", "")
        fail_count += self.c.check_get_lvol_stores("", "", "")
        self.c.delete_bdev(base_name)
        footer(5)
        return fail_count
@@ -157,14 +166,15 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size - 1)
        fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
                                                     self.total_size - 1)
        if self.c.destroy_lvol_store(uuid_store) != 0:
            fail_count += 1

        fail_count += self.c.check_get_lvol_stores("", "")
        fail_count += self.c.check_get_lvol_stores("", "", "")
        self.c.delete_bdev(base_name)
        footer(6)
        return fail_count
@@ -174,7 +184,8 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        size = ((self.total_size - 1) / 4)

        for _ in range(4):
@@ -182,7 +193,7 @@ class TestCases(object):
            fail_count += self.c.check_get_bdevs_methods(uuid_bdev, size)

        self.c.destroy_lvol_store(uuid_store)
        fail_count += self.c.check_get_lvol_stores("", "")
        fail_count += self.c.check_get_lvol_stores("", "", "")
        self.c.delete_bdev(base_name)
        footer(7)
        return fail_count
@@ -197,7 +208,8 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        size = ((self.total_size - 1) / 4)
        uuid_bdev = self.c.construct_lvol_bdev(uuid_store, size)
        fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
@@ -212,7 +224,7 @@ class TestCases(object):
        fail_count += self.c.resize_lvol_bdev(uuid_bdev, 0)

        self.c.destroy_lvol_store(uuid_store)
        fail_count += self.c.check_get_lvol_stores("", "")
        fail_count += self.c.check_get_lvol_stores("", "", "")
        self.c.delete_bdev(base_name)
        footer(9)
        return fail_count
@@ -232,7 +244,8 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        if self.c.construct_lvol_store(base_name, self.cluster_size) == 0:
            fail_count += 1
        self.c.destroy_lvol_store(uuid_store)
@@ -253,7 +266,8 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size - 1)
        fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
                                                     self.total_size - 1)
@@ -279,7 +293,8 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        uuid_bdev = self.c.construct_lvol_bdev(uuid_store, self.total_size - 1)
        fail_count += self.c.check_get_bdevs_methods(uuid_bdev,
                                                     self.total_size - 1)
@@ -305,7 +320,8 @@ class TestCases(object):
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)

        if self.c.delete_bdev(base_name) != 0:
            fail_count += 1
@@ -330,21 +346,42 @@ class TestCases(object):
        header(20)
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        self.c.delete_bdev(base_name)
        fail_count += self.c.check_get_lvol_stores("", "")
        fail_count += self.c.check_get_lvol_stores("", "", "")
        footer(20)
        return fail_count

    def test_case21(self):
        header(21)
        print self.block_size
        print self.total_size
        fail_count = 0
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        if self.c.construct_lvol_store(base_name,
                                       (self.total_size * 1024 * 1024) + 1) == 0:
            fail_count += 1
        footer(21)
        return fail_count

    def test_case22(self):
        header(22)
        fail_count = 0
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        if self.c.construct_lvol_store(base_name, 0) == 0:
            fail_count += 1
        footer(22)
        return fail_count

    def test_case23(self):
        header(23)
        base_name = self.c.construct_malloc_bdev(self.total_size,
                                                 self.block_size)
        uuid_store = self.c.construct_lvol_store(base_name, self.cluster_size)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store)
        fail_count = self.c.check_get_lvol_stores(base_name, uuid_store,
                                                  self.cluster_size)
        pid_path = path.join(self.path, 'vhost.pid')
        with io.open(pid_path, 'r') as vhost_pid:
            pid = int(vhost_pid.readline())
@@ -358,10 +395,10 @@ class TestCases(object):
                    if err.errno == ESRCH:
                        pass
                    else:
                        return 1
                        fail_count += 1
                else:
                    return 1
                    fail_count += 1
            else:
                return 1
        footer(21)
                fail_count += 1
        footer(23)
        return fail_count
Loading